# HG changeset patch # User Matt Harbison # Date 1670274304 18000 # Node ID f4a363b25859589f4aeab628060e5b888feadb70 # Parent 9d8757ddd0ab746ab06a54cf96b0ee95360dbae0 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 diff -r 9d8757ddd0ab -r f4a363b25859 mercurial/extensions.py --- a/mercurial/extensions.py Wed Dec 07 11:26:07 2022 -0500 +++ b/mercurial/extensions.py Mon Dec 05 16:05:04 2022 -0500 @@ -841,6 +841,22 @@ paths = _disabledpaths() if name in paths: return _disabledhelp(paths[name]) + else: + try: + import hgext + from hgext import __index__ # pytype: disable=import-error + + # The extensions are filesystem based, so either an error occurred + # or all are enabled. + if util.safehasattr(hgext, '__file__'): + return + + if name in _order: # enabled + return + else: + return gettext(__index__.docs.get(name)) + except (ImportError, AttributeError): + pass def _walkcommand(node):