[Bps-public-commit] Prophet branch, master, updated. 106b9ccc91b96e0c9ed97fdafa061c44c2397fcd

jesse jesse at bestpractical.com
Thu Jun 4 12:48:43 EDT 2009


The branch, master has been updated
       via  106b9ccc91b96e0c9ed97fdafa061c44c2397fcd (commit)
      from  3512a60b49458b916c5d983d0f6c06acd13351f8 (commit)

Summary of changes:
 lib/Prophet/CLI/Command/Merge.pm |    2 +-
 lib/Prophet/Replica.pm           |   18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 106b9ccc91b96e0c9ed97fdafa061c44c2397fcd
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 4 12:47:46 2009 -0400

    Added an after_integrate_changeset hook to traverse_changesets to support foreign replica metadata recording; fixes to keep up with the API

diff --git a/lib/Prophet/CLI/Command/Merge.pm b/lib/Prophet/CLI/Command/Merge.pm
index d16aa3e..4e43515 100644
--- a/lib/Prophet/CLI/Command/Merge.pm
+++ b/lib/Prophet/CLI/Command/Merge.pm
@@ -97,7 +97,7 @@ sub _do_merge {
     $self->source->traverse_changesets(
         after    => $source_last_seen,
         callback => sub { 
-                my %args = shift;
+                my %args = (@_);
                 if ($self->target->should_accept_changeset($args{changeset})) {
                         print $args{changeset}->as_string;
                 } 
diff --git a/lib/Prophet/Replica.pm b/lib/Prophet/Replica.pm
index 31c0c11..0dd8f39 100644
--- a/lib/Prophet/Replica.pm
+++ b/lib/Prophet/Replica.pm
@@ -145,6 +145,16 @@ sub _url_to_replica_class {
 Given a L<Prophet::Replica> to import changes from, traverse all the
 changesets we haven't seen before and integrate them into this replica.
 
+This routine calls L<traverse_changesets> on the 'from' replica,
+passing in the most recent changeset the current replica has seen
+and a callback routine which calls L<integrate_changeset> on the
+local replica.
+
+That callback itself takes a callback, L<after_integrate_changeset>
+, which a replica implementation can use to perform some action
+after a changeset is integrated into a peer.  L<after_integrate_changeset>
+takes a paramhash, currently with only a single key, 'changeset'.
+
 =cut
 
 sub import_changesets {
@@ -179,6 +189,12 @@ sub import_changesets {
                 resolver_class     => $args{'resolver_class'},
                 resdb              => $args{'resdb'},
             );
+
+            if (ref ($callback_args{after_integrate_changeset})) {
+                $callback_args{after_integrate_changeset}->(changeset => $callback_args{changeset});
+            }
+
+
         }
     );
 }
@@ -486,7 +502,7 @@ sub fetch_changesets {
     my %args = validate( @_, { after => 1 } );
     my @results;
 
-    $self->traverse_changesets( %args, callback => sub { push @results, $_[0] } );
+    $self->traverse_changesets( %args, callback => sub { my %args = @_; push @results, $args{changeset} } );
 
     return \@results;
 }

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



More information about the Bps-public-commit mailing list