changeset 49759:cfe8d88a453e

peer: get the `path` object down to the httppeer One more peer with a path stored.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 03 Dec 2022 00:24:28 +0100
parents 20f262ab6fd3
children 5bceea1a8234
files mercurial/debugcommands.py mercurial/httppeer.py
diffstat 2 files changed, 11 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Sat Dec 03 05:53:13 2022 +0100
+++ b/mercurial/debugcommands.py	Sat Dec 03 00:24:28 2022 +0100
@@ -4500,7 +4500,8 @@
                 _(b'--peer %s not supported with HTTP peers') % opts[b'peer']
             )
         else:
-            peer = httppeer.makepeer(ui, path, opener=opener)
+            peer_path = urlutil.try_path(ui, path)
+            peer = httppeer.makepeer(ui, peer_path, opener=opener)
 
         # We /could/ populate stdin/stdout with sock.makefile()...
     else:
--- a/mercurial/httppeer.py	Sat Dec 03 05:53:13 2022 +0100
+++ b/mercurial/httppeer.py	Sat Dec 03 00:24:28 2022 +0100
@@ -382,8 +382,7 @@
 
 class httppeer(wireprotov1peer.wirepeer):
     def __init__(self, ui, path, url, opener, requestbuilder, caps):
-        super().__init__(ui)
-        self._path = path
+        super().__init__(ui, path=path)
         self._url = url
         self._caps = caps
         self.limitedarguments = caps is not None and b'httppostargs' not in caps
@@ -398,7 +397,7 @@
     # Begin of ipeerconnection interface.
 
     def url(self):
-        return self._path
+        return self.path.loc
 
     def local(self):
         return None
@@ -602,14 +601,13 @@
     ``requestbuilder`` is the type used for constructing HTTP requests.
     It exists as an argument so extensions can override the default.
     """
-    u = urlutil.url(path)
-    if u.query or u.fragment:
-        raise error.Abort(
-            _(b'unsupported URL component: "%s"') % (u.query or u.fragment)
-        )
+    if path.url.query or path.url.fragment:
+        msg = _(b'unsupported URL component: "%s"')
+        msg %= path.url.query or path.url.fragment
+        raise error.Abort(msg)
 
     # urllib cannot handle URLs with embedded user or passwd.
-    url, authinfo = u.authinfo()
+    url, authinfo = path.url.authinfo()
     ui.debug(b'using %s\n' % url)
 
     opener = opener or urlmod.opener(ui, authinfo)
@@ -624,9 +622,8 @@
 def make_peer(ui, path, create, intents=None, createopts=None):
     if create:
         raise error.Abort(_(b'cannot create new http repository'))
-    path = path.loc
     try:
-        if path.startswith(b'https:') and not urlmod.has_https:
+        if path.url.scheme == b'https' and not urlmod.has_https:
             raise error.Abort(
                 _(b'Python support for SSL and HTTPS is not installed')
             )
@@ -636,7 +633,7 @@
         return inst
     except error.RepoError as httpexception:
         try:
-            r = statichttprepo.make_peer(ui, b"static-" + path, create)
+            r = statichttprepo.make_peer(ui, b"static-" + path.loc, create)
             ui.note(_(b'(falling back to static-http)\n'))
             return r
         except error.RepoError: