This should be a very simple thing to have run, but for some reason it won\'t work with my Mercurial repository. All I want is for the remote repo to automatically run
Tthe reason I've found for this has nothing to do with redirecting stdout
to stderr
. As you may see in the wiki page it is not specified on the wiki's current version
https://www.mercurial-scm.org/wiki/FAQ#FAQ.2FCommonProblems.Any_way_to_.27hg_push.27_and_have_an_automatic_.27hg_update.27_on_the_remote_server.3F
The problem I've found is around permissions.
In my original setup, I had a user, lets say hguser
with a repo on its home, and a script /etc/init.d/hg.init
to launch hg serve
. The problem being hg serve
was being run by root
, while most files under the repo pertained to hguser
(some of them switched to root
at some point, but it won't mind, since I'll correct them with chown
)
Solution:
chown -R hguser:hguser /home/hguser/repo
(to correct ALL files, back to hguser)su hguser -c "hg serve ..."
(in my case from /etc/init.d/hg.init
)changegroup = hg update -C
under [hooks]
in repo/.hg/hgrc
as usualNow it should work on push
PS: in my case, I rather update to the head of a specific branch, so I use hg update -C -r staging
, to make the staging server update only to the head of the intended branch, even if the tip
is from another branch (like development
for instance)
BTW my hg.init
script ended up like this: (notice the su hguser
part)
#!/bin/sh
#
# Startup script for mercurial server.
#
# @see http://jf.blogs.teximus.com/2011/01/running-mercurial-hg-serve-on-linux.html
HG=/usr/bin/hg
CONF=/etc/mercurial/hgweb.config
# Path to PID file of running mercurial process.
PID_FILE=/etc/mercurial/hg.pid
state=$1
case "$state" in
'start')
echo "Mecurial Server service starting."
(su hguser -c "${HG} serve -d --webdir-conf ${CONF} -p 8000 --pid-file ${PID_FILE}")
;;
'stop')
if [ -f "${PID_FILE}" ]; then
PID=`cat "${PID_FILE}"`
if [ "${PID}" -gt 1 ]; then
kill -TERM ${PID}
echo "Stopping the Mercurial service PID=${PID}."
else
echo Bad PID for Mercurial -- \"${PID}\"
fi
else
echo No PID file recorded for mercurial
fi
;;
*)
echo "$0 {start|stop}"
exit 1
;;
esac
PS: due credit to http://jf.blogs.teximus.com/2011/01/running-mercurial-hg-serve-on-linux.html
Try turning on hook debugging to see why it's not running.
Likely a permissions issue or something like that.
I had the same problem pushing from Windows Eclipse via http, but after capturing stderr, I found that the full path was needed to the hg.bat file. My hooks section now looks like:
[hooks]
incoming = c:\Python27\Scripts\hg.bat update > hg_log.txt 2>>hg_err.txt
Hope this helps someone else. SteveT