Read about our upcoming Code of Conduct on this issue

Commit 8029f096 authored by Matt Harbison's avatar Matt Harbison
Browse files

Byteify all `ui.config()` calls

Mercurial both wants and returns bytes from these.
parent e4e41ce8c509
......@@ -684,14 +684,14 @@ def keyring_supported_smtp(ui, username):
except ImportError:
from mercurial.utils import parsebool # pytype: disable=import-error
local_hostname = ui.config('smtp', 'local_hostname')
tls = ui.config('smtp', 'tls', 'none')
local_hostname = ui.config(b'smtp', b'local_hostname')
tls = ui.config(b'smtp', b'tls', b'none')
# backward compatible: when tls = true, we use starttls.
starttls = tls == 'starttls' or parsebool(tls)
smtps = tls == 'smtps'
starttls = tls == b'starttls' or parsebool(tls)
smtps = tls == b'smtps'
if (starttls or smtps) and not util.safehasattr(socket, 'ssl'):
raise error.Abort(_(b"can't use TLS: Python SSL support not installed"))
mailhost = ui.config('smtp', 'host')
mailhost = ui.config(b'smtp', b'host')
if not mailhost:
raise error.Abort(_(b'smtp.host not configured - cannot send mail'))
if getattr(sslutil, 'sslkwargs', None) is None:
......@@ -723,8 +723,8 @@ def keyring_supported_smtp(ui, username):
defaultport = 465
else:
defaultport = 25
mailport = util.getport(ui.config('smtp', 'port', defaultport))
ui.note(_(b'sending mail: smtp host %s, port %s\n') %
mailport = util.getport(ui.config(b'smtp', b'port', defaultport))
ui.note(_(b'sending mail: smtp host %s, port %d\n') %
(mailhost, mailport))
s.connect(host=mailhost, port=mailport)
if starttls:
......@@ -775,8 +775,8 @@ def _smtp(ui):
mercurial/mail.py. It calls the original unless username
without password is given in the configuration.
"""
username = ui.config('smtp', 'username')
password = ui.config('smtp', 'password')
username = ui.config(b'smtp', b'username')
password = ui.config(b'smtp', b'password')
if username and not password:
return keyring_supported_smtp(ui, username)
......
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