[Bps-public-commit] r12480 - in Prophet/branches/moose: . lib/Prophet/Replica
sartak at bestpractical.com
sartak at bestpractical.com
Sat May 17 08:42:27 EDT 2008
Author: sartak
Date: Sat May 17 08:42:26 2008
New Revision: 12480
Modified:
Prophet/branches/moose/ (props changed)
Prophet/branches/moose/lib/Prophet/Replica.pm
Prophet/branches/moose/lib/Prophet/Replica/Native.pm
Prophet/branches/moose/lib/Prophet/Replica/SVN.pm
Log:
r56228 at onn: sartak | 2008-05-17 08:42:19 -0400
Basic moosification of Prophet::Replica and its subclasses
Modified: Prophet/branches/moose/lib/Prophet/Replica.pm
==============================================================================
--- Prophet/branches/moose/lib/Prophet/Replica.pm (original)
+++ Prophet/branches/moose/lib/Prophet/Replica.pm Sat May 17 08:42:26 2008
@@ -1,16 +1,38 @@
-use warnings;
-use strict;
-
-
package Prophet::Replica;
-use base qw/Class::Accessor/;
+use Moose;
use Params::Validate qw(:all);
use UNIVERSAL::require;
use Data::UUID;
use Path::Class;
-
-__PACKAGE__->mk_accessors(qw(state_handle resolution_db_handle is_resdb is_state_handle db_uuid url));
+has state_handle => (
+ is => 'rw',
+ isa => 'Prophet::Replica',
+);
+
+has resolution_db_handle => (
+ is => 'rw',
+ isa => 'Prophet::Replica',
+);
+
+has is_resdb => (
+ is => 'rw',
+ isa => 'Bool',
+);
+
+has is_state_handle => (
+ is => 'rw',
+ isa => 'Bool',
+);
+
+has db_uuid => (
+ is => 'rw',
+ isa => 'Str',
+);
+
+has url => (
+ is => 'rw',
+);
use constant state_db_uuid => 'state';
use Module::Pluggable search_path => 'Prophet::Replica', sub_name => 'core_replica_types', require => 0, except => qr/Prophet::Replica::(.*)::/;
@@ -798,5 +820,8 @@
Carp::confess(@_);
}
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
1;
Modified: Prophet/branches/moose/lib/Prophet/Replica/Native.pm
==============================================================================
--- Prophet/branches/moose/lib/Prophet/Replica/Native.pm (original)
+++ Prophet/branches/moose/lib/Prophet/Replica/Native.pm Sat May 17 08:42:26 2008
@@ -1,9 +1,6 @@
-use warnings;
-use strict;
-
package Prophet::Replica::Native;
-use base qw/Prophet::Replica/;
-
+use Moose;
+extends 'Prophet::Replica';
use Params::Validate qw(:all);
use LWP::Simple ();
use Path::Class;
@@ -14,9 +11,28 @@
use Prophet::ChangeSet;
use Prophet::Conflict;
-__PACKAGE__->mk_accessors(qw/url _db_uuid _uuid/);
-__PACKAGE__->mk_accessors(
- qw(fs_root_parent fs_root target_replica cas_root record_cas_dir changeset_cas_dir record_dir current_edit)
+has _db_uuid => (
+ is => 'rw',
+);
+
+has _uuid => (
+ is => 'rw',
+);
+
+has fs_root_parent => (
+ is => 'rw',
+);
+
+has fs_root => (
+ is => 'rw',
+);
+
+has target_replica => (
+ is => 'rw',
+);
+
+has current_edit => (
+ is => 'rw',
);
use constant scheme => 'prophet';
@@ -653,4 +669,7 @@
return $self->_file_exists( $self->_record_type_root( $args{'type'} ) );
}
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
1;
Modified: Prophet/branches/moose/lib/Prophet/Replica/SVN.pm
==============================================================================
--- Prophet/branches/moose/lib/Prophet/Replica/SVN.pm (original)
+++ Prophet/branches/moose/lib/Prophet/Replica/SVN.pm Sat May 17 08:42:26 2008
@@ -1,21 +1,41 @@
-use warnings;
-use strict;
-
package Prophet::Replica::SVN;
-use base qw/Prophet::Replica/;
+use Moose;
+extends 'Prophet::Replica';
use Params::Validate qw(:all);
use UNIVERSAL::require;
-
-
-
-
# require rather than use to make them late-binding
use Prophet::ChangeSet;
use Prophet::Conflict;
-__PACKAGE__->mk_accessors(qw/url ra fs_root repo_handle current_edit _pool/);
-
+has ra => (
+ is => 'rw',
+ isa => 'SVN::Ra',
+ lazy => 1,
+ default => sub {
+ my $self = shift;
+ require Prophet::Replica::SVN::Util;
+ my ( $baton, $ref ) = SVN::Core::auth_open_helper( Prophet::Replica::SVN::Util->get_auth_providers );
+ my $config = Prophet::Replica::SVN::Util->svnconfig;
+ return SVN::Ra->new(url => $self->url, config => $config, auth => $baton, pool => $self->_pool);
+ },
+);
+
+has fs_root => (
+ is => 'rw',
+);
+
+has repo_handle => (
+ is => 'rw',
+);
+
+has current_edit => (
+ is => 'rw',
+);
+
+has _pool => (
+ is => 'rw',
+);
use constant scheme => 'svn';
@@ -26,14 +46,6 @@
=cut
-sub _get_ra {
- my $self = shift;
- require Prophet::Replica::SVN::Util;
- my ( $baton, $ref ) = SVN::Core::auth_open_helper( Prophet::Replica::SVN::Util->get_auth_providers );
- my $config = Prophet::Replica::SVN::Util->svnconfig;
- return SVN::Ra->new( url => $self->url, config => $config, auth => $baton, pool => $self->_pool );
-}
-
sub setup {
my $self = shift;
require SVN::Core; require SVN::Ra; require SVN::Delta; require SVN::Repos; require SVN::Fs;
@@ -43,10 +55,6 @@
#$self->state_handle( $self->prophet_handle ); XXX DO THIS RIGHT
}
-
-
- $self->ra( $self->_get_ra );
-
if ( $self->is_resdb ) {
# XXX: should probably just point to self
@@ -124,7 +132,6 @@
require Prophet::Replica::SVN::ReplayEditor;
my $editor = Prophet::Replica::SVN::ReplayEditor->new( _debug => 0 );
- $editor->ra( $self->_get_ra );
my $pool = SVN::Pool->new_default;
# This horrible hack is here because I have no idea how to pass custom variables into the editor
@@ -477,5 +484,8 @@
}
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
1;
More information about the Bps-public-commit
mailing list