Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/commands.py @ 1342:5a42da1db402
Warn on failure to import an extension
author | mpm@selenic.com |
---|---|
date | Fri, 23 Sep 2005 19:04:19 -0700 |
parents | d4b25df77a9e |
children | 3729e2773cca |
comparison
equal
deleted
inserted
replaced
1341:3ab6e55ee361 | 1342:5a42da1db402 |
---|---|
2044 | 2044 |
2045 u = ui.ui() | 2045 u = ui.ui() |
2046 external = [] | 2046 external = [] |
2047 for x in u.extensions(): | 2047 for x in u.extensions(): |
2048 if x[1]: | 2048 if x[1]: |
2049 mod = imp.load_source(x[0], x[1]) | 2049 try: |
2050 mod = imp.load_source(x[0], x[1]) | |
2051 except: | |
2052 u.warn("*** failed to import extension %s\n" % x[1]) | |
2053 continue | |
2050 else: | 2054 else: |
2051 def importh(name): | 2055 def importh(name): |
2052 mod = __import__(name) | 2056 mod = __import__(name) |
2053 components = name.split('.') | 2057 components = name.split('.') |
2054 for comp in components[1:]: | 2058 for comp in components[1:]: |
2055 mod = getattr(mod, comp) | 2059 mod = getattr(mod, comp) |
2056 return mod | 2060 return mod |
2057 mod = importh(x[0]) | 2061 try: |
2062 mod = importh(x[0]) | |
2063 except: | |
2064 u.warn("failed to import extension %s\n" % x[0]) | |
2065 continue | |
2066 | |
2058 external.append(mod) | 2067 external.append(mod) |
2059 for x in external: | 2068 for x in external: |
2060 cmdtable = getattr(x, 'cmdtable', {}) | 2069 cmdtable = getattr(x, 'cmdtable', {}) |
2061 for t in cmdtable: | 2070 for t in cmdtable: |
2062 if t in table: | 2071 if t in table: |