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

login
register
mail settings
Submitter Yuya Nishihara
Date May 19, 2017, 3:25 p.m.
Message ID <9f15f346510482387718.1495207516@mimosa>
Download mbox | patch
Permalink /patch/20724/
State Accepted
Headers show

Comments

Yuya Nishihara - May 19, 2017, 3:25 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

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:]: