[PATCH 2 of 3 RFC] url: remember http password database in ui object
liscju
piotr.listkiewicz at gmail.com
Thu Jun 9 07:02:56 EDT 2016
# HG changeset patch
# User liscju <piotr.listkiewicz at gmail.com>
# Date 1465465296 -7200
# Thu Jun 09 11:41:36 2016 +0200
# Node ID 4d9b3b414988081cb9b8bc19f8533cf2f13195f4
# Parent 45be12e882c975ff1acfa368d65bff7729eae593
url: remember http password database in ui object
This makes http password database stored permanently
in ui object. The question is when this database should
be cleared, usually there is no need to do this,
but with commandserver.runcommand it probably should but
I don't know where to do this.
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -26,6 +26,7 @@ from . import (
formatter,
progress,
scmutil,
+ url,
util,
)
@@ -124,6 +125,8 @@ class ui(object):
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 +138,8 @@ class ui(object):
for f in scmutil.rcpath():
self.readconfig(f, trust=True)
+ self.httppasswordmgrdb = url.passwordmgrdb()
+
def copy(self):
return self.__class__(self)
diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -367,7 +367,7 @@ if has_https:
keepalive.KeepAliveHandler.__init__(self)
urlreq.httpshandler.__init__(self)
self.ui = ui
- self.pwmgr = passwordmgr(self.ui, passwordmgrdb())
+ self.pwmgr = passwordmgr(self.ui, self.ui.httppasswordmgrdb)
def _start_transaction(self, h, req):
_generic_start_transaction(self, h, req)
@@ -482,7 +482,9 @@ def opener(ui, authinfo=None):
# experimental config: ui.usehttp2
if ui.configbool('ui', 'usehttp2', False):
handlers = [
- httpconnectionmod.http2handler(ui, passwordmgr(ui, passwordmgrdb()))
+ httpconnectionmod.http2handler(
+ ui,
+ passwordmgr(ui, ui.httppasswordmgrdb))
]
else:
handlers = [httphandler()]
@@ -491,7 +493,7 @@ def opener(ui, authinfo=None):
handlers.append(proxyhandler(ui))
- passmgr = passwordmgr(ui, passwordmgrdb())
+ passmgr = passwordmgr(ui, ui.httppasswordmgrdb)
if authinfo is not None:
passmgr.add_password(*authinfo)
user, passwd = authinfo[2:4]
More information about the Mercurial-devel
mailing list