Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 2056:1f6d520557ec
Polished exception handling when importing extensions:
- Warning about failed import is printed on one line.
- For this warning the [extensions] section key is used, because the value
doesn't have to be set.
- Whan a --traceback is requested, exit immediately to not mix up problems
when importing an extension with other problems.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 11 Apr 2006 07:08:16 +0200 |
parents | f70952384ae7 |
children | fef2d653beaf |
comparison
equal
deleted
inserted
replaced
2055:bd94dda70bbe | 2056:1f6d520557ec |
---|---|
3261 sys.exit(1) | 3261 sys.exit(1) |
3262 | 3262 |
3263 external = [] | 3263 external = [] |
3264 for x in u.extensions(): | 3264 for x in u.extensions(): |
3265 def on_exception(exc, inst): | 3265 def on_exception(exc, inst): |
3266 u.warn(_("*** failed to import extension %s\n") % x[1]) | 3266 u.warn(_("*** failed to import extension %s: %s\n") % (x[0], inst)) |
3267 u.warn("%s\n" % inst) | |
3268 if "--traceback" in sys.argv[1:]: | 3267 if "--traceback" in sys.argv[1:]: |
3269 traceback.print_exc() | 3268 traceback.print_exc() |
3269 sys.exit(0) | |
3270 if x[1]: | 3270 if x[1]: |
3271 try: | 3271 try: |
3272 mod = imp.load_source(x[0], x[1]) | 3272 mod = imp.load_source(x[0], x[1]) |
3273 except Exception, inst: | 3273 except Exception, inst: |
3274 on_exception(Exception, inst) | 3274 on_exception(Exception, inst) |