5

I have a script that is in the top level of my working copy and would like to use it as a Mercurial hook. If I use an absolute pathname to the hook then everything is fine, but I want a relative pathname so the whole thing can be easily moved around, used in other working copies and other developers can copy the hgrc as is.

/space/project/.hg/hgrc contains

[hooks]
update = genid

The genid script is at /space/project/genid

The hook is invoked just fine if I am in /space/project but if my current directory is /space/project/src/tools then 'hg update' will give an error as the hook cannot be found.

4

3 回答 3

2

In certain cases, environment variables are expanded in mercurial configuration. So you can check out if you can use a environment variable.

[hooks]
update = $MercurialHooks/genid

See Faq (12) in https://www.mercurial-scm.org/wiki/TipsAndTricks

于 2010-11-18T21:59:44.760 回答
2

Python hooks cannot use a relative path. Script hooks can like this:

[hooks]
update = ./genid
于 2010-11-18T23:23:25.200 回答
0

I had the same problem and couldnt resolve it. The workaround was easy though! I versioned the file in the repo and just copied it to my .hg folder! Not ideal but it isnt that likely to change and other repo users can still get a copy of the file

于 2014-02-10T14:38:59.927 回答