comparison mercurial/cmdutil.py @ 4632:8d46056960ab

dispatch: report failed imports nicely
author Matt Mackall <mpm@selenic.com>
date Mon, 18 Jun 2007 21:30:27 -0500
parents e6d105a51ec7
children ff7253a0d1da
comparison
equal deleted inserted replaced
4631:e3afa670e484 4632:8d46056960ab
113 ui.warn(" %r\n" % (inst[1],)) 113 ui.warn(" %r\n" % (inst[1],))
114 elif not inst[1]: 114 elif not inst[1]:
115 ui.warn(_(" empty string\n")) 115 ui.warn(_(" empty string\n"))
116 else: 116 else:
117 ui.warn("\n%r\n" % util.ellipsis(inst[1])) 117 ui.warn("\n%r\n" % util.ellipsis(inst[1]))
118 except ImportError, inst:
119 m = str(inst).split()[-1]
120 ui.warn(_("abort: could not import module %s!\n" % m))
121 if m in "mpatch bdiff".split():
122 ui.warn(_("(did you forget to compile extensions?)\n"))
123 elif m in "zlib".split():
124 ui.warn(_("(is your Python install correct?)\n"))
125
118 except util.Abort, inst: 126 except util.Abort, inst:
119 ui.warn(_("abort: %s\n") % inst) 127 ui.warn(_("abort: %s\n") % inst)
120 except SystemExit, inst: 128 except SystemExit, inst:
121 # Commands shouldn't sys.exit directly, but give a return code. 129 # Commands shouldn't sys.exit directly, but give a return code.
122 # Just in case catch this and and pass exit code to caller. 130 # Just in case catch this and and pass exit code to caller.