D886: ui: convert to/from Optional[bytes] to Optional[str] in password manager
durin42 (Augie Fackler)
phabricator at mercurial-scm.org
Wed Oct 4 12:26:51 EDT 2017
durin42 updated this revision to Diff 2421.
durin42 marked 3 inline comments as done.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D886?vs=2298&id=2421
REVISION DETAIL
https://phab.mercurial-scm.org/D886
AFFECTED FILES
mercurial/ui.py
CHANGE DETAILS
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -135,6 +135,15 @@
""",
}
+def _maybestrurl(maybebytes):
+ if maybebytes is None:
+ return None
+ return pycompat.strurl(maybebytes)
+
+def _maybebytesurl(maybestr):
+ if maybestr is None:
+ return None
+ return pycompat.bytesurl(maybestr)
class httppasswordmgrdbproxy(object):
"""Delays loading urllib2 until it's needed."""
@@ -147,10 +156,18 @@
return self._mgr
def add_password(self, realm, uris, user, passwd):
- return self._get_mgr().add_password(realm, uris, user, passwd)
+ if isinstance(uris, tuple):
+ uris = tuple(_maybestrurl(u) for u in uris)
+ else:
+ uris = _maybestrurl(uris)
+ return self._get_mgr().add_password(
+ _maybestrurl(realm), uris,
+ _maybestrurl(user), _maybestrurl(passwd))
def find_user_password(self, realm, uri):
- return self._get_mgr().find_user_password(realm, uri)
+ return tuple(_maybebytesurl(v) for v in
+ self._get_mgr().find_user_password(_maybestrurl(realm),
+ _maybestrurl(uri)))
def _catchterm(*args):
raise error.SignalInterrupt
To: durin42, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
More information about the Mercurial-devel
mailing list