[Bps-public-commit] r16604 - sd/trunk/lib/App/SD/Replica/rt

ruz at bestpractical.com ruz at bestpractical.com
Wed Oct 29 15:58:19 EDT 2008


Author: ruz
Date: Wed Oct 29 15:58:05 2008
New Revision: 16604

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

Log:
* lower code deepness

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	Wed Oct 29 15:58:05 2008
@@ -144,39 +144,41 @@
 sub transcode_one_txn {
     my ($self, $txn, $ticket) = (@_);
     
-        if ( my $sub = $self->can( '_recode_txn_' . $txn->{'Type'} ) ) {
-            my $changeset = Prophet::ChangeSet->new(
-                {   original_source_uuid => $self->sync_source->uuid,
-                    original_sequence_no => $txn->{'id'},
-                    creator => $self->resolve_user_id_to( email_address => $txn->{'Creator'} ),
-                }
-            );
-
-            if ( ( $txn->{'Ticket'} ne $ticket->{$self->sync_source->uuid . '-id'} ) && $txn->{'Type'} !~ /^(?:Comment|Correspond)$/ ) {
-                warn "Skipping a data change from a merged ticket" . $txn->{'Ticket'} . ' vs ' . $ticket->{$self->sync_source->uuid . '-id'};
-                next;
-            }
-
+    my $sub = $self->can( '_recode_txn_' . $txn->{'Type'} );
+    unless ( $sub ) {
+        die "Transaction type $txn->{Type} (for transaction $txn->{id}) not implemented yet";
+    }
 
+    my $changeset = Prophet::ChangeSet->new(
+        {   original_source_uuid => $self->sync_source->uuid,
+            original_sequence_no => $txn->{'id'},
+            creator => $self->resolve_user_id_to( email_address => $txn->{'Creator'} ),
+        }
+    );
 
-            delete $txn->{'OldValue'} if ( $txn->{'OldValue'} eq '');
-            delete $txn->{'NewValue'} if ( $txn->{'NewValue'} eq '');
+    if ( $txn->{'Ticket'} ne $ticket->{$self->sync_source->uuid . '-id'}
+        && $txn->{'Type'} !~ /^(?:Comment|Correspond)$/
+    ) {
+        warn "Skipping a data change from a merged ticket" . $txn->{'Ticket'}
+            .' vs '. $ticket->{$self->sync_source->uuid . '-id'};
+        next;
+    }
 
-            $sub->( $self, ticket => $ticket, txn          => $txn, changeset    => $changeset);
-            $self->translate_prop_names($changeset);
+    delete $txn->{'OldValue'} if ( $txn->{'OldValue'} eq '');
+    delete $txn->{'NewValue'} if ( $txn->{'NewValue'} eq '');
 
-            if (my $attachments = delete $txn->{'_attachments'}) {
-               for my $attach (@$attachments) { 
-                    $self->_recode_attachment_create( ticket => $ticket, txn => $txn, changeset =>$changeset, attachment => $attach); 
-               }
-            }
+    $sub->( $self, ticket => $ticket, txn          => $txn, changeset    => $changeset);
+    $self->translate_prop_names($changeset);
 
-            return $changeset;
-        } else {
-            die "Transaction type $txn->{Type} (for transaction $txn->{id}) not implemented yet";
-        }
+    if (my $attachments = delete $txn->{'_attachments'}) {
+       for my $attach (@$attachments) { 
+            $self->_recode_attachment_create( ticket => $ticket, txn => $txn, changeset =>$changeset, attachment => $attach); 
+       }
     }
 
+    return $changeset;
+}
+
 
 sub _recode_attachment_create {
     my $self   = shift;



More information about the Bps-public-commit mailing list