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

sunnavy at bestpractical.com sunnavy at bestpractical.com
Wed May 20 05:17:40 EDT 2009


The branch, master has been updated
       via  296c389728df2b46bdc4789bb4b4ad28ab681353 (commit)
       via  7f3a948407dc9fa682cf95093b015e8e0b984b21 (commit)
      from  52e2d13a80216c7018320af4f6635d89ca5bfcf6 (commit)

Summary of changes:
 lib/App/SD/Replica/gcode.pm             |   13 +++++++-
 lib/App/SD/Replica/gcode/PullEncoder.pm |   52 ++++++++-----------------------
 2 files changed, 25 insertions(+), 40 deletions(-)

- Log -----------------------------------------------------------------
commit 7f3a948407dc9fa682cf95093b015e8e0b984b21
Author: sunnavy <sunnavy at gmail.com>
Date:   Wed May 20 15:25:53 2009 +0800

    set PROP_MAP in gcode.pm

diff --git a/lib/App/SD/Replica/gcode.pm b/lib/App/SD/Replica/gcode.pm
index c6a2892..8a885cf 100644
--- a/lib/App/SD/Replica/gcode.pm
+++ b/lib/App/SD/Replica/gcode.pm
@@ -10,9 +10,20 @@ use Memoize;
 use constant scheme => 'gcode';
 use constant pull_encoder => 'App::SD::Replica::gcode::PullEncoder';
 use constant push_encoder => 'App::SD::Replica::gcode::PushEncoder';
+use Prophet::ChangeSet;
+
+our %PROP_MAP = (
+    summary  => 'summary',
+    status   => 'status',
+    owner    => 'owner',
+    reporter => 'reporter',
+    cc       => 'cc',
+    closed   => 'completed',
+    reported => 'created',
+    labels   => 'tags',
+);
 
 
-use Prophet::ChangeSet;
 has query => ( isa => 'Str', is => 'rw');
 has gcode => ( isa => 'Net::Google::Code', is => 'rw');
 has project => ( isa => 'Str', is => 'rw');
diff --git a/lib/App/SD/Replica/gcode/PullEncoder.pm b/lib/App/SD/Replica/gcode/PullEncoder.pm
index bfce8d8..efbdd5f 100644
--- a/lib/App/SD/Replica/gcode/PullEncoder.pm
+++ b/lib/App/SD/Replica/gcode/PullEncoder.pm
@@ -352,7 +352,7 @@ sub translate_prop_status {
     return lc($status);
 }
 
