unable to return a failure from a hook

Haszlakiewicz, Eric EHASZLA at transunion.com
Fri Jan 14 16:22:27 CST 2011


I'm trying to write a hook that causes a commit to fail based on some custom checks.  I can get most of the stuff I was to do to work, but the basic step of causing a failure to happen doesn't work.  
Based on what I see on the HookExamples on the wiki, I expect that I should be able to do this:

> cat example.py   (actually in Library.zip)

def hook(ui, repo, hooktype, **kwargs):
        print "returning false";
        return False

> grep -B 2 example mercurial.ini
[hooks]
pretxncommit.example = python:example.hook

But instead, hg ignores the return value, and commits the change:
> hg stat
M myfile.txt
> hg ci -m "commit something"
returning false
> hg stat
(that produces no output, all files are checked in)

Am I doing something wrong?  Is there some other way I'm supposed to indicate a failure in a hook?

eric



More information about the Mercurial mailing list