##// END OF EJS Templates
Preliminarly works under py3
Marcin Kasperski -
r276:2e8904dc default
parent child Browse files
Show More
@@ -184,12 +184,23 b' class PasswordStore(object):'
184
184
185 def clear_http_password(self, url, username):
185 def clear_http_password(self, url, username):
186 """Drops saved password"""
186 """Drops saved password"""
187 self.set_http_password(url, username, "")
187 self.set_http_password(url, username, b"")
188
188
189 @staticmethod
189 @staticmethod
190 def _format_http_key(url, username):
190 def _format_http_key(url, username):
191 """Construct actual key for password identification"""
191 """Construct actual key for password identification"""
192 return "%s@@%s" % (username, url)
192 # keyring expects str, mercurial feeds as here mostly with bytes
193 key = "%s@@%s" % (meu.pycompat.sysstr(username),
194 meu.pycompat.sysstr(url))
195 return key
196
197 @staticmethod
198 def _format_smtp_key(machine, port, username):
199 """Construct key for SMTP password identification"""
200 key = "%s@@%s:%s" % (meu.pycompat.sysstr(username),
201 meu.pycompat.sysstr(machine),
202 str(port))
203 return key
193
204
194 def get_smtp_password(self, machine, port, username):
205 def get_smtp_password(self, machine, port, username):
195 """Checks for SMTP password in keyring, returns
206 """Checks for SMTP password in keyring, returns
@@ -208,11 +219,6 b' class PasswordStore(object):'
208 self.set_smtp_password(machine, port, username, "")
219 self.set_smtp_password(machine, port, username, "")
209
220
210 @staticmethod
221 @staticmethod
211 def _format_smtp_key(machine, port, username):
212 """Construct key for SMTP password identification"""
213 return "%s@@%s:%s" % (username, machine, str(port))
214
215 @staticmethod
216 def _read_password_from_keyring(pwdkey):
222 def _read_password_from_keyring(pwdkey):
217 """Physically read from keyring"""
223 """Physically read from keyring"""
218 keyring = import_keyring()
224 keyring = import_keyring()
@@ -220,9 +226,10 b' class PasswordStore(object):'
220 password = keyring.get_password(KEYRING_SERVICE, pwdkey)
226 password = keyring.get_password(KEYRING_SERVICE, pwdkey)
221 except Exception as err:
227 except Exception as err:
222 ui = uimod.ui()
228 ui = uimod.ui()
223 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",
229 ui.warn(meu.ui_string(
224 err))
230 "keyring: keyring backend doesn't seem to work, password can not be restored. Falling back to prompts. Error details: %s\n",
225 return ''
231 err))
232 return b''
226 # Reverse recoding from next routine
233 # Reverse recoding from next routine
227 if isinstance(password, meu.pycompat.unicode):
234 if isinstance(password, meu.pycompat.unicode):
228 return encoding.tolocal(password.encode('utf-8'))
235 return encoding.tolocal(password.encode('utf-8'))
@@ -841,7 +848,7 b' def cmd_keyring_clear(ui, repo, path, **'
841 of path alias (``bitbucket``).
848 of path alias (``bitbucket``).
842 """
849 """
843 path_url = path
850 path_url = path
844 for name, url in ui.configitems('paths'):
851 for name, url in ui.configitems(b'paths'):
845 if name == path:
852 if name == path:
846 path_url = url
853 path_url = url
847 break
854 break
General Comments 0
You need to be logged in to leave comments. Login now