httppeer: move url opening in its own method
authorBoris Feld <boris.feld@octobus.net>
Fri, 12 Jan 2018 10:14:20 +0000
changeset 35697 5a7906ed78d4
parent 35696 925107e37619
child 35698 0c4b23ccf1a5
httppeer: move url opening in its own method This will help adding debugging logic to request opening when investigating Mercurial performance.
mercurial/httppeer.py
--- a/mercurial/httppeer.py	Fri Jan 12 10:57:29 2018 +0000
+++ b/mercurial/httppeer.py	Fri Jan 12 10:14:20 2018 +0000
@@ -161,6 +161,9 @@
                 h.close()
                 getattr(h, "close_all", lambda: None)()
 
+    def _openurl(self, req):
+        return self._urlopener.open(req)
+
     # Begin of _basepeer interface.
 
     @util.propertycache
@@ -298,7 +301,7 @@
             self.ui.debug("sending %s bytes\n" % size)
             req.add_unredirected_header('Content-Length', '%d' % size)
         try:
-            resp = self._urlopener.open(req)
+            resp = self._openurl(req)
         except urlerr.httperror as inst:
             if inst.code == 401:
                 raise error.Abort(_('authorization failed'))