# HG changeset patch # User Marcin Kasperski # Date 2019-11-10 23:56:57 # Node ID 2e8904dcd77ca6002ff5ab25feece1b0b8dee53a # Parent cc32dad51a3da6665b7f28ffafafc9ef6d7c445e Preliminarly works under py3 diff --git a/mercurial_keyring.py b/mercurial_keyring.py --- a/mercurial_keyring.py +++ b/mercurial_keyring.py @@ -184,12 +184,23 @@ class PasswordStore(object): def clear_http_password(self, url, username): """Drops saved password""" - self.set_http_password(url, username, "") + self.set_http_password(url, username, b"") @staticmethod def _format_http_key(url, username): """Construct actual key for password identification""" - return "%s@@%s" % (username, url) + # keyring expects str, mercurial feeds as here mostly with bytes + key = "%s@@%s" % (meu.pycompat.sysstr(username), + meu.pycompat.sysstr(url)) + return key + + @staticmethod + def _format_smtp_key(machine, port, username): + """Construct key for SMTP password identification""" + key = "%s@@%s:%s" % (meu.pycompat.sysstr(username), + meu.pycompat.sysstr(machine), + str(port)) + return key def get_smtp_password(self, machine, port, username): """Checks for SMTP password in keyring, returns @@ -208,11 +219,6 @@ class PasswordStore(object): self.set_smtp_password(machine, port, username, "") @staticmethod - def _format_smtp_key(machine, port, username): - """Construct key for SMTP password identification""" - return "%s@@%s:%s" % (username, machine, str(port)) - - @staticmethod def _read_password_from_keyring(pwdkey): """Physically read from keyring""" keyring = import_keyring() @@ -220,9 +226,10 @@ class PasswordStore(object): password = keyring.get_password(KEYRING_SERVICE, pwdkey) except Exception as err: ui = uimod.ui() - ui.warn(meu.ui_string("keyring: keyring backend doesn't seem to work, password can not be restored. Falling back to prompts. Error details: %s\n", - err)) - return '' + ui.warn(meu.ui_string( + "keyring: keyring backend doesn't seem to work, password can not be restored. Falling back to prompts. Error details: %s\n", + err)) + return b'' # Reverse recoding from next routine if isinstance(password, meu.pycompat.unicode): return encoding.tolocal(password.encode('utf-8')) @@ -841,7 +848,7 @@ def cmd_keyring_clear(ui, repo, path, ** of path alias (``bitbucket``). """ path_url = path - for name, url in ui.configitems('paths'): + for name, url in ui.configitems(b'paths'): if name == path: path_url = url break