mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
extensions: factor import error reporting out
To clarify third party extensions lookup, we are about to add a third place where extensions are searched for. So we factor the error reporting logic out to be able to easily reuse it in the next patch.
This commit is contained in:
parent
1ab6440d02
commit
e51996ccf2
@ -79,6 +79,12 @@ def _importh(name):
|
||||
mod = getattr(mod, comp)
|
||||
return mod
|
||||
|
||||
def _reportimporterror(ui, err, failed, next):
|
||||
ui.debug('could not import %s (%s): trying %s\n'
|
||||
% (failed, err, next))
|
||||
if ui.debugflag:
|
||||
ui.traceback()
|
||||
|
||||
def load(ui, name, path):
|
||||
if name.startswith('hgext.') or name.startswith('hgext/'):
|
||||
shortname = name[6:]
|
||||
@ -98,10 +104,7 @@ def load(ui, name, path):
|
||||
try:
|
||||
mod = _importh("hgext.%s" % name)
|
||||
except ImportError as err:
|
||||
ui.debug('could not import hgext.%s (%s): trying %s\n'
|
||||
% (name, err, name))
|
||||
if ui.debugflag:
|
||||
ui.traceback()
|
||||
_reportimporterror(ui, err, "hgext.%s" % name, name)
|
||||
mod = _importh(name)
|
||||
|
||||
# Before we do anything with the extension, check against minimum stated
|
||||
|
Loading…
Reference in New Issue
Block a user