Mercurial > hg
changeset 28506:10252652c6e4
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 11 Mar 2016 10:28:58 +0000 |
parents | d5512a0a8ad6 |
children | 9bcbd9412225 |
files | mercurial/extensions.py |
diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/extensions.py Fri Mar 11 10:24:54 2016 +0000 +++ b/mercurial/extensions.py Fri Mar 11 10:28:58 2016 +0000 @@ -79,6 +79,12 @@ 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 @@ 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