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

jesse at bestpractical.com jesse at bestpractical.com
Fri Apr 4 06:08:18 EDT 2008


Author: jesse
Date: Fri Apr  4 06:08:17 2008
New Revision: 11494

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

Log:
 r29169 at 68-247-156-63:  jesse | 2008-04-03 23:16:47 -1000
 * Prophet can now commit back to an RT instance


Modified: SVN-PropDB/bin/sd
==============================================================================
--- SVN-PropDB/bin/sd	(original)
+++ SVN-PropDB/bin/sd	Fri Apr  4 06:08:17 2008
@@ -123,6 +123,18 @@
     # Trivial first pass:
 #    only support pull
     my $url = shift @ARGV;
+
+
+
+    local $ENV{PROPHET_RESOLVER} = 'Prompt';
+    my %args =  ( to => $url, from => "file://".$CLI->handle->repo_path );
+
+    $CLI->args(\%args);
+    $CLI->do_merge();
+
+
+
+return;
     my $source = Prophet::Sync::Source->new( { url => 'file://'.$CLI->handle->repo_path } );
     my $target = Prophet::Sync::Source->new( { url => $url });
 #    my $changesets = $source->new_changesets_for($target);

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 06:08:17 2008
@@ -125,7 +125,7 @@
     #   - merge tickets for the same
     # we'll want to skip or remove those changesets
 
-    return if $changeset->original_source_uuid eq $self->prophet_handle->uuid;
+    return if $changeset->original_source_uuid eq $self->uuid;
 
     $self->remove_redundant_data($changeset);    #Things we have already seen
 

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 06:08:17 2008
@@ -7,12 +7,14 @@
 use UNIVERSAL::require;
 use RT::Client::REST       ();
 use RT::Client::REST::User ();
+   use RT::Client::REST::Ticket;
+
 use Memoize;
 use Prophet::Handle;
 use Prophet::ChangeSet;
 use Prophet::Conflict;
 
-__PACKAGE__->mk_accessors(qw/prophet_handle ressource is_resdb rt rt_url rt_query/);
+__PACKAGE__->mk_accessors(qw/prophet_handle ressource is_resdb rt rt_url rt_queue rt_query/);
 
 our $DEBUG = $Prophet::Handle::DEBUG;
 
@@ -47,20 +49,40 @@
 
 =cut
 
+sub record_changeset_integration {
+    my ($self, $source_uuid, $source_seq) = @_;
+warn "H";
+    my $cache = App::Cache->new({ ttl => 60*60 }); # la la la
+    return $cache->set($self->uuid.'-'.$source_uuid, $source_seq);
+}
+
 
 
-sub integrate_changeset {
+sub record_integration_changeset {
+    warn "record_integration_changeset should be renamed to 'record_original_change";
+    my ($self, $changeset) = @_;
+    $self->record_changeset($changeset);
+
+    # does the merge ticket recording & _source_metadata (book keeping for what
+
+    $self->record_changeset_integration( $changeset->original_source_uuid, $changeset->original_sequence_no );
+}
+
+
+sub record_changeset {
     my $self = shift;
     my ($changeset) = validate_pos(@_, { isa => 'Prophet::ChangeSet'});
     $self->_integrate_change($_) for $changeset->changes;
+warn "J";
+
 }
 
 sub _integrate_change {
     my $self = shift;
     my ($change) = validate_pos(@_, { isa => 'Prophet::Change'});
-    
-    if ($change->node_type eq 'ticket' and $change->file_system_op eq 'add_file') {
-        $slef->integrate_ticket_create($change); # ALSO WANT CHANGESET
+
+    if ($change->node_type eq 'ticket' and $change->change_type eq 'add_file') {
+        $self->integrate_ticket_create($change); # ALSO WANT CHANGESET
     } elsif ($change->node_type eq 'comment') {
         $self->integrate_comment($change);
     } elsif ($change->node_type eq 'ticket') {
@@ -76,10 +98,10 @@
     my $self = shift;
     my ($change) = validate_pos(@_, { isa => 'Prophet::Change'});
     # Figure out the remote site's ticket ID for this change's record
-    my $ticket = RT::Client::REST::Ticket->new(rt => $self->rt);
-    $ticket->retrieve($remote_ticket_id);
-
-#        %{ $self->_recode_props_for_integrate($change)},
+    my $remote_ticket_id = ' AAAAAAH need to look up ';
+    my $ticket = RT::Client::REST::Ticket->new(rt => $self->rt,
+                id => $remote_ticket_id,
+                %{ $self->_recode_props_for_integrate($change)})->store();
 
     # for each propchange in this change 
         # apply the change to the remote RT server
@@ -93,16 +115,13 @@
    my $self = shift;
    my ($change) = validate_pos(@_, { isa => 'Prophet::Change'});
    # Build up a ticket object out of all the record's attributes
-   
-   
-   
+   warn "fooo";   
    my $ticket = RT::Client::REST::Ticket->new(
         rt => $self->rt,
+        queue => $self->rt_queue(),
         %{ $self->_recode_props_for_integrate($change)},
-    );
-    
-    $ticket->store("Not yet pulling in ticket creation comment");   
-   
+    )->store(text => "Not yet pulling in ticket creation comment");   
+   warn "Bar";
    # Grab the related comment
    # Create the ticket
    # fetch the ticket ID
@@ -111,6 +130,9 @@
 
 }
 
+sub conflicts_from_changeset { return; }
+
+sub accepts_changesets { 1 }
 
 sub _recode_props_for_integrate {
     my $self = shift;
@@ -121,16 +143,20 @@
     my %attr;
     my %cf;
     for my $key (keys %props) {
-    
+        next unless ($key =~ /^(summary|queue|status|owner|custom)/);
         if ($key =~ /^custom-(.*)/) {
             $cf{$1} = $props{$key};
+        } elsif ($key eq 'summary') { 
+            $attr{'subject'} = $props{summary};
+        
         } else {
+
             $attr{$key} = $props{$key};
         }
     }
     $attr{cf} = \%cf;
     return \%attr;
-    }
+}
 
 
 sub integrate_comment {
@@ -167,6 +193,7 @@
         $uri->userinfo(undef);
     }
     $self->rt_url("$uri");
+    $self->rt_queue($type);
     $self->rt_query($query. " AND Queue = '$type'");
     $self->rt( RT::Client::REST->new( server => $server ) );
     unless ($username) {
@@ -288,6 +315,7 @@
     return \@changesets;
 
 }
+sub _recode_txn_CommentEmailRecord     { return; }
 
 sub _recode_txn_EmailRecord     { return; }
 sub _recode_txn_AddReminder     { return; }
@@ -570,7 +598,7 @@
     return $cache->get($self->uuid.'-'.$source_uuid) || 0;
 }
 
-sub record_changeset_integration {
+sub _integration {
     my ($self, $source_uuid, $source_seq) = @_;
 
     my $cache = App::Cache->new({ ttl => 60*60 }); # la la la



More information about the Bps-public-commit mailing list