Mercurial > hg
changeset 29378:fea71f66ebff
url: remember http password database in ui object
This makes http password database stored in ui object.
It allows reusing authentication information when we
use this database for creating password manager for
the new connection.
author | liscju <piotr.listkiewicz@gmail.com> |
---|---|
date | Thu, 09 Jun 2016 11:41:36 +0200 |
parents | 2c019aac6b99 |
children | fc777c855d66 |
files | mercurial/ui.py mercurial/url.py |
diffstat | 2 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Sun Jun 05 23:36:23 2016 +0200 +++ b/mercurial/ui.py Thu Jun 09 11:41:36 2016 +0200 @@ -29,6 +29,8 @@ util, ) +urlreq = util.urlreq + samplehgrcs = { 'user': """# example user config (see "hg help config" for more info) @@ -124,6 +126,8 @@ self.callhooks = src.callhooks self.insecureconnections = src.insecureconnections self.fixconfig() + + self.httppasswordmgrdb = src.httppasswordmgrdb else: self.fout = sys.stdout self.ferr = sys.stderr @@ -135,6 +139,8 @@ for f in scmutil.rcpath(): self.readconfig(f, trust=True) + self.httppasswordmgrdb = urlreq.httppasswordmgrwithdefaultrealm() + def copy(self): return self.__class__(self) @@ -142,6 +148,7 @@ """Clear internal state that shouldn't persist across commands""" if self._progbar: self._progbar.resetstate() # reset last-print time of progress bar + self.httppasswordmgrdb = urlreq.httppasswordmgrwithdefaultrealm() def formatter(self, topic, opts): return formatter.formatter(self, topic, opts)
--- a/mercurial/url.py Sun Jun 05 23:36:23 2016 +0200 +++ b/mercurial/url.py Thu Jun 09 11:41:36 2016 +0200 @@ -365,7 +365,7 @@ urlreq.httpshandler.__init__(self) self.ui = ui self.pwmgr = passwordmgr(self.ui, - urlreq.httppasswordmgrwithdefaultrealm()) + self.ui.httppasswordmgrdb) def _start_transaction(self, h, req): _generic_start_transaction(self, h, req) @@ -482,7 +482,7 @@ handlers = [ httpconnectionmod.http2handler( ui, - passwordmgr(ui, urlreq.httppasswordmgrwithdefaultrealm())) + passwordmgr(ui, ui.httppasswordmgrdb)) ] else: handlers = [httphandler()] @@ -491,7 +491,7 @@ handlers.append(proxyhandler(ui)) - passmgr = passwordmgr(ui, urlreq.httppasswordmgrwithdefaultrealm()) + passmgr = passwordmgr(ui, ui.httppasswordmgrdb) if authinfo is not None: passmgr.add_password(*authinfo) user, passwd = authinfo[2:4]