diff mercurial/hook.py @ 7916:f779e1996e23

ability to load hooks from arbitrary python module
author Alexander Solovyov <piranha@piranha.org.ua>
date Fri, 27 Mar 2009 01:28:09 +0200
parents b8d750daadde
children cce63ef1045b
line wrap: on
line diff
--- a/mercurial/hook.py	Sun Mar 29 19:06:56 2009 +0200
+++ b/mercurial/hook.py	Fri Mar 27 01:28:09 2009 +0200
@@ -7,6 +7,7 @@
 
 from i18n import _
 import util, os, sys
+from mercurial import extensions
 
 def _pythonhook(ui, repo, name, hname, funcname, args, throw):
     '''call python hook. hook is callable object, looked up as
@@ -109,8 +110,13 @@
             if callable(cmd):
                 r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r
             elif cmd.startswith('python:'):
-                r = _pythonhook(ui, repo, name, hname, cmd[7:].strip(),
-                                args, throw) or r
+                if cmd.count(':') == 2:
+                    path, cmd = cmd[7:].split(':')
+                    mod = extensions.loadpath(path, 'hgkook.%s' % hname)
+                    hookfn = getattr(mod, cmd)
+                else:
+                    hookfn = cmd[7:].strip()
+                r = _pythonhook(ui, repo, name, hname, hookfn, args, throw) or r
             else:
                 r = _exthook(ui, repo, hname, cmd, args, throw) or r
     finally: