[Bps-public-commit] r11509 - in SVN-PropDB: . doc lib/Prophet/Sync/Source

jesse at bestpractical.com jesse at bestpractical.com
Fri Apr 4 19:56:16 EDT 2008


Author: jesse
Date: Fri Apr  4 19:56:15 2008
New Revision: 11509

Modified:
   SVN-PropDB/   (props changed)
   SVN-PropDB/doc/todo
   SVN-PropDB/lib/Prophet/Sync/Source.pm
   SVN-PropDB/lib/Prophet/Sync/Source/RT.pm

Log:
 r29192 at 68-246-40-124:  jesse | 2008-04-04 13:56:04 -1000
 * Do a slightly better job not pulling transactions from a remote RT when we know we've seen them


Modified: SVN-PropDB/doc/todo
==============================================================================
--- SVN-PropDB/doc/todo	(original)
+++ SVN-PropDB/doc/todo	Fri Apr  4 19:56:15 2008
@@ -1,33 +1,26 @@
-
 Todo
 
+
+- prophet databases need uuids.
+    - each replica should know the uuid of the database it is a replica of
+    - merging between replicas with different uuids should require a 'force' argument of some kind.
+
 - refactor Source::integrate_changeset to get the merge ticket and let the source(dst) decide how to record them, rather than having handle does the job
 - also need to send along all merge tickets we have
 
 
--  ::CLI should automatically discover an app's model class based on the type name @done
-- Creation of bug tracking model classes @done
 - validation on bug tracker fields
-	- status @done
 	- severity
 
 - ability to add comments to a bug (visible history entries)
-    - relations between models @done
     - maybe long-prop edits
 
 - push to a remote prophet
-    - find out what the remote _would_ pull by inspecting its merge tickets on  @done
-            - current replica @done
-        - once we do that, we can find out who _we_ have synced from after that point, right? Then we want: @done
-            - anyone we have a merge ticket for _since_ the last time the other party saw us. @done
             
     - bundle all changesets newer than that which we know the other party hasn't seen up as a serialized structure (FeedSync? Storable ;)?)
     - send them to remote to "pull from textfile
-    - nobu @done
 
 - pull from a remote RT by url and query
-    - get RT to give us a list of ticket records matching our query @done
-    - get rt ro give us a list of history entries on those ticket records @done
     - be able to tell RT to only give us history entries newer than the $DATE of RT history entry with ID #1234 (which is the sequence number we used for the merge ticket from the remote RT).
 
     - massage this crap into a sequence of prophet changesets
@@ -58,54 +51,8 @@
 
 
 
-Bug tracker:
+Archive:
 
-     summary  		RT: subject
-     status			RT: status(new,open,stalled,resolved, rejected)
-     severity		
-     custom fields	RT: cf-*
-     owner			RT: owner
-     keywords/tags	 
-[csv]reported by		RT: requestors
-     comments		RT: comment/correspond
-   					RT: Queue
-   					RT: priority
-   NO					RT: initial_priority
-   NO					RT: final_priority
-   					RT: time_estimated
-   					RT: time_worked
-   					RT: time_left
-[dt]				RT: created
-[dt]    			RT: starts
-   					RT: started
-   					RT: lastupdated
-   					RT: resolved
-    NO				RT: told (last user contact)
-[csv] 				RT: links * many
-[csv]   				DependsOn
-[csv]   				DependedOnBy
-[csv]   				RefersTo
-[csv]   				ReferredToBy
-[csv]					MemberOf
-[csv]					HasMember
-   					
-[csv]  				RT: admin_ccs
-[csv]				RT: ccs
-   		
-   		
-				
-   		
-   					
-    attachments / patches
-    
-    milestones?
-    custom fields with possible values - loaded from some other record/table
-    
-    comments
-        seperate records referring to the ticket uuid
-        
-
-Done, I think.
 
 - when committing any change:
     - record the original depot uuid and change sequence_no as revprops
@@ -126,3 +73,14 @@
 - handle conflicting conflict resolutions
 - base bug tracking schema
 
+-  ::CLI should automatically discover an app's model class based on the type name @done
+- Creation of bug tracking model classes @done
+	- status @done
+    - relations between models @done
+    - find out what the remote _would_ pull by inspecting its merge tickets on  @done
+            - current replica @done
+        - once we do that, we can find out who _we_ have synced from after that point, right? Then we want: @done
+            - anyone we have a merge ticket for _since_ the last time the other party saw us. @done
+    - nobu @done
+    - get RT to give us a list of ticket records matching our query @done
+    - get rt ro give us a list of history entries on those ticket records @done

Modified: SVN-PropDB/lib/Prophet/Sync/Source.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Sync/Source.pm	(original)
+++ SVN-PropDB/lib/Prophet/Sync/Source.pm	Fri Apr  4 19:56:15 2008
@@ -290,20 +290,42 @@
     return $records;
 }
 
