diff mercurial/extensions.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 9eca39a91964
children 013fcd112f13
line wrap: on
line diff
--- a/mercurial/extensions.py	Wed Jul 18 07:51:20 2012 -0700
+++ b/mercurial/extensions.py	Fri Jul 06 18:41:25 2012 +0200
@@ -42,7 +42,12 @@
         fd, fpath, desc = imp.find_module(f, [d])
         return imp.load_module(module_name, fd, fpath, desc)
     else:
-        return imp.load_source(module_name, path)
+        try:
+            return imp.load_source(module_name, path)
+        except IOError, exc:
+            if not exc.filename:
+                exc.filename = path # python does not fill this
+            raise
 
 def load(ui, name, path):
     # unused ui argument kept for backwards compatibility