Mercurial > public > mercurial-scm > hg-stable
diff mercurial/sslutil.py @ 26587:56b2bcea2529
error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.
For great justice.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 08 Oct 2015 12:55:45 -0700 |
parents | 696f6e2be282 |
children | 9e15286609ae |
line wrap: on
line diff
--- a/mercurial/sslutil.py Mon Oct 05 22:49:24 2015 -0700 +++ b/mercurial/sslutil.py Thu Oct 08 12:55:45 2015 -0700 @@ -14,7 +14,7 @@ import sys from .i18n import _ -from . import util +from . import error, util _canloaddefaultcerts = False try: @@ -50,7 +50,7 @@ # closed # - see http://bugs.python.org/issue13721 if not sslsocket.cipher(): - raise util.Abort(_('ssl connection failed')) + raise error.Abort(_('ssl connection failed')) return sslsocket except AttributeError: def wrapsocket(sock, keyfile, certfile, ui, cert_reqs=ssl.CERT_NONE, @@ -62,7 +62,7 @@ # closed # - see http://bugs.python.org/issue13721 if not sslsocket.cipher(): - raise util.Abort(_('ssl connection failed')) + raise error.Abort(_('ssl connection failed')) return sslsocket def _verifycert(cert, hostname): @@ -140,7 +140,7 @@ elif cacerts: cacerts = util.expandpath(cacerts) if not os.path.exists(cacerts): - raise util.Abort(_('could not find web.cacerts: %s') % cacerts) + raise error.Abort(_('could not find web.cacerts: %s') % cacerts) else: cacerts = _defaultcacerts() if cacerts and cacerts != '!': @@ -163,15 +163,15 @@ hostfingerprint = self.ui.config('hostfingerprints', host) if not sock.cipher(): # work around http://bugs.python.org/issue13721 - raise util.Abort(_('%s ssl connection error') % host) + raise error.Abort(_('%s ssl connection error') % host) try: peercert = sock.getpeercert(True) peercert2 = sock.getpeercert() except AttributeError: - raise util.Abort(_('%s ssl connection error') % host) + raise error.Abort(_('%s ssl connection error') % host) if not peercert: - raise util.Abort(_('%s certificate error: ' + raise error.Abort(_('%s certificate error: ' 'no certificate received') % host) peerfingerprint = util.sha1(peercert).hexdigest() nicefingerprint = ":".join([peerfingerprint[x:x + 2] @@ -179,7 +179,7 @@ if hostfingerprint: if peerfingerprint.lower() != \ hostfingerprint.replace(':', '').lower(): - raise util.Abort(_('certificate for %s has unexpected ' + raise error.Abort(_('certificate for %s has unexpected ' 'fingerprint %s') % (host, nicefingerprint), hint=_('check hostfingerprint configuration')) self.ui.debug('%s certificate matched fingerprint %s\n' % @@ -187,13 +187,13 @@ elif cacerts != '!': msg = _verifycert(peercert2, host) if msg: - raise util.Abort(_('%s certificate error: %s') % (host, msg), + raise error.Abort(_('%s certificate error: %s') % (host, msg), hint=_('configure hostfingerprint %s or use ' '--insecure to connect insecurely') % nicefingerprint) self.ui.debug('%s certificate successfully verified\n' % host) elif strict: - raise util.Abort(_('%s certificate with fingerprint %s not ' + raise error.Abort(_('%s certificate with fingerprint %s not ' 'verified') % (host, nicefingerprint), hint=_('check hostfingerprints or web.cacerts ' 'config setting'))