[Bps-public-commit] r8924 - in SVKUI: . trunk/lib/SVKUI/Model

clsung at bestpractical.com clsung at bestpractical.com
Tue Sep 4 23:42:11 EDT 2007


Author: clsung
Date: Tue Sep  4 23:42:10 2007
New Revision: 8924

Modified:
   SVKUI/   (props changed)
   SVKUI/trunk/lib/SVKUI.pm
   SVKUI/trunk/lib/SVKUI/Model/Project.pm

Log:
 r8954 at going04:  clsung | 2007-09-05 11:42:16 +0800
 - move auth-related function to SVKUI.pm
   - try to setup_auth at the first time.
     - should we cache it (auth) ?
   - but problem may arise: multiple session?


Modified: SVKUI/trunk/lib/SVKUI.pm
==============================================================================
--- SVKUI/trunk/lib/SVKUI.pm	(original)
+++ SVKUI/trunk/lib/SVKUI.pm	Tue Sep  4 23:42:10 2007
@@ -93,46 +93,28 @@
 
 our $current_user;
 our $current_pass;
+
+sub setup_auth {
+    my ($class, $authuser, $authpass) = @_;
+    $current_user = $authuser;
+    $current_pass = $authpass;
+    warn "Setting user to ".$current_user;
+}
+
 sub _svkcmd {
     my $class = shift;
     my $cmd = shift || 'help';
     my @args = @_;
 
-#    local *SVK::Config::_simple_prompt = sub {
-#	my ($cred, $realm, $default_username, $may_save, $pool) = @_;
-#	warn "Setting user/pass to ".$current_user;
-#	$cred->username($current_user);
-#	$cred->password($current_pass);
-#	$cred->may_save(0);
-#	return $SVN::_Core::SVN_NO_ERROR;
-#    };
+    local *SVK::Config::_simple_prompt = sub {
+	my ($cred, $realm, $default_username, $may_save, $pool) = @_;
+	warn "Has user set to ".$current_user;
+	$cred->username($current_user);
+	$cred->password($current_pass);
+	$cred->may_save(0);
+	return $SVN::_Core::SVN_NO_ERROR;
+    };
     return $class->svk->$cmd(@args);
 }
 
-sub setup_auth {
-    my $class = shift;
-    $current_user = shift;
-    $current_pass = shift;
-    warn "Setting user to ".$current_user;
-    SVK::Config->auth_providers(
-	sub {
-	    [
-#	    SVN::Client::get_username_provider(),
-	    SVN::Client::get_simple_prompt_provider( $class->can('_svkui_auth'), 0 ),
-	    ];
-	}
-    );
-}
-
-sub _svkui_auth {
-#SVK::Config->_simple_prompt(
-    my ($cred, $realm, $default_username, $may_save, $pool) = @_;
-    warn "Setting user/pass to ".$current_user;
-    $cred->username($current_user);
-    $cred->password($current_pass);
-    $cred->may_save(0);
-    return $SVN::_Core::SVN_NO_ERROR;
-}
-#);
-
 1;

Modified: SVKUI/trunk/lib/SVKUI/Model/Project.pm
==============================================================================
--- SVKUI/trunk/lib/SVKUI/Model/Project.pm	(original)
+++ SVKUI/trunk/lib/SVKUI/Model/Project.pm	Tue Sep  4 23:42:10 2007
@@ -68,22 +68,6 @@
 
 # Your model-specific methods go here.
 
-#our $current_user;
-#our $current_pass;
-#sub setup_auth {
-#    my $self = shift;
-#    $current_user = $self->authuser;
-#    $current_pass = $self->authpass;
-#    warn "Setting user to ".$current_user;
-#    SVK::Config->auth_providers(
-#	sub {
-#	    [
-#	    SVN::Client::get_simple_prompt_provider( \&_svkui_auth, 0 ),
-#	    ];
-#	}
-#    );
-#}
-
 #sub _svkui_auth {
 #    my ($cred, $realm, $default_username, $may_save, $pool) = @_;
 #    warn "Setting user/pass to ".$current_user;
@@ -111,17 +95,17 @@
     my $self = shift;
     my $path = shift;
     return 1 unless defined($self->url);
-    #SVKUI->setup_auth($au,$pa) if defined($pa);
-    local *SVK::Config::_simple_prompt = sub {
-	my ($cred, $realm, $default_username, $may_save, $pool) = @_;
-	my $current_user = $self->authuser;
-	my $current_pass = $self->authpass;
-	warn "Setting user/pass to ".$current_user;
-	$cred->username($current_user);
-	$cred->password($current_pass);
-	$cred->may_save(0);
-	return $SVN::_Core::SVN_NO_ERROR;
-    };
+    SVKUI->setup_auth($self->authuser, $self->authpass) if defined($self->authpass);
+    #local *SVK::Config::_simple_prompt = sub {
+#	my ($cred, $realm, $default_username, $may_save, $pool) = @_;
+#	my $current_user = $self->authuser;
+#	my $current_pass = $self->authpass;
+#	warn "Setting user/pass to ".$current_user;
+#	$cred->username($current_user);
+#	$cred->password($current_pass);
+#	$cred->may_save(0);
+#	return $SVN::_Core::SVN_NO_ERROR;
+#    };
     warn 'svk mirror '.$path.' '.$self->url;
     if (SVKUI->_svkcmd('mirror', $path, $self->url)) {
 	warn 'svk mirror '.$path.' '.$self->url.' fail!';



More information about the Bps-public-commit mailing list