mercurial/ui.py
changeset 34482 75de5d456b60
parent 34426 ae2fcf7af409
child 34568 63c19b7fa100
equal deleted inserted replaced
34480:cbda631c1dde 34482:75de5d456b60
   133 # blackbox =
   133 # blackbox =
   134 # churn =
   134 # churn =
   135 """,
   135 """,
   136 }
   136 }
   137 
   137 
       
   138 def _maybestrurl(maybebytes):
       
   139     if maybebytes is None:
       
   140         return None
       
   141     return pycompat.strurl(maybebytes)
       
   142 
       
   143 def _maybebytesurl(maybestr):
       
   144     if maybestr is None:
       
   145         return None
       
   146     return pycompat.bytesurl(maybestr)
   138 
   147 
   139 class httppasswordmgrdbproxy(object):
   148 class httppasswordmgrdbproxy(object):
   140     """Delays loading urllib2 until it's needed."""
   149     """Delays loading urllib2 until it's needed."""
   141     def __init__(self):
   150     def __init__(self):
   142         self._mgr = None
   151         self._mgr = None
   145         if self._mgr is None:
   154         if self._mgr is None:
   146             self._mgr = urlreq.httppasswordmgrwithdefaultrealm()
   155             self._mgr = urlreq.httppasswordmgrwithdefaultrealm()
   147         return self._mgr
   156         return self._mgr
   148 
   157 
   149     def add_password(self, realm, uris, user, passwd):
   158     def add_password(self, realm, uris, user, passwd):
   150         return self._get_mgr().add_password(realm, uris, user, passwd)
   159         if isinstance(uris, tuple):
       
   160             uris = tuple(_maybestrurl(u) for u in uris)
       
   161         else:
       
   162             uris = _maybestrurl(uris)
       
   163         return self._get_mgr().add_password(
       
   164             _maybestrurl(realm), uris,
       
   165             _maybestrurl(user), _maybestrurl(passwd))
   151 
   166 
   152     def find_user_password(self, realm, uri):
   167     def find_user_password(self, realm, uri):
   153         return self._get_mgr().find_user_password(realm, uri)
   168         return tuple(_maybebytesurl(v) for v in
       
   169                      self._get_mgr().find_user_password(_maybestrurl(realm),
       
   170                                                         _maybestrurl(uri)))
   154 
   171 
   155 def _catchterm(*args):
   172 def _catchterm(*args):
   156     raise error.SignalInterrupt
   173     raise error.SignalInterrupt
   157 
   174 
   158 # unique object used to detect no default value has been provided when
   175 # unique object used to detect no default value has been provided when