[svk-commit] r2130 - in branches/mirror-pipeline: . lib/SVK
lib/SVK/Command t/mirror
clkao at bestpractical.com
clkao at bestpractical.com
Fri Nov 10 10:37:38 EST 2006
Author: clkao
Date: Fri Nov 10 10:37:37 2006
New Revision: 2130
Modified:
branches/mirror-pipeline/ (props changed)
branches/mirror-pipeline/lib/SVK/Command/Cmerge.pm
branches/mirror-pipeline/lib/SVK/Config.pm
branches/mirror-pipeline/lib/SVK/Mirror.pm
branches/mirror-pipeline/lib/SVK/Mirror/Backend/SVNRa.pm
branches/mirror-pipeline/lib/SVK/Version.pm
branches/mirror-pipeline/t/mirror/dav-authz.t
Log:
r7249 at ubuntu (orig r2125): mndrix | 2006-11-07 15:46:40 +0000
Eliminate some warnings in 09cmerge.t and 74chgspec.t (caused by the
SVK::Depot refactor?)
r7260 at ubuntu (orig r2126): clkao | 2006-11-10 03:07:47 +0000
Make ra auth providers overridable.
r7261 at ubuntu (orig r2127): clkao | 2006-11-10 03:25:58 +0000
Support win32 and keychain auth providers if available.
r7262 at ubuntu (orig r2128): clkao | 2006-11-10 10:28:28 +0000
trunk is now 1.99_04
r7263 at ubuntu (orig r2129): clkao | 2006-11-10 14:13:48 +0000
assume mirror is locked if token is ours.
Modified: branches/mirror-pipeline/lib/SVK/Command/Cmerge.pm
==============================================================================
--- branches/mirror-pipeline/lib/SVK/Command/Cmerge.pm (original)
+++ branches/mirror-pipeline/lib/SVK/Command/Cmerge.pm Fri Nov 10 10:37:37 2006
@@ -77,7 +77,7 @@
$ceditor->replay (SVN::Delta::Editor->new
(_debug => 0,
_editor => [ $repos->get_commit_editor
- ("file://$src->{repospath}",
+ ('file://' . $src->depot->repospath,
$tmpbranch,
$ENV{USER}, "merge $self->{chgspec} from $src->{path}",
sub { print loc("Committed revision %1.\n", $_[0]) })
Modified: branches/mirror-pipeline/lib/SVK/Config.pm
==============================================================================
--- branches/mirror-pipeline/lib/SVK/Config.pm (original)
+++ branches/mirror-pipeline/lib/SVK/Config.pm Fri Nov 10 10:37:37 2006
@@ -4,7 +4,36 @@
use base 'Class::Data::Inheritable';
-__PACKAGE__->mk_classdata(qw(_svnconfig));
+__PACKAGE__->mk_classdata('_svnconfig');
+__PACKAGE__->mk_classdata('auth_providers');
+
+# XXX: this is 1.3 api. use SVN::Auth::* for 1.4 and we don't have to load ::Client anymore
+# (well, fix svn perl bindings to wrap the prompt functions correctly first.
+require SVN::Client;
+__PACKAGE__->auth_providers(
+ sub {
+ my $keychain = SVN::_Core->can('svn_auth_get_keychain_simple_provider');
+ my $win32 = SVN::_Core->can('svn_auth_get_windows_simple_provider');
+ [
+ $keychain ? $keychain : (),
+ $win32 ? $win32 : (),
+ SVN::Client::get_simple_provider(),
+ SVN::Client::get_ssl_server_trust_file_provider(),
+ SVN::Client::get_username_provider(),
+ SVN::Client::get_simple_prompt_provider( \&_simple_prompt, 2 ),
+ SVN::Client::get_ssl_server_trust_prompt_provider(
+ \&_ssl_server_trust_prompt
+ ),
+ SVN::Client::get_ssl_client_cert_prompt_provider(
+ \&_ssl_client_cert_prompt, 2
+ ),
+ SVN::Client::get_ssl_client_cert_pw_prompt_provider(
+ \&_ssl_client_cert_pw_prompt, 2
+ ),
+ SVN::Client::get_username_prompt_provider( \&_username_prompt, 2 ),
+ ];
+ }
+);
my $pool = SVN::Pool->new;
@@ -18,4 +47,132 @@
return $class->_svnconfig( SVN::Core::config_get_config(undef, $pool) );
}
+# Note: Use a proper default pool when calling get_auth_providers
+sub get_auth_providers {
+ my $class = shift;
+ return $class->auth_providers->();
+}
+
+use constant OK => $SVN::_Core::SVN_NO_ERROR;
+
+# Implement auth callbacks
+sub _simple_prompt {
+ my ($cred, $realm, $default_username, $may_save, $pool) = @_;
+
+ if (defined $default_username and length $default_username) {
+ print "Authentication realm: $realm\n" if defined $realm and length $realm;
+ $cred->username($default_username);
+ }
+ else {
+ _username_prompt($cred, $realm, $may_save, $pool);
+ }
+
+ $cred->password(_read_password("Password for '" . $cred->username . "': "));
+ $cred->may_save($may_save);
+
+ return OK;
+}
+
+sub _ssl_server_trust_prompt {
+ my ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_;
+
+ print "Error validating server certificate for '$realm':\n";
+
+ print " - The certificate is not issued by a trusted authority. Use the\n",
+ " fingerprint to validate the certificate manually!\n"
+ if ($failures & $SVN::Auth::SSL::UNKNOWNCA);
+
+ print " - The certificate hostname does not match.\n"
+ if ($failures & $SVN::Auth::SSL::CNMISMATCH);
+
+ print " - The certificate is not yet valid.\n"
+ if ($failures & $SVN::Auth::SSL::NOTYETVALID);
+
+ print " - The certificate has expired.\n"
+ if ($failures & $SVN::Auth::SSL::EXPIRED);
+
+ print " - The certificate has an unknown error.\n"
+ if ($failures & $SVN::Auth::SSL::OTHER);
+
+ printf(
+ "Certificate information:\n".
+ " - Hostname: %s\n".
+ " - Valid: from %s until %s\n".
+ " - Issuer: %s\n".
+ " - Fingerprint: %s\n",
+ map $cert_info->$_, qw(hostname valid_from valid_until issuer_dname fingerprint)
+ );
+
+ print(
+ $may_save
+ ? "(R)eject, accept (t)emporarily or accept (p)ermanently? "
+ : "(R)eject or accept (t)emporarily? "
+ );
+
+ my $choice = lc(substr(<STDIN> || 'R', 0, 1));
+
+ if ($choice eq 't') {
+ $cred->may_save(0);
+ $cred->accepted_failures($failures);
+ }
+ elsif ($may_save and $choice eq 'p') {
+ $cred->may_save(1);
+ $cred->accepted_failures($failures);
+ }
+
+ return OK;
+}
+
+sub _ssl_client_cert_prompt {
+ my ($cred, $realm, $may_save, $pool) = @_;
+
+ print "Client certificate filename: ";
+ chomp(my $filename = <STDIN>);
+ $cred->cert_file($filename);
+
+ return OK;
+}
+
+sub _ssl_client_cert_pw_prompt {
+ my ($cred, $realm, $may_save, $pool) = @_;
+
+ $cred->password(_read_password("Passphrase for '%s': "));
+
+ return OK;
+}
+
+sub _username_prompt {
+ my ($cred, $realm, $may_save, $pool) = @_;
+
+ print "Authentication realm: $realm\n" if defined $realm and length $realm;
+ print "Username: ";
+ chomp(my $username = <STDIN>);
+ $username = '' unless defined $username;
+
+ $cred->username($username);
+
+ return OK;
+}
+
+sub _read_password {
+ my ($prompt) = @_;
+
+ print $prompt;
+
+ require Term::ReadKey;
+ Term::ReadKey::ReadMode('noecho');
+
+ my $password = '';
+ while (defined(my $key = Term::ReadKey::ReadKey(0))) {
+ last if $key =~ /[\012\015]/;
+ $password .= $key;
+ }
+
+ Term::ReadKey::ReadMode('restore');
+ print "\n";
+
+ return $password;
+}
+
+
1;
Modified: branches/mirror-pipeline/lib/SVK/Mirror.pm
==============================================================================
--- branches/mirror-pipeline/lib/SVK/Mirror.pm (original)
+++ branches/mirror-pipeline/lib/SVK/Mirror.pm Fri Nov 10 10:37:37 2006
@@ -215,6 +215,7 @@
{
while (1) {
my $who = $fs->revision_prop( 0, $token ) or last LOCKED;
+ last if $who eq $content;
$lock_message->($self, $who);
sleep 1;
}
Modified: branches/mirror-pipeline/lib/SVK/Mirror/Backend/SVNRa.pm
==============================================================================
--- branches/mirror-pipeline/lib/SVK/Mirror/Backend/SVNRa.pm (original)
+++ branches/mirror-pipeline/lib/SVK/Mirror/Backend/SVNRa.pm Fri Nov 10 10:37:37 2006
@@ -4,15 +4,12 @@
use SVN::Core;
use SVN::Ra;
-use SVN::Client ();
use SVK::I18N;
use SVK::Editor;
use SVK::Mirror::Backend::SVNRaPipe;
use Class::Autouse qw(SVK::Editor::SubTree SVK::Editor::CopyHandler);
-use constant OK => $SVN::_Core::SVN_NO_ERROR;
-
## class SVK::Mirror::Backend::SVNRa;
## has $.mirror is weak;
## has ($!config, $!auth_baton, $!auth_ref);
@@ -237,6 +234,7 @@
}
}
$self->_ra_finished($ra);
+ # FIXME: if we do ^c here $err would be empty. do something else.
return $self->_has_replay(0)
if $err->apr_err == $SVN::Error::RA_NOT_IMPLEMENTED # ra_svn
|| $err->apr_err == $SVN::Error::UNSUPPORTED_FEATURE; # ra_dav
@@ -277,140 +275,12 @@
my $auth_pool = SVN::Pool::create (${ $self->mirror->pool });
$auth_pool->default;
- my ($baton, $ref) = SVN::Core::auth_open_helper([
- SVN::Client::get_simple_provider (),
- SVN::Client::get_ssl_server_trust_file_provider (),
- SVN::Client::get_username_provider (),
- SVN::Client::get_simple_prompt_provider( $self->can('_simple_prompt'), 2),
- SVN::Client::get_ssl_server_trust_prompt_provider( $self->can('_ssl_server_trust_prompt') ),
- SVN::Client::get_ssl_client_cert_prompt_provider( $self->can('_ssl_client_cert_prompt'), 2 ),
- SVN::Client::get_ssl_client_cert_pw_prompt_provider( $self->can('_ssl_client_cert_pw_prompt'), 2 ),
- SVN::Client::get_username_prompt_provider( $self->can('_username_prompt'), 2),
- ]);
+ my ($baton, $ref) = SVN::Core::auth_open_helper(SVK::Config->get_auth_providers);
$self->_auth_baton($baton);
$self->_auth_ref($ref);
}
-# Implement auth callbacks
-sub _simple_prompt {
- my ($cred, $realm, $default_username, $may_save, $pool) = @_;
-
- if (defined $default_username and length $default_username) {
- print "Authentication realm: $realm\n" if defined $realm and length $realm;
- $cred->username($default_username);
- }
- else {
- _username_prompt($cred, $realm, $may_save, $pool);
- }
-
- $cred->password(_read_password("Password for '" . $cred->username . "': "));
- $cred->may_save($may_save);
-
- return OK;
-}
-
-sub _ssl_server_trust_prompt {
- my ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_;
-
- print "Error validating server certificate for '$realm':\n";
-
- print " - The certificate is not issued by a trusted authority. Use the\n",
- " fingerprint to validate the certificate manually!\n"
- if ($failures & $SVN::Auth::SSL::UNKNOWNCA);
-
- print " - The certificate hostname does not match.\n"
- if ($failures & $SVN::Auth::SSL::CNMISMATCH);
-
- print " - The certificate is not yet valid.\n"
- if ($failures & $SVN::Auth::SSL::NOTYETVALID);
-
- print " - The certificate has expired.\n"
- if ($failures & $SVN::Auth::SSL::EXPIRED);
-
- print " - The certificate has an unknown error.\n"
- if ($failures & $SVN::Auth::SSL::OTHER);
-
- printf(
- "Certificate information:\n".
- " - Hostname: %s\n".
- " - Valid: from %s until %s\n".
- " - Issuer: %s\n".
- " - Fingerprint: %s\n",
- map $cert_info->$_, qw(hostname valid_from valid_until issuer_dname fingerprint)
- );
-
- print(
- $may_save
- ? "(R)eject, accept (t)emporarily or accept (p)ermanently? "
- : "(R)eject or accept (t)emporarily? "
- );
-
- my $choice = lc(substr(<STDIN> || 'R', 0, 1));
-
- if ($choice eq 't') {
- $cred->may_save(0);
- $cred->accepted_failures($failures);
- }
- elsif ($may_save and $choice eq 'p') {
- $cred->may_save(1);
- $cred->accepted_failures($failures);
- }
-
- return OK;
-}
-
-sub _ssl_client_cert_prompt {
- my ($cred, $realm, $may_save, $pool) = @_;
-
- print "Client certificate filename: ";
- chomp(my $filename = <STDIN>);
- $cred->cert_file($filename);
-
- return OK;
-}
-
-sub _ssl_client_cert_pw_prompt {
- my ($cred, $realm, $may_save, $pool) = @_;
-
- $cred->password(_read_password("Passphrase for '%s': "));
-
- return OK;
-}
-
-sub _username_prompt {
- my ($cred, $realm, $may_save, $pool) = @_;
-
- print "Authentication realm: $realm\n" if defined $realm and length $realm;
- print "Username: ";
- chomp(my $username = <STDIN>);
- $username = '' unless defined $username;
-
- $cred->username($username);
-
- return OK;
-}
-
-sub _read_password {
- my ($prompt) = @_;
-
- print $prompt;
-
- require Term::ReadKey;
- Term::ReadKey::ReadMode('noecho');
-
- my $password = '';
- while (defined(my $key = Term::ReadKey::ReadKey(0))) {
- last if $key =~ /[\012\015]/;
- $password .= $key;
- }
-
- Term::ReadKey::ReadMode('restore');
- print "\n";
-
- return $password;
-}
-
=back
=head2 METHODS
Modified: branches/mirror-pipeline/lib/SVK/Version.pm
==============================================================================
--- branches/mirror-pipeline/lib/SVK/Version.pm (original)
+++ branches/mirror-pipeline/lib/SVK/Version.pm Fri Nov 10 10:37:37 2006
@@ -1,6 +1,6 @@
package SVK;
-our $VERSION = '1.99_03';
+our $VERSION = '1.99_04';
=head1 NAME
Modified: branches/mirror-pipeline/t/mirror/dav-authz.t
==============================================================================
--- branches/mirror-pipeline/t/mirror/dav-authz.t (original)
+++ branches/mirror-pipeline/t/mirror/dav-authz.t Fri Nov 10 10:37:37 2006
@@ -49,7 +49,7 @@
plan skip_all => "Can't find mod_dav_svn and mod_authz_svn";
}
-plan tests => 3;
+plan tests => 5;
my $utf8 = SVK::Util::get_encoding;
@@ -80,27 +80,16 @@
#our $DEBUG=1;
#$ENV{DEBUG_INTERACTIVE}=1;
-no warnings 'redefine';
-*SVK::Mirror::Backend::SVNRa::_initialize_auth = sub {
- my $self = shift;
- # create a subpool that is not automatically destroyed
- my $auth_pool = SVN::Pool::create(${ $self->mirror->pool });
- $auth_pool->default;
-
- my ($baton, $ref) = SVN::Core::auth_open_helper([
- SVN::Client::get_simple_provider (),
- SVN::Client::get_ssl_server_trust_file_provider (),
- SVN::Client::get_username_provider (),
- SVN::Client::get_simple_prompt_provider( __PACKAGE__->can('_my_prompt'), 2),
- ]);
-
- $self->_auth_baton($baton);
- $self->_auth_ref($ref);
-};
+use SVK::Config;
+SVK::Config->auth_providers(
+ sub {
+ [ SVN::Client::get_simple_prompt_provider( \&my_prompt, 2 ) ]
+ }
+);
my $prompt_called = 0;
-sub _my_prompt {
+sub my_prompt {
my ($cred, $realm, $default_username, $may_save, $pool) = @_;
++$prompt_called;
$cred->username('test');
@@ -110,7 +99,6 @@
}
$svk->mirror ('//remote', "$uri/A");
-
is_output ($svk, 'sync', ['//remote'],
["Syncing $uri/A",
'Retrieving log information from 1 to 2',
@@ -120,3 +108,27 @@
$svk->mirror('--detach', '//remote');
+###### readable root, C requires authz
+overwrite_file($policy, "
+[/]
+* = r
+test = rw
+[/C]
+* =
+test = rw
+");
+$svk->mkdir(-pm => 'something restricited', '/test/C/lala');
+
+$prompt_called = 0;
+$svk->mirror ('//remote-full', "$uri");
+ok($prompt_called, "prompt called");
+
+is_output ($svk, 'sync', ['//remote-full'],
+ ["Syncing $uri",
+ 'Retrieving log information from 1 to 3',
+ 'Committed revision 6 from revision 1.',
+ 'Committed revision 7 from revision 2.',
+ 'Committed revision 8 from revision 3.']);
+
+$server->stop;
+print "\n";
More information about the svk-commit
mailing list