[svk-commit] r3151 - in trunk: lib/SVK lib/SVK/Command t

nobody at bestpractical.com nobody at bestpractical.com
Sun May 17 12:40:43 EDT 2009


Author: clkao
Date: Sun May 17 12:40:41 2009
New Revision: 3151

Modified:
   trunk/   (props changed)
   trunk/lib/SVK/Command/Revert.pm
   trunk/lib/SVK/XD.pm
   trunk/t/07smerge-co-deleted.t
   trunk/t/18replaced.t

Log:
Make tests pass with svn 1.6's stricter transaction restriction on node
deletion.

 r13749 at mtl-2:  clkao | 2009-05-17 23:00:38 +0800
 - Create branch replace-fixes
 r13750 at mtl-2:  clkao | 2009-05-17 23:26:18 +0800
 refactor xd representation for deleted nodes.
 
 r13751 at mtl-2:  clkao | 2009-05-18 00:04:35 +0800
 correct the test which tries to delete an non-existing path.
 r13752 at mtl-2:  clkao | 2009-05-18 00:28:46 +0800
 two-stage revert for replaced nodes.

 r13749 at mtl-2:  clkao | 2009-05-17 23:00:38 +0800
 - Create branch replace-fixes
 r13750 at mtl-2:  clkao | 2009-05-17 23:26:18 +0800
 refactor xd representation for deleted nodes.
 
 r13751 at mtl-2:  clkao | 2009-05-18 00:04:35 +0800
 correct the test which tries to delete an non-existing path.
 r13752 at mtl-2:  clkao | 2009-05-18 00:28:46 +0800
 two-stage revert for replaced nodes.


Modified: trunk/lib/SVK/Command/Revert.pm
==============================================================================
--- trunk/lib/SVK/Command/Revert.pm	(original)
+++ trunk/lib/SVK/Command/Revert.pm	Sun May 17 12:40:41 2009
@@ -79,6 +79,7 @@
     my ($self, $target) = @_;
     my $xdroot = $target->create_xd_root;
 
