[PATCH 1 of 1] hooks: print out more information when loading a python hook fails

Simon Heimberg simohe at besonet.ch
Sun Jul 1 18:18:51 CDT 2012


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1341184478 -7200
# Node ID b7a4855420be012502e8095f4e2b4cd3d27edade
# Parent  fba17a64fa4978bfea19222da5e64a18cfddeecd
hooks: print out more information when loading a python hook fails

diff -r fba17a64fa49 -r b7a4855420be mercurial/hook.py
--- a/mercurial/hook.py	Fre Jun 29 00:40:52 2012 -0500
+++ b/mercurial/hook.py	Mon Jul 02 01:14:38 2012 +0200
@@ -169,7 +169,13 @@
                     path = util.expandpath(path)
                     if repo:
                         path = os.path.join(repo.root, path)
-                    mod = extensions.loadpath(path, 'hghook.%s' % hname)
+                    try:
+                        mod = extensions.loadpath(path, 'hghook.%s' % hname)
+                    except Exception, exc:
+                        ui.write(_("loading %s hook failed:") % hname)
+                        if isinstance(exc, IOError) and not exc.filename:
+                            exc.filename = path # python does not fill this
+                        raise
                     hookfn = getattr(mod, cmd)
                 else:
                     hookfn = cmd[7:].strip()


More information about the Mercurial-devel mailing list