D3238: httppeer: allow opener to be passed to makepeer()

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Wed Apr 11 13:01:36 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6b08cf6b900f: httppeer: allow opener to be passed to makepeer() (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3238?vs=7956&id=7999

REVISION DETAIL
  https://phab.mercurial-scm.org/D3238

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/httppeer.py

CHANGE DETAILS

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -620,9 +620,12 @@
 
     return respurl, set(rawcaps.split())
 
-def makepeer(ui, path, requestbuilder=urlreq.request):
+def makepeer(ui, path, opener=None, requestbuilder=urlreq.request):
     """Construct an appropriate HTTP peer instance.
 
+    ``opener`` is an ``url.opener`` that should be used to establish
+    connections, perform HTTP requests.
+
     ``requestbuilder`` is the type used for constructing HTTP requests.
     It exists as an argument so extensions can override the default.
     """
@@ -635,7 +638,7 @@
     url, authinfo = u.authinfo()
     ui.debug('using %s\n' % url)
 
-    opener = urlmod.opener(ui, authinfo)
+    opener = opener or urlmod.opener(ui, authinfo)
 
     respurl, caps = performhandshake(ui, url, opener, requestbuilder)
 
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2915,12 +2915,7 @@
             raise error.Abort(_('--peer %s not supported with HTTP peers') %
                               opts['peer'])
         else:
-            url, caps = httppeer.performhandshake(ui, url, opener,
-                                                  httppeer.urlreq.request)
-
-            peer = httppeer.httppeer(ui, path, url, opener,
-                                     httppeer.urlreq.request,
-                                     caps)
+            peer = httppeer.makepeer(ui, path, opener=opener)
 
         # We /could/ populate stdin/stdout with sock.makefile()...
     else:



To: indygreg, #hg-reviewers, durin42
Cc: mercurial-devel


More information about the Mercurial-devel mailing list