@matheusbsbs / matheus-bagliano / commits / d976acfd89
Fork 0

git-svn: move authentication prompts into their own namespace

I'm going to be reorganizing some more code. Signed-off-by: Eric Wong <normalperson@yhbt.net>

Eric Wong committed Jan 4, 2007 at 00:45 UTC d976acfd89a7ea539cdaf3fc806308d426b8007a
1 file changed +24 -16
git-svn.perl
+24 -16
@@ -69,7 +69,7 @@ my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
69 $_limit, $_verbose, $_incremental, $_oneline, $_l_fmt, $_show_commit,
70 $_version, $_upgrade, $_authors, $_branch_all_refs, @_opt_m,
71 $_merge, $_strategy, $_dry_run, $_ignore_nodate, $_non_recursive,
72 - $_username, $_config_dir, $_no_auth_cache,
72 + $_config_dir,
73 $_pager, $_color, $_prefix);
74 my (@_branch_from, %tree_map, %users, %rusers, %equiv);
75 my ($_svn_can_do_switch);
@@ -83,9 +83,9 @@ my %fc_opts = ( 'no-ignore-externals' => \$_no_ignore_ext,
83 'repack:i' => \$_repack,
84 'no-metadata' => \$_no_metadata,
85 'quiet|q' => \$_q,
86 - 'username=s' => \$_username,
86 + 'username=s' => \$Git::SVN::Prompt::_username,
87 'config-dir=s' => \$_config_dir,
88 - 'no-auth-cache' => \$_no_auth_cache,
88 + 'no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache,
89 'ignore-nodate' => \$_ignore_nodate,
90 'repack-flags|repack-args|repack-opts=s' => \$_repack_flags);
91
@@ -131,9 +131,9 @@ my %cmd = (
131 'Initialize multiple trees (like git-svnimport)',
132 { %multi_opts, %init_opts,
133 'revision|r=i' => \$_revision,
134 - 'username=s' => \$_username,
134 + 'username=s' => \$Git::SVN::Prompt::_username,
135 'config-dir=s' => \$_config_dir,
136 - 'no-auth-cache' => \$_no_auth_cache,
136 + 'no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache,
137 'prefix=s' => \$_prefix,
138 } ],
139 'multi-fetch' => [ \&multi_fetch,
@@ -1912,7 +1912,13 @@ sub show_commit_normal {
1912 }
1913 }
1914
1915 -sub _simple_prompt {
1915 +package Git::SVN::Prompt;
1916 +use strict;
1917 +use warnings;
1918 +require SVN::Core;
1919 +use vars qw/$_no_auth_cache $_username/;
1920 +
1921 +sub simple {
1922 my ($cred, $realm, $default_username, $may_save, $pool) = @_;
1923 $may_save = undef if $_no_auth_cache;
1924 $default_username = $_username if defined $_username;
@@ -1923,7 +1929,7 @@ sub _simple_prompt {
1929 }
1930 $cred->username($default_username);
1931 } else {
1926 - _username_prompt($cred, $realm, $may_save, $pool);
1932 + username($cred, $realm, $may_save, $pool);
1933 }
1934 $cred->password(_read_password("Password for '" .
1935 $cred->username . "': ", $realm));
@@ -1931,7 +1937,7 @@ sub _simple_prompt {
1937 $SVN::_Core::SVN_NO_ERROR;
1938 }
1939
1934 -sub _ssl_server_trust_prompt {
1940 +sub ssl_server_trust {
1941 my ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_;
1942 $may_save = undef if $_no_auth_cache;
1943 print STDERR "Error validating server certificate for '$realm':\n";
@@ -1980,7 +1986,7 @@ prompt:
1986 $SVN::_Core::SVN_NO_ERROR;
1987 }
1988
1983 -sub _ssl_client_cert_prompt {
1989 +sub ssl_client_cert {
1990 my ($cred, $realm, $may_save, $pool) = @_;
1991 $may_save = undef if $_no_auth_cache;
1992 print STDERR "Client certificate filename: ";
@@ -1991,7 +1997,7 @@ sub _ssl_client_cert_prompt {
1997 $SVN::_Core::SVN_NO_ERROR;
1998 }
1999
1994 -sub _ssl_client_cert_pw_prompt {
2000 +sub ssl_client_cert_pw {
2001 my ($cred, $realm, $may_save, $pool) = @_;
2002 $may_save = undef if $_no_auth_cache;
2003 $cred->password(_read_password("Password: ", $realm));
@@ -1999,7 +2005,7 @@ sub _ssl_client_cert_pw_prompt {
2005 $SVN::_Core::SVN_NO_ERROR;
2006 }
2007
2002 -sub _username_prompt {
2008 +sub username {
2009 my ($cred, $realm, $may_save, $pool) = @_;
2010 $may_save = undef if $_no_auth_cache;
2011 if (defined $realm && length $realm) {
@@ -2035,6 +2041,8 @@ sub _read_password {
2041 $password;
2042 }
2043
2044 +package main;
2045 +
2046 sub libsvn_connect {
2047 my ($url) = @_;
2048 SVN::_Core::svn_config_ensure($_config_dir, undef);
@@ -2042,16 +2050,16 @@ sub libsvn_connect {
2050 SVN::Client::get_simple_provider(),
2051 SVN::Client::get_ssl_server_trust_file_provider(),
2052 SVN::Client::get_simple_prompt_provider(
2045 - \&_simple_prompt, 2),
2053 + \&Git::SVN::Prompt::simple, 2),
2054 SVN::Client::get_ssl_client_cert_prompt_provider(
2047 - \&_ssl_client_cert_prompt, 2),
2055 + \&Git::SVN::Prompt::ssl_client_cert, 2),
2056 SVN::Client::get_ssl_client_cert_pw_prompt_provider(
2049 - \&_ssl_client_cert_pw_prompt, 2),
2057 + \&Git::SVN::Prompt::ssl_client_cert_pw, 2),
2058 SVN::Client::get_username_provider(),
2059 SVN::Client::get_ssl_server_trust_prompt_provider(
2052 - \&_ssl_server_trust_prompt),
2060 + \&Git::SVN::Prompt::ssl_server_trust),
2061 SVN::Client::get_username_prompt_provider(
2054 - \&_username_prompt, 2),
2062 + \&Git::SVN::username, 2),
2063 ]);
2064 my $config = SVN::Core::config_get_config($_config_dir);
2065 my $ra = SVN::Ra->new(url => $url, auth => $baton,