[Bps-public-commit] r17615 - in Prophet/trunk: lib/Prophet/CLI/Command lib/Prophet/Replica t

jesse at bestpractical.com jesse at bestpractical.com
Wed Jan 7 15:00:21 EST 2009


Author: jesse
Date: Wed Jan  7 15:00:20 2009
New Revision: 17615

Modified:
   Prophet/trunk/lib/Prophet/App.pm
   Prophet/trunk/lib/Prophet/CLI/Command/Clone.pm
   Prophet/trunk/lib/Prophet/CLI/Command/Merge.pm
   Prophet/trunk/lib/Prophet/ForeignReplica.pm
   Prophet/trunk/lib/Prophet/Replica.pm
   Prophet/trunk/lib/Prophet/Replica/prophet.pm
   Prophet/trunk/lib/Prophet/Replica/sqlite.pm
   Prophet/trunk/lib/Prophet/ReplicaExporter.pm
   Prophet/trunk/t/export.t

Log:
* Fix an inheritance issue (API change)

Modified: Prophet/trunk/lib/Prophet/App.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/App.pm	(original)
+++ Prophet/trunk/lib/Prophet/App.pm	Wed Jan  7 15:00:20 2009
@@ -12,7 +12,7 @@
         my $self = shift;
         my $root = $ENV{'PROPHET_REPO'} || File::Spec->catdir($ENV{'HOME'}, '.prophet');
         my $type = $self->default_replica_type;
-        return Prophet::Replica->new( url => $type.':file://' . $root, app_handle => $self, 
+        return Prophet::Replica->get_handle( url => $type.':file://' . $root, app_handle => $self, 
                 
                 );
     },
@@ -28,7 +28,7 @@
             if $self->handle->resolution_db_handle;
         my $root = ($ENV{'PROPHET_REPO'} || File::Spec->catdir($ENV{'HOME'}, '.prophet')) . "_res";
         my $type = $self->default_replica_type;
-        my $r = Prophet::Replica->new( url => $type.':file://' . $root );
+        my $r = Prophet::Replica->get_handle( url => $type.':file://' . $root );
         if (!$r->replica_exists && $r->can_initialize) { $r->initialize}
 
         return $r;

Modified: Prophet/trunk/lib/Prophet/CLI/Command/Clone.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Clone.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Clone.pm	Wed Jan  7 15:00:20 2009
@@ -7,11 +7,11 @@
 
     $self->set_arg( 'to' => $self->app_handle->handle->url() );
 
