path: have `peer` constructor accept a `path` object
We don't do anything fancy with it yet, but this is an important step towards
having the peers aware of their "source" and associated configurations.
--- a/mercurial/hg.py Thu Dec 01 01:46:46 2022 +0100
+++ b/mercurial/hg.py Wed Nov 30 19:43:26 2022 +0100
@@ -243,7 +243,13 @@
def peer(uiorrepo, opts, path, create=False, intents=None, createopts=None):
'''return a repository peer for the specified path'''
rui = remoteui(uiorrepo, opts)
- scheme = urlutil.url(path).scheme
+ 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
+ else:
+ scheme = urlutil.url(path).scheme
if scheme in peer_schemes:
cls = peer_schemes[scheme]
peer = cls.instance(