Patchwork [3,of,5] help: load module doc of disabled extension in extensions.disabledcmd()

login
register
mail settings
Submitter Yuya Nishihara
Date May 11, 2018, 1:29 p.m.
Message ID <dd2a166e87eae4c5029a.1526045370@mimosa>
Download mbox | patch
Permalink /patch/31508/
State Accepted
Headers show

Comments

Yuya Nishihara - May 11, 2018, 1:29 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1525339322 -32400
#      Thu May 03 18:22:02 2018 +0900
# Node ID dd2a166e87eae4c5029a1d0c1194a6076c544a37
# Parent  ad36b4eb9903d325bc157831a482c8e30fe6e819
help: load module doc of disabled extension in extensions.disabledcmd()

This helps rewriting _finddisablecmd() to not load the module.

Patch

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -675,11 +675,12 @@  def _finddisabledcmd(ui, cmd, name, path
             break
     else:
         cmd = aliases[0]
-    return (cmd, name, mod)
+    doc = gettext(pycompat.getdoc(mod))
+    return (cmd, name, doc)
 
 def disabledcmd(ui, cmd, strict=False):
     '''import disabled extensions until cmd is found.
-    returns (cmdname, extname, module)'''
+    returns (cmdname, extname, doc)'''
 
     paths = _disabledpaths(strip_init=True)
     if not paths:
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -574,9 +574,9 @@  def help_(ui, commands, name, unknowncmd
         return rst
 
     def helpextcmd(name, subtopic=None):
-        cmd, ext, mod = extensions.disabledcmd(ui, name,
+        cmd, ext, doc = extensions.disabledcmd(ui, name,
                                                ui.configbool('ui', 'strict'))
-        doc = gettext(pycompat.getdoc(mod)).splitlines()[0]
+        doc = doc.splitlines()[0]
 
         rst = listexts(_("'%s' is provided by the following "
                               "extension:") % cmd, {ext: doc}, indent=4,