[Bps-public-commit] Prophet branch, master, updated. 2bcfa92f20f93d7f7dc4ce595ea8aee10d7920e8

spang at bestpractical.com spang at bestpractical.com
Mon Jul 20 12:00:29 EDT 2009


The branch, master has been updated
       via  2bcfa92f20f93d7f7dc4ce595ea8aee10d7920e8 (commit)
      from  06ed5c413831e55329c9b02434ca0f64731b04d0 (commit)

Summary of changes:
 lib/Prophet/CLI/Command/Push.pm |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

- Log -----------------------------------------------------------------
commit 2bcfa92f20f93d7f7dc4ce595ea8aee10d7920e8
Author: Christine Spang <spang at mit.edu>
Date:   Mon Jul 20 16:52:27 2009 +0100

    don't let users push to foreign replicas they haven't pulled from yet (ticket DC1AE280-FA4E-11DD-89ED-4AB794F21BD5)

diff --git a/lib/Prophet/CLI/Command/Push.pm b/lib/Prophet/CLI/Command/Push.pm
index 417a112..dbe7bd4 100644
--- a/lib/Prophet/CLI/Command/Push.pm
+++ b/lib/Prophet/CLI/Command/Push.pm
@@ -22,6 +22,27 @@ sub run {
         : $self->arg('to')
     );
 
+    # don't let users push to foreign replicas they haven't pulled from yet
+    # without --force
+    my %seen_replicas_by_url = $self->config->sources( by_variable => 1 );
+    my %seen_replicas_by_pull_url = $self->config->sources(
+        by_variable => 1,
+        variable => 'pull-url',
+    );
+
+    (my $class, undef, undef) = Prophet::Replica->_url_to_replica_class(
+        url       => $self->arg('to'),
+        app_handle => $self->app_handle,
+    );
+
+    die "Can't push to foreign replica that's never been pulled from! (Override with --force.)\n"
+        unless
+            $class->isa('Prophet::ForeignReplica') &&
+            ! $self->has_arg('force') &&
+            ( exists $seen_replicas_by_url{$self->arg('to')} ||
+              exists $seen_replicas_by_pull_url{$self->arg('to')} );
+
+    # prepare to run merge command (superclass)
     $self->set_arg( from =>  $self->handle->url );
     $self->set_arg( db_uuid => $self->handle->db_uuid );
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list