[Bps-public-commit] SD branch, master, updated. 4c3a92b82188a5f7d9f94131aa1216337ffeff62

jesse jesse at bestpractical.com
Mon Jun 8 15:54:14 EDT 2009


The branch, master has been updated
       via  4c3a92b82188a5f7d9f94131aa1216337ffeff62 (commit)
      from  5027d6850e3e2ddb77b6c8b57a0960101981434a (commit)

Summary of changes:
 lib/App/SD/ForeignReplica.pm |   39 +++++++++++++++++++++++++++++++++++++--
 1 files changed, 37 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 4c3a92b82188a5f7d9f94131aa1216337ffeff62
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Mon Jun 8 15:53:50 2009 -0400

    Added a "before_load_changeset" hook to SD in advance of the same in Prophet ; docs

diff --git a/lib/App/SD/ForeignReplica.pm b/lib/App/SD/ForeignReplica.pm
index 5198204..e66d4d1 100644
--- a/lib/App/SD/ForeignReplica.pm
+++ b/lib/App/SD/ForeignReplica.pm
@@ -1,6 +1,6 @@
 package App::SD::ForeignReplica;
 use Any::Moose;
-use Params::Validate;
+use Params::Validate qw/:all/;
 
 extends 'Prophet::ForeignReplica';
 sub integrate_changeset {
@@ -51,7 +51,21 @@ sub integrate_change {
     $recoder->integrate_change($change,$changeset);
 }
 
-# XXX TODO docs
+=head2 record_pushed_transactions
+
+Walk the set of transactions on the ticket whose id you've passed in, looking for updates by the 'current user' which happened after start_time and before now. Then mark those transactions as ones that originated in SD, so we don't accidentally push them later.
+
+=over
+
+=item ticket
+
+=item changeset
+
+=item start_time
+
+=back
+
+=cut
 
 sub record_pushed_transactions {
     my $self = shift;
@@ -152,6 +166,8 @@ sub traverse_changesets {
     my %args = validate( @_,
         {   after    => 1,
             callback => 1,
+            before_load_changeset_callback => { type => CODEREF, optional => 1},
+            reporting_callback => { type => CODEREF, optional => 1 },
         }
     );
 
@@ -159,6 +175,17 @@ sub traverse_changesets {
     my $recoder = $self->pull_encoder->new( { sync_source => $self } );
     my ( $changesets ) = $recoder->run( after => $args{'after'} );
     for my $changeset (@$changesets) {
+        if ( $args{'before_load_changeset_callback'} ) {
+            my $continue = $args{'before_load_changeset_callback'}->(
+                changeset_metadata => $self->_construct_changeset_index_entry($changeset)
+            );
+
+            next unless $continue;
+
+        }
+
+
+
         $args{callback}->(
             changeset                 => $changeset,
             after_integrate_changeset => sub {
@@ -177,11 +204,19 @@ sub traverse_changesets {
 
             }
         );
+        $args{reporting_callback}->($changeset) if ($args{reporting_callback});
 
     }
 
 }
 
+sub _construct_changeset_index_entry {
+    my $self = shift;
+    my $changeset = shift;
+
+    return [ $changeset->sequence_no, $changeset->original_source_uuid, $changeset->original_sequence_no, $changeset->calculate_sha1];
+
+}
 
 sub remote_uri_path_for_id {
     die "your subclass needds to implement this to be able to ".

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



More information about the Bps-public-commit mailing list