Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hg.py @ 49804:c0acf5440fe1
peer-or-repo: build a peer directly in the `peer` function
We skip the ambiguous _peerorrepo function to explicitly build a peer within
the dedicated function. This mean explicitly getting a peer from an explicitly
create repository when necessary.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 29 Nov 2022 22:04:23 +0100 |
parents | c37287340c00 |
children | ebb5e38fdafc |
comparison
equal
deleted
inserted
replaced
49803:c37287340c00 | 49804:c0acf5440fe1 |
---|---|
248 | 248 |
249 | 249 |
250 def peer(uiorrepo, opts, path, create=False, intents=None, createopts=None): | 250 def peer(uiorrepo, opts, path, create=False, intents=None, createopts=None): |
251 '''return a repository peer for the specified path''' | 251 '''return a repository peer for the specified path''' |
252 rui = remoteui(uiorrepo, opts) | 252 rui = remoteui(uiorrepo, opts) |
253 return _peerorrepo( | 253 scheme = urlutil.url(path).scheme |
254 rui, path, create, intents=intents, createopts=createopts | 254 if scheme in peer_schemes: |
255 ).peer() | 255 cls = peer_schemes[scheme] |
256 peer = cls.instance( | |
257 rui, | |
258 path, | |
259 create, | |
260 intents=intents, | |
261 createopts=createopts, | |
262 ) | |
263 _setup_repo_or_peer(rui, peer) | |
264 else: | |
265 # this is a repository | |
266 repo = repository( | |
267 rui, | |
268 path, | |
269 create, | |
270 intents=intents, | |
271 createopts=createopts, | |
272 ) | |
273 peer = repo.peer() | |
274 return peer | |
256 | 275 |
257 | 276 |
258 def defaultdest(source): | 277 def defaultdest(source): |
259 """return default destination of clone if none is given | 278 """return default destination of clone if none is given |
260 | 279 |