comparison mercurial/extensions.py @ 49781:f4a363b25859 stable

extensions: load help from hgext.__index__ as a fallback this time Prior to 843418dc0b1b, `hgext.__index__` was consulted first if present, which caused the longer help from the extension modules to be ignored, even when available. But that change causes a bunch of test failures when the pyoxidized binary bundles *.pyc in the binary, saying the there's no help topic for `hg help $disabled_extension` and suggesting the use of `--keyword`, rather than showing a summary and indicating that it is disabled. Current failures were in test-check-help.t, test-extension.t, test-help.t, and test-qrecord.t. Ideally, we would read the various *.pyc files from memory and slurp in the docstring, but I know that they used to not be readable as resources, and I can't figure out how to make it work now. So maybe 3.9 and/or the current PyOxidizer doesn't support it yet. I got closer in py2exe with `importlib.resources.open_binary("hgext", "rebase.pyc")`, but `open_binary()` on *.pyc fails in pyoxidizer.[1] Either way, the *.pyc can't be passed to `ast.parse()` as `extensions._disabledcmdtable()` is doing, so I'm setting that aside for now. [1] https://github.com/indygreg/PyOxidizer/issues/649
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 05 Dec 2022 16:05:04 -0500
parents 9d8757ddd0ab
children b9eb65a1ec14 94506fc107b7
comparison
equal deleted inserted replaced
49780:9d8757ddd0ab 49781:f4a363b25859
839 def disabled_help(name): 839 def disabled_help(name):
840 """Obtain the full help text for a disabled extension, or None.""" 840 """Obtain the full help text for a disabled extension, or None."""
841 paths = _disabledpaths() 841 paths = _disabledpaths()
842 if name in paths: 842 if name in paths:
843 return _disabledhelp(paths[name]) 843 return _disabledhelp(paths[name])
844 else:
845 try:
846 import hgext
847 from hgext import __index__ # pytype: disable=import-error
848
849 # The extensions are filesystem based, so either an error occurred
850 # or all are enabled.
851 if util.safehasattr(hgext, '__file__'):
852 return
853
854 if name in _order: # enabled
855 return
856 else:
857 return gettext(__index__.docs.get(name))
858 except (ImportError, AttributeError):
859 pass
844 860
845 861
846 def _walkcommand(node): 862 def _walkcommand(node):
847 """Scan @command() decorators in the tree starting at node""" 863 """Scan @command() decorators in the tree starting at node"""
848 todo = collections.deque([node]) 864 todo = collections.deque([node])