Show More
@@ -42,7 +42,12 b' def loadpath(path, module_name):' | |||||
42 | fd, fpath, desc = imp.find_module(f, [d]) |
|
42 | fd, fpath, desc = imp.find_module(f, [d]) | |
43 | return imp.load_module(module_name, fd, fpath, desc) |
|
43 | return imp.load_module(module_name, fd, fpath, desc) | |
44 | else: |
|
44 | else: | |
45 | return imp.load_source(module_name, path) |
|
45 | try: | |
|
46 | return imp.load_source(module_name, path) | |||
|
47 | except IOError, exc: | |||
|
48 | if not exc.filename: | |||
|
49 | exc.filename = path # python does not fill this | |||
|
50 | raise | |||
46 |
|
51 | |||
47 | def load(ui, name, path): |
|
52 | def load(ui, name, path): | |
48 | # unused ui argument kept for backwards compatibility |
|
53 | # unused ui argument kept for backwards compatibility |
@@ -169,7 +169,11 b' def hook(ui, repo, name, throw=False, **' | |||||
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() |
@@ -530,6 +530,20 b' test python hook configured with python:' | |||||
530 | nothing changed |
|
530 | nothing changed | |
531 | [1] |
|
531 | [1] | |
532 |
|
532 | |||
|
533 | $ echo '[hooks]' > .hg/hgrc | |||
|
534 | $ echo "update.ne = python:`pwd`/nonexisting.py:testhook" >> .hg/hgrc | |||
|
535 | $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc | |||
|
536 | ||||
|
537 | $ hg up null | |||
|
538 | loading update.ne hook failed: | |||
|
539 | abort: No such file or directory: $TESTTMP/d/repo/nonexisting.py | |||
|
540 | [255] | |||
|
541 | ||||
|
542 | $ hg id | |||
|
543 | loading pre-identify.npmd hook failed: | |||
|
544 | abort: No module named repo! | |||
|
545 | [255] | |||
|
546 | ||||
533 | $ cd ../../b |
|
547 | $ cd ../../b | |
534 |
|
548 | |||
535 | make sure --traceback works on hook import failure |
|
549 | make sure --traceback works on hook import failure |
General Comments 0
You need to be logged in to leave comments.
Login now