[svk-commit] r2308 - in trunk: t

nobody at bestpractical.com nobody at bestpractical.com
Sun Mar 4 18:32:20 EST 2007


Author: clkao
Date: Sun Mar  4 18:32:19 2007
New Revision: 2308

Modified:
   trunk/lib/SVK/Editor/Checkout.pm
   trunk/lib/SVK/Editor/XD.pm
   trunk/t/07smerge-rename.t

Log:
Fix a bug that smerge to checkout with changes to a copied file is
causing incomplete svn delta string.


Modified: trunk/lib/SVK/Editor/Checkout.pm
==============================================================================
--- trunk/lib/SVK/Editor/Checkout.pm	(original)
+++ trunk/lib/SVK/Editor/Checkout.pm	Sun Mar  4 18:32:19 2007
@@ -188,7 +188,7 @@
     my ($self, $path, $checksum) = @_;
     my $copath = $path;
     $self->{get_copath}($copath);
-    die loc("result checksum mismatch")
+    die loc("result checksum mismatch for %1 (%2 vs %3)", $path, $self->{iod}{$path}->hexdigest, $checksum)
 	if $self->{iod}{$path} && $self->{iod}{$path}->hexdigest ne $checksum;
 
     if ((my $base = $self->{base}{$path})) {

Modified: trunk/lib/SVK/Editor/XD.pm
==============================================================================
--- trunk/lib/SVK/Editor/XD.pm	(original)
+++ trunk/lib/SVK/Editor/XD.pm	Sun Mar  4 18:32:19 2007
@@ -147,7 +147,7 @@
     my $base = SVK::XD::get_fh ($self->{oldroot}, '<', $dpath, $basename);
     if (!$self->{ignore_checksum} && $checksum) {
 	my $md5 = md5_fh ($base);
-	die loc("source checksum mismatch") if $md5 ne $checksum;
+	die loc("source checksum mismatch for %1 (%2 vs %3)", $path, $md5, $checksum) if $md5 ne $checksum;
 	seek $base, 0, 0;
     }
 
@@ -209,6 +209,11 @@
 		  target => $target, target_baton => $ret );
 	}
 	$self->_schedule_entry($copath, $editor, @arg);
+	if (defined $arg[0]) {
+	    # special treatment to turn this node into something with base
+	    delete $self->{added}{$path};
+	    delete $self->{iod}{$path};
+	}
     }
     return $ret;
 }
@@ -325,22 +330,24 @@
     my ($self) = @_;
 }
 
+# XXX: this should be splitted to prepare base and schedule entry
 sub _schedule_entry {
     my ($self, $copath, $editor, $copyfrom, $copyfrom_rev) = @_;
     my %copy;
     if (defined $copyfrom) {
+	# Note that the delta run through $self here is for preparing
+	# the base for subsequent editor calls that operates on top of
+	# these.
 	my $fs = $self->{oldroot}->fs;
 	my $from_root = $fs->revision_root($copyfrom_rev);
 	$editor->{master_editor} = SVK::Editor::Checkout->new(%$self);
 	if (defined $editor->{target}) {
 	    # XXX: depot_delta can't generate single file fulltext.
-	    my $handle = $editor->apply_textdelta($editor->{target_baton},
-						  $from_root->file_md5_checksum($copyfrom));
+	    my $handle = $editor->apply_textdelta($editor->{target_baton}, '');
 		if ($handle && $#{$handle} >= 0) {
-		    if ($self->{send_fulltext}) {
-			SVN::TxDelta::send_stream($from_root->file_content($copyfrom),
-						  @$handle);
-		    }
+		    SVN::TxDelta::send_stream($from_root->file_contents($copyfrom),
+					      @$handle);
+		    $editor->close_file($editor->{target_baton}, $from_root->file_md5_checksum($copyfrom));
 		}
 	}
 	else {

Modified: trunk/t/07smerge-rename.t
==============================================================================
--- trunk/t/07smerge-rename.t	(original)
+++ trunk/t/07smerge-rename.t	Sun Mar  4 18:32:19 2007
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-use Test::More tests => 2;
+use Test::More tests => 4;
 use strict;
 use File::Path;
 use Cwd;
@@ -7,7 +7,7 @@
 
 my ($xd, $svk) = build_test();
 our $output;
-my ($copath, $corpath) = get_copath ('smerge-moved');
+my ($copath, $corpath) = get_copath ('smerge-rename');
 $svk->mkdir ('-m', 'trunk', '//trunk');
 $svk->checkout ('//trunk', $copath);
 my ($repospath, undef, $repos) = $xd->find_repos ('//', 1);
@@ -55,3 +55,41 @@
 	    qr'New merge ticket: .*:/trunk:8',
 	    'Empty merge.',
 	    '2 conflicts found.']);
+
+$ENV{SVKRESOLVE} = 's';
+is_output ($svk, 'smerge', ['--track-rename', '//trunk', '//local', -m => 'merge with renames'],
+	   ['Auto-merging (2, 8) /trunk to /local (base /trunk:2).',
+	    'Collecting renames, this might take a while.',
+	    'A + A/deep.new',
+	    'U   A/deep.new/foo',
+	    'A + A/deep.new/bar',
+	    'U   A/normal',
+	    'A + A/foo.new',
+	    'D   A/bar',
+	    'C   A/deep',
+	    'D   A/deep/foo',
+	    'C   A/deep/test.pl',
+	    'D   A/foo',
+	    'U   test.pl - A/deep/test.pl',
+	    qr'New merge ticket: .*:/trunk:8',
+	    'Empty merge.',
+	    '2 conflicts found.']);
+
+my ($lcopath, $lcorpath) = get_copath ('smerge-moved');
+$svk->checkout ('//local', $lcopath);
+is_output ($svk, 'smerge', ['--track-rename', '//trunk', $lcopath],
+	   ['Auto-merging (2, 8) /trunk to /local (base /trunk:2).',
+	    'Collecting renames, this might take a while.',
+	    __("A + $lcopath/A/deep.new"),
+	    __("U   $lcopath/A/deep.new/foo"),
+	    __("A + $lcopath/A/deep.new/bar"),
+	    __("U   $lcopath/A/normal"),
+	    __("A + $lcopath/A/foo.new"),
+	    __("D   $lcopath/A/bar"),
+	    __("C   $lcopath/A/deep"),
+	    __("D   $lcopath/A/deep/foo"),
+	    __("C   $lcopath/A/deep/test.pl"),
+	    __("D   $lcopath/A/foo"),
+	    __("U   $lcopath/test.pl - A/deep/test.pl"),
+	    "New merge ticket: $uuid:/trunk:8",
+	    '2 conflicts found.']);


More information about the svk-commit mailing list