changeset 4632:8d46056960ab

dispatch: report failed imports nicely
author Matt Mackall <mpm@selenic.com>
date Mon, 18 Jun 2007 21:30:27 -0500
parents e3afa670e484
children ff7253a0d1da
files mercurial/cmdutil.py
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Mon Jun 18 19:43:26 2007 -0500
+++ b/mercurial/cmdutil.py	Mon Jun 18 21:30:27 2007 -0500
@@ -115,6 +115,14 @@
             ui.warn(_(" empty string\n"))
         else:
             ui.warn("\n%r\n" % util.ellipsis(inst[1]))
+    except ImportError, inst:
+        m = str(inst).split()[-1]
+        ui.warn(_("abort: could not import module %s!\n" % m))
+        if m in "mpatch bdiff".split():
+            ui.warn(_("(did you forget to compile extensions?)\n"))
+        elif m in "zlib".split():
+            ui.warn(_("(is your Python install correct?)\n"))
+            
     except util.Abort, inst:
         ui.warn(_("abort: %s\n") % inst)
     except SystemExit, inst: