[PATCH 6 of 8 V2] extensions: optionally print hint on import failure

Yuya Nishihara yuya at tcha.org
Fri May 19 11:25:16 EDT 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1494744405 -32400
#      Sun May 14 15:46:45 2017 +0900
# Node ID 9f15f34651048238771830b2b476099c308f2676
# Parent  a084f404ccae65bc7a067f122dcce79c80c51328
extensions: optionally print hint on import failure

Test will be added by the next patch.

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -172,13 +172,15 @@ def loadall(ui):
         try:
             load(ui, name, path)
         except Exception as inst:
-            inst = _forbytes(inst)
+            msg = _forbytes(inst)
             if path:
                 ui.warn(_("*** failed to import extension %s from %s: %s\n")
-                        % (name, path, inst))
+                        % (name, path, msg))
             else:
                 ui.warn(_("*** failed to import extension %s: %s\n")
-                        % (name, inst))
+                        % (name, msg))
+            if isinstance(inst, error.Hint) and inst.hint:
+                ui.warn(_("*** (%s)\n") % inst.hint)
             ui.traceback()
 
     for name in _order[newindex:]:


More information about the Mercurial-devel mailing list