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

nobody at bestpractical.com nobody at bestpractical.com
Wed May 21 02:37:17 EDT 2008


Author: clsung
Date: Wed May 21 02:37:16 2008
New Revision: 2898

Modified:
   trunk/lib/SVK/Command/Branch.pm
   trunk/t/bm/online-offline.t

Log:
- fix http://task.hm/EKYL
  - flag check_only is not used in Switch, so checking in Branch.pm
- when online (from local to remote), for a non-existent branch
  - copy it, sm it, and delete
  - when issued with '-C', just tell user what we will do
    - since copy is fake, then no way to fake a sm


Modified: trunk/lib/SVK/Command/Branch.pm
==============================================================================
--- trunk/lib/SVK/Command/Branch.pm	(original)
+++ trunk/lib/SVK/Command/Branch.pm	Wed May 21 02:37:16 2008
@@ -354,10 +354,18 @@
 	    $self->{rev} = $which_rev_we_branch;
 	    $src = $self->arg_uri_maybe($depot_root.'/'.$which_depotpath);
 	    $self->{message} = "- Create branch $src_branch_path to $dst_branch_path";
-#	    if ($self->{check_only}) {
-#		$logger->info(
-#		    loc ("We will copy branch %1 to %2"), $
-#	    }
+	    if ($self->{check_only}) {
+		$logger->info(
+		    loc ("We will copy branch %1 to %2", $src_branch_path, $dst_branch_path)
+		);
+		$logger->info(
+		    loc ("Then do a smerge on %1", $dst_branch_path)
+		);
+		$logger->info(
+		    loc ("Finally delete the src branch %1", $src_branch_path)
+		);
+		return;
+	    }
 	    local *handle_direct_item = sub {
 		my $self = shift;
 		$self->SVK::Command::Copy::handle_direct_item(@_);
@@ -864,7 +872,8 @@
 
 	# XXX: we have a little conflict in private hash argname.
 	$self->{rev} = undef;
-	$self->SVK::Command::Switch::run($dst, $target) if $target->isa('SVK::Path::Checkout');
+	$self->SVK::Command::Switch::run($dst, $target)
+	    if $target->isa('SVK::Path::Checkout') and !$self->{check_only};
     } else {
 	$self->SUPER::run($target, @args);
     }
@@ -917,7 +926,8 @@
 
 	# XXX: we have a little conflict in private hash argname.
 	$self->{rev} = undef;
-	$self->SVK::Command::Switch::run($local, $target) if $target->isa('SVK::Path::Checkout');
+	$self->SVK::Command::Switch::run($local, $target)
+	    if $target->isa('SVK::Path::Checkout') and !$self->{check_only};
     } else {
 	$self->SUPER::run($proj, $target, $branch_name);
     }

Modified: trunk/t/bm/online-offline.t
==============================================================================
--- trunk/t/bm/online-offline.t	(original)
+++ trunk/t/bm/online-offline.t	Wed May 21 02:37:16 2008
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 use strict;
 use SVK::Test;
-plan tests => 18;
+plan tests => 21;
 our $output;
 
 my ($xd, $svk) = build_test('test');
@@ -37,7 +37,13 @@
 append_file('A/be', "fnordorz\n");
 $svk->commit(-m => 'orz');
 
-$svk->br('--online'); # XXX: check output
+is_output($svk, 'br', ['--online', '-C'],
+    ["We will copy branch //local/MyProject/foo to //mirror/MyProject/branches/foo",
+     "Then do a smerge on //mirror/MyProject/branches/foo",
+     "Finally delete the src branch //local/MyProject/foo"]);
+
+is_output_like ($svk, 'branch', ['--online'],
+    qr|U   A/be|);
 
 is_output_like ($svk, 'info', [],
    qr|Depot Path: //mirror/MyProject/branches/foo|);
@@ -45,6 +51,8 @@
 # since branch name is not the same, just do move and switch
 is_output ($svk, 'info', ['//local/MyProject/foo'],
     ["Path //local/MyProject/foo does not exist."]);
+#warn $output;
+#exit;
 
 is_ancestor($svk, '//mirror/MyProject/branches/foo', '/mirror/MyProject/trunk', 6);
 
@@ -70,6 +78,9 @@
 $svk->commit ('-m', 'commit message on local branch','');
 
 # now should do smerge first, then sw to the branch 
+is_output_like ($svk, 'branch', ['--online', '-C'],
+    qr|U   B/S/Q/qu|);
+
 is_output_like ($svk, 'branch', ['--online'],
     qr|U   B/S/Q/qu|);
 


More information about the svk-commit mailing list