-    my $source = Prophet::Replica->new(
+    my $source = Prophet::Replica->get_handle(
         url        => $self->arg('from'),
         app_handle => $self->app_handle,
     );
-    my $target = Prophet::Replica->new(
+    my $target = Prophet::Replica->get_handle(
         url        => $self->arg('to'),
         app_handle => $self->app_handle,
     );

Modified: Prophet/trunk/lib/Prophet/CLI/Command/Merge.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Merge.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Merge.pm	Wed Jan  7 15:00:20 2009
@@ -9,12 +9,12 @@
 sub run {
     my $self = shift;
 
-    $self->source( Prophet::Replica->new(
+    $self->source( Prophet::Replica->get_handle(
         url       => $self->arg('from'),
         app_handle => $self->app_handle,
     ));
 
-    $self->target( Prophet::Replica->new(
+    $self->target( Prophet::Replica->get_handle(
         url       => $self->arg('to'),
         app_handle => $self->app_handle,
     ));

Modified: Prophet/trunk/lib/Prophet/ForeignReplica.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/ForeignReplica.pm	(original)
+++ Prophet/trunk/lib/Prophet/ForeignReplica.pm	Wed Jan  7 15:00:20 2009
@@ -17,7 +17,7 @@
     my $state_handle_url =      $self->app_handle->default_replica_type . ":" . $self->app_handle->handle->url;
     $self->log( "Connecting to state database ".$state_handle_url);
     $self->state_handle(
-        Prophet::Replica->new(
+        Prophet::Replica->get_handle(
                url => $state_handle_url,
                 db_uuid => $self->state_db_uuid,
                 app_handle => $self->app_handle

Modified: Prophet/trunk/lib/Prophet/Replica.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica.pm	Wed Jan  7 15:00:20 2009
@@ -69,30 +69,28 @@
 
 =head1 METHODS
 
-=head3 new
+=head3 get_handle
 
 Determines what replica class to use and instantiates it. Returns the
 new replica object.
 
 =cut
 
-sub new {
+sub get_handle {
     my $class = shift;
-    my %args  = @_ == 1 ? %{ $_[0] } : @_;
+    my %args = @_ == 1 ? %{ $_[0] } : @_;
 
-    my ($new_class, $scheme, $url) = $class->_url_to_replica_class(%args);
+    my ( $new_class, $scheme, $url ) = $class->_url_to_replica_class(%args);
 
-    if (!$new_class) {
-        $class->log_fatal("$scheme isn't a replica type I know how to handle. (The Replica URL given was $args{url}).");
+    if ( !$new_class ) {
+        $class->log_fatal(
+            "$scheme isn't a replica type I know how to handle. (The Replica URL given was $args{url})."
+        );
     }
 
-    if ( $class eq $new_class) { 
-        return $class->SUPER::new(%args) 
-    } else {
-        Prophet::App->require($new_class);
-        return $new_class->new(%args);
-        }
-};
+    Prophet::App->require($new_class);
+    return $new_class->new(%args);
+}
 
 
 sub replica_exists {
@@ -1136,7 +1134,7 @@
     return $self->app_handle->config->display_name_for_uuid($uuid);
 }
 
-__PACKAGE__->meta->make_immutable;
+__PACKAGE__->meta->make_immutable();
 no Moose;
 
 1;

Modified: Prophet/trunk/lib/Prophet/Replica/prophet.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica/prophet.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica/prophet.pm	Wed Jan  7 15:00:20 2009
@@ -63,7 +63,7 @@
     default => sub {
         my $self = shift;
         return if $self->is_resdb || $self->is_state_handle;
-        return Prophet::Replica->new(
+        return Prophet::Replica->get_handle(
             {   url        => "prophet:" . $self->url . '/resolutions',
                 app_handle => $self->app_handle,
                 is_resdb   => 1,
@@ -1064,7 +1064,7 @@
     );
 }
 
-__PACKAGE__->meta->make_immutable(replace_constructor => 1);
+__PACKAGE__->meta->make_immutable();
 no Moose;
 
 1;

Modified: Prophet/trunk/lib/Prophet/Replica/sqlite.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica/sqlite.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica/sqlite.pm	Wed Jan  7 15:00:20 2009
@@ -68,7 +68,7 @@
     default => sub {
         my $self = shift;
         return if $self->is_resdb || $self->is_state_handle;
-        return Prophet::Replica->new(
+        return Prophet::Replica->get_handle(
             {   url        => $self->url . '/resolutions',
                 app_handle => $self->app_handle,
                 is_resdb   => 1,

Modified: Prophet/trunk/lib/Prophet/ReplicaExporter.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/ReplicaExporter.pm	(original)
+++ Prophet/trunk/lib/Prophet/ReplicaExporter.pm	Wed Jan  7 15:00:20 2009
@@ -23,7 +23,7 @@
     default => sub {
         my $self = shift;
         confess "No target_path specified" unless $self->has_target_path;
-        my $replica = Prophet::Replica->new(url => "prophet:file://" . $self->target_path, app_handle => $self->app_handle);
+        my $replica = Prophet::Replica->get_handle(url => "prophet:file://" . $self->target_path, app_handle => $self->app_handle);
 
         my $src = $self->source_replica;
         my %init_args = (

Modified: Prophet/trunk/t/export.t
==============================================================================
--- Prophet/trunk/t/export.t	(original)
+++ Prophet/trunk/t/export.t	Wed Jan  7 15:00:20 2009
@@ -64,7 +64,7 @@
     is( $latest, $cli->handle->latest_sequence_no );
     use_ok('Prophet::Replica::prophet');
     diag("Checking changesets in $path");
-    my $changesets =  Prophet::Replica->new( { url => 'prophet:file://' . $path, app_handle => Prophet::CLI->new->app_handle } )->fetch_changesets( after => 0 );
+    my $changesets =  Prophet::Replica->get_handle( { url => 'prophet:file://' . $path, app_handle => Prophet::CLI->new->app_handle } )->fetch_changesets( after => 0 );
     my @changesets = grep {$_->has_changes} @$changesets;
     is( $#changesets, 2, "We found a total of 3 changesets" );
     # XXX: compare the changeset structure



More information about the Bps-public-commit mailing list