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

jesse jesse at bestpractical.com
Mon Jun 8 12:54:39 EDT 2009


The branch, master has been updated
       via  a9677ee0b3efe74d36118c63fe9e747562c9fbe0 (commit)
      from  4b59cae79062dafa5cc57090d1beaa0ad87b5bec (commit)

Summary of changes:
 lib/Prophet/FilesystemReplica.pm     |    4 +++-
 lib/Prophet/Replica.pm               |    2 ++
 lib/Prophet/Replica/prophet_cache.pm |    3 ++-
 lib/Prophet/Replica/sqlite.pm        |   19 ++++++++++---------
 lib/Prophet/Server/Dispatcher.pm     |    3 ++-
 5 files changed, 19 insertions(+), 12 deletions(-)

- Log -----------------------------------------------------------------
commit a9677ee0b3efe74d36118c63fe9e747562c9fbe0
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Mon Jun 8 12:54:10 2009 -0400

    update how we pass changeset metadata to the traverse_changesets callback.

diff --git a/lib/Prophet/FilesystemReplica.pm b/lib/Prophet/FilesystemReplica.pm
index 31db51b..8c57b38 100644
--- a/lib/Prophet/FilesystemReplica.pm
+++ b/lib/Prophet/FilesystemReplica.pm
@@ -183,13 +183,15 @@ sub traverse_changesets {
                 sequence_no => $rev,
                 index_file  => $chgidx
             );
+            $args{callback}->( changeset => $data);
         } else {
            $data = $self->_changeset_index_entry(
                 sequence_no => $rev,
                 index_file  => $chgidx
             );
+            $args{callback}->( changeset_metadata => $data);
+
         }
-            $args{callback}->( changeset => $data);
         $args{reporting_callback}->($data) if ($args{reporting_callback});
 
     }
diff --git a/lib/Prophet/Replica.pm b/lib/Prophet/Replica.pm
index cdf0c40..51a8807 100644
--- a/lib/Prophet/Replica.pm
+++ b/lib/Prophet/Replica.pm
@@ -177,6 +177,8 @@ sub import_changesets {
 
     warn "The source (@{[$source->url]}) does not exist" unless ($source->replica_exists);
 
+    $self->log_debug("Integrating changesets from ".$source->uuid. " after ". $self->last_changeset_from_source( $self->uuid ));
+
     $source->traverse_changesets(
         after    => $self->last_changeset_from_source( $self->uuid ),
         callback => sub {
diff --git a/lib/Prophet/Replica/prophet_cache.pm b/lib/Prophet/Replica/prophet_cache.pm
index 19aad64..db94a65 100644
--- a/lib/Prophet/Replica/prophet_cache.pm
+++ b/lib/Prophet/Replica/prophet_cache.pm
@@ -226,7 +226,8 @@ sub mirror_from {
             callback =>
 
                 sub {
-                my $data = shift;
+                my %args = (@_);
+                my $data = $args{changeset_metadata};
                 my ( $seq, $orig_uuid, $orig_seq, $key ) = @{$data};
                 if ( -e File::Spec->catdir( $self->fs_root, $self->changeset_cas->filename($key) ) ) {
                     return;
diff --git a/lib/Prophet/Replica/sqlite.pm b/lib/Prophet/Replica/sqlite.pm
index 302901c..3569f95 100644
--- a/lib/Prophet/Replica/sqlite.pm
+++ b/lib/Prophet/Replica/sqlite.pm
@@ -404,10 +404,10 @@ sub traverse_changesets {
     my $self = shift;
     my %args = validate(
         @_,
-        {   after    => 1,
-            callback => 1,
-            until    => 0,
-            reverse  => 0,
+        {   after           => 1,
+            callback        => 1,
+            until           => 0,
+            reverse         => 0,
             load_changesets => { default => 1 }
         }
     );
@@ -415,8 +415,8 @@ sub traverse_changesets {
     my $first_rev = ( $args{'after'} + 1 ) || 1;
     my $latest = $self->latest_sequence_no;
 
-    if ( defined $args{until} && $args{until} < $latest) {
-            $latest = $args{until};
+    if ( defined $args{until} && $args{until} < $latest ) {
+        $latest = $args{until};
     }
 
     $self->log_debug("Traversing changesets between $first_rev and $latest");
@@ -427,11 +427,11 @@ sub traverse_changesets {
         my $data;
         if ( $args{load_changesets} ) {
             $data = $self->_load_changeset_from_db( sequence_no => $rev );
-            $args{callback}->(changeset => $data);
+            $args{callback}->( changeset => $data );
         } else {
             my $row = $self->_load_changeset_metadata_from_db( sequence_no => $rev );
             $data = [ $row->{sequence_no}, $row->{original_source_uuid}, $row->{original_sequence_no}, $row->{sha1} ];
-            $args{callback}->($data);
+            $args{callback}->(changeset_metadata => $data);
 
         }
     }
@@ -445,7 +445,8 @@ sub read_changeset_index {
                 after=> 0,
                 load_changesets => 0,
                 callback => sub {
-                    my $data            = shift;
+                    my %args = (@_);
+                    my $data            = $args{changeset_metadata};
                     my $changeset_index_line = pack( 'Na16NH40',
                         $data->[0],
                         Data::UUID->new->from_string( $data->[1]),
diff --git a/lib/Prophet/Server/Dispatcher.pm b/lib/Prophet/Server/Dispatcher.pm
index 0d11f41..b4e7133 100644
--- a/lib/Prophet/Server/Dispatcher.pm
+++ b/lib/Prophet/Server/Dispatcher.pm
@@ -56,7 +56,8 @@ under { method => 'GET' } => sub {
                 after=> 0,
                 load_changesets => 0,
                 callback => sub {
-                    my $data            = shift;
+                    my %args = (@_);
+                    my $data            = $args{changeset_metadata};
                     my $changeset_index_line = pack( 'Na16NH40',
                         $data->[0],
                         Data::UUID->new->from_string( $data->[1]),

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



More information about the Bps-public-commit mailing list