[Bps-public-commit] r12265 - in Shipwright/trunk: lib/Shipwright/Script

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon May 12 12:38:11 EDT 2008


Author: sunnavy
Date: Mon May 12 12:38:10 2008
New Revision: 12265

Modified:
   Shipwright/trunk/   (props changed)
   Shipwright/trunk/lib/Shipwright/Script/Flags.pm

Log:
 r12296 at sunnavys-mb:  sunnavy | 2008-05-13 00:16:43 +0800
 updated Flags.pm since flags method changed its api


Modified: Shipwright/trunk/lib/Shipwright/Script/Flags.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Flags.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Flags.pm	Mon May 12 12:38:10 2008
@@ -43,11 +43,11 @@
         log_file   => $self->log_file,
     );
 
-    my $old = $shipwright->backend->flags( dist => $self->dist ) || [];
+    my $flags = $shipwright->backend->flags;
 
     unless ( defined $self->add || defined $self->delete || defined $self->set )
     {
-        print join( ', ', @$old ), "\n";
+        print join( ', ', @{ $flags->{ $self->dist } || [] } ), "\n";
         return;
     }
 
@@ -55,30 +55,25 @@
         die 'you should specify one and only one of add, delete and set';
     }
 
-    my $new;
-
     if ( defined $self->add ) {
         $self->add( [ grep { /^\w+$/ } split /,\s*/, $self->add ] );
-        $new = [ uniq @{ $self->add }, @$old ];
+        $flags->{ $self->dist } =
+          [ uniq @{ $self->add }, @{ $flags->{ $self->dist } || [] } ];
     }
     elsif ( defined $self->delete ) {
         $self->delete( [ split /,\s*/, $self->delete ] );
         my %seen;    # lookup table
         @seen{ @{ $self->delete } } = ();
 
-        for (@$old) {
-            push( @$new, $_ ) unless exists $seen{$_};
-        }
+        @{ $flags->{ $self->dist } } =
+          grep { exists $seen{$_} } @{ $flags->{ $self->dist } || [] };
 
     }
     elsif ( defined $self->set ) {
-        $new = [ grep { /^\w+$/ } split /,\s*/, $self->set ];
+        $flags->{ $self->dist } = [ grep { /^\w+$/ } split /,\s*/, $self->set ];
     }
 
-    $shipwright->backend->flags(
-        dist  => $self->dist,
-        flags => $new,
-    );
+    $shipwright->backend->flags( $flags );
 
 }
 



More information about the Bps-public-commit mailing list