Read about our upcoming Code of Conduct on this issue

Commit 7d6e838a authored by Matt Harbison's avatar Matt Harbison
Browse files

Synchronize `keyring_supported_smtp()` with core `mail._smtp()`

Aside from the customization of fetching the password from the store, I left the
default config arg for `smtp.tls` and the `util.safehasattr(socket, 'ssl')`
check for TLS to support ancient Mercurial versions.

I think this area could be improved greatly by changing Mercurial to have a
separate function that fetches the username/password that this extension could
wrap and replace, and another function that can be given a username/password to
try the login.  That would eliminate a lot of code duplication that I'm not
entirely convinced is py3 safe in core Mercurial, such as passing the exception
to `error.Abort` a couple lines below.
parent 7ad91f572a89
......@@ -755,7 +755,7 @@ def keyring_supported_smtp(ui, username):
return s.sendmail(sender, recipients, msg)
except smtplib.SMTPRecipientsRefused as inst:
recipients = [r[1] for r in inst.recipients.values()]
raise error.Abort('\n' + '\n'.join(recipients))
raise error.Abort(b'\n' + b'\n'.join(recipients))
except smtplib.SMTPException as inst:
raise error.Abort(inst)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment