unable to return a failure from a hook
Wagner Bruna
wagner.bruna+mercurial at gmail.com
Fri Jan 14 16:45:20 CST 2011
On 01/14/2011 08:22 PM, Haszlakiewicz, Eric wrote:
>
> 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:
The hook function must actually return True (or throw an exception)
for failure - for consistency with return codes of program hooks, I guess.
Regards,
Wagner
>> 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