[svk-commit] r2778 - in branches/moose/lib/SVK: Path

nobody at bestpractical.com nobody at bestpractical.com
Mon Apr 28 13:16:08 EDT 2008


Author: clkao
Date: Mon Apr 28 13:16:02 2008
New Revision: 2778

Added:
   branches/moose/lib/SVK/Path/CommandTargetRole.pm
Modified:
   branches/moose/lib/SVK/Path.pm
   branches/moose/lib/SVK/Path/Checkout.pm
   branches/moose/lib/SVK/Path/Txn.pm

Log:
Make pool / inspector vivification sane with moose build.

Modified: branches/moose/lib/SVK/Path.pm
==============================================================================
--- branches/moose/lib/SVK/Path.pm	(original)
+++ branches/moose/lib/SVK/Path.pm	Mon Apr 28 13:16:02 2008
@@ -63,6 +63,8 @@
 use SVK::Root;
 use Moose;
 
+with('SVK::Path::CommandTargetRole');
+
 extends qw(SVK::Accessor);
 
 has depot => (
@@ -81,7 +83,7 @@
 #	traits => [qw(Clone)],
 );
 
-has [qw(_root _inspector _pool)] => (
+has [qw(_root)] => (
 	is => "rw",
 	traits => [qw(NoClone)],
 );
@@ -104,7 +106,7 @@
 
 sub refresh_revision {
     my ($self) = @_;
-    $self->_inspector(undef);
+    $self->clear_inspector;
     $self->_root(undef);
     Carp::cluck unless $self->repos;
     $self->revision($self->repos->fs->youngest_rev);
@@ -112,6 +114,14 @@
     return $self;
 }
 
+sub _build_inspector {
+    my $self = shift;
+    return SVK::Inspector::Root->new
+	({ root => $self->repos->fs->revision_root($self->revision, $self->pool),
+	   _pool => $self->pool,
+	   anchor => $self->path_anchor });
+}
+
 =head2 root
 
 Returns the root representing the file system of the revision at the
@@ -216,30 +226,6 @@
     return ($txn, $editor, $post_handler_ref);
 }
 
-sub pool {
-    my $self = shift;
-    $self->_pool( SVN::Pool->new )
-	unless $self->_pool;
-
-    return $self->_pool;
-}
-
-sub inspector {
-    my $self = shift;
-    $self->_inspector( $self->_get_inspector )
-	unless $self->_inspector;
-
-    return $self->_inspector;
-}
-
-sub _get_inspector {
-    my $self = shift;
-    return SVK::Inspector::Root->new
-	({ root => $self->repos->fs->revision_root($self->revision, $self->pool),
-	   _pool => $self->pool,
-	   anchor => $self->path_anchor });
-}
-
 sub _get_remote_editor {
     my ($self, $m, $mpath, $message, $mcallback) = @_;
     my ($base_rev, $editor) = $m->get_merge_back_editor

Modified: branches/moose/lib/SVK/Path/Checkout.pm
==============================================================================
--- branches/moose/lib/SVK/Path/Checkout.pm	(original)
+++ branches/moose/lib/SVK/Path/Checkout.pm	Mon Apr 28 13:16:02 2008
@@ -53,6 +53,7 @@
 
 use SVK::Version;  our $VERSION = $SVK::VERSION;
 
+with('SVK::Path::CommandTargetRole');
 extends 'SVK::Accessor';
 
 use SVK::Path;
@@ -74,10 +75,14 @@
     traits => [qw(Clone)],
 );
 
-has [qw(_pool _inspector)] => (
-    is => "rw",
-    traits => [qw(NoClone)],
-);
+
+# XXX:
+for my $pass_through (qw/_to_pclass dump copy_ancestors _copy_ancestors nearest_copy is_merged_from/) {
+    no strict 'refs';
+    no warnings 'once';
+    *{$pass_through} = *{'SVK::Path::'.$pass_through};
+}
+
 
 use Class::Autouse qw(SVK::Editor::XD SVK::Root::Checkout);
 
@@ -206,8 +211,6 @@
     return $_copath_catsplit->($copath, $paths);
 }
 
-#sub report { __PACKAGE__->make_accessor('report')->(@_) }
-
 sub report_copath {
     my ($self, $copath) = @_;
     my $report = length($self->report) ? $self->report : undef;
@@ -267,12 +270,12 @@
 
 }
 
-sub _get_inspector {
+sub _build_inspector {
     my $self = shift;
     return SVK::Inspector::Root->new
 	({ root => $self->root,
 	   anchor => $self->path_anchor,
-	   _pool => $self->pool,
+	   pool => $self->pool,
 	 });
 }
 
@@ -284,16 +287,10 @@
 sub refresh_revision {
     my $self = shift;
     $self->source->refresh_revision;
-    $self->_inspector(undef);
+    $self->clear_inspector;
     return $self;
 }
 
-# XXX:
-for my $pass_through (qw/pool inspector _to_pclass dump copy_ancestors _copy_ancestors nearest_copy is_merged_from/) {
-    no strict 'refs';
-    no warnings 'once';
-    *{$pass_through} = *{'SVK::Path::'.$pass_through};
-}
 
 sub for_checkout_delta {
     my $self = shift;

Added: branches/moose/lib/SVK/Path/CommandTargetRole.pm
==============================================================================
--- (empty file)
+++ branches/moose/lib/SVK/Path/CommandTargetRole.pm	Mon Apr 28 13:16:02 2008
@@ -0,0 +1,32 @@
+package SVK::Path::CommandTargetRole;
+use Moose::Role;
+
+with('MooseX::Clone');
+
+has inspector => (
+	isa => "SVK::Inspector",
+	is  => "rw",
+	clearer => 'clear_inspector',
+	traits  => [qw(NoClone)],
+	lazy_build => 1,
+);
+
+requires '_build_inspector';
+
+has pool => (
+	isa  => "SVN::Pool",
+	is   => "rw",
+	lazy => 1,
+	default => sub { SVN::Pool->new },
+	traits  => [qw(NoClone)],
+);
+
+sub _build_inspector {
+    my $self = shift;
+    return SVK::Inspector::Root->new
+	({ root => $self->repos->fs->revision_root($self->revision, $self->pool),
+	   _pool => $self->pool,
+	   anchor => $self->path_anchor });
+}
+
+1;

Modified: branches/moose/lib/SVK/Path/Txn.pm
==============================================================================
--- branches/moose/lib/SVK/Path/Txn.pm	(original)
+++ branches/moose/lib/SVK/Path/Txn.pm	Mon Apr 28 13:16:02 2008
@@ -55,7 +55,7 @@
 
 has 'txn' => ( is => "rw" );
 
-sub _get_inspector {
+sub _build_inspector {
     my $self = shift;
 
     Carp::cluck unless $self->repos;


More information about the svk-commit mailing list