[svk-commit] r2781 - in trunk: lib/SVK t/bm

nobody at bestpractical.com nobody at bestpractical.com
Tue Apr 29 03:29:27 EDT 2008


Author: clsung
Date: Tue Apr 29 03:29:26 2008
New Revision: 2781

Modified:
   trunk/lib/SVK/Command/Branch.pm
   trunk/lib/SVK/Project.pm
   trunk/t/bm/merge.t

Log:
- fix problems addressed in jesse's mail => "br explodey"
- add depotpath_in_branch_or_tag() in Project.pm
  - to get depotpath of a given branch or tag, or undef if none found.

Modified: trunk/lib/SVK/Command/Branch.pm
==============================================================================
--- trunk/lib/SVK/Command/Branch.pm	(original)
+++ trunk/lib/SVK/Command/Branch.pm	Tue Apr 29 03:29:26 2008
@@ -72,8 +72,8 @@
      'merge'            => 'merge',
      'push'             => 'push',
      'move'             => 'move',
-     'rm|remove'           => 'remove',
-     'del|delete'           => 'remove',
+     'rm|remove'        => 'remove',
+     'del|delete'       => 'remove',
      'setup'            => 'setup',
      'switch-to'        => 'switch',
     );
@@ -387,20 +387,16 @@
 
     @srcs = map { $self->expand_branch($proj, $_) } @srcs;
 
-    my $branch_path = '/'.$proj->depot->depotname.'/'.$proj->branch_location;
-    my $dst_branch_path = $branch_path.'/'.$dst;
-    $dst_branch_path =  '/'.$proj->depot->depotname.'/'.$proj->trunk
+    my $dst_depotpath = $dst;
+    $dst_depotpath = '/'.$proj->depot->depotname.'/'.$proj->trunk
 	if $dst eq 'trunk';
+    $dst_depotpath = $proj->depotpath_in_branch_or_tag($dst_depotpath) || $dst_depotpath;
+    $dst = $self->arg_co_maybe($dst_depotpath);
+    $dst->root->check_path($dst->path)
+	or die loc("Path or branche %1 does not included in current Project\n", $dst->depotpath);
+    $dst_depotpath = $dst->depotpath;
 
-    # try to get checkout from copath (if dst is specified PATH)
-    # if failed (SVN::Node::none), get from depotpath
-    if (-e $dst) {
-	my $copath = abs_path($dst);
-	my ($entry, @where) = $self->{xd}{checkout}->get($copath, 1);
-	$dst = $self->arg_depotpath($entry->{depotpath});
-    } else {
-	$dst = $self->arg_depotpath($dst_branch_path)
-    }
+    $dst = $self->arg_depotpath($dst_depotpath);
 
     # see also check_only in incmrental smerge.  this should be a
     # better api in svk::path
@@ -411,12 +407,12 @@
     }
 
     for my $src (@srcs) {
-	my $src_branch_path = $branch_path.'/'.$src;
+	my $src_branch_path = $proj->depotpath_in_branch_or_tag($src);
 	$src_branch_path =  '/'.$proj->depot->depotname.'/'.$proj->trunk
 	    if $src eq 'trunk';
 	$src = $self->arg_depotpath($src_branch_path);
 
-	$self->{message} = "- Merge $src_branch_path to $dst_branch_path";
+	$self->{message} = "- Merge $src_branch_path to ".$dst->depotpath;
 	my $ret = $self->SUPER::run($src, $dst);
 	$dst->refresh_revision;
     }

Modified: trunk/lib/SVK/Project.pm
==============================================================================
--- trunk/lib/SVK/Project.pm	(original)
+++ trunk/lib/SVK/Project.pm	Tue Apr 29 03:29:26 2008
@@ -85,6 +85,7 @@
 
 sub tags {
     my $self = shift;
+    return [] unless $self->tag_location;
 
     my $fs              = $self->depot->repos->fs;
     my $root            = $fs->revision_root( $fs->youngest_rev );
@@ -238,4 +239,13 @@
     return ($project_name, $trunk_path, $branch_path, $tag_path);
 }
 
+sub depotpath_in_branch_or_tag {
+    my ($self, $name) = @_;
+    # return 1 for branch, 2 for tag, others => 0
+    return '/'.$self->depot->depotname.'/'.$self->branch_location.'/'.$name
+	if grep { $_ eq $name } @{$self->branches};
+    return '/'.$self->depot->depotname.'/'.$self->tag_location.'/'.$name
+	if grep { $_ eq $name } @{$self->tags};
+    return ;
+}
 1;

Modified: trunk/t/bm/merge.t
==============================================================================
--- trunk/t/bm/merge.t	(original)
+++ trunk/t/bm/merge.t	Tue Apr 29 03:29:26 2008
@@ -173,7 +173,7 @@
     qr'Target: [\w\d-]+:/branches/merge/foo:19',
     "        ($uri)",
     "Log:",
-    "- Merge //mirror/MyProject/branches/merge/foo2 to //mirror/MyProject/branches/.",
+    "- Merge //mirror/MyProject/branches/merge/foo2 to //mirror/MyProject/branches/merge/foo",
     @$patch1,
     '',
     '==== BEGIN SVK PATCH BLOCK ====',


More information about the svk-commit mailing list