diff --git a/mercurial/extensions.py b/mercurial/extensions.py --- a/mercurial/extensions.py +++ b/mercurial/extensions.py @@ -729,6 +729,8 @@ def _disabledpaths(): '''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 @@ def _disabledpaths(): 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.