[svk-commit] r2855 - in trunk: lib/SVK t
nobody at bestpractical.com
nobody at bestpractical.com
Sat May 10 06:19:36 EDT 2008
Author: nothingmuch
Date: Sat May 10 06:19:35 2008
New Revision: 2855
Modified:
trunk/lib/SVK/Command/Branch.pm
trunk/lib/SVK/Project.pm
trunk/t/81branch.t
Log:
--tag option for SVK::Command::Branch, only handled in ::create at the moment
Modified: trunk/lib/SVK/Command/Branch.pm
==============================================================================
--- trunk/lib/SVK/Command/Branch.pm (original)
+++ trunk/lib/SVK/Command/Branch.pm Sat May 10 06:19:35 2008
@@ -72,6 +72,7 @@
'local' => 'local',
'project=s' => 'project',
'switch-to' => 'switch',
+ 'tag' => "tag",
'verbose' => 'verbose', # TODO
map { my $cmd = $_; s/\|.*$//; ($cmd => $_) } @SUBCOMMANDS
);
@@ -232,7 +233,7 @@
delete $self->{from} if $self->{from} and $self->{from} eq 'trunk';
my $src_path = $proj->branch_path($self->{from} ? $self->{from} : 'trunk');
- my $newbranch_path = $proj->branch_path($branch_name, $self->{local});
+ my $newbranch_path = $self->dst_path($proj, $branch_name);
my $src = $self->arg_uri_maybe($src_path);
die loc("Invalid --from argument") if
@@ -247,7 +248,8 @@
my $ret = $self->SUPER::run($src, $dst);
if (!$ret) {
- $logger->info( loc("Project branch created: %1%2%3\n",
+ $logger->info( loc("Project %1 created: %2%3%4\n",
+ $self->{tag} ? "tag" : "branch",
$branch_name,
$self->{local} ? ' (in local)' : '',
$self->{from} ? " (from $self->{from})" : '',
@@ -262,6 +264,16 @@
return;
}
+sub dst_path {
+ my ( $self, $proj, $branch_name ) = @_;
+
+ if ( $self->{tag} ) {
+ $proj->tag_path($branch_name);
+ } else {
+ $proj->branch_path($branch_name, $self->{local});
+ }
+}
+
package SVK::Command::Branch::move;
use base qw( SVK::Command::Move SVK::Command::Smerge SVK::Command::Delete SVK::Command::Branch::create );
use SVK::I18N;
@@ -803,7 +815,7 @@
branch --create BRANCH [DEPOTPATH]
branch --list [--all]
- branch --create BRANCH [--local] [--switch-to] [DEPOTPATH]
+ branch --create BRANCH [--tag] [--local] [--switch-to] [DEPOTPATH]
branch --move BRANCH1 BRANCH2
branch --merge BRANCH1 BRANCH2 ... TARGET
branch --checkout BRANCH [PATH] [DEPOTPATH]
@@ -815,6 +827,7 @@
-l [--list] : list branches for this project
--create : create a new branch
+ --tag : create in the tags directory
--local : targets in local branch
--delete : delete BRANCH(s)
--checkout : checkout BRANCH in current directory
Modified: trunk/lib/SVK/Project.pm
==============================================================================
--- trunk/lib/SVK/Project.pm (original)
+++ trunk/lib/SVK/Project.pm Sat May 10 06:19:35 2008
@@ -318,6 +318,13 @@
return $branch_path;
}
+sub tag_path {
+ my ($self, $tname) = @_;
+ my $tag_path = ($tname ne 'trunk' ? $self->tag_location . "/$tname" : $self->trunk);
+ $tag_path = '/'.dir($self->depot->depotname)->subdir($tag_path);
+ return $tag_path;
+}
+
sub info {
my ($self, $target) = @_;
Modified: trunk/t/81branch.t
==============================================================================
--- trunk/t/81branch.t (original)
+++ trunk/t/81branch.t Sat May 10 06:19:35 2008
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 5;
+use Test::More tests => 6;
use SVK::Test;
use File::Path;
@@ -36,3 +36,4 @@
qr'Project branch created: feature/foobar \(in local\)');
is_output_like ($svk, 'info', [], qr'Copied From: /mirror/MyProject/trunk, Rev. \d+');
+is_output_like ($svk, 'branch', ['--create', '--tag', 'bar'], qr'Project tag created: bar');
More information about the svk-commit
mailing list