Mercurial > hg
changeset 49691: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 |
files | mercurial/hg.py |
diffstat | 1 files changed, 22 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hg.py Tue Nov 29 22:03:10 2022 +0100 +++ b/mercurial/hg.py Tue Nov 29 22:04:23 2022 +0100 @@ -250,9 +250,28 @@ def peer(uiorrepo, opts, path, create=False, intents=None, createopts=None): '''return a repository peer for the specified path''' rui = remoteui(uiorrepo, opts) - return _peerorrepo( - rui, path, create, intents=intents, createopts=createopts - ).peer() + scheme = urlutil.url(path).scheme + if scheme in peer_schemes: + cls = peer_schemes[scheme] + peer = cls.instance( + rui, + path, + create, + intents=intents, + createopts=createopts, + ) + _setup_repo_or_peer(rui, peer) + else: + # this is a repository + repo = repository( + rui, + path, + create, + intents=intents, + createopts=createopts, + ) + peer = repo.peer() + return peer def defaultdest(source):