-=head2 news_changesets_for
+=head2 news_changesets_for Prophet::Sync::Source
 
-Returns the local changesets that are new to the replica $other.
+Returns the local changesets that have not yet been seen by the replica we're passing in.
 
 =cut
 
 sub new_changesets_for {
-    my ( $self, $other ) = @_;
+    my $self = shift;
+    my (  $other ) = validate_pos(@_, { isa => 'Prophet::Sync::Source'});
 
-    my $since = $other->last_changeset_from_source( $self->uuid );
+    return [ 
+        grep { $self->should_send_changeset( changeset => $_, to => $other ) }
+                    @{ $self->fetch_changesets( after => $other->last_changeset_from_source( $self->uuid ) ) } 
+        ];
+}
+
+=head2 should_send_changeset { to => Prophet::Sync::Source, changeset => Prophet::ChangeSet }
 
-    return [ grep { !( $_->is_nullification || $_->is_resolution ) && !$other->has_seen_changeset($_) }
-            @{ $self->fetch_changesets( after => $since ) } ];
+Returns true if the replica C<to> hasn't yet seen the changeset C<changeset>
 
+
+=cut
+
+sub should_send_changeset {
+    my $self = shift;
+    my %args = validate(@_, { to => { isa => 'Prophet::Sync::Source'}, changeset =>{ isa=> 'Prophet::ChangeSet' }});
+    
+     return undef if ( $args{'changeset'}->is_nullification || $args{'changeset'}->is_resolution );
+     return undef if $args{'to'}->has_seen_changeset($args{'changeset'});
+     
+    return 1;     
 }
 
+    
+    
+    
+
+
 1;

Modified: SVN-PropDB/lib/Prophet/Sync/Source/RT.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Sync/Source/RT.pm	(original)
+++ SVN-PropDB/lib/Prophet/Sync/Source/RT.pm	Fri Apr  4 19:56:15 2008
@@ -76,11 +76,27 @@
                                     rt => $self->rt, 
                                     id => $args{'ticket'} )->transactions->get_iterator->()
                             ) {
-            last if $txn->id <= $self->last_changeset_from_source();
+            last if $txn->id <= $self->last_changeset_from_source( $changeset->original_source_uuid  );
             $self->record_pushed_transaction(transaction => $txn->id, changeset => $args{'changeset'});
         }
 }
 
+=head2 prophet_has_seen_transaction $transaction_id
+
+Given an transaction id, will return true if this transaction originated in Prophet 
+and was pushed to RT or originated in RT and has already been pulled to the prophet replica.
+
+=cut
+
+sub  prophet_has_seen_transaction {
+    my $self = shift;
+    my ($id) = validate_pos(@_, 1 );
+    my $cache = App::Cache->new( { ttl => 60 * 60 } );                                                
+    return $cache->get(
+        $self->uuid,
+        '-txn-' . $id)
+         
+}
 
 sub record_pushed_transaction {
     my $self  = shift;
@@ -97,18 +113,28 @@
     );
 }
 
+
 sub get_remote_id_for {
     my ( $self, $ticket_uuid ) = @_;
-
     # XXX: should not access CLI handle
     my $ticket = Prophet::Record->new( handle => Prophet::CLI->new->handle, type => 'ticket' );
     $ticket->load( uuid => $ticket_uuid );
     return $ticket->prop( $self->uuid . '-id' );
 }
 
+
+
+=head2 has_seen_changeset Prophet::ChangeSet
+
+Returns true if the RT instance we're pushing to has seen the changeset we've passed in.
+
+
+=cut
+
 sub has_seen_changeset {
-    my ( $self, $changeset ) = @_;
-    # XXXX: this is actually not right, because new_changesets_for
+    my $self = shift;
+    my ($changeset) = validate_pos( @_, { isa => 'Prophet::ChangeSet' } );
+        # XXXX: this is actually not right, because new_changesets_for
     # is calling has_seen_changeset on $other, rather than us
     my $cache = App::Cache->new( { ttl => 60 * 60 } );    # la la la
     my $txn_id = $changeset->original_sequence_no;
@@ -116,7 +142,6 @@
     # XXX: extract the original txn id from $changeset
     #    warn "===> ? ".$self->uuid,'-txn-'.$txn_id;
     my $ret = $cache->get( $self->uuid, '-txn-' . $txn_id );
-
     #    warn "==> $ret";
     return $ret;
 }
@@ -635,6 +660,9 @@
     my $ticket = shift;
     my @txns;
     for my $txn ( $self->rt->get_transaction_ids( parent_id => $ticket ) ) {
+    
+        next if $self->prophet_has_seen_transaction($txn);    
+    
         push @txns, $self->rt->get_transaction( parent_id => $ticket, id => $txn, type => 'ticket' );
     }
     return \@txns;



More information about the Bps-public-commit mailing list