Mercurial > public > mercurial-scm > hg
comparison mercurial/hook.py @ 28080:37b818cad146
hook: for python hook ImportErrors, add note to run with --traceback
I personally found it completely non-obvious that --traceback prints out stack
traces for failed imports.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Thu, 11 Feb 2016 22:52:23 -0800 |
parents | 0c9e914029be |
children | cedbe8723d99 |
comparison
equal
deleted
inserted
replaced
28079:0c9e914029be | 28080:37b818cad146 |
---|---|
62 ui.traceback(e1) | 62 ui.traceback(e1) |
63 if ui.tracebackflag: | 63 if ui.tracebackflag: |
64 ui.warn(_('exception from second failed import ' | 64 ui.warn(_('exception from second failed import ' |
65 'attempt:\n')) | 65 'attempt:\n')) |
66 ui.traceback(e2) | 66 ui.traceback(e2) |
67 | |
68 if not ui.tracebackflag: | |
69 tracebackhint = _( | |
70 'run with --traceback for stack trace') | |
71 else: | |
72 tracebackhint = None | |
67 raise error.HookLoadError( | 73 raise error.HookLoadError( |
68 _('%s hook is invalid: import of "%s" failed') % | 74 _('%s hook is invalid: import of "%s" failed') % |
69 (hname, modname)) | 75 (hname, modname), hint=tracebackhint) |
70 sys.path = oldpaths | 76 sys.path = oldpaths |
71 try: | 77 try: |
72 for p in funcname.split('.')[1:]: | 78 for p in funcname.split('.')[1:]: |
73 obj = getattr(obj, p) | 79 obj = getattr(obj, p) |
74 except AttributeError: | 80 except AttributeError: |