[svk-commit] r2583 - in branches/bm: t/bm
nobody at bestpractical.com
nobody at bestpractical.com
Thu Nov 1 04:25:11 EDT 2007
Author: clsung
Date: Thu Nov 1 04:25:10 2007
New Revision: 2583
Modified:
branches/bm/lib/SVK/Command/Branch.pm
branches/bm/t/bm/basic.t
Log:
- add 'svk branch --switch-to <branch_path>'
- fix depotpath
Modified: branches/bm/lib/SVK/Command/Branch.pm
==============================================================================
--- branches/bm/lib/SVK/Command/Branch.pm (original)
+++ branches/bm/lib/SVK/Command/Branch.pm Thu Nov 1 04:25:10 2007
@@ -146,8 +146,8 @@
$source->path
);
- my $trunk_path = '//'.$proj->depot->depotname.'/'.$proj->trunk;
- my $newbranch_path = '//'.$proj->depot->depotname.'/'.
+ my $trunk_path = '/'.$proj->depot->depotname.'/'.$proj->trunk;
+ my $newbranch_path = '/'.$proj->depot->depotname.'/'.
( $self->{local} ? $proj->local_root : $proj->branch_location ).
'/'.$branch_path.'/';
# XXX if $self->{local};
@@ -165,7 +165,7 @@
# call SVK::Command::Switch here if --switch-to
$self->SVK::Command::Switch::run(
$self->arg_uri_maybe($newbranch_path),
- $self->arg_copath('')
+ $target
) if $self->{switch};
}
return;
@@ -200,7 +200,7 @@
$source->path
);
- my $branch_path = '//'.$proj->depot->depotname.'/'.$proj->branch_location;
+ my $branch_path = '/'.$proj->depot->depotname.'/'.$proj->branch_location;
my $src_branch_path = $branch_path.'/'.$src.'/';
my $dst_branch_path = $branch_path.'/'.$dst.'/';
@@ -263,6 +263,46 @@
return;
}
+package SVK::Command::Branch::switch;
+use base qw( SVK::Command::Switch SVK::Command::Branch );
+use SVK::I18N;
+use SVK::Util qw( is_uri );
+
+sub parse_arg {
+ my ($self, @arg) = @_;
+ return if $#arg != 0;
+
+ my $dst = shift(@arg);
+ die loc ("Copy destination can't be URI.\n")
+ if is_uri ($dst);
+
+ die loc ("More than one URI found.\n")
+ if (grep {is_uri($_)} @arg) > 1;
+
+ return ($self->arg_co_maybe (''), $dst);
+}
+
+
+sub run {
+ my ($self, $target, $new_path) = @_;
+
+ my $source = $target->source;
+ my $proj = SVK::Project->create_from_path(
+ $source->depot,
+ $source->path
+ );
+
+ my $newtarget_path = '/'.$proj->depot->depotname.'/'.
+ ($new_path ne 'trunk' ?
+ $proj->branch_location . "/$new_path/" : $proj->trunk);
+
+ $self->SUPER::run(
+ $self->arg_uri_maybe($newtarget_path),
+ $target
+ );
+ return;
+}
+
1;
__DATA__
Modified: branches/bm/t/bm/basic.t
==============================================================================
--- branches/bm/t/bm/basic.t (original)
+++ branches/bm/t/bm/basic.t Thu Nov 1 04:25:10 2007
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
use SVK::Test;
-plan tests => 5;
+plan tests => 9;
our $output;
my ($xd, $svk) = build_test('test');
@@ -38,3 +38,19 @@
is_output($svk, 'br', ['-l'],
['Foo','feature/foo']);
+
+$svk->branch('--switch', 'trunk'); # switch to trunk
+is_output_like ($svk, 'info', [],
+ qr'Depot Path: //mirror/MyProject/trunk', 'Switch to trunk');
+
+$svk->branch('--switch-to', 'feature/foo'); # switch to foo
+is_output_like ($svk, 'info', [],
+ qr'Depot Path: //mirror/MyProject/branches/feature/foo', 'Switch to feature/foo branch');
+
+$svk->branch('--switch-to', '//mirror/MyProject/trunk'); # switch to trunk via //mirror/MyProject/trunk
+is_output_like ($svk, 'info', [],
+ qr'Depot Path: //mirror/MyProject/branches/feature/foo', 'Switch to trunk');
+
+$svk->branch('--switch-to', '//mirror/MyProject/branches/feature/foo'); # switch to foo
+is_output_like ($svk, 'info', [],
+ qr'Depot Path: //mirror/MyProject/branches/feature/foo', 'Switch to feature/foo branch');
More information about the svk-commit
mailing list