Mercurial > public > mercurial-scm > hg
diff mercurial/mail.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 | ce26928cbe41 |
children | ab1af5e7d734 |
line wrap: on
line diff
--- a/mercurial/mail.py Mon Oct 05 22:49:24 2015 -0700 +++ b/mercurial/mail.py Thu Oct 08 12:55:45 2015 -0700 @@ -18,6 +18,7 @@ from .i18n import _ from . import ( encoding, + error, sslutil, util, ) @@ -93,7 +94,7 @@ return new_socket else: def SMTPS(sslkwargs, keyfile=None, certfile=None, **kwargs): - raise util.Abort(_('SMTPS requires Python 2.6 or later')) + raise error.Abort(_('SMTPS requires Python 2.6 or later')) def _smtp(ui): '''build an smtp connection and return a function to send mail''' @@ -103,14 +104,14 @@ starttls = tls == 'starttls' or util.parsebool(tls) smtps = tls == 'smtps' if (starttls or smtps) and not util.safehasattr(socket, 'ssl'): - raise util.Abort(_("can't use TLS: Python SSL support not installed")) + raise error.Abort(_("can't use TLS: Python SSL support not installed")) mailhost = ui.config('smtp', 'host') if not mailhost: - raise util.Abort(_('smtp.host not configured - cannot send mail')) + raise error.Abort(_('smtp.host not configured - cannot send mail')) verifycert = ui.config('smtp', 'verifycert', 'strict') if verifycert not in ['strict', 'loose']: if util.parsebool(verifycert) is not False: - raise util.Abort(_('invalid smtp.verifycert configuration: %s') + raise error.Abort(_('invalid smtp.verifycert configuration: %s') % (verifycert)) verifycert = False if (starttls or smtps) and verifycert: @@ -151,16 +152,16 @@ try: s.login(username, password) except smtplib.SMTPException as inst: - raise util.Abort(inst) + raise error.Abort(inst) def send(sender, recipients, msg): try: return s.sendmail(sender, recipients, msg) except smtplib.SMTPRecipientsRefused as inst: recipients = [r[1] for r in inst.recipients.values()] - raise util.Abort('\n' + '\n'.join(recipients)) + raise error.Abort('\n' + '\n'.join(recipients)) except smtplib.SMTPException as inst: - raise util.Abort(inst) + raise error.Abort(inst) return send @@ -174,7 +175,7 @@ fp.write(msg) ret = fp.close() if ret: - raise util.Abort('%s %s' % ( + raise error.Abort('%s %s' % ( os.path.basename(program.split(None, 1)[0]), util.explainexit(ret)[0])) @@ -208,11 +209,11 @@ method = ui.config('email', 'method', 'smtp') if method == 'smtp': if not ui.config('smtp', 'host'): - raise util.Abort(_('smtp specified as email transport, ' + raise error.Abort(_('smtp specified as email transport, ' 'but no smtp host configured')) else: if not util.findexe(method): - raise util.Abort(_('%r specified as email transport, ' + raise error.Abort(_('%r specified as email transport, ' 'but not in PATH') % method) def mimetextpatch(s, subtype='plain', display=False): @@ -302,13 +303,13 @@ dom = dom.decode(encoding.encoding).encode('idna') addr = '%s@%s' % (acc, dom) except UnicodeDecodeError: - raise util.Abort(_('invalid email address: %s') % addr) + raise error.Abort(_('invalid email address: %s') % addr) except ValueError: try: # too strict? addr = addr.encode('ascii') except UnicodeDecodeError: - raise util.Abort(_('invalid local address: %s') % addr) + raise error.Abort(_('invalid local address: %s') % addr) return email.Utils.formataddr((name, addr)) def addressencode(ui, address, charsets=None, display=False):