comparison mercurial/hg.py @ 49754:ec30fe6917ec

peer: build a `path` object on the fly when needed So now, we always have a `path` object around when building the peer
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 02 Dec 2022 17:41:44 +0100
parents f075a9463ee7
children 2d11a98db799
comparison
equal deleted inserted replaced
49753:ff7134e03629 49754:ec30fe6917ec
242 return repo.filtered(b'visible') 242 return repo.filtered(b'visible')
243 243
244 244
245 def peer(uiorrepo, opts, path, create=False, intents=None, createopts=None): 245 def peer(uiorrepo, opts, path, create=False, intents=None, createopts=None):
246 '''return a repository peer for the specified path''' 246 '''return a repository peer for the specified path'''
247 ui = getattr(uiorrepo, 'ui', uiorrepo)
247 rui = remoteui(uiorrepo, opts) 248 rui = remoteui(uiorrepo, opts)
248 if util.safehasattr(path, 'url'): 249 if util.safehasattr(path, 'url'):
249 # this is a urlutil.path object 250 # this is already a urlutil.path object
250 scheme = path.url.scheme # pytype: disable=attribute-error 251 peer_path = path
251 # XXX for now we don't do anything more than that
252 path = path.loc # pytype: disable=attribute-error
253 else: 252 else:
254 scheme = urlutil.url(path).scheme 253 peer_path = urlutil.path(ui, None, rawloc=path, validate_path=False)
254 scheme = peer_path.url.scheme # pytype: disable=attribute-error
255 if scheme in peer_schemes: 255 if scheme in peer_schemes:
256 cls = peer_schemes[scheme] 256 cls = peer_schemes[scheme]
257 peer = cls.make_peer( 257 peer = cls.make_peer(
258 rui, 258 rui,
259 path, 259 peer_path.loc,
260 create, 260 create,
261 intents=intents, 261 intents=intents,
262 createopts=createopts, 262 createopts=createopts,
263 ) 263 )
264 _setup_repo_or_peer(rui, peer) 264 _setup_repo_or_peer(rui, peer)
265 else: 265 else:
266 # this is a repository 266 # this is a repository
267 repo_path = peer_path.loc # pytype: disable=attribute-error
268 if not repo_path:
269 repo_path = peer_path.rawloc # pytype: disable=attribute-error
267 repo = repository( 270 repo = repository(
268 rui, 271 rui,
269 path, 272 repo_path,
270 create, 273 create,
271 intents=intents, 274 intents=intents,
272 createopts=createopts, 275 createopts=createopts,
273 ) 276 )
274 peer = repo.peer() 277 peer = repo.peer()