+    my @replaced;
 	$self->{xd}->checkout_delta
 	    ( $target->for_checkout_delta,
 	      xdroot => $xdroot,
@@ -92,11 +93,11 @@
 	      ( notify => SVK::Notify->new
 		( cb_flush => sub {
 		      my ($path, $status) = @_;
+		      my $st = $status->[0];
+                      push @replaced, $path if $st eq 'R';
 		      my $dpath = length $path ? $target->path_anchor."/$path" : $target->path_anchor;
 	              to_native($path);
-		      my $st = $status->[0];
 		      my $copath = $target->copath ($path);
-
                       if ($st =~ /[DMRC!]/) {
 			  # conflicted items do not necessarily exist
 			  return $self->do_unschedule ($target, $copath)
@@ -117,6 +118,11 @@
 		),
 	      ));
 
+    if (@replaced) {
+        $target->source->targets(\@replaced);
+        $self->run($target);
+    }
+
     return;
 }
 

Modified: trunk/lib/SVK/XD.pm
==============================================================================
--- trunk/lib/SVK/XD.pm	(original)
+++ trunk/lib/SVK/XD.pm	Sun May 17 12:40:41 2009
@@ -729,6 +729,9 @@
 
     $target->anchorify unless $target->source->{targets};
 
+    my @paths = grep {is_symlink($_) || -e $_} $target->copath_targets;
+    my @to_schedule = @paths;
+
     # check for if the file/dir is modified.
     $self->checkout_delta ( $target->for_checkout_delta,
 			    %arg,
@@ -748,6 +751,8 @@
 				    	push @modified, $copath;
 				    }
 				    elsif ($st eq 'D') {
+                                        push @to_schedule, $copath
+                                            unless -e $copath;
 					push @deleted, $copath;
 				    }
 				    else {
@@ -771,8 +776,6 @@
     }
 
     # actually remove it from checkout path
-    my @paths = grep {is_symlink($_) || -e $_} $target->copath_targets;
-    
     my $ignore = $self->ignore;
     find(sub {
 	     return if m/$ignore/;
@@ -789,8 +792,9 @@
     for (@deleted) {
 	print "D   ".$target->report_copath($_)."\n"
 	    unless $arg{quiet};
-	
+    }	
 	# don't schedule unknown/added files for deletion as this confuses revert.    
+    for (@to_schedule) {
 	$self->{checkout}->store ($_, {'.schedule' => 'delete'})
 	    unless $noschedule{$_};
     }
@@ -817,7 +821,6 @@
         $target->for_checkout_delta,
         %arg,
         xdroot => $target->create_xd_root,
-        delete_verbose => 1,
         editor => SVK::Editor::Status->new(
             notify => SVK::Notify->new(
                 cb_flush => sub {
@@ -1176,15 +1179,23 @@
     my ($self, %arg) = @_;
     $arg{rev} = $self->_delta_rev(\%arg);
     $arg{editor}->delete_entry (@arg{qw/entry rev baton pool/});
-
     if ($arg{kind} == $SVN::Node::dir && $arg{delete_verbose}) {
-	foreach my $file (sort $self->{checkout}->find
-			  ($arg{copath}, {'.schedule' => 'delete'})) {
-	    next if $file eq $arg{copath};
-	    $file = abs2rel($file, $arg{copath} => undef, '/');
-	    from_native($file, 'path', $arg{encoder});
-	    $arg{editor}->delete_entry ("$arg{entry}/$file", @arg{qw/rev baton pool/});
-	}
+        my @paths;
+        $self->depot_delta( oldroot => $arg{base_root}->fs->revision_root(0),
+                            newroot => $arg{base_root},
+                            oldpath => ['/', ''],
+                            newpath => $arg{path},
+                            no_textdela => 1,
+			    editor => SVK::Editor::Status->new
+			    ( notify => SVK::Notify->new
+			      ( cb_flush => sub {
+				    my ($path, $status) = @_;
+                                    push @paths, $path
+                                        if $status->[0] eq 'A';
+                                }))
+                        );
+        $arg{editor}->delete_entry("$arg{entry}/$_", @arg{qw/rev baton pool/})
+            for sort @paths;
     }
 }
 
@@ -1452,7 +1463,8 @@
 	my ($ccinfo, $ccschedule) = $self->get_entry($copath, 1);
 	# a replace with history node requires handling the copy anchor in the
 	# latter direntries loop.  we should really merge the two.
-	if ($ccschedule eq 'replace' && $ccinfo->{'.copyfrom'}) {
+        if ($ccschedule eq 'replace') {# && $ccinfo->{'.copyfrom'}) {
+#	if ($ccschedule eq 'replace' && $ccinfo->{'.copyfrom'}) {
 	    delete $entries->{$entry};
 	    $targets->{$entry} = $newtarget if defined $targets;
 	    next;

Modified: trunk/t/07smerge-co-deleted.t
==============================================================================
--- trunk/t/07smerge-co-deleted.t	(original)
+++ trunk/t/07smerge-co-deleted.t	Sun May 17 12:40:41 2009
@@ -13,7 +13,7 @@
 $svk->mkdir ('-m', 'trunk', '//trunk');
 my $tree = create_basic_tree ($xd, '//trunk');
 $svk->cp ('-m', 'branch', '//trunk', '//local');
-$svk->rm ('-m', 'remove branch', '//local', '//local-moved');
+$svk->rm ('-m', 'remove branch', '//local');
 $svk->co ('//trunk', $copath);
 append_file("$copath/me", "a change\n");
 $svk->ci ('-m', 'change file', $copath );

Modified: trunk/t/18replaced.t
==============================================================================
--- trunk/t/18replaced.t	(original)
+++ trunk/t/18replaced.t	Sun May 17 12:40:41 2009
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-use Test::More tests => 28;
+use Test::More tests => 31;
 use strict;
 our $output;
 use SVK::Test;
@@ -21,28 +21,49 @@
 overwrite_file ("$copath/A/be", "foobar\n2nd replace\n");
 overwrite_file ("$copath/A/neu", "foobar\n2nd replace\n");
 # XXX: notify flush and cb_unknown ordering
-# XXX: A/be shouldn't be replace, it's actually an add. but this
-# requires more .scheudle fix with anchor.
 is_output ($svk, 'add', ["$copath/A"],
-	   [__"A   $copath/A/neu",
-	    __"R   $copath/A",
-	    __"R   $copath/A/be"]);
+	   [
+	    __"A   $copath/A/be",
+            __"A   $copath/A/neu",
+            __"R   $copath/A",
+        ]);
+
+is_output ($svk, 'status', ["$copath/A"],
+	   [__"R   $copath/A",
+	    __"A   $copath/A/be",
+            __"A   $copath/A/neu",
+        ]);
+
 overwrite_file ("$copath/A/unused", "foobar\n2nd replace\n");
 is_output ($svk, 'status', ["$copath"],
 	   [__"R   $copath/A",
-	    __"R   $copath/A/be",
+	    __"A   $copath/A/be",
 	    __"A   $copath/A/neu",
 	    __"?   $copath/A/unused",
-	    __"D   $copath/A/Q",
-	    __"D   $copath/A/Q/qu",
-	    __"D   $copath/A/Q/qz"]);
+        ]);
 
 is_output ($svk, 'add', ['-N', "$copath/A"],
 	   [__("$copath/A already added.")]);
-$svk->revert ('-R', $copath);
+
+is_output($svk, 'revert', ['-R', $copath],
+          ['Reverted '.__('t/checkout/replaced/A'),
+           'Reverted '.__('t/checkout/replaced/A/be'),
+           'Reverted '.__('t/checkout/replaced/A/neu'),
+           __('t/checkout/replaced/A/unused').' is not versioned; ignored.',
+           'Reverted '.__('t/checkout/replaced/A/Q'),
+           'Reverted '.__('t/checkout/replaced/A/Q/qu'),
+           'Reverted '.__('t/checkout/replaced/A/Q/qz'),
+           'Reverted '.__('t/checkout/replaced/A/be'),
+           __('t/checkout/replaced/A/neu').' is not versioned; ignored.',
+           __('t/checkout/replaced/A/unused').' is not versioned; ignored.',
+       ]);
+
+
 is_output ($svk, 'status', [$copath],
 	   [__"?   $copath/A/neu",
 	    __"?   $copath/A/unused"], 'revert replaced tree items');
+ok(-d "$copath/A/Q");
+
 unlink ("$copath/A/neu");
 unlink ("$copath/A/unused");
 $svk->rm ("$copath/A");
@@ -50,8 +71,10 @@
 overwrite_file ("$copath/A/be", "foobar\n2nd replace\n");
 overwrite_file ("$copath/A/neu", "foobar\n2nd replace\n");
 $svk->add ("$copath/A");
+
 is_output ($svk, 'commit', ['-m', 'replace A/be', $copath],
 	   ['Committed revision 5.']);
+
 $svk->rm ("$copath/A");
 $svk->status ($copath);
 overwrite_file ("$copath/A", "dir replaced as file\n");
@@ -60,9 +83,8 @@
 	   [__"R   $copath/A"]);
 
 is_output ($svk, 'status', [$copath],
-	   [__"R   $copath/A",
-	    __"D   $copath/A/be",
-	    __"D   $copath/A/neu"], 'file replacing dir');
+	   [__"R   $copath/A"],
+           'file replacing dir');
 $svk->commit ('-m', 'commit the replace', $copath);
 
 mkdir ("$copath/T1");
@@ -127,10 +149,7 @@
 	  ['R   A']);
 
 is_output($svk, 'st', [],
-	  ['R   A',
-	   __('D   A/be'),
-	   __('D   A/neu'),
-	  ]);
+	  ['R   A' ]);
 ok(-f 'A');
 is_output($svk, 'ci', [-m => 'message'],
 	  ['Committed revision 13.']);


More information about the svk-commit mailing list