[svk-commit] r2169 - in trunk: lib/SVK t

clkao at bestpractical.com clkao at bestpractical.com
Sat Nov 18 02:21:01 EST 2006


Author: clkao
Date: Sat Nov 18 02:21:01 2006
New Revision: 2169

Modified:
   trunk/lib/SVK/Command.pm
   trunk/lib/SVK/Command/List.pm
   trunk/lib/SVK/Command/Propget.pm
   trunk/t/33prop.t

Log:
svk pg -R.

Modified: trunk/lib/SVK/Command.pm
==============================================================================
--- trunk/lib/SVK/Command.pm	(original)
+++ trunk/lib/SVK/Command.pm	Sat Nov 18 02:21:01 2006
@@ -1009,7 +1009,7 @@
 }
 
 
-=head3 run_command_recursively($target, $code, [$level])
+=head3 run_command_recursively($target, $code)
 
 Traverse C<$target> and and invoke C<$code> with each node.
 
@@ -1017,26 +1017,29 @@
 
 sub run_command_recursively {
     my ($self, $target, $code, $level) = @_;
-    $level ||= 0;
     my $root = $target->root;
-
     unless ((my $kind = $root->check_path ($target->path_anchor)) == $SVN::Node::dir) {
-       die loc("Path %1 is not versioned.\n", $target->path_anchor)
-           unless $kind == $SVN::Node::file;
-       $code->($target, $SVN::Node::file, 0);
        return;
     }
+    $code->($target, $target->root->check_path($target->path_anchor), -1);
+    $self->_descend_with($target, $code, 0)
+}
 
+sub _descend_with {
+    my ($self, $target, $code, $level) = @_;
+    my $root = $target->root;
     my $entries = $root->dir_entries ($target->path_anchor);
     my $pool = SVN::Pool->new_default;
     for (sort keys %$entries) {
 	$pool->clear;
+	my $kind = $entries->{$_}->kind;
+	next if $kind == $SVN::Node::unknown;
 	my $child = $target->new->descend($_);
-	$code->($child, $entries->{$_}->kind, $level);
+	$code->($child, $kind, $level);
 
-	my $isdir = ($entries->{$_}->kind == $SVN::Node::dir);
+	my $isdir = ($kind == $SVN::Node::dir);
 	if ($isdir && $self->{recursive} && (!$self->{'depth'} || ( $level < $self->{'depth'}))) {
-	    $self->run_command_recursively($child, $code, $level+1);
+	    $self->_descend_with($child, $code, $level+1);
 	}
     }
 }

Modified: trunk/lib/SVK/Command/List.pm
==============================================================================
--- trunk/lib/SVK/Command/List.pm	(original)
+++ trunk/lib/SVK/Command/List.pm	Sat Nov 18 02:21:01 2006
@@ -33,6 +33,12 @@
                 $self->apply_revision($arg),
                 sub {
                     my ( $target, $kind, $level ) = @_;
+                    if ( $level == -1 ) {
+                        return if $kind == $SVN::Node::dir;
+                        die loc( "Path %1 is not versioned.\n",
+                            $target->path_anchor )
+                            unless $kind == $SVN::Node::file;
+                    }
                     $self->_print_item( $target, $kind, $level, $enc );
                 }
             );

Modified: trunk/lib/SVK/Command/Propget.pm
==============================================================================
--- trunk/lib/SVK/Command/Propget.pm	(original)
+++ trunk/lib/SVK/Command/Propget.pm	Sat Nov 18 02:21:01 2006
@@ -21,16 +21,21 @@
 }
 
 sub run {
-    my ($self, $pname, @targets) = @_;
+    my ( $self, $pname, @targets ) = @_;
 
-    foreach my $target (@targets) {
-        my $proplist = $self->_proplist($target);
-        exists $proplist->{$pname} or next;
-
-        print $target->report, ' - ' if @targets > 1 and !$self->{strict};
-        print $proplist->{$pname};
-        print "\n" if !$self->{strict};
-    }
+    $self->run_command_recursively(
+        $_,
+        sub {
+            my $target   = shift;
+            my $proplist = $self->_proplist($target);
+            exists $proplist->{$pname} or return;
+
+            print $target->report, ' - '
+                if !$self->{strict} && ( $self->{recursive} || @targets > 1 );
+            print $proplist->{$pname};
+            print "\n" if !$self->{strict};
+        }
+    ) for @targets;
 
     return;
 }

Modified: trunk/t/33prop.t
==============================================================================
--- trunk/t/33prop.t	(original)
+++ trunk/t/33prop.t	Sat Nov 18 02:21:01 2006
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-use Test::More tests => 54;
+use Test::More tests => 55;
 use strict;
 use File::Temp;
 use SVK::Test;
@@ -58,6 +58,8 @@
 
 is_output ($svk, 'pg', ['myprop', "$copath/A"],
 	   ['myvalue']);
+is_output ($svk, 'pg', [-R => 'myprop', "$copath"],
+	   ['t/checkout/prop/A - myvalue']);
 
 $svk->commit ('-m', 'commit', $copath);
 


More information about the svk-commit mailing list