Search code examples
mercurialhookmercurial-hook

How to use a relative pathname to a Mercurial hook


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.


Solution

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

    [hooks]
    update = ./genid