httppeer: consolidate _requestbuilder assignments and document
authorGregory Szorc <gregory.szorc@gmail.com>
Thu, 15 Mar 2018 11:19:16 -0700
changeset 36967 586891c561dc
parent 36966 66651ec259ea
child 36968 95f4f1bfb650
httppeer: consolidate _requestbuilder assignments and document I collapsed multiple assignments because they don't appear to be necessary. We don't invoke the requestbuilder in anything called during __init__. So there's no reason to not define it earlier AFAICT. This seemingly useless attribute is actually an extension point. Document it as such. (A previous version of this patch removed the attribute because it appeared to just be an alias.) Differential Revision: https://phab.mercurial-scm.org/D2723
mercurial/httppeer.py
--- a/mercurial/httppeer.py	Mon Mar 05 00:18:07 2018 -0500
+++ b/mercurial/httppeer.py	Thu Mar 15 11:19:16 2018 -0700
@@ -138,7 +138,9 @@
         self._path = path
         self._caps = None
         self._urlopener = None
-        self._requestbuilder = None
+        # This is an its own attribute to facilitate extensions overriding
+        # the default type.
+        self._requestbuilder = urlreq.request
         u = util.url(path)
         if u.query or u.fragment:
             raise error.Abort(_('unsupported URL component: "%s"') %
@@ -151,7 +153,6 @@
         ui.debug('using %s\n' % self._url)
 
         self._urlopener = urlmod.opener(ui, authinfo)
-        self._requestbuilder = urlreq.request
 
     def __del__(self):
         urlopener = getattr(self, '_urlopener', None)