changeset 49800:0d5b2e010614

peer-or-repo: stop relying on AttributeError in `islocal` This will confused pytypes in a future changeset.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 30 Nov 2022 13:55:15 +0100
parents b478e1b132e9
children f73f02ef8cb6
files mercurial/hg.py
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Tue Nov 29 21:42:08 2022 +0100
+++ b/mercurial/hg.py	Wed Nov 30 13:55:15 2022 +0100
@@ -164,10 +164,11 @@
 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()