[svk-commit] r2896 - in trunk: t/bm
nobody at bestpractical.com
nobody at bestpractical.com
Wed May 21 01:38:41 EDT 2008
Author: clsung
Date: Wed May 21 01:38:39 2008
New Revision: 2896
Modified:
trunk/lib/SVK/Command/Branch.pm
trunk/t/bm/move.t
Log:
- add sub dst_name()
- we're encourage to use dst_name/dst_path;
- --move now check if the dst branch is exists.
Modified: trunk/lib/SVK/Command/Branch.pm
==============================================================================
--- trunk/lib/SVK/Command/Branch.pm (original)
+++ trunk/lib/SVK/Command/Branch.pm Wed May 21 01:38:39 2008
@@ -173,6 +173,16 @@
return grep { m/$match/ } @{ $proj->branches };
}
+sub dst_name {
+ my ( $self, $proj, $branch_path ) = @_;
+
+ if ( $self->{tag} ) {
+ $proj->tag_name($branch_path);
+ } else {
+ $proj->branch_name($branch_path, $self->{local});
+ }
+}
+
sub dst_path {
my ( $self, $proj, $branch_name ) = @_;
@@ -311,14 +321,17 @@
my $depot_root = '/'.$proj->depot->depotname;
my $branch_path = $depot_root.$proj->branch_location;
- my $dst_branch_path = $dst_path;
- $dst_branch_path = $branch_path.'/'.$dst_path.'/'
- unless $dst_path =~ m#^$depot_root/#;
+ # Normalize name and path
+ my $dst_name = $self->dst_name($proj, $dst_path);
+ my $dst_branch_path = $self->dst_path($proj, $dst_name);
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",
- $branch_path, $self->{local} ? '(in local)' : '');
+ or die loc("Project branch already exists: %1%2\n",
+ $branch_path, $self->{local} ? ' (in local)' : '');
+ die loc("Project branch already exists: %1%2\n",
+ $dst_name, $self->{local} ? ' (in local)' : '')
+ if grep /$dst_name/,@{$proj->branches};
$self->{parent} = 1;
for my $src_path (@src_paths) {
Modified: trunk/t/bm/move.t
==============================================================================
--- trunk/t/bm/move.t (original)
+++ trunk/t/bm/move.t Wed May 21 01:38:39 2008
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 19;
+use Test::More tests => 20;
use SVK::Test;
use File::Path;
@@ -129,3 +129,5 @@
["Committed revision 21.",
"Project branch created: localbar (in local)"]);
+is_output ($svk, 'branch', ['--move', 'hasbugs/bar', 'hasbugs/mar'],
+ ['Project branch already exists: hasbugs/mar']);
More information about the svk-commit
mailing list