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

jesse jesse at bestpractical.com
Thu Jun 4 12:52:53 EDT 2009


The branch, master has been updated
       via  adb203dde5130a3a6922e3fe804a1d88a9bc00e6 (commit)
       via  5fc301e5745544bef838addc9422566e09808c09 (commit)
       via  d6b64c3c789bd43abc190fdfbb99857a5d8299e4 (commit)
       via  5792d21821ef37c44eda97360bca16fb6190b758 (commit)
       via  cf1ed5fb76848f80dcf232e15b147cefb7659ffb (commit)
      from  3942ad3afb4e724c552c8657fcc27dbfd11086c2 (commit)

Summary of changes:
 lib/App/SD/ForeignReplica.pm             |   28 +++++++++++++++++++---------
 lib/App/SD/ForeignReplica/PullEncoder.pm |    2 +-
 lib/App/SD/Replica/gcode/PullEncoder.pm  |   11 +++--------
 lib/App/SD/Util.pm                       |    3 ++-
 t/sd-hm/tag.t                            |    2 +-
 5 files changed, 26 insertions(+), 20 deletions(-)

- Log -----------------------------------------------------------------
commit cf1ed5fb76848f80dcf232e15b147cefb7659ffb
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 4 12:48:53 2009 -0400

    added a diag in case of a test fail

diff --git a/t/sd-hm/tag.t b/t/sd-hm/tag.t
index f6b5894..ceba4d3 100644
--- a/t/sd-hm/tag.t
+++ b/t/sd-hm/tag.t
@@ -56,7 +56,7 @@ my ( $ret, $out, $err );
 
 my $sd_hm_url = "hm:$URL|tag=mytag";
 eval { ( $ret, $out, $err ) = run_script( 'sd', [ 'clone', '--from', $sd_hm_url ] ) };
