[svk-commit] r2566 - in branches/bm: t/bm
nobody at bestpractical.com
nobody at bestpractical.com
Fri Oct 26 04:28:11 EDT 2007
Author: clsung
Date: Fri Oct 26 04:28:10 2007
New Revision: 2566
Added:
branches/bm/t/bm/move.t
Modified:
branches/bm/lib/SVK/Command/Branch.pm
Log:
- my try to implement svk branch --move
Modified: branches/bm/lib/SVK/Command/Branch.pm
==============================================================================
--- branches/bm/lib/SVK/Command/Branch.pm (original)
+++ branches/bm/lib/SVK/Command/Branch.pm Fri Oct 26 04:28:10 2007
@@ -173,12 +173,42 @@
package SVK::Command::Branch::move;
use base qw( SVK::Command::Move SVK::Command::Branch );
use SVK::I18N;
+use SVK::Util qw( is_uri );
-use constant narg => 1;
+sub parse_arg {
+ my ($self, @arg) = @_;
+ return if $#arg < 0;
+
+ my $dst = pop(@arg);
+ die loc ("Copy destination can't be URI.\n")
+ if is_uri ($dst);
+
+ my $src = pop(@arg);
+ die loc ("Copy source can't be URI.\n")
+ if is_uri ($src);
+
+ return ($self->arg_co_maybe (''), $src, $dst);
+}
sub run {
- my ($self, $target) = @_;
- print loc("nothing to move\n");
+ my ($self, $target, $src, $dst) = @_;
+
+ my $source = $target->source;
+ my $proj = SVK::Project->create_from_path(
+ $source->depot,
+ $source->path
+ );
+
+ my $branch_path = '//'.$proj->depot->depotname.'/'.$proj->branch_location;
+ my $src_branch_path = $branch_path.'/'.$src.'/';
+ my $dst_branch_path = $branch_path.'/'.$dst.'/';
+
+ $src = $self->arg_uri_maybe($src_branch_path);
+ $dst = $self->arg_depotpath($dst_branch_path);
+
+ $self->{parent} = 1;
+ $self->{message} ||= "- Move branch $src_branch_path to $dst_branch_path";
+ my $ret = $self->SUPER::run($src, $dst);
return;
}
Added: branches/bm/t/bm/move.t
==============================================================================
--- (empty file)
+++ branches/bm/t/bm/move.t Fri Oct 26 04:28:10 2007
@@ -0,0 +1,27 @@
+#!/usr/bin/perl -w
+use strict;
+use Test::More tests => 3;
+use SVK::Test;
+use File::Path;
+
+my ($xd, $svk) = build_test('test');
+our $output;
+$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 ('MyProject');
+$svk->checkout('//mirror/MyProject/trunk',$copath);
+chdir($copath);
+
+is_output_like ($svk, 'branch', ['--create', 'feature/foo'], qr'Project branch created: feature/foo');
+is_output_like ($svk, 'branch', ['--list'], qr'feature/foo');
+$svk->br('--move', 'feature/foo', 'release-ready/foo');
+is_output_like ($svk, 'branch', ['--list'], qr'release-ready/foo');
More information about the svk-commit
mailing list