[Bps-public-commit] r16302 - in sd/trunk/lib/App/SD: CLI/Model Replica Replica/hm Replica/rt

jesse at bestpractical.com jesse at bestpractical.com
Wed Oct 15 02:43:34 EDT 2008


Author: jesse
Date: Wed Oct 15 02:43:34 2008
New Revision: 16302

Modified:
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Show.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Update.pm
   sd/trunk/lib/App/SD/CLI/Model/Ticket.pm
   sd/trunk/lib/App/SD/Replica/hm.pm
   sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm
   sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm
   sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm

Log:
* kill foreach in favor of for

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm	Wed Oct 15 02:43:34 2008
@@ -25,7 +25,7 @@
 
         (my $props_ref, my $comment) = $self->parse_record_string($ticket);
 
-        foreach my $prop (keys %$props_ref) {
+        for my $prop (keys %$props_ref) {
             $self->set_prop($prop => $props_ref->{$prop});
         }
 

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm	Wed Oct 15 02:43:34 2008
@@ -23,7 +23,7 @@
     my @comments = sort by_creation_date @{$record->comments};
     if (@comments) {
         print "\n=head1 COMMENTS\n\n";
-        foreach my $comment (@comments) {
+        for my $comment (@comments) {
             my $creator = $comment->prop('creator');
             my $created = $comment->prop('created');
             my $content = $comment->prop('content');

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Show.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Show.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Show.pm	Wed Oct 15 02:43:34 2008
@@ -26,7 +26,7 @@
     my @comments = sort by_creation_date @{$record->comments};
     if (@comments) {
         print "\n= COMMENTS\n\n";
-        foreach my $comment (@comments) {
+        for my $comment (@comments) {
             my $creator = $comment->prop('creator');
             my $created = $comment->prop('created');
             my $content = $comment->prop('content');

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Update.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Update.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Update.pm	Wed Oct 15 02:43:34 2008
@@ -34,14 +34,14 @@
     # if a formerly existing prop was removed from the output, delete it
     # (deleting is currently the equivalent of setting to '', and
     # we want to do this all in one changeset)
-    foreach my $prop (keys %{$record->get_props}) {
+    for my $prop (keys %{$record->get_props}) {
         unless ($prop =~ $do_not_edit) {
             $props_ref->{$prop} = '' if !exists $props_ref->{$prop};
         }
     }
 
     # don't add props that didn't change to the changeset
-    foreach my $prop (keys %$props_ref) {
+    for my $prop (keys %$props_ref) {
         delete $props_ref->{$prop}
             if $props_ref->{$prop} eq $record->prop($prop);
     }

Modified: sd/trunk/lib/App/SD/CLI/Model/Ticket.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Model/Ticket.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Model/Ticket.pm	Wed Oct 15 02:43:34 2008
@@ -125,7 +125,7 @@
     # the props that will be added to the new ticket and prevent
     # users from being able to break things by changing props
     # that shouldn't be changed, such as uuid
-    foreach my $prop ($record->props_to_show) {
+    for my $prop ($record->props_to_show) {
         if ($prop =~ $props_not_to_edit) {
             if ($prop eq 'id' && $update) {
                 # id isn't a *real* prop, so we have to mess with it some more
@@ -202,7 +202,7 @@
     my %new_props;
     my $comment = '';
 
-    foreach my $line (@lines) {
+    for my $line (@lines) {
         if ($line =~ separator_pattern()) {
             $last_seen_sep = $1;
         } elsif ($line =~ comment_pattern() or

Modified: sd/trunk/lib/App/SD/Replica/hm.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/hm.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/hm.pm	Wed Oct 15 02:43:34 2008
@@ -123,7 +123,7 @@
 
     my $txns = $self->hm->search( 'TaskTransaction', task_id => $args{task} ) || [];
     my @matched;
-    foreach my $txn (@$txns) {
+    for my $txn (@$txns) {
         next if $txn->{'id'} < $args{'starting_transaction'};    # Skip things we've pushed
 
         next if $self->prophet_has_seen_transaction( $txn->{'id'} );

Modified: sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm	Wed Oct 15 02:43:34 2008
@@ -31,7 +31,7 @@
         my $change = $self->$method( task => $args{'task'}, transaction => $txn );
 
         $changeset->add_change( { change => $change } );
-        foreach my $email ( @{ $txn->{email_entries} } ) {
+        for my $email ( @{ $txn->{email_entries} } ) {
             if ( my $sub = $self->can( '_recode_email_' . 'blah' ) ) {
                 $sub->(
                     $self,
@@ -80,7 +80,7 @@
     } );
 
     $args{'task'}{ $source->uuid .'-'. $_ } = delete $args{'task'}{$_}
-        foreach qw(id record_locator);
+        for qw(id record_locator);
 
     while( my ($k, $v) = each %{ $args{'task'} } ) {
         $res->add_prop_change( { name => $k, old => undef, new => $v } );
@@ -99,7 +99,7 @@
         change_type => 'update_file'
     } );
 
-    foreach my $entry ( @{ $args{'transaction'}{'history_entries'} } ) {
+    for my $entry ( @{ $args{'transaction'}{'history_entries'} } ) {
         $self->add_prop_change(
             change         => $res,
             history_entry  => $entry,

Modified: sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm	Wed Oct 15 02:43:34 2008
@@ -112,7 +112,7 @@
     return $attr unless $source_props;
 
     my %source_props = %$source_props;
-    foreach (grep exists $source_props{$_}, qw(group owner requestor)) {
+    for (grep exists $source_props{$_}, qw(group owner requestor)) {
         $source_props{$_.'_id'} = delete $source_props{$_};
     }
 

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 15 02:43:34 2008
@@ -77,14 +77,14 @@
     $ticket->{'id'} =~ s/^ticket\///g;
 
     $ticket->{ $self->sync_source->uuid . '-' . lc($_) } = delete $ticket->{$_}
-        foreach qw(Queue id);
-    delete $ticket->{$_} foreach
+        for qw(Queue id);
+    delete $ticket->{$_} for
         grep !defined $ticket->{$_} || $ticket->{$_} eq '',
         keys %$ticket;
     $ticket->{$_} = $self->date_to_iso( $ticket->{$_} )
-        foreach qw(Created Resolved Told LastUpdated Due Starts Started);
+        for qw(Created Resolved Told LastUpdated Due Starts Started);
     $ticket->{$_} =~ s/ minutes$//
-        foreach grep defined $ticket->{$_}, qw(TimeWorked TimeLeft TimeEstimated);
+        for grep defined $ticket->{$_}, qw(TimeWorked TimeLeft TimeEstimated);
     $ticket->{'Status'} =~ s/^(resolved|rejected)$/closed/;
     return $ticket;
 }
@@ -125,7 +125,7 @@
             type      => 'ticket'
         );
         if ( my $attachments = delete $txn_hash->{'Attachments'} ) {
-            foreach my $attach ( split( /\n/, $attachments ) ) {
+            for my $attach ( split( /\n/, $attachments ) ) {
                 next unless ( $attach =~ /^(\d+):/ );
                 my $id = $1;
                 my $a  = $rt_handle->get_attachment( parent_id => $args{'ticket'}, id        => $id);
@@ -166,7 +166,7 @@
             $self->translate_prop_names($changeset);
 
             if (my $attachments = delete $txn->{'_attachments'}) {
-               foreach my $attach (@$attachments) { 
+               for my $attach (@$attachments) { 
                     $self->_recode_attachment_create( ticket => $ticket, txn => $txn, changeset =>$changeset, attachment => $attach); 
                }
             }



More information about the Bps-public-commit mailing list