I'm trying to create a Mercurial hook that runs when the commits are being pushed to the main repository. I created a python script as given below:
# commit.py from mercurial import ui, hg from mercurial.i18n import gettext as _ def getV1ID(ui, repo, **kwargs): ui.write("The hook works!!!") v1id = ui.prompt('Enter the VersionOne ID') ui.write('VersionOne ID: '+v1id)
For each branch, this commit.py
is duplicated as it contains mechanisms that needs to run before code gets pushed onto the main respository. The push should only be successful if those pre-push mechanisms pass. Users can modify their local commit.py so that they only run a subset of those pre-push operations depending on the project their working on and each person could be working on more than one project at a time. And so, commit.py
cannot be a global python script that can reside in .hg
folder.
To make mercurial run the local commit.py
, in my mercurial.ini file (in C:\Users\UserName\mercurial.ini), I added the following statement:
[hooks] prechangegroup = python:./commit.py:getV1ID
The python script runs if I place it inside .hg
folder, but not when I do this. Can anyone help me shed light on this issue? Many thanks.