changeset 6204:f8a86ea7521b

When failing to load an extension, show where Hg tried to load it from.
author Jesse Glick <jesse.glick@sun.com>
date Mon, 03 Mar 2008 12:46:57 -0500
parents 3a75fcc96dac
children b193a6e59131
files mercurial/extensions.py tests/test-bad-extension tests/test-bad-extension.out
diffstat 3 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/extensions.py	Sun Mar 02 23:32:13 2008 +0100
+++ b/mercurial/extensions.py	Mon Mar 03 12:46:57 2008 -0500
@@ -78,8 +78,12 @@
         except (util.SignalInterrupt, KeyboardInterrupt):
             raise
         except Exception, inst:
-            ui.warn(_("*** failed to import extension %s: %s\n") %
-                    (name, inst))
+            if path:
+                ui.warn(_("*** failed to import extension %s from %s: %s\n")
+                        % (name, path, inst))
+            else:
+                ui.warn(_("*** failed to import extension %s: %s\n")
+                        % (name, inst))
             if ui.print_exc():
                 return 1
 
--- a/tests/test-bad-extension	Sun Mar 02 23:32:13 2008 +0100
+++ b/tests/test-bad-extension	Mon Mar 03 12:46:57 2008 -0500
@@ -7,5 +7,7 @@
 echo "gpg =" >> $HGRCPATH
 echo "hgext.gpg =" >> $HGRCPATH
 echo "badext = $abspath" >> $HGRCPATH
+echo "badext2 =" >> $HGRCPATH
 
-hg -q help help
+hg -q help help 2>&1 | python -c \
+  "import sys; sys.stdout.write(sys.stdin.read().replace('$abspath', '.../badext.py'))"
--- a/tests/test-bad-extension.out	Sun Mar 02 23:32:13 2008 +0100
+++ b/tests/test-bad-extension.out	Mon Mar 03 12:46:57 2008 -0500
@@ -1,4 +1,5 @@
-*** failed to import extension badext: bit bucket overflow
+*** failed to import extension badext from .../badext.py: bit bucket overflow
+*** failed to import extension badext2: No module named badext2
 hg help [COMMAND]
 
 show help for a command, extension, or list of commands