path: have `peer` constructor accept a `path` object
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 30 Nov 2022 19:43:26 +0100
changeset 49707 aa36771ef505
parent 49706 f27fbb908b10
child 49708 0df2cff04291
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.
mercurial/hg.py
--- 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(