Mercurial auto update problem

2019-02-19 18:19发布

问题:

We are starting to use Mercurial for source control. We have configured the HGRC configuration file to do an auto update after we push to the "central" repository. With some PCs we get this error msg:

warning: changegroup hook exited with status -1

HGRC looks like this:

[ui] 
username=ADMIN
verbose=true

[hooks]
changegroup = hg update >&2

Later we perform the update manually and everything works right.

回答1:

It might be related with the user actually executing the hook, which might not be the one with the correct privileges.

Do you have a IIS webserver managing your Mercurial repos?

(from the thread:)

From experience with Mercurial/IIS, things I'd recommend trying:

  • (a) Does running a simple non-HG command work? Permissions on cmd.exe will affect out-of-process python hooks.
  • (b) Does a simple hook like 'python -c "import sys; sys.exit(0)"' work?
  • (c) If you make it this far, can you confirm that the process is running as the user you think it's running as, with a hook that does something like:
import win32api
username = win32api.GetUserName()
(write username to a file so you can read it)


回答2:

I had a very simmilar issue. This finally works now:

changegroup = cmd /c hg update

The bold cmd /c causes cmd.exe to spawn which will execute hg update as we want it to, but now the exit value from cmd.exe will be 0.

Longer Story:

setup: win 2008 server.
mercurial 1.9.3
hgwebdir via plain http, its an internal network

error: my error was funnily not the -1 as in your case but
"warning: changegroup hook exited with status 1"
Anyway, the update was not performed.

I found out that I can put the hooks into either .hgrc or into hgweb.config the problem was the same here or there. I finally put it into hgweb.config as below, so all repositories are auto commiting, which is way better than having this loose branch all the time. The main reason I wanted auto commit is that the respositories on the vcs & build server hold now the latest version which makes admin tasks often simpler.

[web]
push_ssl = False allow_push = *

[collections]
c:\Dev\Reps = c:\Dev\Reps

[ui]
debug=true

[hooks]
changegroup = cmd /c hg update