changeset 49707:aa36771ef505

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 30 Nov 2022 19:43:26 +0100
parents f27fbb908b10
children 0df2cff04291
files mercurial/hg.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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(