[svk-commit] r2574 - in branches/bm: t/bm
nobody at bestpractical.com
nobody at bestpractical.com
Tue Oct 30 01:21:21 EDT 2007
Author: clsung
Date: Tue Oct 30 01:21:19 2007
New Revision: 2574
Modified:
branches/bm/lib/SVK/Command/Branch.pm
branches/bm/t/bm/merge.t
Log:
- implement '--merge -C feature/* trunk'
Modified: branches/bm/lib/SVK/Command/Branch.pm
==============================================================================
--- branches/bm/lib/SVK/Command/Branch.pm (original)
+++ branches/bm/lib/SVK/Command/Branch.pm Tue Oct 30 01:21:19 2007
@@ -214,9 +214,9 @@
}
package SVK::Command::Branch::merge;
-use base qw( SVK::Command::Merge SVK::Command::Branch);
+use base qw( SVK::Command::Merge SVK::Command::Switch SVK::Command::Branch);
use SVK::I18N;
-use SVK::Util qw( is_uri );
+use SVK::Util qw( is_uri traverse_history );
use constant narg => 1;
@@ -228,15 +228,16 @@
die loc ("Copy destination can't be URI.\n")
if is_uri ($dst);
- my $src = pop(@arg);
- die loc ("Copy source can't be URI.\n")
- if is_uri ($src);
+ for (@arg) {
+ die loc ("Copy source can't be URI.\n")
+ if is_uri ($_);
+ }
- return ($self->arg_co_maybe (''), $src, $dst);
+ return ($self->arg_co_maybe (''), $dst, @arg);
}
sub run {
- my ($self, $target, $src, $dst) = @_;
+ my ($self, $target, $dst, @srcs) = @_;
my $source = $target->source;
my $proj = SVK::Project->create_from_path(
@@ -244,22 +245,37 @@
$source->path
);
- my $branch_path = '//'.$proj->depot->depotname.'/'.$proj->branch_location;
- my $src_branch_path = $branch_path.'/'.$src.'/';
- my $dst_branch_path = $branch_path.'/'.$dst.'/';
- $dst_branch_path = '//'.$proj->trunk if $dst eq 'trunk';
+ my $branch_path = '/'.$proj->depot->depotname.'/'.$proj->branch_location;
+ my $dst_branch_path = $branch_path.'/'.$dst;
+ $dst_branch_path = '/'.$proj->depot->depotname.'/'.$proj->trunk
+ if $dst eq 'trunk';
- $src = $self->arg_uri_maybe($src_branch_path);
$dst = $self->arg_depotpath($dst_branch_path);
- # extract the fromrev and torev from src
- my $N = $src->root->node_created_rev( $src->path );
- my ($m, $mpath) = $src->is_mirrored;
- my $M = $m->fromrev;
-
- push @{$self->{revspec}},"$N:$M";
- $self->{message} ||= "- Merge $src_branch_path to $dst_branch_path";
- my $ret = $self->SUPER::run($src, $dst);
+ for my $src (@srcs) {
+ my $src_branch_path = $branch_path.'/'.$src;
+ $src = $self->arg_depotpath($src_branch_path);
+ # extract the fromrev and torev from src
+
+ my ($m) = $src->is_mirrored;
+ my $N = $src->root->node_created_rev( $src->path );
+
+ my $M = $m->fromrev;
+ traverse_history (
+ root => $src->root,
+ path => $src->path,
+ cross => 0,
+ callback => sub {
+ my $rev = $_[1];
+ $M = $rev if $rev < $M;
+ },
+ );
+
+ undef $self->{revspec};
+ push @{$self->{revspec}},"$N:$M";
+ $self->{message} ||= "- Merge $src_branch_path to $dst_branch_path";
+ my $ret = $self->SUPER::run($src, $dst);
+ }
return;
}
Modified: branches/bm/t/bm/merge.t
==============================================================================
--- branches/bm/t/bm/merge.t (original)
+++ branches/bm/t/bm/merge.t Tue Oct 30 01:21:19 2007
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 6;
+use Test::More tests => 7;
use SVK::Test;
use File::Path;
@@ -42,7 +42,9 @@
is_output ($svk, 'branch', ['--merge', '-C', 'feature/bar', 'trunk'],
[ "Checking locally against mirror source $uri.", 'g A/Q/qu']);
-is_output ($svk, 'branch', ['--merge', '-C', 'feature/*', 'trunk'],
+is_output ($svk, 'branch', ['--merge', '-C', 'feature/foo', 'trunk'],
+ [ "Checking locally against mirror source $uri.", 'gg A/be']);
+
+is_output ($svk, 'branch', ['--merge', '-C', 'feature/bar', 'feature/foo', 'trunk'],
[ "Checking locally against mirror source $uri.", 'g A/Q/qu',
"Checking locally against mirror source $uri.", 'gg A/be']);
-warn $output;
More information about the svk-commit
mailing list