‘ve written two functions in a file commit_hooks.py that I want to run before any commit is made persistent, but I can’t figure out how to write my hgrc to detect them.
The function headers are:
def precommit_bad_merge(ui, repo, parent1=None, parent2=None, **kwargs):
...
def precommit_bad_branching(ui, repo, **kwargs):
...
I’ve tried using this “guide“, but the documentation is too “man pagey” for me. The following is an outcast which doesn’t work.
[hooks]
precommit = ..\..\mno2\commit_hooks.py
Update!
Rewriting the hook line to:
precommit = D:\environments\next\mno2\commit_hooks.py
make Mercurial detect the precommit hook, but it always exits with status 1 for some reason.
Set up your
[hooks]section like this:The syntax for the
precommitline that you used is for external hooks, so it was treating your python file as a self-contained script (which I’m assuming it’s not since you’re using the function signatures for in-process hooks).You may need to have the python executable in your path (I do).
For more information, see the definitive guide’s section on in-process hooks; there’s some useful information hidden in the comments.