Patchwork D8344: extensions: refactor function for obtaining disabled extension help

login
register
mail settings
Submitter phabricator
Date March 30, 2020, 1:30 a.m.
Message ID <differential-rev-PHID-DREV-lrbntlvqfq6j6a7q7ta2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45948/
State Superseded
Headers show

Comments

phabricator - March 30, 2020, 1:30 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The way this worked before was hgext.__index__ was consulted.
  This file appears to only be present on some Windows distributions.
  
  This file contains a dict mapping extension name to its summary line,
  not its full docstring.
  
  The problem with this is that code in the help system was calling
  this function to resolve help text. If hgext.__index__ was present,
  only the summary line would be displayed. If not, the full extension
  help would be printed.
  
  This commit changes the function to not use hgext.__index__ such that
  it always returns the full extension help text.
  
  As a result of this change, test-extension.t and test-qrecord.t
  now pass when run from environments that have an hgext.__index__.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8344

AFFECTED FILES
  mercurial/extensions.py
  mercurial/help.py
  mercurial/hg.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel
phabricator - March 30, 2020, 7:14 p.m.
mharbison72 added a comment.


  I noticed inconsistencies with this too.  I was wondering if we should populate `__index__` with the full help text to avoid that.  (The other inconsistency that comes to mind is printing out the disabled extension list in `hg help extensions`.)  While it is apparently only used for py2exe based stuff, it might be handy with PyOxidizer too, until that gains the ability to enumerate and read embedded *.py files and directories as resources.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8344/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8344

To: indygreg, #hg-reviewers
Cc: mharbison72, mercurial-devel

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -695,7 +695,7 @@ 
         # data.
         createopts[b'lfs'] = True
 
-        if extensions.disabledext(b'lfs'):
+        if extensions.disabled_help(b'lfs'):
             ui.status(
                 _(
                     b'(remote is using large file support (lfs), but it is '
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -966,7 +966,7 @@ 
             doc = gettext(pycompat.getdoc(mod)) or _(b'no help text available')
         except KeyError:
             mod = None
-            doc = extensions.disabledext(name)
+            doc = extensions.disabled_help(name)
             if not doc:
                 raise error.UnknownCommand(name)
 
diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -808,18 +808,8 @@ 
     return exts
 
 
-def disabledext(name):
-    '''find a specific disabled extension from hgext. returns desc'''
-    try:
-        from hgext import __index__  # pytype: disable=import-error
-
-        if name in _order:  # enabled
-            return
-        else:
-            return gettext(__index__.docs.get(name))
-    except (ImportError, AttributeError):
-        pass
-
+def disabled_help(name):
+    """Obtain the full help text for a disabled extension, or None."""
     paths = _disabledpaths()
     if name in paths:
         return _disabledhelp(paths[name])