2

I am using Mercurial SCM over a LAN using a normal shared folder instead of HTTP and I'm having a problem getting the auto update hook to run.

I have entered this hook as detailed in the FAQ. This installs the hook, but when I push something to the remote repository, I get an error:

added 1 changesets with 1 changes to 1 files
running hook changegroup: hg update >&2
warning: changegroup hook exited with status -1

There is another stackoverflow question similar to this, but it offers no solutions other than it may be a permissions error somewhere.

Has anyone else had this problem and can anyone else shed any more light on this or give me a heads up on where to start fixing this? Thanks.

Community
  • 1
  • 1
Gary Willoughby
  • 50,926
  • 41
  • 133
  • 199
  • If you're on windows then `>&2` won't work for you, that's a bash shell-ism. – Ry4an Brase Jan 05 '11 at 18:18
  • @Ry4an: As described in http://support.microsoft.com/kb/110930 it's also possible for Windows. – Raphael Bossek Jan 05 '11 at 18:38
  • I recall many windows users having to remove that to get it working int he past, but perhaps they had less able versions of command.exe? Or is it that mercurial invokes the hook w/o running it through whatever does that output redirection? I don't have a windows system on which to test, but I've seen windows folks have to remove that to make this particular trick work. – Ry4an Brase Jan 05 '11 at 19:47

1 Answers1

3

Is hg in your standard search PATH ?

Replace your .hgrc configuration with a custom script, e.g.

[hooks]
changegroup = /var/tmp/myscript.sh

[ui]
debug = true

(unix) In the /var/tmp/myscript.sh write something like this:

#!/bin/sh
set -e
echo ---------- >>/tmp/myscript.log
set >>/tmp/myscript.log
echo --- >>/tmp/myscript.log
pwd >>/tmp/myscript.log
hg update >>/tmp/myscript.log 2>&1

(unix) Do not forget to mark as executable: chmod a+x /var/tmp/myscript.sh

(windows) The corresponding batch file myscript.bat is:

@echo off
echo ------ >>%TEMP%\myscript.log
set >>%TEMP%\myscript.log
echo --- >>%TEMP%\myscript.log
cd >>%TEMP%\myscript.log
hg update >>%TEMP%\myscript.log 2>&1

(windows) Of course, the line in .hgrc is changegroup = \your\directory\myscript.bat.

Run your hg push command to reproduce the problem.

Check the content of the /tmp/myscript.log file.

Raphael Bossek
  • 1,904
  • 14
  • 25