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

clkao at bestpractical.com clkao at bestpractical.com
Mon Nov 6 23:45:57 EST 2006


Author: clkao
Date: Mon Nov  6 23:45:57 2006
New Revision: 2121

Modified:
   trunk/Makefile.PL
   trunk/lib/SVK/Command/Checkout.pm
   trunk/lib/SVK/Command/Pull.pm
   trunk/lib/SVK/XD.pm

Log:
Revert r2110 for the incompatible changes regarding data::hierarchy.
This will be moved to a branch until trunk and 1.0 are both happy with
the compatibility.


Modified: trunk/Makefile.PL
==============================================================================
--- trunk/Makefile.PL	(original)
+++ trunk/Makefile.PL	Mon Nov  6 23:45:57 2006
@@ -17,7 +17,7 @@
     'Algorithm::Annotate'      => '0',
     'Algorithm::Diff'          => '1.1901',
     'YAML::Syck'               => '0.60',
-    'Data::Hierarchy'          => '0.40',
+    'Data::Hierarchy'          => '0.30',
     'PerlIO::via::dynamic'     => '0.11',
     'PerlIO::via::symlink'     => '0.02',
     'IO::Digest'               => '0',

Modified: trunk/lib/SVK/Command/Checkout.pm
==============================================================================
--- trunk/lib/SVK/Command/Checkout.pm	(original)
+++ trunk/lib/SVK/Command/Checkout.pm	Mon Nov  6 23:45:57 2006
@@ -135,15 +135,16 @@
 sub _find_copath {
     my ($self, $path) = @_;
     my $abs_path = abs_path_noexist($path);
-    my $hierarchy = $self->{xd}{checkout};
+    my $map = $self->{xd}{checkout}{hash};
 
     # Check if this is a checkout path
-    return $abs_path if defined $abs_path
-      and $hierarchy->defines($abs_path, 'depotpath');
+    return $abs_path if defined $abs_path and $map->{$abs_path};
 
     # Find all copaths that matches this depotpath
-    return sort $hierarchy->find('/',
-                                 { depotpath => qr/^\Q$path\E$/ });
+    return sort grep {
+        defined $map->{$_}{depotpath}
+            and $map->{$_}{depotpath} eq $path
+    } keys %$map;
 }
 
 sub _not_if_floating {
@@ -164,12 +165,11 @@
 
 sub run {
     my ($self) = @_;
-    my $hierarchy = $self->{xd}{checkout};
-    my @checkouts = $hierarchy->find('/', { depotpath => qr/.*/ });
+    my $map = $self->{xd}{checkout}{hash};
     my $fmt = "%1s %-30s\t%-s\n";
     printf $fmt, ' ', loc('Depot Path'), loc('Path');
     print '=' x 72, "\n";
-    print sort(map sprintf($fmt, -e $_ ? ' ' : '?', $hierarchy->get($_)->{depotpath}, $_), @checkouts);
+    print sort(map sprintf($fmt, -e $_ ? ' ' : '?', $map->{$_}{depotpath}, $_), grep $map->{$_}{depotpath}, keys %$map);
     return;
 }
 
@@ -205,15 +205,19 @@
     }
 
     # Manually relocate all paths
-    my $hierarchy = $self->{xd}{checkout};
+    my $map = $self->{xd}{checkout}{hash};
 
     my $abs_path = abs_path($path);
