[svk-commit] r2348 - trunk/lib/SVK/Path

nobody at bestpractical.com nobody at bestpractical.com
Thu Mar 15 21:01:41 EDT 2007


Author: clkao
Date: Thu Mar 15 21:01:41 2007
New Revision: 2348

Modified:
   trunk/lib/SVK/Path/Checkout.pm

Log:
Make svk checkout more robust about continuing an incomplete checkout.

Modified: trunk/lib/SVK/Path/Checkout.pm
==============================================================================
--- trunk/lib/SVK/Path/Checkout.pm	(original)
+++ trunk/lib/SVK/Path/Checkout.pm	Thu Mar 15 21:01:41 2007
@@ -99,6 +99,18 @@
     return $root;
 }
 
+sub _mkpath {
+    my ($root, $path) = @_;
+    my @path = ();
+    for my $dir (File::Spec::Unix->splitdir($path)) {
+	push @path, $dir;
+	next unless length $dir;
+	my $cur = File::Spec::Unix->catdir(@path);
+	$root->make_dir($cur)
+	    unless $root->check_path($cur);
+    }
+}
+
 sub create_xd_root {
     my $self = shift;
     my $copath = $self->copath($self->copath_target);
@@ -125,19 +137,20 @@
 	my $path = abs2rel($_, $coroot => $coroot_path, '/');
 	unless ($root) {
 	    $root = $base_root->txn_root($self->pool);;
-	    $base_rev = $base_root->node_created_rev($path, $pool);
-	    if ($base_rev == 0) {
+	    if ($base_root->revision_root_revision == 0) {
 		# for interrupted checkout, the anchor will be at rev 0
-		my @path = ();
-		for my $dir (File::Spec::Unix->splitdir($path)) {
-		    push @path, $dir;
-		    next unless length $dir;
-		    $root->make_dir(File::Spec::Unix->catdir(@path));
-		}
+		_mkpath($root, $path);
+		$base_rev = 0;
+	    }
+	    else {
+		$base_rev = $base_root->node_created_rev($path, $pool);
 	    }
 	    next;
 	}
 	my $parent = Path::Class::File->new_foreign('Unix', $path)->parent;
+	if ($base_rev ==0 && !$root->check_path("$parent", $pool)) {
+	    _mkpath($root, "$parent");
+	}
 	next if $cinfo->{revision} == $root->node_created_rev("$parent", $pool);
 	my ($fromroot, $frompath) = $base_root->get_revision_root($path, $cinfo->{revision}, $pool);
 	$root->delete($path, $pool)


More information about the svk-commit mailing list