Merge with crew-stable.
authorMartin Geisler <mg@lazybytes.net>
Mon, 10 Aug 2009 23:27:08 +0200
changeset 9333 4e7149ed98e8
parent 9331 9d68d9deda51 (current diff)
parent 9332 872d49dd577a (diff)
child 9334 08f59f7916f9
child 9342 c47693630e72
Merge with crew-stable.
--- a/mercurial/hook.py	Mon Aug 10 23:02:58 2009 +0200
+++ b/mercurial/hook.py	Mon Aug 10 23:27:08 2009 +0200
@@ -27,6 +27,13 @@
             raise util.Abort(_('%s hook is invalid ("%s" not in '
                                'a module)') % (hname, funcname))
         modname = funcname[:d]
+        oldpaths = sys.path[:]
+        if hasattr(sys, "frozen"):
+            # binary installs require sys.path manipulation
+            path, name = os.path.split(modname)
+            if path and name:
+                sys.path.append(path)
+                modname = name
         try:
             obj = __import__(modname)
         except ImportError:
@@ -37,6 +44,7 @@
                 raise util.Abort(_('%s hook is invalid '
                                    '(import of "%s" failed)') %
                                  (hname, modname))
+        sys.path = oldpaths
         try:
             for p in funcname.split('.')[1:]:
                 obj = getattr(obj, p)
@@ -110,9 +118,9 @@
             if hasattr(cmd, '__call__'):
                 r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r
             elif cmd.startswith('python:'):
-                if cmd.count(':') == 2:
-                    path, cmd = cmd[7:].split(':')
-                    mod = extensions.loadpath(path, 'hgkook.%s' % hname)
+                if cmd.count(':') >= 2:
+                    path, cmd = cmd[7:].rsplit(':', 1)
+                    mod = extensions.loadpath(path, 'hghook.%s' % hname)
                     hookfn = getattr(mod, cmd)
                 else:
                     hookfn = cmd[7:].strip()