-    if ($hierarchy->defines($abs_path, 'depotpath') and -d $abs_path) {
+    if ($map->{$abs_path} and -d $abs_path) {
         move_path($path => $report);
         $target = abs_path ($report);
     }
 
-    $hierarchy->move($copath[0] => $target);
+    my $prefix = $copath[0].$SEP;
+    my $length = length($copath[0]);
+    foreach my $key (sort grep { index("$_$SEP", $prefix) == 0 } keys %$map) {
+        $map->{$target . substr($key, $length)} = delete $map->{$key};
+    }
 
     print loc("Checkout '%1' relocated to '%2'.\n", $path, $target);
 
@@ -265,17 +269,16 @@
 
 sub run {
     my ($self) = @_;
+    my $map = $self->{xd}{checkout}{hash};
 
     $self->_not_if_floating('--purge');
 
-    my $hierarchy = $self->{xd}{checkout};
-    my @checkouts = $hierarchy->find('/', { depotpath => qr/.*/ });
     $self->rebless('checkout::detach');
 
-    for my $path (@checkouts) {
+    for my $path (sort grep $map->{$_}{depotpath}, keys %$map) {
 	next if -e $path;
 
-	my $depotpath = $hierarchy->get($path)->{depotpath};
+	my $depotpath = $map->{$path}{depotpath};
 
 	get_prompt(loc(
 	    "Purge checkout of %1 to non-existing directory %2? (y/n) ",

Modified: trunk/lib/SVK/Command/Pull.pm
==============================================================================
--- trunk/lib/SVK/Command/Pull.pm	(original)
+++ trunk/lib/SVK/Command/Pull.pm	Mon Nov  6 23:45:57 2006
@@ -23,7 +23,8 @@
     $self->{incremental} = !$self->{lump};
 
     if ($self->{all}) {
-        @arg = $self->{xd}{checkout}->find('/', { depotpath => qr/.*/ });
+        my $checkout = $self->{xd}{checkout}{hash};
+        @arg = sort grep $checkout->{$_}{depotpath}, keys %$checkout;
     } 
     elsif ( @arg == 1 and !$self->arg_co_maybe($arg[0])->isa('SVK::Path::Checkout')) {
         # If the last argument is a depot path, rather than a copath

Modified: trunk/lib/SVK/XD.pm
==============================================================================
--- trunk/lib/SVK/XD.pm	(original)
+++ trunk/lib/SVK/XD.pm	Mon Nov  6 23:45:57 2006
@@ -162,7 +162,8 @@
 	}
         elsif ($info) {
             $info->{checkout}{sep} = $SEP;
-            $self->_loadify_checkout($info);
+            $info->{checkout} = $info->{checkout}->to_absolute($self->{floating})
+                if $self->{floating};
         }
     }
 
@@ -225,8 +226,8 @@
     my $ancient_backup = $file.".bak.".$$;
 
     my $tmphash = { map { $_ => $hash->{$_}} qw/checkout depotmap/ };
-    $self->_savify_checkout($tmphash);
-
+    $tmphash->{checkout} = $tmphash->{checkout}->to_relative($self->{floating})
+        if $self->{floating};
     DumpFile ($tmpfile, $tmphash);
 
     if (not -f $tmpfile ) {
@@ -251,30 +252,6 @@
     }
 }
 
-sub _savify_checkout {
-    my ($self, $hash) = @_;
-    if ($self->{floating}) {
-        $hash->{checkout} = $hash->{checkout}->to_relative($self->{floating});
-    } else {
-        $hash->{checkout} = $hash->{checkout}->save;
-    }
-}
-
-sub _loadify_checkout {
-    my ($self, $hash) = @_;
-    if ($self->{floating}) {
-        $hash->{checkout} = $hash->{checkout}->to_absolute($self->{floating});
-    } else {
-        # This should be a Data::Hierarchy::Savable, but in case
-        # somebody was using an older svk with DH 0.3 and upgraded
-        # both svk and DH and still has a serialized Data::Hierarchy
-        # in their config file, don't call ->load unless the method is
-        # there (and let DH _autoupgrade do its trick).
-        $hash->{checkout} = $hash->{checkout}->load
-          if $hash->{checkout}->can('load');
-    }
-}
-
 sub store {
     my ($self) = @_;
     $self->{updated} = 1;
@@ -291,7 +268,8 @@
         # the changes from the paths we locked, and write it out.
 	$self->giant_lock ();
 	my $info = LoadFile ($self->{statefile});
-        $self->_loadify_checkout($info);
+	$info->{checkout} = $info->{checkout}->to_absolute($self->{floating})
+	    if $self->{floating};
 	my @paths = $info->{checkout}->find ('', {lock => $$});
 	$info->{checkout}->merge ($self->{checkout}, $_)
 	    for @paths;


More information about the svk-commit mailing list