# HG changeset patch # User Pierre-Yves David # Date 1669999304 -3600 # Node ID ec30fe6917ec9ea528131d199f60c5630a38ced2 # Parent ff7134e03629cccf890c11fad291b71b7626d378 peer: build a `path` object on the fly when needed So now, we always have a `path` object around when building the peer diff -r ff7134e03629 -r ec30fe6917ec mercurial/hg.py --- a/mercurial/hg.py Sat Dec 03 00:16:07 2022 +0100 +++ b/mercurial/hg.py Fri Dec 02 17:41:44 2022 +0100 @@ -244,19 +244,19 @@ def peer(uiorrepo, opts, path, create=False, intents=None, createopts=None): '''return a repository peer for the specified path''' + ui = getattr(uiorrepo, 'ui', uiorrepo) rui = remoteui(uiorrepo, opts) if util.safehasattr(path, 'url'): - # this is a urlutil.path object - scheme = path.url.scheme # pytype: disable=attribute-error - # XXX for now we don't do anything more than that - path = path.loc # pytype: disable=attribute-error + # this is already a urlutil.path object + peer_path = path else: - scheme = urlutil.url(path).scheme + peer_path = urlutil.path(ui, None, rawloc=path, validate_path=False) + scheme = peer_path.url.scheme # pytype: disable=attribute-error if scheme in peer_schemes: cls = peer_schemes[scheme] peer = cls.make_peer( rui, - path, + peer_path.loc, create, intents=intents, createopts=createopts, @@ -264,9 +264,12 @@ _setup_repo_or_peer(rui, peer) else: # this is a repository + repo_path = peer_path.loc # pytype: disable=attribute-error + if not repo_path: + repo_path = peer_path.rawloc # pytype: disable=attribute-error repo = repository( rui, - path, + repo_path, create, intents=intents, createopts=createopts,