[PATCH] hook: try to load python hook starting from repo root if not found

Alexander Solovyov alexander at solovyov.net
Tue Dec 7 08:51:08 CST 2010


# HG changeset patch
# User Alexander Solovyov <alexander at solovyov.net>
# Date 1291732024 -3600
# Node ID ea190e7ddffdbe601cbac12dcaa106450f48be45
# Parent  b068f5d824047531f2f3d34666fcebe642852b5d
hook: try to load python hook starting from repo root if not found

diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -135,7 +135,11 @@ def hook(ui, repo, name, throw=False, **
             elif cmd.startswith('python:'):
                 if cmd.count(':') >= 2:
                     path, cmd = cmd[7:].rsplit(':', 1)
-                    mod = extensions.loadpath(path, 'hghook.%s' % hname)
+                    try:
+                        mod = extensions.loadpath(path, 'hghook.%s' % hname)
+                    except IOError:
+                        mod = extensions.loadpath(os.path.join(repo.root, path),
+                                                  'hghook.%s' % hname)
                     hookfn = getattr(mod, cmd)
                 else:
                     hookfn = cmd[7:].strip()


More information about the Mercurial-devel mailing list