comparison mercurial/extensions.py @ 25364:de23a552fc23

extensions: show traceback on load failure if --traceback flag is set Before this patch, there was no handy way to investigate the reason why extension couldn't be loaded. If ui.debug is set, tracebacks of both "hgext.foo" and "foo" are displayed because the first ImportError could occur at very deep dependency module.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 30 Mar 2015 16:23:35 +0900
parents e6e7d1cce04d
children 328739ea70c3
comparison
equal deleted inserted replaced
25363:3ff4b07412ad 25364:de23a552fc23
83 try: 83 try:
84 mod = importh("hgext.%s" % name) 84 mod = importh("hgext.%s" % name)
85 except ImportError, err: 85 except ImportError, err:
86 ui.debug('could not import hgext.%s (%s): trying %s\n' 86 ui.debug('could not import hgext.%s (%s): trying %s\n'
87 % (name, err, name)) 87 % (name, err, name))
88 if ui.debugflag:
89 ui.traceback()
88 mod = importh(name) 90 mod = importh(name)
89 _extensions[shortname] = mod 91 _extensions[shortname] = mod
90 _order.append(shortname) 92 _order.append(shortname)
91 for fn in _aftercallbacks.get(shortname, []): 93 for fn in _aftercallbacks.get(shortname, []):
92 fn(loaded=True) 94 fn(loaded=True)
108 ui.warn(_("*** failed to import extension %s from %s: %s\n") 110 ui.warn(_("*** failed to import extension %s from %s: %s\n")
109 % (name, path, inst)) 111 % (name, path, inst))
110 else: 112 else:
111 ui.warn(_("*** failed to import extension %s: %s\n") 113 ui.warn(_("*** failed to import extension %s: %s\n")
112 % (name, inst)) 114 % (name, inst))
115 ui.traceback()
113 116
114 for name in _order[newindex:]: 117 for name in _order[newindex:]:
115 uisetup = getattr(_extensions[name], 'uisetup', None) 118 uisetup = getattr(_extensions[name], 'uisetup', None)
116 if uisetup: 119 if uisetup:
117 uisetup(ui) 120 uisetup(ui)