mercurial/hg.py
changeset 49691 c0acf5440fe1
parent 49690 c37287340c00
child 49692 ebb5e38fdafc
--- 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):