Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
17216:01c1ee4bd1dd | 17217:1b2b727a885f |
---|---|
167 if cmd.count(':') >= 2: | 167 if cmd.count(':') >= 2: |
168 path, cmd = cmd[7:].rsplit(':', 1) | 168 path, cmd = cmd[7:].rsplit(':', 1) |
169 path = util.expandpath(path) | 169 path = util.expandpath(path) |
170 if repo: | 170 if repo: |
171 path = os.path.join(repo.root, path) | 171 path = os.path.join(repo.root, path) |
172 mod = extensions.loadpath(path, 'hghook.%s' % hname) | 172 try: |
173 mod = extensions.loadpath(path, 'hghook.%s' % hname) | |
174 except Exception: | |
175 ui.write(_("loading %s hook failed:\n") % hname) | |
176 raise | |
173 hookfn = getattr(mod, cmd) | 177 hookfn = getattr(mod, cmd) |
174 else: | 178 else: |
175 hookfn = cmd[7:].strip() | 179 hookfn = cmd[7:].strip() |
176 r = _pythonhook(ui, repo, name, hname, hookfn, args, throw) or r | 180 r = _pythonhook(ui, repo, name, hname, hookfn, args, throw) or r |
177 else: | 181 else: |