[svk-commit] r2694 - in trunk: t/bm

nobody at bestpractical.com nobody at bestpractical.com
Sat Feb 9 09:59:56 EST 2008


Author: clsung
Date: Sat Feb  9 09:59:54 2008
New Revision: 2694

Modified:
   trunk/lib/SVK/Command/Branch.pm
   trunk/t/bm/move.t

Log:
- implement 
  - svk br move //local/foobar //mirror/remotefoobar
- test case provided

Modified: trunk/lib/SVK/Command/Branch.pm
==============================================================================
--- trunk/lib/SVK/Command/Branch.pm	(original)
+++ trunk/lib/SVK/Command/Branch.pm	Sat Feb  9 09:59:54 2008
@@ -237,18 +237,22 @@
 }
 
 sub run {
-    my ($self, $target, $dst, $src) = @_;
+    my ($self, $target, $dst_path, $src_path) = @_;
 
     my $proj = $self->load_project($target);
 
-    my $branch_path = '/'.$proj->depot->depotname.'/'.$proj->branch_location;
-    my $src_branch_path = $branch_path.'/'.$src.'/';
-    my $dst_branch_path = $branch_path.'/'.$dst.'/';
-    $src_branch_path = '/'.$proj->depot->depotname.$target->source->path
-	unless ($src);
+    my $depot_root = '/'.$proj->depot->depotname;
+    my $branch_path = $depot_root.'/'.$proj->branch_location;
+    my ($src_branch_path, $dst_branch_path) = ($src_path, $dst_path);
+    $src_branch_path = $branch_path.'/'.$src_path.'/'
+	unless $src_path =~ m#^$depot_root/#;
+    $dst_branch_path = $branch_path.'/'.$dst_path.'/'
+	unless $dst_path =~ m#^$depot_root/#;
+    $src_branch_path = $depot_root.$target->source->path
+	unless ($src_path);
 
-    $src = $self->arg_uri_maybe($src_branch_path);
-    $dst = $self->arg_depotpath($dst_branch_path);
+    my $src = $self->arg_co_maybe($src_branch_path);
+    my $dst = $self->arg_depotpath($dst_branch_path);
     $SVN::Node::none == $dst->root->check_path($dst->path)
 	or $SVN::Node::dir == $dst->root->check_path($dst->path)
 	or die loc("Project branch already exists: %1 %2\n",
@@ -259,7 +263,7 @@
 	# branch first, then sm -I
 	my $which_rev_we_branch = ($src->copy_ancestors)[0]->[1];
 	$self->{rev} = $which_rev_we_branch;
-	$src = $self->arg_uri_maybe('/'.$proj->depot->depotname.'/'.$proj->trunk);
+	$src = $self->arg_uri_maybe($depot_root.'/'.$proj->trunk);
 	$self->{message} = "- Create branch $src_branch_path to $dst_branch_path";
 	local *handle_direct_item = sub {
 	    my $self = shift;

Modified: trunk/t/bm/move.t
==============================================================================
--- trunk/t/bm/move.t	(original)
+++ trunk/t/bm/move.t	Sat Feb  9 09:59:54 2008
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 use strict;
-use Test::More tests => 13;
+use Test::More tests => 16;
 use SVK::Test;
 use File::Path;
 
@@ -86,3 +86,23 @@
 is_output ($svk, 'branch', ['--list'],
     ['feature/bar','feature/mar','feature/remotebar'],
     'Move localfoo to remotebar, cross depot move');
+
+# create to local, not switched, and then move back
+is_output ($svk, 'branch', ['--create', 'localbar', '--local'],
+    ["Committed revision 15.",
+     "Project branch created: localbar (in local)"]);
+
+is_output ($svk, 'branch', ['--move', '//local/MyProject/localbar', 'feature/remotefoo'],
+    ["Merging back to mirror source $uri.",
+     "Merge back committed as revision 12.",
+     "Syncing $uri",
+     "Retrieving log information from 12 to 12",
+     "Committed revision 16 from revision 12.",
+     'Auto-merging (0, 15) /local/MyProject/localbar to /mirror/MyProject/branches/feature/remotefoo (base /mirror/MyProject/trunk:6).',
+     '===> Auto-merging (0, 15) /local/MyProject/localbar to /mirror/MyProject/branches/feature/remotefoo (base /mirror/MyProject/trunk:6).',
+     "Merging back to mirror source $uri.",'Empty merge.',
+     "Different source."]);
+
+is_output ($svk, 'branch', ['--list'],
+    ['feature/bar','feature/mar','feature/remotebar','feature/remotefoo'],
+    'Move localbar to remotefoo, cross depot move w/o switch to local');


More information about the svk-commit mailing list