# HG changeset patch # User Matt Harbison # Date 1670430367 18000 # Node ID 9d8757ddd0ab746ab06a54cf96b0ee95360dbae0 # Parent 7d6c8943353aa6e66342b2095f8b28295036697a extensions: process disabled external paths when `hgext` package is in-memory This fixes `hg help -e ambiguous` in test-helpt.t:2055 with the `ambiguous = !./ambiguous.py` configuration, when `hgext` is not in the filesystem (e.g. pyoxidizer builds with in-memory resources, or TortoiseHg with py2exe), but the disabled external extension is. Now instead of aborting with a suggestion to try `--keyword`, the help command prints text for the extension. diff -r 7d6c8943353a -r 9d8757ddd0ab mercurial/extensions.py --- a/mercurial/extensions.py Mon Dec 05 15:14:33 2022 -0500 +++ b/mercurial/extensions.py Wed Dec 07 11:26:07 2022 -0500 @@ -729,6 +729,8 @@ '''find paths of disabled extensions. returns a dict of {name: path}''' import hgext + exts = {} + # The hgext might not have a __file__ attribute (e.g. in PyOxidizer) and # it might not be on a filesystem even if it does. if util.safehasattr(hgext, '__file__'): @@ -738,23 +740,21 @@ try: files = os.listdir(extpath) except OSError: - return {} - else: - return {} + pass + else: + for e in files: + if e.endswith(b'.py'): + name = e.rsplit(b'.', 1)[0] + path = os.path.join(extpath, e) + else: + name = e + path = os.path.join(extpath, e, b'__init__.py') + if not os.path.exists(path): + continue + if name in exts or name in _order or name == b'__init__': + continue + exts[name] = path - exts = {} - for e in files: - if e.endswith(b'.py'): - name = e.rsplit(b'.', 1)[0] - path = os.path.join(extpath, e) - else: - name = e - path = os.path.join(extpath, e, b'__init__.py') - if not os.path.exists(path): - continue - if name in exts or name in _order or name == b'__init__': - continue - exts[name] = path for name, path in _disabledextensions.items(): # If no path was provided for a disabled extension (e.g. "color=!"), # don't replace the path we already found by the scan above.