Mercurial > hg
diff tests/test-hook.out @ 2155:ff255b41b4aa
support hooks written in python.
to write hook in python, create module with hook function inside.
make sure mercurial can import module (put it in $PYTHONPATH or load it
as extension). hook function should look like this:
def myhook(ui, repo, hooktype, **kwargs):
if hook_passes:
return True
elif hook_explicitly_fails:
return False
elif some_other_failure:
import util
raise util.Abort('helpful failure message')
else:
return
# implicit return of None makes hook fail!
then in .hgrc, add hook with "python:" prefix:
[hooks]
commit = python:mymodule.myhook
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Fri, 28 Apr 2006 15:50:22 -0700 |
parents | 7544700fd931 |
children | b2ae81a7df29 |
line wrap: on
line diff
--- a/tests/test-hook.out Fri Apr 28 14:50:23 2006 -0700 +++ b/tests/test-hook.out Fri Apr 28 15:50:22 2006 -0700 @@ -89,3 +89,43 @@ pulling from ../a searching for changes abort: preoutgoing.forbid hook exited with status 1 +# test python hooks +error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict' +error: preoutgoing.raise hook raised an exception: exception from hook +pulling from ../a +searching for changes +error: preoutgoing.abort hook failed: raise abort from hook +abort: raise abort from hook +pulling from ../a +searching for changes +hook args: + hooktype preoutgoing + source pull +abort: preoutgoing.fail hook failed +pulling from ../a +searching for changes +abort: preoutgoing.uncallable hook is invalid ("hooktests.uncallable" is not callable) +pulling from ../a +searching for changes +abort: preoutgoing.nohook hook is invalid ("hooktests.nohook" is not defined) +pulling from ../a +searching for changes +abort: preoutgoing.nomodule hook is invalid ("nomodule" not in a module) +pulling from ../a +searching for changes +abort: preoutgoing.badmodule hook is invalid (import of "nomodule" failed) +pulling from ../a +searching for changes +abort: preoutgoing.unreachable hook is invalid (import of "hooktests.container" failed) +pulling from ../a +searching for changes +hook args: + hooktype preoutgoing + source pull +adding changesets +adding manifests +adding file changes +added 1 changesets with 1 changes to 1 files +(run 'hg update' to get a working copy) +# make sure --traceback works +Traceback (most recent call last):