28 stringutil, |
28 stringutil, |
29 ) |
29 ) |
30 |
30 |
31 |
31 |
32 def pythonhook(ui, repo, htype, hname, funcname, args, throw): |
32 def pythonhook(ui, repo, htype, hname, funcname, args, throw): |
33 '''call python hook. hook is callable object, looked up as |
33 """call python hook. hook is callable object, looked up as |
34 name in python module. if callable returns "true", hook |
34 name in python module. if callable returns "true", hook |
35 fails, else passes. if hook raises exception, treated as |
35 fails, else passes. if hook raises exception, treated as |
36 hook failure. exception propagates if throw is "true". |
36 hook failure. exception propagates if throw is "true". |
37 |
37 |
38 reason for "true" meaning "hook failed" is so that |
38 reason for "true" meaning "hook failed" is so that |
39 unmodified commands (e.g. mercurial.commands.update) can |
39 unmodified commands (e.g. mercurial.commands.update) can |
40 be run as hooks without wrappers to convert return values.''' |
40 be run as hooks without wrappers to convert return values.""" |
41 |
41 |
42 if callable(funcname): |
42 if callable(funcname): |
43 obj = funcname |
43 obj = funcname |
44 funcname = pycompat.sysbytes(obj.__module__ + "." + obj.__name__) |
44 funcname = pycompat.sysbytes(obj.__module__ + "." + obj.__name__) |
45 else: |
45 else: |