# HG changeset patch # User Pierre-Yves David # Date 2022-11-30 12:55:15 # Node ID 0d5b2e010614c804804f667d2382961f348b2d6d # Parent b478e1b132e9f944251b64ca44f5dfec807a1bc8 peer-or-repo: stop relying on AttributeError in `islocal` This will confused pytypes in a future changeset. diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -164,10 +164,11 @@ def _peerlookup(path): def islocal(repo): '''return true if repo (or path pointing to repo) is local''' if isinstance(repo, bytes): - try: - return _peerlookup(repo).islocal(repo) - except AttributeError: - return False + cls = _peerlookup(repo) + cls.instance # make sure we load the module + if util.safehasattr(cls, 'islocal'): + return cls.islocal(repo) # pytype: disable=module-attr + return False repo.ui.deprecwarn(b"use obj.local() instead of islocal(obj)", b"6.4") return repo.local()