Patchwork [2,of,5,V2] sslutil: use a dict for hanging hg state off the wrapped socket

mail settings
Submitter Gregory Szorc
Date May 15, 2016, 11:18 p.m.
Message ID <0a4ddbaae306c1e8a28a.1463354319@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/15125/
State Accepted
Headers show


Gregory Szorc - May 15, 2016, 11:18 p.m.
# HG changeset patch
# User Gregory Szorc <>
# Date 1463336707 25200
#      Sun May 15 11:25:07 2016 -0700
# Node ID 0a4ddbaae306c1e8a28abc37c54fe29f94042996
# Parent  56ceced54f4efb6da734e24af29b34d0aabc3d6c
sslutil: use a dict for hanging hg state off the wrapped socket

I plan on introducing more state on the socket instance. Instead
of using multiple variables, let's just use one to minimize risk
of name collision.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -166,17 +166,19 @@  def wrapsocket(sock, keyfile, certfile, 
     sslsocket = sslcontext.wrap_socket(sock, server_hostname=serverhostname)
     # check if wrap_socket failed silently because socket had been
     # closed
     # - see
     if not sslsocket.cipher():
         raise error.Abort(_('ssl connection failed'))
-    sslsocket._hgcaloaded = caloaded
+    sslsocket._hgstate = {
+        'caloaded': caloaded,
+    }
     return sslsocket
 def _verifycert(cert, hostname):
     '''Verify that cert (in socket.getpeercert() format) matches hostname.
     CRLs is not handled.
     Returns error message if any problems are found and None on success.
@@ -336,17 +338,17 @@  class validator(object):
         # the same as below for BC.
         if self.ui.insecureconnections:
             self.ui.warn(_('warning: %s certificate with fingerprint %s not '
                            'verified (check hostfingerprints or web.cacerts '
                            'config setting)\n') %
                          (host, nicefingerprint))
-        if not sock._hgcaloaded:
+        if not sock._hgstate['caloaded']:
             if strict:
                 raise error.Abort(_('%s certificate with fingerprint %s not '
                                     'verified') % (host, nicefingerprint),
                                   hint=_('check hostfingerprints or '
                                          'web.cacerts config setting'))
                 self.ui.warn(_('warning: %s certificate with fingerprint %s '
                                'not verified (check hostfingerprints or '