# HG changeset patch # User Mitsuhiro Koga # Date 1350990730 -32400 # Node ID 0b6a6a7c26f352990c3b544d65059c281a446bbc # Parent 7561aef55a4b30c19a0f91ba215f9e50389034ba svnwrap: Improved handling of username_prompt_provider diff --git a/hgsubversion/svnrepo.py b/hgsubversion/svnrepo.py --- a/hgsubversion/svnrepo.py +++ b/hgsubversion/svnrepo.py @@ -207,6 +207,11 @@ class SubversionPrompt(object): self.ui.write('Authentication realm: %s\n' % (realm,)) self.ui.flush() + def username(self, realm, may_save, pool=None): + self.maybe_print_realm(realm) + username = self.ui.prompt('Username: ', default='') + return (username, bool(may_save)) + def simple(self, realm, default_username, may_save, pool=None): self.maybe_print_realm(realm) if default_username: diff --git a/hgsubversion/svnwrap/subvertpy_wrapper.py b/hgsubversion/svnwrap/subvertpy_wrapper.py --- a/hgsubversion/svnwrap/subvertpy_wrapper.py +++ b/hgsubversion/svnwrap/subvertpy_wrapper.py @@ -206,13 +206,13 @@ class SubversionRepo(object): """ def getclientstring(): return 'hgsubversion' - # TODO: handle certificate authentication, Mercurial style - def getuser(realm, may_save): - return self.username or '', False def simple(realm, username, may_save): return _prompt.simple(realm, username, may_save) + def username(realm, may_save): + return _prompt.username(realm, may_save) + def ssl_server_trust(realm, failures, cert_info, may_save): creds = _prompt.ssl_server_trust(realm, failures, cert_info, may_save) if creds is None: @@ -230,11 +230,11 @@ class SubversionRepo(object): ra.get_ssl_client_cert_file_provider(), ra.get_ssl_client_cert_pw_file_provider(), ra.get_ssl_server_trust_file_provider(), - ra.get_username_prompt_provider(getuser, 0), ] if _prompt: providers += [ ra.get_simple_prompt_provider(simple, 2), + ra.get_username_prompt_provider(username, 2), ra.get_ssl_server_trust_prompt_provider(ssl_server_trust), ] diff --git a/hgsubversion/svnwrap/svn_swig_wrapper.py b/hgsubversion/svnwrap/svn_swig_wrapper.py --- a/hgsubversion/svnwrap/svn_swig_wrapper.py +++ b/hgsubversion/svnwrap/svn_swig_wrapper.py @@ -103,6 +103,12 @@ def _simple(realm, default_username, ms, (creds.username, creds.password, creds.may_save) = ret return creds +def _username(realm, ms, pool): + ret = _prompt.username(realm, ms, pool) + creds = core.svn_auth_cred_username_t() + (creds.username, creds.may_save) = ret + return creds + def _ssl_server_trust(realm, failures, cert_info, may_save, pool): cert = [ cert_info.hostname, @@ -166,6 +172,7 @@ def _create_auth_baton(pool, password_st if _prompt: providers += [ client.get_simple_prompt_provider(_simple, 2), + client.get_username_prompt_provider(_username, 2), client.get_ssl_server_trust_prompt_provider(_ssl_server_trust), ]