[svk-commit] r2614 - in branches/bm: t
nobody at bestpractical.com
nobody at bestpractical.com
Mon Nov 26 14:29:20 EST 2007
Author: clkao
Date: Mon Nov 26 14:29:12 2007
New Revision: 2614
Modified:
branches/bm/lib/SVK/Merge.pm
branches/bm/t/36push-pull.t
Log:
Improve merge base finding logic in some cases of pushing pulled revisions.
Modified: branches/bm/lib/SVK/Merge.pm
==============================================================================
--- branches/bm/lib/SVK/Merge.pm (original)
+++ branches/bm/lib/SVK/Merge.pm Mon Nov 26 14:29:12 2007
@@ -117,27 +117,17 @@
sub auto {
my $self = new (@_);
@{$self}{qw/base fromrev/} = $self->find_merge_base(@{$self}{qw/src dst/});
- $self->_rebase;
return $self;
}
-sub _rebase {
- my $self = shift;
-
- my $new_base = $self->_rebase2( $self->{src}, $self->{dst}, $self->{base} );
-
- $self->{base} = $new_base if $new_base;
- return;
-}
-
sub _rebase2 {
my $self = shift;
my ($src, $dst, $base) = @_;
return unless $base->path eq $dst->path;
- $self->{src}->is_merged_from($self->{base})
+ $src->is_merged_from($base)
or return;
my $ddst = $src->prev or return;
@@ -240,6 +230,11 @@
$rev);
}
+ return ($src->new (revision => $merge_baserev), $merge_baserev)
+ if $merge_baserev;
+
+ my @preempt_result;
+
for (grep {exists $srcinfo->{$_} && exists $dstinfo->{$_}}
(sort keys %{ { %$srcinfo, %$dstinfo } })) {
my ($path) = m/:(.*)$/;
@@ -254,17 +249,24 @@
next unless $src->related_to($src->as_depotpath->seek_to($rev));
}
- if ($path eq $dst->path &&
- (my $src_base = $src->is_merged_from($src->mclone(path => $path, revision => $rev)))) {
- ($basepath, $baserev, $baseentry) = ($path, $rev, $_);
- last;
- }
- ($basepath, $baserev, $baseentry) = ($path, $rev, $_)
- if !$basepath || $fs->revision_prop($rev, 'svn:date') gt $fs->revision_prop($baserev, 'svn:date');
+ if (!$basepath || $fs->revision_prop($rev, 'svn:date') gt $fs->revision_prop($baserev, 'svn:date')) {
+ ($basepath, $baserev, $baseentry) = ($path, $rev, $_);
+ if ($path eq $dst->path &&
+ $src->is_merged_from($dst->mclone(revision => $rev))) {
+
+ my ($base, $from) = $self->_mk_base_and_from( $src, $dstinfo, $basepath, $baserev );
+ $base = $self->_rebase2( $src, $dst, $base) || $base;
+ @preempt_result = ($base, $from);
+ }
+ elsif ($path eq $src->path && $dst->is_merged_from($src->mclone(revision => $rev))) {
+ my ($base, $from) = $self->_mk_base_and_from( $src, $dstinfo, $basepath, $baserev );
+ $base = $self->_rebase2( $dst, $src, $base) || $base;
+ @preempt_result = ($base, $from);
+ }
+ }
}
- return ($src->new (revision => $merge_baserev), $merge_baserev)
- if $merge_baserev;
+ return @preempt_result if @preempt_result;
unless ($basepath) {
return ($src->new (path => '/', revision => 0), 0)
@@ -286,6 +288,12 @@
if $minfo->subset_of ($srcinfo) && $minfo->subset_of ($dstinfo);
}
}
+ return $self->_mk_base_and_from( $src, $dstinfo, $basepath, $baserev );
+}
+
+sub _mk_base_and_from {
+ my $self = shift;
+ my ($src, $dstinfo, $basepath, $baserev) = @_;
my $base = $src->as_depotpath->new
(path => $basepath, revision => $baserev, targets => undef);
@@ -294,7 +302,7 @@
# When /A:1 is copied to /B:2, then removed, /B:2 copied to /A:5
# the fromrev shouldn't be /A:1, as it confuses the copy detection during merge.
- my $from = $dstinfo->{$fs->get_uuid.':'.$src->path};
+ my $from = $dstinfo->{$src->depot->repos->fs->get_uuid.':'.$src->path};
if ($from) {
my ($toroot, $fromroot) = $src->nearest_copy;
$from = 0 if $toroot && $from < $toroot->revision_root_revision;
@@ -620,6 +628,7 @@
my $t = $src;
while (my ($toroot, $fromroot, $path) = $t->nearest_copy) {
if ($path eq $self->{base}->path_anchor) {
+ Carp::cluck unless defined $boundry_rev;
$boundry_rev = List::Util::max( $boundry_rev, $toroot->revision_root_revision );
}
$t = $t->mclone( path => $path, revision => $fromroot->revision_root_revision );
Modified: branches/bm/t/36push-pull.t
==============================================================================
--- branches/bm/t/36push-pull.t (original)
+++ branches/bm/t/36push-pull.t Mon Nov 26 14:29:12 2007
@@ -276,9 +276,14 @@
"Syncing $uri/A",
'Retrieving log information from 14 to 14',
'Committed revision 31 from revision 14.',
- '===> Auto-merging (28, 29) /l2 to /m (base */l2:28).',
+ '===> Auto-merging (28, 29) /l2 to /m (base */m:30).',
"Merging back to mirror source $uri/A.",
- 'Empty merge.']);
+ 'U new-file',
+ qr'New merge ticket: .*:/l2:29',
+ 'Merge back committed as revision 15.',
+ "Syncing $uri/A",
+ 'Retrieving log information from 15 to 15',
+ 'Committed revision 32 from revision 15.']);
chdir ($initial_cwd);
$svk->cp (-m => 'copy', '/test/A' => '/test/A-cp');
More information about the svk-commit
mailing list