[svk-commit] r2631 - in branches/smcp-base-bug: t

nobody at bestpractical.com nobody at bestpractical.com
Sat Dec 15 04:12:22 EST 2007


Author: clkao
Date: Sat Dec 15 04:12:21 2007
New Revision: 2631

Modified:
   branches/smcp-base-bug/lib/SVK/Editor/Merge.pm
   branches/smcp-base-bug/t/07smerge-copy.t
   branches/smcp-base-bug/t/07smerge-cpreplace.t

Log:
make resolve_base returns an appropriate inspector and use it.

Modified: branches/smcp-base-bug/lib/SVK/Editor/Merge.pm
==============================================================================
--- branches/smcp-base-bug/lib/SVK/Editor/Merge.pm	(original)
+++ branches/smcp-base-bug/lib/SVK/Editor/Merge.pm	Sat Dec 15 04:12:21 2007
@@ -280,7 +280,7 @@
 	if (defined $arg[0]) {
 	    $self->{notify}->hist_status ($path, '+');
 	    @arg = $self->resolve_copy($path, @arg);
-	    $self->{info}{$path}{baseinfo} = [$self->_resolve_base($path)];
+	    $self->{info}{$path}{baseinfo} = [$self->resolve_base($path, 0, $pool)];
 	    $self->{info}{$path}{fpool} = $pool;
 	}
 	$self->{storage_baton}{$path} =
@@ -307,13 +307,26 @@
 	    $entry->{".${key}_rev"});
 }
 
