[svk-commit] r2713 - in branches/merge_perf: lib/SVK t

nobody at bestpractical.com nobody at bestpractical.com
Wed Mar 26 03:51:38 EDT 2008


Author: clkao
Date: Wed Mar 26 03:51:38 2008
New Revision: 2713

Modified:
   branches/merge_perf/lib/SVK/Merge.pm
   branches/merge_perf/lib/SVK/Merge/Info.pm
   branches/merge_perf/t/05svm.t

Log:
switch to use find_merge_sources2 that defers ->resolve
calls until we intersect the merge info.


Modified: branches/merge_perf/lib/SVK/Merge.pm
==============================================================================
--- branches/merge_perf/lib/SVK/Merge.pm	(original)
+++ branches/merge_perf/lib/SVK/Merge.pm	Wed Mar 26 03:51:38 2008
@@ -203,6 +203,8 @@
     my $repos = $self->{repos};
     my $fs = $repos->fs;
     my $yrev = $fs->youngest_rev;
+    my ($srcinfo2, $dstinfo2) = map {$self->find_merge_sources2($_)} ($src, $dst);
+    my $joint_info = $srcinfo2->intersect($dstinfo2)->resolve($src->depot);
     my ($srcinfo, $dstinfo) = map {$self->find_merge_sources ($_)} ($src, $dst);
     my ($basepath, $baserev, $baseentry);
     my ($merge_base, $merge_baserev) = $self->{merge_base} ?
@@ -237,10 +239,9 @@
 
     my @preempt_result;
 
-    for (grep {exists $srcinfo->{$_} && exists $dstinfo->{$_}}
-	 (sort keys %{ { %$srcinfo, %$dstinfo } })) {
+    for (sort keys %{$joint_info}) {
 	my ($path) = m/:(.*)$/;
-	my $rev = min ($srcinfo->{$_}, $dstinfo->{$_});
+	my $rev = $joint_info->{$_};
 
 	# when the base is one of src or dst, make sure the base is
 	# still the same node (not removed and replaced)
@@ -374,6 +375,27 @@
     return $minfo;
 }
 
+sub find_merge_sources2 {
+    my ($self, $target) = @_;
+    my $pool = SVN::Pool->new_default;
+    my $info = $self->merge_info ($target->new);
+
+    $target = $target->new->as_depotpath ($self->{xd}{checkout}->get ($target->copath. 1)->{revision})
+	if $target->isa('SVK::Path::Checkout');
+    $info->add_target($target);
+
+    return $info if !$target->root->check_path($target->path);
+
+    for (reverse $target->copy_ancestors) {
+	my ($path, $rev) = @$_;
+        # XXX: short circuit it when we have the ancestor already.
+        my $t = $target->mclone( targets => undef, path => $path, revision => $rev)->universal;
+        $info->add_target( $t )
+            if !$info->{ $t->ukey } || $info->{ $t->ukey }->rev < $t->rev;
+    }
+    return $info;
+}
+
 sub _get_new_ticket {
     my ($self, $srcinfo) = @_;
     my $dstinfo = $self->merge_info($self->{dst});

Modified: branches/merge_perf/lib/SVK/Merge/Info.pm
==============================================================================
--- branches/merge_perf/lib/SVK/Merge/Info.pm	(original)
+++ branches/merge_perf/lib/SVK/Merge/Info.pm	Wed Mar 26 03:51:38 2008
@@ -181,12 +181,27 @@
     return $new;
 }
 
+sub intersect {
+    my ($self, $other) = @_;
+    # bring merge history up to date as from source
+    my $new = SVK::Merge::Info->new;
+    for ( keys %{ { %$self, %$other } } ) {
+        if ( $self->{$_} && $other->{$_} ) {
+            $new->{$_} = $self->{$_}{rev} < $other->{$_}{rev}
+                ? $self->{$_}
+                : $other->{$_};
+        }
+    }
+    return $new;
+}
+
 =item resolve
 
 =cut
 
 sub resolve {
     my ( $self, $depot ) = @_;
+
     my $uuid = $depot->repos->fs->get_uuid;
     return {
         map {

Modified: branches/merge_perf/t/05svm.t
==============================================================================
--- branches/merge_perf/t/05svm.t	(original)
+++ branches/merge_perf/t/05svm.t	Wed Mar 26 03:51:38 2008
@@ -98,7 +98,7 @@
         "Syncing $uri/A-99",
         'Retrieving log information from 1 to 28',
         'Committed revision 13 from revision 28.',
-        'Auto-merging (10, 13) /m-99 to /m-99-copy (base /m-99:10).',
+        'Auto-merging (10, 13) /m-99 to /m-99-copy (base /:0).',
         'A   Q',
         'A   Q/qz',
         'A   T',


More information about the svk-commit mailing list