-my %PROP_MAP;
+my %PROP_MAP = %App::SD::Replica::gcode::PROP_MAP;
 
 sub translate_propnames {
     my $self      = shift;
@@ -363,18 +363,19 @@ sub translate_propnames {
 
         my @new_props;
         for my $prop ( $change->prop_changes ) {
-            next if ( ( $PROP_MAP{ lc( $prop->name ) } || '' ) eq '_delete' );
-            $prop->name( $PROP_MAP{ lc( $prop->name ) } )
-              if $PROP_MAP{ lc( $prop->name ) };
+            next
+              unless $PROP_MAP{ lc( $prop->name ) }
+                  && $PROP_MAP{ lc( $prop->name ) } ne '_delete';
 
-            # Normalize away undef -> "" and vice-versa
+            $prop->name( $PROP_MAP{ lc( $prop->name ) } );
+
+              # Normalize away undef -> "" and vice-versa
             for (qw/new_value old_value/) {
                 $prop->$_("") if !defined( $prop->$_() );
             }
             next if ( $prop->old_value eq $prop->new_value );
 
             push @new_props, $prop;
-
         }
         $change->prop_changes( \@new_props );
 

commit 296c389728df2b46bdc4789bb4b4ad28ab681353
Author: sunnavy <sunnavy at gmail.com>
Date:   Wed May 20 17:17:29 2009 +0800

    make use of PROP_MAP for gcode

diff --git a/lib/App/SD/Replica/gcode/PullEncoder.pm b/lib/App/SD/Replica/gcode/PullEncoder.pm
index efbdd5f..7cad1a8 100644
--- a/lib/App/SD/Replica/gcode/PullEncoder.pm
+++ b/lib/App/SD/Replica/gcode/PullEncoder.pm
@@ -12,6 +12,8 @@ has sync_source => (
     is  => 'rw',
 );
 
+my %PROP_MAP = %App::SD::Replica::gcode::PROP_MAP;
+
 sub ticket_id {
     my $self   = shift;
     return shift->id;
@@ -29,7 +31,7 @@ sub _translate_final_ticket_state {
         status      => $self->translate_prop_status( $ticket->status ),
         summary     => $ticket->summary,
         description => $ticket->description,
-        tags        => $ticket->labels,
+        tags        => (join ', ', @{$ticket->labels}),
         cc          => $ticket->cc,
     };
 
@@ -90,7 +92,7 @@ sub translate_ticket_state {
 
         my $updates = $txn->{object}->updates;
 
-        for my $prop (qw(owner status labels)) {
+        for my $prop (qw(owner status labels cc summary)) {
             my @adds;
             my @removes;
             my $values = delete $updates->{$prop};
@@ -100,13 +102,15 @@ sub translate_ticket_state {
                 }
                 if ( $value =~ /^\-(.*)$/ ) {
                     $value = $1;
-                    $earlier_state{$prop} =
-                      $self->warp_list_to_old_value( $earlier_state{$prop},
+                    $earlier_state{ $PROP_MAP{$prop} } =
+                      $self->warp_list_to_old_value(
+                        $earlier_state{ $PROP_MAP{$prop} },
                         $value, undef );
                 }
                 else {
-                    $earlier_state{$prop} =
-                      $self->warp_list_to_old_value( $earlier_state{$prop},
+                    $earlier_state{ $PROP_MAP{$prop} } =
+                      $self->warp_list_to_old_value(
+                        $earlier_state{ $PROP_MAP{$prop} },
                         undef, $value );
                 }
 
@@ -241,9 +245,9 @@ sub transcode_one_txn {
     my $props = $txn->updates;
     foreach my $prop ( keys %{ $props || {} } ) {
         $change->add_prop_change(
-            name => $prop,
-            old  => $txn->{pre_state}->{$prop},
-            new  => $txn->{post_state}->{$prop}
+            name => $PROP_MAP{$prop},
+            old  => $txn->{pre_state}->{$PROP_MAP{$prop}},
+            new  => $txn->{post_state}->{$PROP_MAP{$prop}}
         );
 
     }
@@ -352,37 +356,6 @@ sub translate_prop_status {
     return lc($status);
 }
 
-my %PROP_MAP = %App::SD::Replica::gcode::PROP_MAP;
-
-sub translate_propnames {
-    my $self      = shift;
-    my $changeset = shift;
-
-    for my $change ( $changeset->changes ) {
-        next unless $change->record_type eq 'ticket';
-
-        my @new_props;
-        for my $prop ( $change->prop_changes ) {
-            next
-              unless $PROP_MAP{ lc( $prop->name ) }
-                  && $PROP_MAP{ lc( $prop->name ) } ne '_delete';
-
-            $prop->name( $PROP_MAP{ lc( $prop->name ) } );
-
-              # Normalize away undef -> "" and vice-versa
-            for (qw/new_value old_value/) {
-                $prop->$_("") if !defined( $prop->$_() );
-            }
-            next if ( $prop->old_value eq $prop->new_value );
-
-            push @new_props, $prop;
-        }
-        $change->prop_changes( \@new_props );
-
-    }
-    return $changeset;
-}
-
 sub resolve_user_id_to {
     my $self = shift;
     my $to   = shift;

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



More information about the Bps-public-commit mailing list