comparison mercurial/hg.py @ 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
comparison
equal deleted inserted replaced
49748:78af51ba73c5 49749:be3fcd9e5e52
159 b'ssh': sshpeer, 159 b'ssh': sshpeer,
160 b'static-http': statichttprepo, 160 b'static-http': statichttprepo,
161 } 161 }
162 162
163 163
164 def _peerlookup(path):
165 u = urlutil.url(path)
166 scheme = u.scheme or b'file'
167 if scheme in peer_schemes:
168 return peer_schemes[scheme]
169 if scheme in repo_schemes:
170 return repo_schemes[scheme]
171 return LocalFactory
172
173
174 def islocal(repo): 164 def islocal(repo):
175 '''return true if repo (or path pointing to repo) is local''' 165 '''return true if repo (or path pointing to repo) is local'''
176 if isinstance(repo, bytes): 166 if isinstance(repo, bytes):
177 cls = _peerlookup(repo) 167 u = urlutil.url(repo)
168 scheme = u.scheme or b'file'
169 if scheme in peer_schemes:
170 cls = peer_schemes[scheme]
171 elif scheme in repo_schemes:
172 cls = repo_schemes[scheme]
173 else:
174 cls = LocalFactory
178 cls.instance # make sure we load the module 175 cls.instance # make sure we load the module
179 if util.safehasattr(cls, 'islocal'): 176 if util.safehasattr(cls, 'islocal'):
180 return cls.islocal(repo) # pytype: disable=module-attr 177 return cls.islocal(repo) # pytype: disable=module-attr
181 return False 178 return False
182 repo.ui.deprecwarn(b"use obj.local() instead of islocal(obj)", b"6.4") 179 repo.ui.deprecwarn(b"use obj.local() instead of islocal(obj)", b"6.4")