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

jesse jesse at bestpractical.com
Thu Jun 4 11:05:26 EDT 2009


The branch, master has been updated
       via  3512a60b49458b916c5d983d0f6c06acd13351f8 (commit)
      from  3a4383156b492dc0c7338ba3b350222f4d673acd (commit)

Summary of changes:
 lib/Prophet/CLI/Command/Log.pm     |    4 ++--
 lib/Prophet/CLI/Command/Merge.pm   |    6 +++---
 lib/Prophet/FilesystemReplica.pm   |    6 ++----
 lib/Prophet/Replica.pm             |    5 +++--
 lib/Prophet/Replica/sqlite.pm      |    3 ++-
 lib/Prophet/ReplicaFeedExporter.pm |    8 ++++----
 lib/Prophet/Server/View.pm         |    5 ++---
 7 files changed, 18 insertions(+), 19 deletions(-)

- Log -----------------------------------------------------------------
commit 3512a60b49458b916c5d983d0f6c06acd13351f8
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 4 11:04:38 2009 -0400

    Refactoring toward a more extensible traverse_changesets callback

diff --git a/lib/Prophet/CLI/Command/Log.pm b/lib/Prophet/CLI/Command/Log.pm
index c08eefb..89e5075 100644
--- a/lib/Prophet/CLI/Command/Log.pm
+++ b/lib/Prophet/CLI/Command/Log.pm
@@ -36,8 +36,8 @@ sub run {
         after    => $start - 1,
         until    => $end,
         callback => sub {
-            my $changeset = shift;
-            $self->handle_changeset($changeset);
+            my %args = (@_);
+            $self->handle_changeset($args{changeset});
 
         },
     );
diff --git a/lib/Prophet/CLI/Command/Merge.pm b/lib/Prophet/CLI/Command/Merge.pm
index 9604b82..d16aa3e 100644
--- a/lib/Prophet/CLI/Command/Merge.pm
+++ b/lib/Prophet/CLI/Command/Merge.pm
@@ -97,9 +97,9 @@ sub _do_merge {
     $self->source->traverse_changesets(
         after    => $source_last_seen,
         callback => sub { 
-                my $changeset = shift;
-                if ($self->target->should_accept_changeset($changeset)) {
-                        print $changeset->as_string;
+                my %args = shift;
+                if ($self->target->should_accept_changeset($args{changeset})) {
+                        print $args{changeset}->as_string;
                 } 
          });
 
diff --git a/lib/Prophet/FilesystemReplica.pm b/lib/Prophet/FilesystemReplica.pm
index 9e02448..e33ade3 100644
--- a/lib/Prophet/FilesystemReplica.pm
+++ b/lib/Prophet/FilesystemReplica.pm
@@ -11,9 +11,7 @@ has lwp_useragent => (
     is => 'ro',
     lazy => 1,
     default => sub {
-        my $ua = LWP::UserAgent->new;
-        $ua->timeout(60);
-        $ua->conn_cache(LWP::ConnCache->new());
+        my $ua = LWP::UserAgent->new( timeout => 60, keep_alive => 4, agent => "Prophet/".$Prophet::VERSION);
         return $ua;
     }
 );
@@ -191,7 +189,7 @@ sub traverse_changesets {
                 index_file  => $chgidx
             );
         }
-            $args{callback}->($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 d131c51..31c0c11 100644
--- a/lib/Prophet/Replica.pm
+++ b/lib/Prophet/Replica.pm
@@ -170,8 +170,9 @@ sub import_changesets {
     $source->traverse_changesets(
         after    => $self->last_changeset_from_source( $self->uuid ),
         callback => sub {
+            my %callback_args = (@_);
             $self->integrate_changeset(
-                changeset          => $_[0],
+                changeset          => $callback_args{changeset},
                 conflict_callback  => $args{conflict_callback},
                 reporting_callback => $args{'reporting_callback'},
                 resolver           => $args{resolver},
@@ -692,7 +693,7 @@ sub _read_luid2guid_mappings {
     return \%luid2guid;
 }
 
-=head3 traverse_changesets { after => SEQUENCE_NO, until => SEQUENCE_NO, callback => sub {} }
+=head3 traverse_changesets { after => SEQUENCE_NO, until => SEQUENCE_NO, callback => sub { my %data = (changeset => undef, @_} }
 
 Walk through each changeset in the replica after SEQUENCE_NO, calling the
 C<callback> for each one in turn.
diff --git a/lib/Prophet/Replica/sqlite.pm b/lib/Prophet/Replica/sqlite.pm
index 75cf90c..302901c 100644
--- a/lib/Prophet/Replica/sqlite.pm
+++ b/lib/Prophet/Replica/sqlite.pm
@@ -427,12 +427,13 @@ sub traverse_changesets {
         my $data;
         if ( $args{load_changesets} ) {
             $data = $self->_load_changeset_from_db( sequence_no => $rev );
+            $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}->($data);
     }
 }
 
diff --git a/lib/Prophet/ReplicaFeedExporter.pm b/lib/Prophet/ReplicaFeedExporter.pm
index 626c253..21a75a9 100644
--- a/lib/Prophet/ReplicaFeedExporter.pm
+++ b/lib/Prophet/ReplicaFeedExporter.pm
@@ -39,15 +39,15 @@ sub export {
     $self->source_replica->resolution_db_handle->traverse_changesets(
         after    => 0,
         callback => sub {
-            my $cs = shift;
-            $self->output( $self->format_resolution_changeset($cs));
+            my %args = shift;
+            $self->output( $self->format_resolution_changeset($args{changeset}));
         }
     );
     $self->source_replica->traverse_changesets(
         after    => 0,
         callback => sub {
-            my $cs = shift;
-            $self->output( $self->format_changeset($cs));
+            my %args = (@_);
+            $self->output( $self->format_changeset($args{changeset}));
         }
     );
     $self->output( tag( 'updated', $feed_updated ));
diff --git a/lib/Prophet/Server/View.pm b/lib/Prophet/Server/View.pm
index 8db284b..6d761c6 100644
--- a/lib/Prophet/Server/View.pm
+++ b/lib/Prophet/Server/View.pm
@@ -283,10 +283,9 @@ sub generate_changeset_feed {
     $handle->traverse_changesets(
         after    => $start,
         callback => sub {
-            my $change = shift;
-
+            my %args = (@_);
             $feed->add_entry(
-                title => 'Changeset ' . $change->sequence_no,
+                title => 'Changeset ' . $args{changeset}->sequence_no,
                 # need uuid or absolute link :(
                 category => 'Changeset',
             );

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



More information about the Bps-public-commit mailing list