[svk-commit] r2123 - in branches/dh-refactor: . lib/SVK/Command
clkao at bestpractical.com
clkao at bestpractical.com
Mon Nov 6 23:47:26 EST 2006
Author: clkao
Date: Mon Nov 6 23:47:26 2006
New Revision: 2123
Modified:
branches/dh-refactor/Makefile.PL
branches/dh-refactor/lib/SVK/Command/Checkout.pm
branches/dh-refactor/lib/SVK/Command/Pull.pm
branches/dh-refactor/lib/SVK/XD.pm
Log:
Apply r2110 from trunk.
Modified: branches/dh-refactor/Makefile.PL
==============================================================================
--- branches/dh-refactor/Makefile.PL (original)
+++ branches/dh-refactor/Makefile.PL Mon Nov 6 23:47:26 2006
@@ -17,7 +17,7 @@
'Algorithm::Annotate' => '0',
'Algorithm::Diff' => '1.1901',
'YAML::Syck' => '0.60',
- 'Data::Hierarchy' => '0.30',
+ 'Data::Hierarchy' => '0.40',
'PerlIO::via::dynamic' => '0.11',
'PerlIO::via::symlink' => '0.02',
'IO::Digest' => '0',
Modified: branches/dh-refactor/lib/SVK/Command/Checkout.pm
==============================================================================
--- branches/dh-refactor/lib/SVK/Command/Checkout.pm (original)
+++ branches/dh-refactor/lib/SVK/Command/Checkout.pm Mon Nov 6 23:47:26 2006
@@ -135,16 +135,15 @@
sub _find_copath {
my ($self, $path) = @_;
my $abs_path = abs_path_noexist($path);
- my $map = $self->{xd}{checkout}{hash};
+ my $hierarchy = $self->{xd}{checkout};
# Check if this is a checkout path
- return $abs_path if defined $abs_path and $map->{$abs_path};
+ return $abs_path if defined $abs_path
+ and $hierarchy->defines($abs_path, 'depotpath');
# Find all copaths that matches this depotpath
- return sort grep {
- defined $map->{$_}{depotpath}
- and $map->{$_}{depotpath} eq $path
- } keys %$map;
+ return sort $hierarchy->find('/',
+ { depotpath => qr/^\Q$path\E$/ });
}
sub _not_if_floating {
@@ -165,11 +164,12 @@
sub run {
my ($self) = @_;
- my $map = $self->{xd}{checkout}{hash};
+ my $hierarchy = $self->{xd}{checkout};
+ my @checkouts = $hierarchy->find('/', { depotpath => qr/.*/ });
my $fmt = "%1s %-30s\t%-s\n";
printf $fmt, ' ', loc('Depot Path'), loc('Path');
print '=' x 72, "\n";
- print sort(map sprintf($fmt, -e $_ ? ' ' : '?', $map->{$_}{depotpath}, $_), grep $map->{$_}{depotpath}, keys %$map);
+ print sort(map sprintf($fmt, -e $_ ? ' ' : '?', $hierarchy->get($_)->{depotpath}, $_), @checkouts);
return;
}
@@ -205,19 +205,15 @@
}
# Manually relocate all paths
- my $map = $self->{xd}{checkout}{hash};
+ my $hierarchy = $self->{xd}{checkout};
my $abs_path = abs_path($path);
- if ($map->{$abs_path} and -d $abs_path) {
+ if ($hierarchy->defines($abs_path, 'depotpath') and -d $abs_path) {
move_path($path => $report);
$target = abs_path ($report);
}
- 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};
- }
+ $hierarchy->move($copath[0] => $target);
print loc("Checkout '%1' relocated to '%2'.\n", $path, $target);
@@ -269,16 +265,17 @@
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 (sort grep $map->{$_}{depotpath}, keys %$map) {
+ for my $path (@checkouts) {
next if -e $path;
- my $depotpath = $map->{$path}{depotpath};
+ my $depotpath = $hierarchy->get($path)->{depotpath};
get_prompt(loc(
"Purge checkout of %1 to non-existing directory %2? (y/n) ",
Modified: branches/dh-refactor/lib/SVK/Command/Pull.pm
==============================================================================
--- branches/dh-refactor/lib/SVK/Command/Pull.pm (original)
+++ branches/dh-refactor/lib/SVK/Command/Pull.pm Mon Nov 6 23:47:26 2006
@@ -23,8 +23,7 @@
$self->{incremental} = !$self->{lump};
if ($self->{all}) {
- my $checkout = $self->{xd}{checkout}{hash};
- @arg = sort grep $checkout->{$_}{depotpath}, keys %$checkout;
+ @arg = $self->{xd}{checkout}->find('/', { depotpath => qr/.*/ });
}
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: branches/dh-refactor/lib/SVK/XD.pm
==============================================================================
--- branches/dh-refactor/lib/SVK/XD.pm (original)
+++ branches/dh-refactor/lib/SVK/XD.pm Mon Nov 6 23:47:26 2006
@@ -162,8 +162,7 @@
}
elsif ($info) {
$info->{checkout}{sep} = $SEP;
- $info->{checkout} = $info->{checkout}->to_absolute($self->{floating})
- if $self->{floating};
+ $self->_loadify_checkout($info);
}
}
@@ -226,8 +225,8 @@
my $ancient_backup = $file.".bak.".$$;
my $tmphash = { map { $_ => $hash->{$_}} qw/checkout depotmap/ };
- $tmphash->{checkout} = $tmphash->{checkout}->to_relative($self->{floating})
- if $self->{floating};
+ $self->_savify_checkout($tmphash);
+
DumpFile ($tmpfile, $tmphash);
if (not -f $tmpfile ) {
@@ -252,6 +251,30 @@
}
}
+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;
@@ -268,8 +291,7 @@
# the changes from the paths we locked, and write it out.
$self->giant_lock ();
my $info = LoadFile ($self->{statefile});
- $info->{checkout} = $info->{checkout}->to_absolute($self->{floating})
- if $self->{floating};
+ $self->_loadify_checkout($info);
my @paths = $info->{checkout}->find ('', {lock => $$});
$info->{checkout}->merge ($self->{checkout}, $_)
for @paths;
More information about the svk-commit
mailing list