+sub resolve_base {
+    my ($self, $path, $orig, $pool) = @_;
+    my ($basepath, $fromrev) = $self->_resolve_base($path, $orig);
+    if ($basepath) {
+	my $inspector =
+	    SVK::Inspector::Root->new({ anchor => $self->inspector->anchor,
+					root => $self->{base_root}->fs->revision_root($fromrev, $pool),
+					path_translations => $self->inspector->path_translations });
+	return ($basepath, $fromrev, $inspector);
+    }
+
+    return ($path, undef, $self->inspector) 
+}
+
 sub open_file {
     my ($self, $path, $pdir, $rev, $pool) = @_;
     # modified but rm locally - tag for conflict?
-    my ($basepath, $fromrev) = $self->_resolve_base($path);
-    $basepath = $path unless defined $basepath;
-    if (defined $pdir && $self->inspector->exist($basepath, $pool) == $SVN::Node::file) {
-	$self->{info}{$path}{baseinfo} = [$basepath, $fromrev]
+    my ($basepath, $fromrev, $inspector) = $self->resolve_base($path);
+    if (defined $pdir && $inspector->exist($basepath, $pool) == $SVN::Node::file) {
+	$self->{info}{$path}{baseinfo} = [$basepath, $fromrev, $inspector]
 	    if defined $fromrev;
 	$self->{info}{$path}{open} = [$pdir, $rev];
 	$self->{info}{$path}{fpool} = $pool;
@@ -420,10 +433,10 @@
     return unless $path;
 
     my $info = $self->{info}{$path};
-    my ($basepath, $fromrev) = $info->{baseinfo} ? @{$info->{baseinfo}} : ($path);
+    my ($basepath, $fromrev, $inspector) = $info->{baseinfo} ? @{$info->{baseinfo}} : ($path, undef, $self->inspector);
     my $fh = $info->{fh} = {};
     my $pool = $info->{fpool};
-    if ($pool && ($fh->{local} = $self->inspector->localmod($basepath, $checksum || '', $pool))) {
+    if ($pool && ($fh->{local} = $inspector->localmod($basepath, $checksum || '', $pool))) {
 	# retrieve base
 	unless ($info->{addmerge}) {
 	    $fh->{base} = [$self->_retrieve_base($path, $pool)];
@@ -541,7 +554,7 @@
     my $fh = $info->{fh};
     my $iod;
 
-    my ($basepath, $fromrev) = $info->{baseinfo} ? @{$info->{baseinfo}} : ($path);
+    my ($basepath, $fromrev, $inspector) = $info->{baseinfo} ? @{$info->{baseinfo}} : ($path, undef, $self->inspector);
     no warnings 'uninitialized';
     my $storagebase_checksum = $fh->{local}[CHECKSUM];
     if ($fromrev) {
@@ -555,7 +568,7 @@
 	$self->_merge_file_unchanged ($path, $checksum, $pool), return
 	    if $checksum eq $storagebase_checksum;
 
-	my $eol = $self->inspector->localprop($basepath, 'svn:eol-style', $pool);
+	my $eol = $inspector->localprop($basepath, 'svn:eol-style', $pool);
 	my $eol_layer = SVK::XD::get_eol_layer({'svn:eol-style' => $eol}, '>');
 	$eol_layer = '' if $eol_layer eq ':raw';
 	$self->prepare_fh ($fh, $eol_layer);
@@ -589,7 +602,7 @@
 	    if ($basepath ne $path) {
 		$checksum = $self->{base_root}->fs->revision_root($fromrev, $pool)->file_md5_checksum($basepath, $pool);
 	    }
-	    elsif (my $local = $self->inspector->localmod($basepath, $checksum, $pool)) {
+	    elsif (my $local = $inspector->localmod($basepath, $checksum, $pool)) {
 		$checksum = $local->[CHECKSUM];
 		close $local->[FH];
 	    }
@@ -668,10 +681,9 @@
     unless ($self->{open_nonexist}) {
 	return undef unless defined $pdir;
 
-	my ($basepath, $fromrev) = $self->_resolve_base($path);
-	$basepath = $path unless defined $basepath;
+	my ($basepath, $fromrev, $inspector) = $self->resolve_base($path);
 
-	unless ($self->inspector->exist($basepath, $pool) || $self->{open_nonexist}) {
+	unless ($inspector->exist($basepath, $pool) || $self->{open_nonexist}) {
 	    ++$self->{skipped};
 	    $self->{notify}->flush ($path);
 	    return undef;
@@ -708,22 +720,21 @@
 sub _merge_file_delete {
     my ($self, $path, $rpath, $pdir, $pool) = @_;
 
-    my ($basepath, $fromrev) = $self->_resolve_base($path);
-    $basepath = $path unless defined $basepath;
+    my ($basepath, $fromrev, $inspector) = $self->resolve_base($path);
     
     my $no_base;
     my $md5 = $self->{base_root}->check_path ($rpath, $pool)?
         $self->{base_root}->file_md5_checksum ($rpath, $pool)
         : do { $no_base = 1; require Digest::MD5; Digest::MD5::md5_hex('') };
 
-    return undef unless $self->inspector->localmod ($basepath, $md5, $pool);
+    return undef unless $inspector->localmod ($basepath, $md5, $pool);
     return {} unless $self->{resolve};
 
     my $fh = $self->{info}{$path}->{fh} || {};
     $fh->{base} ||= [$no_base? (tmpfile('base-')): ($self->_retrieve_base($path, $pool))];
     $fh->{new} = [tmpfile('new-')];
     $fh->{local} = [tmpfile('local-')];
-    my ($tmp) = $self->inspector->localmod($basepath, '', $pool);
+    my ($tmp) = $inspector->localmod($basepath, '', $pool);
     slurp_fh ( $tmp->[FH], $fh->{local}[FH]);
     seek $fh->{local}[FH], 0, 0;
     $fh->{local}[CHECKSUM] = $tmp->[CHECKSUM];
@@ -888,10 +899,9 @@
     my ($self, $path, $revision, $pdir, $pool) = @_;
     no warnings 'uninitialized';
     $pool = SVN::Pool->new_default($pool);
-    my ($basepath, $fromrev) = $self->_resolve_base($path);
-    $basepath = $path unless defined $basepath;
+    my ($basepath, $fromrev, $inspector) = $self->resolve_base($path);
 
-    return unless defined $pdir && $self->inspector->exist($basepath);
+    return unless defined $pdir && $inspector->exist($basepath);
     my $rpath = $basepath =~ m{^/} ? $basepath :
 	$self->{base_anchor} eq '/' ? "/$basepath" : "$self->{base_anchor}/$basepath";
     my $torm;

Modified: branches/smcp-base-bug/t/07smerge-copy.t
==============================================================================
--- branches/smcp-base-bug/t/07smerge-copy.t	(original)
+++ branches/smcp-base-bug/t/07smerge-copy.t	Sat Dec 15 04:12:21 2007
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-use Test::More tests => 25;
+use Test::More tests => 26;
 use strict;
 use File::Path;
 use Cwd;
@@ -215,6 +215,11 @@
 	   qr'New merge ticket: .*:/local-many:40',
 	   qr'New merge ticket: .*:/trunk:3',
 	   'Committed revision 41.']);
+is_output($svk, 'cat', ['//trunk-3/B/de'],
+	  ['modify on D/de',
+	   'modify on B/de',
+	   'file de added later',
+	   'modify this on trunk']);
 
 is_output($svk, 'diff', ['-sr40:41', '//'],
 	  ['M + trunk-3/B/de',

Modified: branches/smcp-base-bug/t/07smerge-cpreplace.t
==============================================================================
--- branches/smcp-base-bug/t/07smerge-cpreplace.t	(original)
+++ branches/smcp-base-bug/t/07smerge-cpreplace.t	Sat Dec 15 04:12:21 2007
@@ -17,28 +17,24 @@
 
 # r2 - remove file B
 
-$svk->rm(-m => 'r5 - remove file A/me', "//V/A/me");
+#$svk->rm(-m => 'r5 - remove file A/me', "//V/A/me");
 
 $svk->checkout('//V',$copath);
 # r3 - cp B at 1 to C with modification,
 $svk->cp('//V/A/me' => "$copath/Cme", -r => 4 );
 
-append_file("$copath/Cme", "mmmmmm\n");
+append_file("$copath/Cme", "mmmmmmxx\n");
 $svk->ci(-m => 'r8 - modify Cme', $copath);
-# cp A at 2 to B
-$svk->cp('//V/A/D/de' => "$copath/A/me", -r => 5);
+# cp A at 2 to B, if we comment these two out, 
+#$svk->cp('//V/A/D/de' => "$copath/A/me", -r => 5);
 append_file("$copath/A/me", "mmmmmm\n");
-
 $svk->ci(-m => 'some copy with mods', $copath);
 
-TODO: {
-    local $TODO = 'not yet';
 is_output($svk, 'smerge', [-m => 'go', '//V', '//X'],
-	  ['Auto-merging (3, 7) /V to /X (base /V:3).',
-	   'R + A/me',
-	   'R + Cme',
-	   qr'New merge ticket: .*:/V:7',
-	   'Committed revision 8']);
-}
+	  ['Auto-merging (3, 6) /V to /X (base /V:3).',
+	   'U   A/me',
+	   'A + Cme',
+	   qr'New merge ticket: .*:/V:6',
+	   'Committed revision 7.']);
 
 1;


More information about the svk-commit mailing list