[svk-commit] r2622 - in branches/bm: t/bm

nobody at bestpractical.com nobody at bestpractical.com
Fri Dec 7 04:06:30 EST 2007


Author: clsung
Date: Fri Dec  7 04:06:30 2007
New Revision: 2622

Modified:
   branches/bm/lib/SVK/Command/Branch.pm
   branches/bm/t/bm/remove.t

Log:
- remove multiple branch at one commit
- add tests for it

Modified: branches/bm/lib/SVK/Command/Branch.pm
==============================================================================
--- branches/bm/lib/SVK/Command/Branch.pm	(original)
+++ branches/bm/lib/SVK/Command/Branch.pm	Fri Dec  7 04:06:30 2007
@@ -283,23 +283,27 @@
 
     @dsts = map { $self->expand_branch($proj, $_) } @dsts;
 
-    for my $dst (@dsts) {
+    @dsts = grep { defined($_) } map { 
 	my $target_path = '/'.$proj->depot->depotname.'/'.
 	    ($self->{local} ?
-		$proj->local_root."/$dst"
+		$proj->local_root."/$_"
 		:
-		($dst ne 'trunk' ?
-		    $proj->branch_location . "/$dst" : $proj->trunk)
+		($_ ne 'trunk' ?
+		    $proj->branch_location . "/$_" : $proj->trunk)
 	    );
 
-	$target = $self->arg_uri_maybe($target_path);
-	$target->root->check_path($target->path)
-	    or die loc("No such branch exists: %1 %2\n",
-		$dst, $self->{local} ? '(in local)' : '');
+	my $target = $self->arg_uri_maybe($target_path);
+	$target = $target->root->check_path($target->path) ? $target : undef;
+	$target ? 
+	    $self->{message} .= "- Delete branch ".$target->path."\n" :
+	    warn loc("No such branch exists: %1 %2\n",
+		$_, $self->{local} ? '(in local)' : '');
+
+	$target;
+    } @dsts;
+
+    $self->SUPER::run(@dsts);
 
-	$self->{message} = "- Delete branch $target_path";
-	$self->SUPER::run($target);
-    }
     return;
 }
 

Modified: branches/bm/t/bm/remove.t
==============================================================================
--- branches/bm/t/bm/remove.t	(original)
+++ branches/bm/t/bm/remove.t	Fri Dec  7 04:06:30 2007
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 use strict;
 use SVK::Test;
-plan tests => 7;
+plan tests => 10;
 our $output;
 
 my ($xd, $svk) = build_test('test');
@@ -54,3 +54,23 @@
 
 is_output($svk, 'br', ['-l', '//mirror/MyProject'], []);
 
+#$svk->log('//mirror/MyProject');
+#warn $output;
+$svk->branch('--create', 'foobar5');
+$svk->branch('--create', 'foobar6');
+$svk->branch('--create', 'feature/foobar7');
+$svk->branch('--create', 'bugfix/foobar8');
+
+is_output($svk, 'br', ['-l', '//mirror/MyProject'],
+          ['bugfix/foobar8', 'feature/foobar7', 'foobar5', 'foobar6']);
+
+$svk->branch('--remove', 'fake', 'foobar*');
+
+is_output($svk, 'br', ['-l', '//mirror/MyProject'],
+          ['bugfix/foobar8', 'feature/foobar7']);
+
+$svk->branch('--remove', '*');
+
+is_output($svk, 'br', ['-l', '//mirror/MyProject'], []);
+
+1;


More information about the svk-commit mailing list