Mitsuhiro Koga avatar Mitsuhiro Koga committed 0b6a6a7

svnwrap: Improved handling of username_prompt_provider

Comments (0)

Files changed (3)

hgsubversion/svnrepo.py

             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:

hgsubversion/svnwrap/subvertpy_wrapper.py

         """
         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:
             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),
             ]
 

hgsubversion/svnwrap/svn_swig_wrapper.py

     (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,
     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),
             ]
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.