[svk-commit] r2306 - in trunk/lib/SVK: .

nobody at bestpractical.com nobody at bestpractical.com
Sun Mar 4 15:27:29 EST 2007


Author: clkao
Date: Sun Mar  4 15:27:29 2007
New Revision: 2306

Modified:
   trunk/lib/SVK/Command/Log.pm
   trunk/lib/SVK/MirrorCatalog.pm

Log:
Make mirror catalog cache the SVK::Mirror instances as well.

Modified: trunk/lib/SVK/Command/Log.pm
==============================================================================
--- trunk/lib/SVK/Command/Log.pm	(original)
+++ trunk/lib/SVK/Command/Log.pm	Sun Mar  4 15:27:29 2007
@@ -77,7 +77,7 @@
     my ( $target, $remoteonly ) = @_;
 
     # don't bother if this repository has no mirror
-    return if !$target->mirror->_entries;
+    return unless $target->mirror->entries;
 
     # we might be running log on a path containing mirrors.
     # FIXME: resolve when log outside mirror anchor

Modified: trunk/lib/SVK/MirrorCatalog.pm
==============================================================================
--- trunk/lib/SVK/MirrorCatalog.pm	(original)
+++ trunk/lib/SVK/MirrorCatalog.pm	Sun Mar  4 15:27:29 2007
@@ -56,7 +56,7 @@
 use SVK::Mirror;
 use SVK::Config;
 
-__PACKAGE__->mk_accessors(qw(depot repos cb_lock revprop));
+__PACKAGE__->mk_accessors(qw(depot repos cb_lock revprop _cached_mirror));
 
 =head1 NAME
 
@@ -75,8 +75,8 @@
 
 sub entries {
     my $self = shift;
-    my %mirrors = $self->_entries;
-    return sort keys %mirrors;
+    return sort keys %{$self->_entries} if wantarray;
+    return scalar keys %{$self->_entries};
 }
 
 sub _entries {
@@ -85,12 +85,12 @@
     my $rev = $repos->fs->youngest_rev;
     delete $mirror_cached{$repos}
 	unless ($mirror_cached{$repos}{rev} || -1) == $rev;
-    return %{$mirror_cached{$repos}{hash}}
+    return $mirror_cached{$repos}{hash}
 	if exists $mirror_cached{$repos};
 
     if ($repos->fs->revision_prop(0, 'svn:svnsync:from-url')) {
-	$mirror_cached{$repos} = { rev => $rev, hash => { '/' => 1 } };
-	return ( '/' => 1 );
+	$mirror_cached{$repos} = { rev => $rev, hash => { '/' => undef } };
+	return { '/' => undef };
     }
 
     my @mirrors = grep length,
@@ -99,22 +99,20 @@
 
     my %mirrored = map {
 	local $@;
-	eval {
+	my $m = eval {
             SVK::Mirror->load( { path => $_, depot => $self->depot, pool => SVN::Pool->new });
-	    1;
 	};
-        $@ ? () : ($_ => 1)
+        $@ ? () : ($_ => $m)
 
     } @mirrors;
 
     $mirror_cached{$repos} = { rev => $rev, hash => \%mirrored};
-    return %mirrored;
+    return \%mirrored;
 }
 
 sub get {
     my ($self, $path) = @_;
-    Carp::cluck if ref($path);
-    return SVK::Mirror->load( { path => $path, depot => $self->depot, pool => SVN::Pool->new });
+    return $self->_entries->{$path} || SVK::Mirror->load( { path => $path, depot => $self->depot, pool => SVN::Pool->new });;
 }
 
 sub unlock {


More information about the svk-commit mailing list