changeset 741:b61ef156f4b5

git_handler: use mercurial's password manager mercurial has useful own password manager.
author Takumi IINO <trot.thunder@gmail.com>
date Tue, 17 Jun 2014 15:42:37 +0900
parents a46cd7139699
children ab8562b11c4f
files hggit/git_handler.py
diffstat 1 files changed, 2 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -23,6 +23,7 @@
 from mercurial.node import hex, bin, nullid
 from mercurial import context, util as hgutil
 from mercurial import error
+from mercurial import url
 
 import _ssh
 import hg2git
@@ -1418,7 +1419,7 @@
             if not httpclient:
                 raise RepoError('git via HTTP requires dulwich 0.8.1 or later')
             else:
-                auth_handler = urllib2.HTTPBasicAuthHandler(AuthManager(self.ui))
+                auth_handler = urllib2.HTTPBasicAuthHandler(url.passwordmgr(self.ui))
                 opener = urllib2.build_opener(auth_handler)
                 try:
                     return client.HttpGitClient(uri, opener=opener, thin_packs=False), uri
@@ -1432,31 +1433,3 @@
 
         # if its not git or git+ssh, try a local url..
         return client.SubprocessGitClient(thin_packs=False), uri
-
-class AuthManager(object):
-    def __init__(self, ui):
-        self.ui = ui
-
-    def add_password(self, realm, uri, user, passwd):
-        raise NotImplementedError(
-            'AuthManager currently gets passwords from hg repo config')
-
-    def find_user_password(self, realm, authuri):
-
-        # find a stanza in the auth section which matches this uri
-        for item in self.ui.configitems('auth'):
-            if len(item) < 2:
-                continue
-            if item[0].endswith('.prefix') and authuri.startswith(item[1]):
-                prefix = item[0][:-len('.prefix')]
-                break
-        else:
-            # no matching stanza found!
-            return (None,None)
-
-        self.ui.note(_('using "%s" auth credentials\n') % (prefix,))
-        username = self.ui.config('auth', '%s.username' % prefix)
-        password = self.ui.config('auth', '%s.password' % prefix)
-
-        return (username,password)
-