[Bps-public-commit] SD branch, master, updated. 3942ad3afb4e724c552c8657fcc27dbfd11086c2

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


The branch, master has been updated
       via  3942ad3afb4e724c552c8657fcc27dbfd11086c2 (commit)
      from  aad100ca4c96e0c91a6370f2fd34aa4ddf822b97 (commit)

Summary of changes:
 lib/App/SD/ForeignReplica.pm             |   14 +++++++++++++-
 lib/App/SD/ForeignReplica/PullEncoder.pm |   19 ++-----------------
 t/sd-rt/basic.t                          |    1 +
 3 files changed, 16 insertions(+), 18 deletions(-)

- Log -----------------------------------------------------------------
commit 3942ad3afb4e724c552c8657fcc27dbfd11086c2
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 4 11:03:22 2009 -0400

    Refactoring toward being able to --dry-run when pulling from a foreign replica

diff --git a/lib/App/SD/ForeignReplica.pm b/lib/App/SD/ForeignReplica.pm
index e7378ad..85f55c2 100644
--- a/lib/App/SD/ForeignReplica.pm
+++ b/lib/App/SD/ForeignReplica.pm
@@ -157,10 +157,22 @@ sub traverse_changesets {
 
     Prophet::App->require( $self->pull_encoder());
     my $recoder = $self->pull_encoder->new( { sync_source => $self } );
-    $recoder->run(after => $args{'after'}, callback => $args{'callback'});
+    my ($changesets, $last_modified) = $recoder->run(after => $args{'after'});
+    for my $changeset (@$changesets) {
+        $args{callback}->(changeset=> $changeset);
+
+        # We're treating each individual ticket in the foreign system as its own 'replica'
+        # because of that, we need to hint to the push side of the system what the most recent
+        # txn on each ticket it has.
+        $self->record_last_changeset_from_replica( $changeset->original_source_uuid => $changeset->original_sequence_no );
+    }
+
+    my $previously_modified = App::SD::Util::string_to_datetime( $self->upstream_last_modified_date );
+    $self->record_upstream_last_modified_date($last_modified) if ( ( $last_modified ? $last_modified->epoch : 0 ) > ( $previously_modified ? $previously_modified->epoch : 0 ) );
 
 }
 
+
 sub remote_uri_path_for_id {
     die "your subclass needds to implement this to be able to ".
         "map a remote id to /ticket/id or soemthing";
diff --git a/lib/App/SD/ForeignReplica/PullEncoder.pm b/lib/App/SD/ForeignReplica/PullEncoder.pm
index d142ca9..f418b77 100644
--- a/lib/App/SD/ForeignReplica/PullEncoder.pm
+++ b/lib/App/SD/ForeignReplica/PullEncoder.pm
@@ -5,7 +5,7 @@ use Params::Validate qw/validate/;
 
 sub run {
     my $self = shift;
-    my %args = validate( @_, { after => 1, callback => 1, } );
+    my %args = validate( @_, { after => 1});
 
     $self->sync_source->log('Finding matching tickets');
     my $tickets = $self->find_matching_tickets( query => $self->sync_source->query );
@@ -19,7 +19,6 @@ sub run {
     $self->sync_source->log_debug("Discovering ticket history");
 
     my ( $last_modified, $last_txn, @changesets );
-    my $previously_modified = App::SD::Util::string_to_datetime( $self->sync_source->upstream_last_modified_date );
 
     my $progress = Time::Progress->new();
     $progress->attr( max => $#$tickets );
@@ -32,21 +31,7 @@ sub run {
         ( $last_modified, $changesets ) = $self->transcode_ticket( $ticket, $last_modified );
         unshift @changesets, @$changesets;
     }
-
-    my $cs_counter = 0;
-    for my $changeset (@changesets) {
-        $args{callback}->($changeset);
-
-        # We're treating each individual ticket in the foreign system as its own 'replica'
-        # because of that, we need to hint to the push side of the system what the most recent
-        # txn on each ticket it has.
-        $self->sync_source->record_last_changeset_from_replica(
-            $changeset->original_source_uuid => $changeset->original_sequence_no );
-    }
-
-    $self->sync_source->record_upstream_last_modified_date($last_modified)
-        if ( ( $last_modified ? $last_modified->epoch : 0 ) > ( $previously_modified ? $previously_modified->epoch : 0 ) );
-
+    return (\@changesets, $last_modified);
 }
 
 sub ticket_last_modified { undef}
diff --git a/t/sd-rt/basic.t b/t/sd-rt/basic.t
index 4bc3d56..610df82 100644
--- a/t/sd-rt/basic.t
+++ b/t/sd-rt/basic.t
@@ -55,6 +55,7 @@ my $flyman_rt_id = $ticket->id;
 my ( $ret, $out, $err );
 ( $ret, $out, $err ) = run_script( 'sd', [ 'clone', '--from', $sd_rt_url ] );
 my ( $yatta_id, $flyman_id );
+diag($err) if ($err);
 run_output_matches(
     'sd',
     [ 'ticket', 'list', '--regex', '.' ],

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



More information about the Bps-public-commit mailing list