[Bps-public-commit] r13809 - in sd/trunk/lib/App/SD/Replica: Hiveminder RT

clkao at bestpractical.com clkao at bestpractical.com
Fri Jul 4 10:40:18 EDT 2008


Author: clkao
Date: Fri Jul  4 10:40:04 2008
New Revision: 13809

Modified:
   sd/trunk/lib/App/SD/Replica/Hiveminder/PullEncoder.pm
   sd/trunk/lib/App/SD/Replica/RT.pm
   sd/trunk/lib/App/SD/Replica/RT/PullEncoder.pm

Log:
* is_empty is now !has_changes.
* fix the setup logic for rt replica as well.


Modified: sd/trunk/lib/App/SD/Replica/Hiveminder/PullEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/Hiveminder/PullEncoder.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/Hiveminder/PullEncoder.pm	Fri Jul  4 10:40:04 2008
@@ -75,7 +75,7 @@
         }
 
         $self->translate_props($changeset);
-        unshift @changesets, $changeset unless $changeset->is_empty;
+        unshift @changesets, $changeset if $changeset->has_changes;
     }
     return \@changesets;
 }

Modified: sd/trunk/lib/App/SD/Replica/RT.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/RT.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/RT.pm	Fri Jul  4 10:40:04 2008
@@ -13,7 +13,7 @@
 use Memoize;
 use constant scheme => 'rt';
 
-has rt => ( isa => 'Str', is => 'rw');
+has rt => ( isa => 'RT::Client::REST', is => 'rw');
 has rt_url => ( isa => 'Str', is => 'rw');
 has rt_queue => ( isa => 'Str', is => 'rw');
 has rt_query => ( isa => 'Str', is => 'rw');
@@ -70,6 +70,18 @@
 
 =cut
 
+# XXX: this should be called from superclass, or better, have individual attributes have their own builders.
+
+around 'new' => sub {
+    my ($next, $self, @args) = @_;
+    warn "around $self $next";
+    my $ret = $self->$next(@args);
+    $ret->setup;
+    warn "==> $ret";
+    return $ret;
+};
+
+
 use File::Temp 'tempdir';
 
 sub setup {
@@ -80,7 +92,7 @@
     require RT::Client::REST::User;
     require RT::Client::REST::Ticket;
 
-    my ( $server, $type, $query ) = $self->{url} =~ m/^(.*?)\|(.*?)\|(.*)$/
+    my ( $server, $type, $query ) = $self->{url} =~ m/^rt:(.*?)\|(.*?)\|(.*)$/
         or die "Can't parse rt server spec";
     my $uri = URI->new($server);
     my ( $username, $password );
@@ -98,8 +110,6 @@
 
     $self->rt->login( username => $username, password => $password );
 
-    $self->SUPER::setup(@_);
-
 }
 
 sub record_pushed_transactions {

Modified: sd/trunk/lib/App/SD/Replica/RT/PullEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/RT/PullEncoder.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/RT/PullEncoder.pm	Fri Jul  4 10:40:04 2008
@@ -31,7 +31,7 @@
     my @changesets;
     for my $txn ( sort { $b->{'id'} <=> $a->{'id'} } @{ $args{'transactions'} } ) {
             my $changeset = $self->txn_to_changeset($txn, $ticket, $create_state);
-            unshift @changesets, $changeset unless $changeset->is_empty;
+            unshift @changesets, $changeset if $changeset->has_changes;
         }
 
     return \@changesets;



More information about the Bps-public-commit mailing list