-
+diag($err) if ($err);
 my ($flyman_uuid, $flyman_id );
 {
     run_output_matches( 'sd', [ 'ticket', 'list', '--regex', '.' ], [qr/(.*?)(?{ $flyman_uuid = $1 }) Fly Man (.*)/] );

commit 5792d21821ef37c44eda97360bca16fb6190b758
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 4 12:49:31 2009 -0400

    Added validation to parse_string_to_datetime to catch it being accidentally called as a method

diff --git a/lib/App/SD/Util.pm b/lib/App/SD/Util.pm
index 415b471..5b91200 100644
--- a/lib/App/SD/Util.pm
+++ b/lib/App/SD/Util.pm
@@ -1,8 +1,9 @@
 package App::SD::Util;
 use DateTime;
+use Params::Validate qw/:all/;
 
 sub string_to_datetime {
-    my $date= shift;
+    my ($date)= validate_pos(@_, { type => SCALAR | UNDEF} );
     if ($date =~ /^(\d{4})-(\d{2})-(\d{2})[T\s](\d{1,2}):(\d{2}):(\d{2})Z?$/ ){
         my ($year,$month,$day, $hour,$min,$sec) = ($1,$2,$3,$4,$5,$6);
         my $dt = DateTime->new( year => $year,

commit d6b64c3c789bd43abc190fdfbb99857a5d8299e4
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 4 12:50:26 2009 -0400

    Quiet down debugging output when pulling from google code

diff --git a/lib/App/SD/Replica/gcode/PullEncoder.pm b/lib/App/SD/Replica/gcode/PullEncoder.pm
index 6247fcc..e510f04 100644
--- a/lib/App/SD/Replica/gcode/PullEncoder.pm
+++ b/lib/App/SD/Replica/gcode/PullEncoder.pm
@@ -71,7 +71,7 @@ sub find_matching_tickets {
     my %query                  = (@_);
     my $last_changeset_seen_dt = $self->_only_pull_tickets_modified_after()
       || DateTime->from_epoch( epoch => 0 );
-    $self->sync_source->log("Searching for tickets");
+    $self->sync_source->log("Searching for tickets. This can take a very long time on initial sync or if you haven't synced in a long time.");
     require Net::Google::Code::Issue::Search;
     my $search = Net::Google::Code::Issue::Search->new(
         project => $self->sync_source->project,
@@ -91,9 +91,7 @@ sub _only_pull_tickets_modified_after {
     my $last_pull = $self->sync_source->upstream_last_modified_date();
     return unless $last_pull;
     my $before = App::SD::Util::string_to_datetime($last_pull);
-    die "Failed to parse '" . $self->sync_source->upstream_last_modified_date() . "' as a timestamp"
-        unless ($before);
-
+    $self->log_debug( "Failed to parse '" . $self->sync_source->upstream_last_modified_date() . "' as a timestamp. That means we have to sync ALL history") unless ($before);
     return $before;
 }
 
@@ -192,7 +190,7 @@ sub find_matching_transactions {
             object    => $txn,
           };
     }
-    $self->sync_source->log('Done looking at pulled txns');
+    $self->sync_source->log_debug('Done looking at pulled txns');
 
     return \@txns;
 }
@@ -209,8 +207,6 @@ sub transcode_create_txn {
       $self->resolve_user_id_to( email_address => $create_data->{reporter} );
     my $created = $final_data->{created};
 
-    warn "recording create of "
-      . $self->sync_source->uuid_for_remote_id($ticket_id);
     my $changeset = Prophet::ChangeSet->new(
         {
             original_source_uuid => $ticket_uuid,
@@ -269,7 +265,6 @@ sub transcode_one_txn {
     my $ticket_id   = $newer_ticket_state->{ $self->sync_source->uuid . '-id' };
     my $ticket_uuid =
       $self->sync_source->uuid_for_remote_id( $ticket_id );
-    warn "Recording an update to " . $ticket_uuid;
     my $changeset = Prophet::ChangeSet->new(
         {
             original_source_uuid => $ticket_uuid,

commit 5fc301e5745544bef838addc9422566e09808c09
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 4 12:50:45 2009 -0400

    When pulling from a foreign replica, transactions should be ordered by
    absolute date, rather than by ticket and then date. - This will help
    resume

diff --git a/lib/App/SD/ForeignReplica/PullEncoder.pm b/lib/App/SD/ForeignReplica/PullEncoder.pm
index f418b77..c44b8c0 100644
--- a/lib/App/SD/ForeignReplica/PullEncoder.pm
+++ b/lib/App/SD/ForeignReplica/PullEncoder.pm
@@ -31,7 +31,7 @@ sub run {
         ( $last_modified, $changesets ) = $self->transcode_ticket( $ticket, $last_modified );
         unshift @changesets, @$changesets;
     }
-    return (\@changesets, $last_modified);
+    return [ sort { App::SD::Util::string_to_datetime($a->created) <=> App::SD::Util::string_to_datetime( $b->created) } @changesets];
 }
 
 sub ticket_last_modified { undef}

commit adb203dde5130a3a6922e3fe804a1d88a9bc00e6
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 4 12:52:28 2009 -0400

    Move "post-integrate" logic into the new post_integrate hook rather than just blindly doing it on any traversal

diff --git a/lib/App/SD/ForeignReplica.pm b/lib/App/SD/ForeignReplica.pm
index 85f55c2..1b2a500 100644
--- a/lib/App/SD/ForeignReplica.pm
+++ b/lib/App/SD/ForeignReplica.pm
@@ -157,19 +157,29 @@ sub traverse_changesets {
 
     Prophet::App->require( $self->pull_encoder());
     my $recoder = $self->pull_encoder->new( { sync_source => $self } );
-    my ($changesets, $last_modified) = $recoder->run(after => $args{'after'});
+    my ( $changesets ) = $recoder->run( after => $args{'after'} );
     for my $changeset (@$changesets) {
-        $args{callback}->(changeset=> $changeset);
+        $args{callback}->(
+            changeset                 => $changeset,
+            after_integrate_changeset => sub {
+                $self->record_last_changeset_from_replica(
+                    $changeset->original_source_uuid => $changeset->original_sequence_no );
+
+              # 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.
+                my $previously_modified
+                    = App::SD::Util::string_to_datetime( $self->upstream_last_modified_date );
+                my $created_datetime = App::SD::Util::string_to_datetime( $changeset->created );
+                $self->record_upstream_last_modified_date( $changeset->created )
+                    if ( ( $created_datetime ? $created_datetime->epoch : 0 )
+                    > ( $previously_modified ? $previously_modified->epoch : 0 ) );
+
+            }
+        );
 
-        # 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 ) );
-
 }
 
 

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



More information about the Bps-public-commit mailing list