[Bps-public-commit] r16698 - in Prophet/branches/init-and-clone: . lib/Prophet/CLI lib/Prophet/CLI/Command

jesse at bestpractical.com jesse at bestpractical.com
Thu Nov 6 01:52:57 EST 2008


Author: jesse
Date: Thu Nov  6 01:52:57 2008
New Revision: 16698

Modified:
   Prophet/branches/init-and-clone/   (props changed)
   Prophet/branches/init-and-clone/lib/Prophet/CLI/Command/Clone.pm
   Prophet/branches/init-and-clone/lib/Prophet/CLI/TextEditorCommand.pm
   Prophet/branches/init-and-clone/lib/Prophet/ForeignReplica.pm
   Prophet/branches/init-and-clone/lib/Prophet/Replica.pm
   Prophet/branches/init-and-clone/lib/Prophet/Test.pm

Log:
 r49324 at 31b:  jesse | 2008-11-06 09:21:38 +0900
 * Misc fixes for the init/clone functionality. Backed out some moosification that made stack traces _impossible_ to follow.


Modified: Prophet/branches/init-and-clone/lib/Prophet/CLI/Command/Clone.pm
==============================================================================
--- Prophet/branches/init-and-clone/lib/Prophet/CLI/Command/Clone.pm	(original)
+++ Prophet/branches/init-and-clone/lib/Prophet/CLI/Command/Clone.pm	Thu Nov  6 01:52:57 2008
@@ -2,7 +2,7 @@
 use Moose;
 extends 'Prophet::CLI::Command::Merge';
 
-before 'run' => sub {
+sub run {
     my $self = shift;
 
     $self->set_arg( 'to' => $self->app_handle->handle->url() );
@@ -25,10 +25,12 @@
     }
 
     $target->initialize();
-    $target->set_db_uuid($source->db_uuid);
-    $target->resolution_db_handle->set_db_uuid($source->resolution_db_handle->db_uuid);
-    return $target->_write_cached_upstream_replicas($self->arg('from'));
-
+    $target->set_db_uuid($source->db_uuid) 
+        unless ($source->isa('Prophet::ForeignReplica'));
+    $target->resolution_db_handle->set_db_uuid($source->resolution_db_handle->db_uuid)
+        unless ($source->isa('Prophet::ForeignReplica'));
+    $target->_write_cached_upstream_replicas($self->arg('from'));
+    $self->SUPER::run();
 };
 
 __PACKAGE__->meta->make_immutable;

Modified: Prophet/branches/init-and-clone/lib/Prophet/CLI/TextEditorCommand.pm
==============================================================================
--- Prophet/branches/init-and-clone/lib/Prophet/CLI/TextEditorCommand.pm	(original)
+++ Prophet/branches/init-and-clone/lib/Prophet/CLI/TextEditorCommand.pm	Thu Nov  6 01:52:57 2008
@@ -9,8 +9,8 @@
     my %args = validate( @_,
         {   template => 1,
             record   => 0,
-        });
-
+        }
+    );
 
     my $template = ${ $args{template} };
 

Modified: Prophet/branches/init-and-clone/lib/Prophet/ForeignReplica.pm
==============================================================================
--- Prophet/branches/init-and-clone/lib/Prophet/ForeignReplica.pm	(original)
+++ Prophet/branches/init-and-clone/lib/Prophet/ForeignReplica.pm	Thu Nov  6 01:52:57 2008
@@ -13,18 +13,15 @@
 
 sub BUILD {
     my $self = shift;
-    my $cli  = Prophet::CLI->new();
-
-    # XXX TODO this $cli object should be a Prophet::App object
-    my $state_handle_url =      $cli->app_handle->default_replica_type . ":" . $cli->handle->url;
+    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(
-            {   url => $state_handle_url,
-                db_uuid => $self->state_db_uuid
-            }
-        )
-    );
+               url => $state_handle_url,
+                db_uuid => $self->state_db_uuid,
+                app_handle => $self->app_handle
+        
+    ));
 }
 
 sub conflicts_from_changeset { return; }
@@ -106,6 +103,16 @@
     return $self->last_changeset_from_source($changeset->source_uuid) >= $changeset->sequence_no;
 }
 
+
+
+sub log {
+    my $self = shift;
+    my ($msg) = validate_pos(@_, 1);
+    Carp::confess unless ($self->app_handle);
+    $self->app_handle->log($self->url." (".$self->scheme.":".$self->url." )".": " .$msg);
+}
+
+
 no Moose;
 __PACKAGE__->meta->make_immutable;
 

Modified: Prophet/branches/init-and-clone/lib/Prophet/Replica.pm
==============================================================================
--- Prophet/branches/init-and-clone/lib/Prophet/Replica.pm	(original)
+++ Prophet/branches/init-and-clone/lib/Prophet/Replica.pm	Thu Nov  6 01:52:57 2008
@@ -76,8 +76,7 @@
 
 =cut
 
-around new => sub {
-    my $orig  = shift;
+sub new {
     my $class = shift;
     my %args  = @_ == 1 ? %{ $_[0] } : @_;
 
@@ -88,7 +87,7 @@
     }
 
     if ( $class eq $new_class) { 
-        return $orig->($class, %args) 
+        return $class->SUPER::new(%args) 
     } else {
         Prophet::App->require($new_class);
         return $new_class->new(%args);

Modified: Prophet/branches/init-and-clone/lib/Prophet/Test.pm
==============================================================================
--- Prophet/branches/init-and-clone/lib/Prophet/Test.pm	(original)
+++ Prophet/branches/init-and-clone/lib/Prophet/Test.pm	Thu Nov  6 01:52:57 2008
@@ -261,7 +261,7 @@
 sub database_uuid {
     my $self = shift;
     my $cli  = Prophet::CLI->new();
-    return $cli->handle->db_uuid;
+    return eval { $cli->handle->db_uuid};
 }
 
 =head2 replica_merge_tickets



More information about the Bps-public-commit mailing list