Mercurial > hgsubversion
changeset 844:95d040755254
Added ability to configure the password stores
author | Jerome M. BERGER <jerome.berger@sagemcom.com> |
---|---|
date | Tue, 22 Nov 2011 11:54:25 +0100 |
parents | df2c85478063 |
children | 8cf8ff0f52fe |
files | hgsubversion/help/subversion.rst hgsubversion/svnrepo.py hgsubversion/svnwrap/subvertpy_wrapper.py hgsubversion/svnwrap/svn_swig_wrapper.py |
diffstat | 4 files changed, 31 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/help/subversion.rst +++ b/hgsubversion/help/subversion.rst @@ -306,6 +306,17 @@ settings: Set the username or password for accessing Subversion repositories. + ``hgsubversion.password_stores`` + + List of methods to use for storing passwords (similar to the option of the + same name in the subversion configuration files). Default is + ``gnome_keyring,keychain,kwallet,windows``. Password stores can be disabled + completely by setting this to an empty value. + + .. NOTE:: + + Password stores are only supported with the SWIG bindings. + ``hgsubversion.stupid`` Setting this boolean option to true will force using a slower method for pulling revisions from Subversion. This method is compatible with servers
--- a/hgsubversion/svnrepo.py +++ b/hgsubversion/svnrepo.py @@ -21,6 +21,7 @@ from mercurial import util as hgutil from mercurial import httprepo import mercurial.repo +import re import util import wrappers import svnwrap @@ -107,6 +108,14 @@ class svnremoterepo(mercurial.repo.repos raise hgutil.Abort('no Subversion URL specified') self.path = path self.capabilities = set(['lookup', 'subversion']) + pws = self.ui.config('hgsubversion', 'password_stores', None) + if pws is not None: + # Split pws at comas and strip neighbouring whitespace (whitespace + # at the beginning and end of pws has already been removed by the + # config parser). + self.password_stores = re.split(r'\s*,\s*', pws) + else: + self.password_stores = None @propertycache def svnauth(self): @@ -127,7 +136,7 @@ class svnremoterepo(mercurial.repo.repos @propertycache def svn(self): try: - return svnwrap.SubversionRepo(*self.svnauth) + return svnwrap.SubversionRepo(*self.svnauth, password_stores=self.password_stores) except svnwrap.SubversionConnectionException, e: self.ui.traceback() raise hgutil.Abort(e)
--- a/hgsubversion/svnwrap/subvertpy_wrapper.py +++ b/hgsubversion/svnwrap/subvertpy_wrapper.py @@ -165,8 +165,11 @@ class SubversionRepo(object): This wrapper uses Subvertpy, an alternate set of bindings for Subversion that's more pythonic and sucks less. See earlier in this file for version requirements. + + Note that password stores do not work, the parameter is only here + to ensure that the API is the same as for the SWIG wrapper. """ - def __init__(self, url='', username='', password='', head=None): + def __init__(self, url='', username='', password='', head=None, password_stores=None): parsed = common.parse_url(url, username, password) # --username and --password override URL credentials self.username = parsed[0]
--- a/hgsubversion/svnwrap/svn_swig_wrapper.py +++ b/hgsubversion/svnwrap/svn_swig_wrapper.py @@ -103,7 +103,7 @@ def user_pass_prompt(realm, default_user creds.password = getpass.getpass('Password for %s: ' % creds.username) return creds -def _create_auth_baton(pool): +def _create_auth_baton(pool, password_stores): """Create a Subversion authentication baton. """ # Give the client context baton a suite of authentication # providers.h @@ -124,7 +124,9 @@ def _create_auth_baton(pool): None) if getprovider: # Available in svn >= 1.6 - for name in ('gnome_keyring', 'keychain', 'kwallet', 'windows'): + if password_stores is None: + password_stores = ('gnome_keyring', 'keychain', 'kwallet', 'windows') + for name in password_stores: for type in ('simple', 'ssl_client_cert_pw', 'ssl_server_trust'): p = getprovider(name, type, pool) if p: @@ -158,14 +160,14 @@ class SubversionRepo(object): It uses the SWIG Python bindings, see above for requirements. """ - def __init__(self, url='', username='', password='', head=None): + def __init__(self, url='', username='', password='', head=None, password_stores=None): parsed = common.parse_url(url, username, password) # --username and --password override URL credentials self.username = parsed[0] self.password = parsed[1] self.svn_url = parsed[2] self.auth_baton_pool = core.Pool() - self.auth_baton = _create_auth_baton(self.auth_baton_pool) + self.auth_baton = _create_auth_baton(self.auth_baton_pool, password_stores) # self.init_ra_and_client() assumes that a pool already exists self.pool = core.Pool()