[svk-commit] r2635 - in branches/bm: t/bm
nobody at bestpractical.com
nobody at bestpractical.com
Sat Dec 15 23:50:52 EST 2007
Author: clsung
Date: Sat Dec 15 23:50:51 2007
New Revision: 2635
Added:
branches/bm/t/bm/create.t
Modified:
branches/bm/lib/SVK/Command/Branch.pm
Log:
- add --from 'branch_path' to branch --create,
- we can create non-trunk branch
- a test for it
Modified: branches/bm/lib/SVK/Command/Branch.pm
==============================================================================
--- branches/bm/lib/SVK/Command/Branch.pm (original)
+++ branches/bm/lib/SVK/Command/Branch.pm Sat Dec 15 23:50:51 2007
@@ -60,15 +60,16 @@
use constant narg => undef;
sub options {
- ('l|list' => 'list',
+ ('l|list' => 'list',
'C|check-only' => 'check_only',
- 'create'=> 'create',
- 'all'=> 'all',
- 'local'=> 'local',
- 'merge'=> 'merge',
- 'move' => 'move',
- 'remove'=> 'remove',
- 'switch-to'=> 'switch',
+ 'create' => 'create',
+ 'all' => 'all',
+ 'local' => 'local',
+ 'from=s' => 'from',
+ 'merge' => 'merge',
+ 'move' => 'move',
+ 'remove' => 'remove',
+ 'switch-to' => 'switch',
);
}
@@ -160,12 +161,17 @@
my $proj = $self->load_project($target);
- my $trunk_path = '/'.$proj->depot->depotname.'/'.$proj->trunk;
+ my $src_path = '/'.$proj->depot->depotname.'/'.
+ ( $self->{from} ?
+ $proj->branch_location .'/'. $self->{from}.'/'
+ :
+ $proj->trunk
+ );
my $newbranch_path = '/'.$proj->depot->depotname.'/'.
( $self->{local} ? $proj->local_root : $proj->branch_location ).
'/'.$branch_path.'/';
- my $src = $self->arg_uri_maybe($trunk_path);
+ my $src = $self->arg_uri_maybe($src_path);
my $dst = $self->arg_uri_maybe($newbranch_path);
$SVN::Node::none == $dst->root->check_path($dst->path)
or die loc("Project branch already exists: %1 %2\n",
@@ -176,8 +182,11 @@
my $ret = $self->SUPER::run($src, $dst);
if (!$ret) {
- print loc("Project branch created: %1 %2\n",
- $branch_path, $self->{local} ? '(in local)' : '');
+ print loc("Project branch created: %1%2%3\n",
+ $branch_path,
+ $self->{local} ? ' (in local)' : '',
+ $self->{from} ? " (from $self->{from})" : '',
+ );
# call SVK::Command::Switch here if --switch-to
$self->SVK::Command::Switch::run(
$self->arg_uri_maybe($newbranch_path),
Added: branches/bm/t/bm/create.t
==============================================================================
--- (empty file)
+++ branches/bm/t/bm/create.t Sat Dec 15 23:50:51 2007
@@ -0,0 +1,66 @@
+#!/usr/bin/perl -w
+use strict;
+use Test::More tests => 6;
+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',
+ ['--create', 'feature/bar', '--switch-to'],
+ qr'Project branch created: feature/bar');
+
+overwrite_file ('A/Q/qu', "\nonly a bar\nzz\n");
+$svk->diff();
+$svk->commit ('-m', 'commit message here (r9)','');
+
+is_output ($svk, 'branch',
+ ['--create', 'localfoo', '--local'],
+ ["Committed revision 10.",
+ "Project branch created: localfoo (in local)"]);
+
+$svk->branch('--switch', 'trunk');
+
+is_output ($svk, 'branch',
+ ['--create', 'localbar', '--local', '--switch-to'],
+ ["Committed revision 11.",
+ "Project branch created: localbar (in local)",
+ 'Syncing /'."/mirror/MyProject/trunk(/mirror/MyProject/trunk) in ".__($corpath).' to 11.']);
+
+is_output ($svk, 'branch',
+ ['--create', 'feature/foobar', '--from', 'feature/bar'],
+ ["Merging back to mirror source $uri.",
+ "Merge back committed as revision 9.",
+ "Syncing $uri",
+ 'Retrieving log information from 9 to 9',
+ 'Committed revision 12 from revision 9.',
+ "Project branch created: feature/foobar (from feature/bar)"]);
+
+is_output ($svk, 'info',['//mirror/MyProject/branches/feature/foobar'],
+ ["Depot Path: //mirror/MyProject/branches/feature/foobar",
+ "Revision: 12", "Last Changed Rev.: 12",
+ qr/Last Changed Date: \d{4}-\d{2}-\d{2}/,
+ "Mirrored From: $uri, Rev. 9",
+ "Copied From: /mirror/MyProject/branches/feature/bar, Rev. 9",
+ "Copied From: /mirror/MyProject/trunk, Rev. 6",
+ "Merged From: /mirror/MyProject/branches/feature/bar, Rev. 9",
+ "Merged From: /mirror/MyProject/trunk, Rev. 6",'']);
+
+ warn $output;
+
More information about the svk-commit
mailing list