mercurial/extensions.py
changeset 28506 10252652c6e4
parent 28505 d5512a0a8ad6
child 28541 4b81487a01d4
equal deleted inserted replaced
28505:d5512a0a8ad6 28506:10252652c6e4
    77     components = name.split('.')
    77     components = name.split('.')
    78     for comp in components[1:]:
    78     for comp in components[1:]:
    79         mod = getattr(mod, comp)
    79         mod = getattr(mod, comp)
    80     return mod
    80     return mod
    81 
    81 
       
    82 def _reportimporterror(ui, err, failed, next):
       
    83     ui.debug('could not import %s (%s): trying %s\n'
       
    84              % (failed, err, next))
       
    85     if ui.debugflag:
       
    86         ui.traceback()
       
    87 
    82 def load(ui, name, path):
    88 def load(ui, name, path):
    83     if name.startswith('hgext.') or name.startswith('hgext/'):
    89     if name.startswith('hgext.') or name.startswith('hgext/'):
    84         shortname = name[6:]
    90         shortname = name[6:]
    85     else:
    91     else:
    86         shortname = name
    92         shortname = name
    96         mod = loadpath(path, 'hgext.%s' % name)
   102         mod = loadpath(path, 'hgext.%s' % name)
    97     else:
   103     else:
    98         try:
   104         try:
    99             mod = _importh("hgext.%s" % name)
   105             mod = _importh("hgext.%s" % name)
   100         except ImportError as err:
   106         except ImportError as err:
   101             ui.debug('could not import hgext.%s (%s): trying %s\n'
   107             _reportimporterror(ui, err, "hgext.%s" % name, name)
   102                      % (name, err, name))
       
   103             if ui.debugflag:
       
   104                 ui.traceback()
       
   105             mod = _importh(name)
   108             mod = _importh(name)
   106 
   109 
   107     # Before we do anything with the extension, check against minimum stated
   110     # Before we do anything with the extension, check against minimum stated
   108     # compatibility. This gives extension authors a mechanism to have their
   111     # compatibility. This gives extension authors a mechanism to have their
   109     # extensions short circuit when loaded with a known incompatible version
   112     # extensions short circuit when loaded with a known incompatible version