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

nobody at bestpractical.com nobody at bestpractical.com
Tue May 6 06:27:21 EDT 2008


Author: clkao
Date: Tue May  6 06:27:21 2008
New Revision: 2801

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

Log:
simple cases for br online and offline.


Modified: trunk/lib/SVK/Command/Branch.pm
==============================================================================
--- trunk/lib/SVK/Command/Branch.pm	(original)
+++ trunk/lib/SVK/Command/Branch.pm	Tue May  6 06:27:21 2008
@@ -61,7 +61,7 @@
 our $fromProp;
 use constant narg => undef;
 
-my @SUBCOMMANDS = qw(merge move push remove|rm|del|delete checkout|co create setup);
+my @SUBCOMMANDS = qw(merge move push remove|rm|del|delete checkout|co create setup online offline);
 
 sub options {
     ('l|list'           => 'list',
@@ -640,6 +640,56 @@
     }
     return;
 }
+
+package SVK::Command::Branch::online;
+use base qw( SVK::Command::Branch::move SVK::Command::Switch );
+use SVK::I18N;
+use SVK::Logger;
+
+sub lock { $_[0]->lock_target ($_[1]); };
+
+sub parse_arg {
+    my ($self, $arg) = @_;
+    my $target = $self->arg_co_maybe($arg || '');
+    # XXX: make sure we are a local branch
+    $self->{switch} = 1 if $target->isa('SVK::Path::Checkout');
+    # XXX: if the remote branch of the same name already exists, do a
+    # smerge instead
+    $self->{branch_name} = $target->_to_pclass($target->path)->dir_list(-1);
+
+    return ($target, $self->{branch_name}, $target->depotpath);
+}
+
+sub run {
+    my ($self, $target, @args) = @_;
+    $self->SUPER::run($target, @args);
+    my $proj = $self->load_project($target);
+
+    my $newtarget = $target->mclone( path => '/'. $proj->branch_location . '/' . $self->{branch_name} )->refresh_revision;
+
+    # XXX: we have a little conflict in private hash argname.
+    $self->{rev} = undef;
+    $self->SVK::Command::Switch::run($newtarget, $target) if $target->isa('SVK::Path::Checkout');
+}
+
+package SVK::Command::Branch::offline;
+use base qw( SVK::Command::Branch::create );
+use SVK::I18N;
+use SVK::Logger;
+
+# --offline FOO:
+#   --create FOO --local  if FOO/local does't exist 
+
+# --offline (at checkout of branch FOO
+#   --create FOO --from FOO --local
+
+sub run {
+    my ($self, $target, $branch_path) = @_;
+    $self->{local} = 1;
+    $self->{switch} = 1;
+    $self->SUPER::run($target, $branch_path);
+}
+
 1;
 
 __DATA__

Modified: trunk/t/bm/online-offline.t
==============================================================================
--- trunk/t/bm/online-offline.t	(original)
+++ trunk/t/bm/online-offline.t	Tue May  6 06:27:21 2008
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 use strict;
 use SVK::Test;
-plan tests => 6;
+plan tests => 5;
 our $output;
 
 my ($xd, $svk) = build_test('test');
@@ -17,16 +17,12 @@
 $svk->mirror('//mirror/MyProject', $uri);
 $svk->sync('//mirror/MyProject');
 
-$svk->cp(-m => 'branch foo', '//mirror/MyProject/trunk', '//mirror/MyProject/branches/foo');
-
 my ($copath, $corpath) = get_copath('basic-trunk');
 
 $svk->checkout('//mirror/MyProject/trunk', $copath);
 
 chdir($copath);
 
-TODO: {
-local $TODO = '--online/--offline not implemented yet';
 # this should be is_output(_like) instead of just run it
 # but I'm not sure what's the correct message yet
 $svk->br('--offline','foo');
@@ -34,15 +30,25 @@
 is_output_like ($svk, 'info', [],
    qr|Depot Path: //local/MyProject/foo|);
 
+is_ancestor($svk, '//local/MyProject/foo', '/mirror/MyProject/trunk', 6);
+
 is_output($svk, 'br', ['-l', '--local', '//mirror/MyProject'],
           ['foo']);
+append_file('A/be', "fnordorz\n");
+$svk->commit(-m => 'orz');
 
-# should online need an argument ?
-$svk->br('--online');
+$svk->br('--online'); # XXX: check output
 
 is_output_like ($svk, 'info', [],
    qr|Depot Path: //mirror/MyProject/branches/foo|);
 
+is_ancestor($svk, '//mirror/MyProject/branches/foo', '/mirror/MyProject/trunk', 6);
+
+
+exit;
+TODO: {
+# should online need an argument ?
+
 # let's play with feature/foobar branch now
 
 is_output_like ($svk, 'branch', ['--create', 'feature/foobar'],


More information about the svk-commit mailing list