mercurial/commands.py
changeset 1424 918cb47d725e
parent 1420 b32b3509c7ab
child 1431 16a5d349963c
equal deleted inserted replaced
1423:76239f0cb0dc 1424:918cb47d725e
  2066         pass
  2066         pass
  2067 
  2067 
  2068     u = ui.ui()
  2068     u = ui.ui()
  2069     external = []
  2069     external = []
  2070     for x in u.extensions():
  2070     for x in u.extensions():
       
  2071         def on_exception(Exception, inst):
       
  2072             u.warn(_("*** failed to import extension %s\n") % x[1])
       
  2073             u.warn("%s\n" % inst)
       
  2074             if "--traceback" in sys.argv[1:]:
       
  2075                 traceback.print_exc()
  2071         if x[1]:
  2076         if x[1]:
  2072             try:
  2077             try:
  2073                 mod = imp.load_source(x[0], x[1])
  2078                 mod = imp.load_source(x[0], x[1])
  2074             except:
  2079             except Exception, inst:
  2075                 u.warn(_("*** failed to import extension %s\n") % x[1])
  2080                 on_exception(Exception, inst)
  2076                 continue
  2081                 continue
  2077         else:
  2082         else:
  2078             def importh(name):
  2083             def importh(name):
  2079                 mod = __import__(name)
  2084                 mod = __import__(name)
  2080                 components = name.split('.')
  2085                 components = name.split('.')
  2081                 for comp in components[1:]:
  2086                 for comp in components[1:]:
  2082                     mod = getattr(mod, comp)
  2087                     mod = getattr(mod, comp)
  2083                 return mod
  2088                 return mod
  2084             try:
  2089             try:
  2085                 mod = importh(x[0])
  2090                 mod = importh(x[0])
  2086             except:
  2091             except Exception, inst:
  2087                 u.warn(_("failed to import extension %s\n") % x[0])
  2092                 on_exception(Exception, inst)
  2088                 continue
  2093                 continue
  2089 
  2094 
  2090         external.append(mod)
  2095         external.append(mod)
  2091     for x in external:
  2096     for x in external:
  2092         cmdtable = getattr(x, 'cmdtable', {})
  2097         cmdtable = getattr(x, 'cmdtable', {})