diff mercurial/hook.py @ 17217:1b2b727a885f

hooks: print out more information when loading a python hook fails When loading a python hook with file syntax fails, there is no information that this happened while loading a hook. When the python file does not exist even the file name is not printed. (Only that a file is missing.) This patch adds this information and a test for loading a non existing file and a directory not being a python module.
author Simon Heimberg <simohe@besonet.ch>
date Fri, 06 Jul 2012 18:41:25 +0200
parents 15d4d475de9e
children 98166640b356
line wrap: on
line diff
--- a/mercurial/hook.py	Wed Jul 18 07:51:20 2012 -0700
+++ b/mercurial/hook.py	Fri Jul 06 18:41:25 2012 +0200
@@ -169,7 +169,11 @@
                     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:
+                        ui.write(_("loading %s hook failed:\n") % hname)
+                        raise
                     hookfn = getattr(mod, cmd)
                 else:
                     hookfn = cmd[7:].strip()