changeset 49749:be3fcd9e5e52

peer: dissolve `_peerlookup` into its last two callers This is about to need more changes and the function won't be useful. We do it early to clarify later changes.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 02 Dec 2022 18:04:37 +0100
parents 78af51ba73c5
children f075a9463ee7
files hgext/schemes.py mercurial/hg.py
diffstat 2 files changed, 17 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/schemes.py	Sat Dec 03 03:45:45 2022 +0100
+++ b/hgext/schemes.py	Fri Dec 02 18:04:37 2022 +0100
@@ -82,7 +82,15 @@
 
     def instance(self, ui, url, create, intents=None, createopts=None):
         url = self.resolve(url)
-        return hg._peerlookup(url).instance(
+        u = urlutil.url(url)
+        scheme = u.scheme or b'file'
+        if scheme in hg.peer_schemes:
+            cls = hg.peer_schemes[scheme]
+        elif scheme in hg.repo_schemes:
+            cls = hg.repo_schemes[scheme]
+        else:
+            cls = hg.LocalFactory
+        return cls.instance(
             ui, url, create, intents=intents, createopts=createopts
         )
 
--- a/mercurial/hg.py	Sat Dec 03 03:45:45 2022 +0100
+++ b/mercurial/hg.py	Fri Dec 02 18:04:37 2022 +0100
@@ -161,20 +161,17 @@
 }
 
 
-def _peerlookup(path):
-    u = urlutil.url(path)
-    scheme = u.scheme or b'file'
-    if scheme in peer_schemes:
-        return peer_schemes[scheme]
-    if scheme in repo_schemes:
-        return repo_schemes[scheme]
-    return LocalFactory
-
-
 def islocal(repo):
     '''return true if repo (or path pointing to repo) is local'''
     if isinstance(repo, bytes):
-        cls = _peerlookup(repo)
+        u = urlutil.url(repo)
+        scheme = u.scheme or b'file'
+        if scheme in peer_schemes:
+            cls = peer_schemes[scheme]
+        elif scheme in repo_schemes:
+            cls = repo_schemes[scheme]
+        else:
+            cls = LocalFactory
         cls.instance  # make sure we load the module
         if util.safehasattr(cls, 'islocal'):
             return cls.islocal(repo)  # pytype: disable=module-attr