[svk-commit] r2104 - trunk/lib/SVK

clkao at bestpractical.com clkao at bestpractical.com
Fri Nov 3 14:45:31 EST 2006


Author: clkao
Date: Fri Nov  3 14:45:30 2006
New Revision: 2104

Modified:
   trunk/lib/SVK/Root.pm
   trunk/lib/SVK/XD.pm

Log:
Fix a bug that svk diff doesn't use the signature cache to check if files
are modified, spotted by DannyB++.


Modified: trunk/lib/SVK/Root.pm
==============================================================================
--- trunk/lib/SVK/Root.pm	(original)
+++ trunk/lib/SVK/Root.pm	Fri Nov  3 14:45:30 2006
@@ -49,4 +49,14 @@
     return $self->new({ txn => $txn, root => $txn->root($pool) });
 }
 
+sub same_root {
+    my ($self, $other) = @_;
+    return 1 if $self eq $other;
+    return unless ref($self) eq __PACKAGE__ && ref($other) eq __PACKAGE__;
+    if ($self->txn) {
+	return $other->txn ? $self->txn->name eq $other->txn->name : 0;
+    }
+    return $self->revision_root_revision == $other->revision_root_revision;
+}
+
 1;

Modified: trunk/lib/SVK/XD.pm
==============================================================================
--- trunk/lib/SVK/XD.pm	(original)
+++ trunk/lib/SVK/XD.pm	Fri Nov  3 14:45:30 2006
@@ -1117,7 +1117,7 @@
     }
     else {
 	# deleted during base_root -> xdroot
-	if ($arg{xdroot} ne $arg{base_root} && $arg{kind} == $SVN::Node::none) {
+	if (!$arg{base_root_is_xd} && $arg{kind} == $SVN::Node::none) {
 	    $self->_node_deleted (%arg);
 	    return 1;
 	}
@@ -1170,7 +1170,7 @@
     if (!$arg{base} or $arg{in_copy}) {
 	$newprops = $fullprop;
     }
-    elsif ($arg{base_root} ne $arg{xdroot} && $arg{base}) {
+    elsif (!$arg{base_root_is_xd} && $arg{base}) {
 	$newprops = _prop_delta ($arg{base_root}->node_proplist ($arg{base_path}), $fullprop)
 	    if $arg{kind} && $arg{base_kind} && _prop_changed (@arg{qw/base_root base_path xdroot path/});
     }
@@ -1264,7 +1264,6 @@
 
 sub _delta_dir {
     my ($self, %arg) = @_;
-    # warn "===> $arg{entry} ".join(',',(caller)[0..2]) if $ENV{SVKDEBUG};
     if ($arg{entry} && $arg{exclude} && exists $arg{exclude}{$arg{entry}}) {
 	$arg{cb_exclude}->($arg{path}, $arg{copath}) if $arg{cb_exclude};
 	return;
@@ -1329,7 +1328,7 @@
     if ($descend) {
 
     my $signature;
-    if ($self->{signature} && $arg{xdroot} eq $arg{base_root}) {
+    if ($self->{signature} && $arg{base_root_is_xd}) {
 	$signature = $self->{signature}->load ($arg{copath});
 	# if we are not iterating over all entries, keep the old signatures
 	$signature->{keepold} = 1 if defined $targets
@@ -1380,7 +1379,7 @@
 			base => !$obs,
 			depth => defined $arg{depth} ? defined $targets ? $arg{depth} : $arg{depth} - 1: undef,
 			entry => $newentry,
-			kind => $arg{xdroot} eq $arg{base_root} ? $kind : $arg{xdroot}->check_path ($newpath),
+			kind => $arg{base_root_is_xd} ? $kind : $arg{xdroot}->check_path ($newpath),
 			base_kind => $kind,
 			targets => $newtarget,
 			baton => $baton,
@@ -1434,7 +1433,7 @@
 			 path => $arg{path} eq '/' ? "/$entry" : "$arg{path}/$entry",
 			 base_path => $arg{base_path} eq '/' ? "/$entry" : "$arg{base_path}/$entry",
 			 targets => $newtarget, base_kind => $SVN::Node::none);
-	$newpaths{kind} = $arg{xdroot} eq $arg{base_root} ? $SVN::Node::none :
+	$newpaths{kind} = $arg{base_root_is_xd} ? $SVN::Node::none :
 	    $arg{xdroot}->check_path ($newpaths{path}) != $SVN::Node::none;
 	my ($ccinfo, $sche) = $self->get_entry($newpaths{copath});
 	my $add = $sche || $arg{auto_add} || $newpaths{kind};
@@ -1462,7 +1461,7 @@
 	my ($type, $st) = _node_type ($newpaths{copath}) or next;
 	my $delta = $type eq 'directory' ? \&_delta_dir : \&_delta_file;
 	my $copyfrom = $ccinfo->{'.copyfrom'};
-	my $fromroot = $copyfrom ? $arg{repos}->fs->revision_root ($ccinfo->{'.copyfrom_rev'}) : undef;
+	my ($fromroot) = $copyfrom ? $arg{xdroot}->get_revision_root($newpaths{path}, $ccinfo->{'.copyfrom_rev'}) : undef;
 	$self->$delta ( %arg, %newpaths, add => 1, baton => $baton,
 			root => 0, base => 0, cinfo => $ccinfo,
 			type => $type,
@@ -1473,6 +1472,7 @@
 			  _really_in_copy => 1,
 			  in_copy => $arg{expand_copy},
 			  base_kind => $fromroot->check_path ($copyfrom),
+			  base_root_is_xd => 0,
 			  base_root => $fromroot,
 			  base_path => $copyfrom) : (),
 		      );
@@ -1504,7 +1504,8 @@
     $arg{encoder} = get_encoder;
     Carp::cluck unless defined $arg{base_path};
     my $kind = $arg{base_kind} = $arg{base_root}->check_path ($arg{base_path});
-    $arg{kind} = $arg{base_root} eq $arg{xdroot} ? $kind : $arg{xdroot}->check_path ($arg{path});
+    $arg{base_root_is_xd} = $arg{base_root}->same_root($arg{xdroot});
+    $arg{kind} = $arg{base_root_is_xd} ? $kind : $arg{xdroot}->check_path ($arg{path});
     die "checkout_delta called with non-dir node"
 	   unless $kind == $SVN::Node::dir;
     my ($copath, $repospath) = @arg{qw/copath repospath/};


More information about the svk-commit mailing list