[PATCH 1 of 4] ssl: rename ssl_wrap_socket() to conform to our naming convention

Yuya Nishihara yuya at tcha.org
Fri Jun 5 09:21:20 CDT 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1433507128 -32400
#      Fri Jun 05 21:25:28 2015 +0900
# Node ID 9d1c617159398bdb9f552fe312f5bac55521c28e
# Parent  51e7acc34b0ab0e540dffdb22127914f2353d5e2
ssl: rename ssl_wrap_socket() to conform to our naming convention

I've removed ssl_ prefix because the module name contains ssl.

diff --git a/mercurial/httpconnection.py b/mercurial/httpconnection.py
--- a/mercurial/httpconnection.py
+++ b/mercurial/httpconnection.py
@@ -277,7 +277,7 @@ class http2handler(urllib2.HTTPHandler, 
         kwargs.update(sslutil.sslkwargs(self.ui, host))
 
         con = HTTPConnection(host, port, use_ssl=True,
-                             ssl_wrap_socket=sslutil.ssl_wrap_socket,
+                             ssl_wrap_socket=sslutil.wrapsocket,
                              ssl_validator=sslutil.validator(self.ui, host),
                              **kwargs)
         return con
diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -45,8 +45,8 @@ class STARTTLS(smtplib.SMTP):
             raise smtplib.SMTPException(msg)
         (resp, reply) = self.docmd("STARTTLS")
         if resp == 220:
-            self.sock = sslutil.ssl_wrap_socket(self.sock, keyfile, certfile,
-                                                **self._sslkwargs)
+            self.sock = sslutil.wrapsocket(self.sock, keyfile, certfile,
+                                           **self._sslkwargs)
             if not util.safehasattr(self.sock, "read"):
                 # using httplib.FakeSocket with Python 2.5.x or earlier
                 self.sock.read = self.sock.recv
@@ -74,9 +74,9 @@ if util.safehasattr(smtplib.SMTP, '_get_
             if self.debuglevel > 0:
                 print >> sys.stderr, 'connect:', (host, port)
             new_socket = socket.create_connection((host, port), timeout)
-            new_socket = sslutil.ssl_wrap_socket(new_socket,
-                                                 self.keyfile, self.certfile,
-                                                 **self._sslkwargs)
+            new_socket = sslutil.wrapsocket(new_socket,
+                                            self.keyfile, self.certfile,
+                                            **self._sslkwargs)
             self.file = smtplib.SSLFakeFile(new_socket)
             return new_socket
 else:
diff --git a/mercurial/sslutil.py b/mercurial/sslutil.py
--- a/mercurial/sslutil.py
+++ b/mercurial/sslutil.py
@@ -21,9 +21,9 @@ try:
         _canloaddefaultcerts = util.safehasattr(ssl_context,
                                                 'load_default_certs')
 
-        def ssl_wrap_socket(sock, keyfile, certfile, ui,
-                            cert_reqs=ssl.CERT_NONE,
-                            ca_certs=None, serverhostname=None):
+        def wrapsocket(sock, keyfile, certfile, ui,
+                       cert_reqs=ssl.CERT_NONE,
+                       ca_certs=None, serverhostname=None):
             # Allow any version of SSL starting with TLSv1 and
             # up. Note that specifying TLSv1 here prohibits use of
             # newer standards (like TLSv1_2), so this is the right way
@@ -55,9 +55,9 @@ try:
                 raise util.Abort(_('ssl connection failed'))
             return sslsocket
     except AttributeError:
-        def ssl_wrap_socket(sock, keyfile, certfile, ui,
-                            cert_reqs=ssl.CERT_NONE,
-                            ca_certs=None, serverhostname=None):
+        def wrapsocket(sock, keyfile, certfile, ui,
+                       cert_reqs=ssl.CERT_NONE,
+                       ca_certs=None, serverhostname=None):
             sslsocket = ssl.wrap_socket(sock, keyfile, certfile,
                                         cert_reqs=cert_reqs, ca_certs=ca_certs,
                                         ssl_version=ssl.PROTOCOL_TLSv1)
@@ -72,9 +72,9 @@ except ImportError:
 
     import socket, httplib
 
-    def ssl_wrap_socket(sock, keyfile, certfile, ui,
-                        cert_reqs=CERT_REQUIRED,
-                        ca_certs=None, serverhostname=None):
+    def wrapsocket(sock, keyfile, certfile, ui,
+                   cert_reqs=CERT_REQUIRED,
+                   ca_certs=None, serverhostname=None):
         if not util.safehasattr(socket, 'ssl'):
             raise util.Abort(_('Python SSL support not found'))
         if ca_certs:
diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -175,8 +175,8 @@ class httpconnection(keepalive.HTTPConne
             self.sock.connect((self.host, self.port))
             if _generic_proxytunnel(self):
                 # we do not support client X.509 certificates
-                self.sock = sslutil.ssl_wrap_socket(self.sock, None, None, None,
-                                                    serverhostname=self.host)
+                self.sock = sslutil.wrapsocket(self.sock, None, None, None,
+                                               serverhostname=self.host)
         else:
             keepalive.HTTPConnection.connect(self)
 
@@ -338,7 +338,7 @@ if has_https:
             if self.realhostport: # use CONNECT proxy
                 _generic_proxytunnel(self)
                 host = self.realhostport.rsplit(':', 1)[0]
-            self.sock = sslutil.ssl_wrap_socket(
+            self.sock = sslutil.wrapsocket(
                 self.sock, self.key_file, self.cert_file, serverhostname=host,
                 **sslutil.sslkwargs(self.ui, host))
             sslutil.validator(self.ui, host)(self.sock)


More information about the Mercurial-devel mailing list