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

nobody at bestpractical.com nobody at bestpractical.com
Fri Dec 7 01:34:50 EST 2007


Author: clsung
Date: Fri Dec  7 01:34:49 2007
New Revision: 2618

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

Log:
- to support multiple branches removal.
- t/bm/remove.t to address that
- wildcard '*' unsupport now

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 01:34:49 2007
@@ -258,36 +258,39 @@
 
 sub parse_arg {
     my ($self, @arg) = @_;
-    return if $#arg != 0;
+    return if $#arg < 0;
 
-    my $dst = shift(@arg);
-    die loc ("Destination can't be URI.\n")
-	if is_uri ($dst);
+    for (@arg) {
+	die loc ("Copy source can't be URI.\n")
+	    if is_uri ($_);
+    }
 
-    return ($self->arg_co_maybe (''), $dst);
+    return ($self->arg_co_maybe (''), @arg);
 }
 
 
 sub run {
-    my ($self, $target, $dst_path) = @_;
+    my ($self, $target, @dst_paths) = @_;
 
     my $proj = $self->load_project($target);
 
-    my $target_path = '/'.$proj->depot->depotname.'/'.
-        ($self->{local} ?
-	    $proj->local_root."/$dst_path"
-	    :
-	    ($dst_path ne 'trunk' ?
-		$proj->branch_location . "/$dst_path" : $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_path, $self->{local} ? '(in local)' : '');
+    for my $dst (@dst_paths) {
+	my $target_path = '/'.$proj->depot->depotname.'/'.
+	    ($self->{local} ?
+		$proj->local_root."/$dst"
+		:
+		($dst ne 'trunk' ?
+		    $proj->branch_location . "/$dst" : $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)' : '');
 
-    $self->{message} = "- Delete branch $target_path";
-    $self->SUPER::run($target);
+	$self->{message} = "- Delete branch $target_path";
+	$self->SUPER::run($target);
+    }
     return;
 }
 

Added: branches/bm/t/bm/remove.t
==============================================================================
--- (empty file)
+++ branches/bm/t/bm/remove.t	Fri Dec  7 01:34:49 2007
@@ -0,0 +1,43 @@
+#!/usr/bin/perl -w
+use strict;
+use SVK::Test;
+plan tests => 5;
+our $output;
+
+my ($xd, $svk) = build_test('test');
+
+$svk->mkdir(-m => 'trunk', '/test/trunk');
+$svk->mkdir(-m => 'trunk', '/test/branches');
+$svk->mkdir(-m => 'trunk', '/test/tags');
+my $tree = create_basic_tree($xd, '/test/trunk');
+
+my $depot = $xd->find_depot('test');
+my $uri = uri($depot->repospath);
+
+$svk->mirror('//mirror/MyProject', $uri);
+$svk->sync('//mirror/MyProject');
+
+my ($copath, $corpath) = get_copath('basic-trunk');
+
+$svk->checkout('//mirror/MyProject/trunk', $copath);
+
+chdir($copath);
+
+is_output_like ($svk, 'branch', ['--create', 'feature/foo', '--switch-to'], qr'Project branch created: feature/foo');
+
+is_output_like ($svk, 'branch', ['--create', 'bugfix/bar', '--switch-to'], qr'Project branch created: bugfix/bar');
+
+$svk->branch('--create', 'bugfix/foobar');
+$svk->branch('--create', 'feature/barfoo');
+
+is_output($svk, 'br', ['-l', '//mirror/MyProject'],
+          ['bugfix/bar', 'bugfix/foobar', 'feature/barfoo', 'feature/foo']);
+
+$svk->branch('--remove', 'feature/foo', 'feature/barfoo');
+
+is_output($svk, 'br', ['-l', '//mirror/MyProject'],
+          ['bugfix/bar', 'bugfix/foobar']);
+
+$svk->branch('--remove', 'bugfix/*');
+
+is_output($svk, 'br', ['-l', '//mirror/MyProject'], []);


More information about the svk-commit mailing list