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

jesse jesse at bestpractical.com
Wed Jun 3 17:15:44 EDT 2009


The branch, master has been updated
       via  2e83f5efd1d4ee4da083dde11fe3592e61e54046 (commit)
      from  95b9c27ff3ea50a912c464e3ba4a8b61697ff64b (commit)

Summary of changes:
 lib/Prophet/Replica.pm |   25 ++++++++++---------------
 t/simple-push.t        |    3 +--
 2 files changed, 11 insertions(+), 17 deletions(-)

- Log -----------------------------------------------------------------
commit 2e83f5efd1d4ee4da083dde11fe3592e61e54046
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Wed Jun 3 17:15:22 2009 -0400

    Replaced a weirdly factored should_send_changeset with a more useful should_accept_changeset

diff --git a/lib/Prophet/Replica.pm b/lib/Prophet/Replica.pm
index 0d8b5b8..d131c51 100644
--- a/lib/Prophet/Replica.pm
+++ b/lib/Prophet/Replica.pm
@@ -264,11 +264,7 @@ sub integrate_changeset {
     # we'll want to skip or remove those changesets
 
 
-    if (   $changeset->is_resolution
-        || $changeset->is_nullification
-        || !$changeset->has_changes
-        || $self->has_seen_changeset($changeset) ) {
-
+    if (!  $self->should_accept_changeset($changeset) ){
         # if it's a changeset we don't care about, mark it as seen and move on
         $self->record_integration_of_changeset($changeset);
         $args{'reporting_callback'}->( changeset => $changeset, )
@@ -453,23 +449,22 @@ sub _check_db_uuids_on_merge {
     }
 }
 
-=head3 should_send_changeset { to => L<Prophet::Replica>, changeset => L<Prophet::ChangeSet> }
+=head3 should_accept_changeset { from => L<Prophet::Replica>, changeset => L<Prophet::ChangeSet> }
 
-Returns true if the replica C<to> hasn't yet seen the changeset C<changeset>.
+Returns true if this replica hasn't yet seen the changeset C<changeset>.
 
 =cut
 
-sub should_send_changeset {
+sub should_accept_changeset {
     my $self = shift;
-    my %args = validate( @_, { to => { isa => 'Prophet::Replica' },
-                               changeset => { isa => 'Prophet::ChangeSet' } });
+    my ($changeset) = validate_pos( @_, { changeset => { isa => 'Prophet::ChangeSet' } });
 
-    $self->log_debug("Should I send " .$args{changeset}->original_sequence_no .
-        " from ".$self->display_name_for_uuid($args{changeset}->original_source_uuid) . " to " .
-        $args{'to'}->display_name_for_uuid);
+    $self->log_debug("Should I accept " .$changeset->original_sequence_no .
+        " from ".$self->display_name_for_uuid($changeset->original_source_uuid));
 
-    return undef if ( $args{'changeset'}->is_nullification || $args{'changeset'}->is_resolution );
-    return undef if $args{'to'}->has_seen_changeset( $args{'changeset'} );
+    return undef if (! $changeset->has_changes);
+    return undef if ( $changeset->is_nullification || $changeset->is_resolution );
+    return undef if $self->has_seen_changeset( $changeset );
 
     return 1;
 }
diff --git a/t/simple-push.t b/t/simple-push.t
index a2d529e..60c05fc 100644
--- a/t/simple-push.t
+++ b/t/simple-push.t
@@ -79,8 +79,7 @@ $bob->traverse_changesets(
     after    => $alice->last_changeset_from_source($bob->uuid),
     callback => sub {
         my $cs = shift;
-        return unless $bob->should_send_changeset( changeset => $cs, to => $alice);
-        return unless $cs->has_changes;
+        return unless $alice->should_accept_changeset( $cs);
         push @{$changesets}, $cs->as_hash;
     }
 );

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



More information about the Bps-public-commit mailing list