[PATCH 1 of 4] http: plugable passwordmgr instance

Markus Zapke-Gründemann markuszapke at gmx.net
Fri Sep 14 09:46:48 CDT 2012


# HG changeset patch
# User Markus Zapke-Gründemann <markus at keimlink.de>
# Date 1347617249 -7200
# Node ID edb5487b1bb7e60aa46d77243487eee1a27223b9
# Parent  fc1a5d0eb3bbb1116051b65dcd2873389f9d7ed4
http: plugable passwordmgr instance

Allows to replace the passwordmgr with a different implementation.

diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -318,6 +318,8 @@ class httphandler(keepalive.HTTPHandler)
         _generic_start_transaction(self, h, req)
         return keepalive.HTTPHandler._start_transaction(self, h, req)
 
+pwmgrclass = passwordmgr
+
 if has_https:
     class httpsconnection(httplib.HTTPSConnection):
         response_class = keepalive.HTTPResponse
@@ -342,7 +344,7 @@ if has_https:
             keepalive.KeepAliveHandler.__init__(self)
             urllib2.HTTPSHandler.__init__(self)
             self.ui = ui
-            self.pwmgr = passwordmgr(self.ui)
+            self.pwmgr = pwmgrclass(ui)
 
         def _start_transaction(self, h, req):
             _generic_start_transaction(self, h, req)
@@ -438,7 +440,7 @@ def opener(ui, authinfo=None):
     authinfo will be added to the password manager
     '''
     if ui.configbool('ui', 'usehttp2', False):
-        handlers = [httpconnectionmod.http2handler(ui, passwordmgr(ui))]
+        handlers = [httpconnectionmod.http2handler(ui, pwmgrclass(ui))]
     else:
         handlers = [httphandler()]
         if has_https:
@@ -446,7 +448,7 @@ def opener(ui, authinfo=None):
 
     handlers.append(proxyhandler(ui))
 
-    passmgr = passwordmgr(ui)
+    passmgr = pwmgrclass(ui)
     if authinfo is not None:
         passmgr.add_password(*authinfo)
         user, passwd = authinfo[2:4]


More information about the Mercurial-devel mailing list