Patchwork [2,of,4,V2] httppeer: move url opening in its own method

login
register
mail settings
Submitter Boris Feld
Date Jan. 18, 2018, 10:01 a.m.
Message ID <b3c2b26ca38f2617ed9a.1516269716@FB>
Download mbox | patch
Permalink /patch/26840/
State Accepted
Headers show

Comments

Boris Feld - Jan. 18, 2018, 10:01 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1515752060 0
#      Fri Jan 12 10:14:20 2018 +0000
# Node ID b3c2b26ca38f2617ed9a7ef91db0c908a0a516c4
# Parent  2037b549cf196c6a06a6a2d895f8fbdd4fee077d
# EXP-Topic exchangedebug
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b3c2b26ca38f
httppeer: move url opening in its own method

This will help adding debugging logic to request opening when investigating
Mercurial performance.

Patch

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -161,6 +161,9 @@  class httppeer(wireproto.wirepeer):
                 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 @@  class httppeer(wireproto.wirepeer):
             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'))