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

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Feb 11 21:43:43 EST 2008


Author: sunnavy
Date: Mon Feb 11 21:43:42 2008
New Revision: 10809

Modified:
   Shipwright/META.yml
   Shipwright/Makefile.PL
   Shipwright/lib/Shipwright/Script/Update.pm

Log:
refactor find_deps in update cmd

Modified: Shipwright/META.yml
==============================================================================
--- Shipwright/META.yml	(original)
+++ Shipwright/META.yml	Mon Feb 11 21:43:42 2008
@@ -30,7 +30,6 @@
   Hash::Merge: 0
   IPC::Run3: 0
   LWP::UserAgent: 0
-  List::MoreUtils: 0
   Log::Log4perl: 0
   Module::CoreList: 0
   UNIVERSAL::require: 0

Modified: Shipwright/Makefile.PL
==============================================================================
--- Shipwright/Makefile.PL	(original)
+++ Shipwright/Makefile.PL	Mon Feb 11 21:43:42 2008
@@ -16,7 +16,6 @@
 requires 'File::Slurp' => 0;
 requires 'Hash::Merge' => 0;
 requires 'IPC::Run3' => 0;
-requires 'List::MoreUtils' => 0;
 requires 'Log::Log4perl' => 0;
 requires 'LWP::UserAgent' => 0;
 requires 'Module::CoreList' => 0;

Modified: Shipwright/lib/Shipwright/Script/Update.pm
==============================================================================
--- Shipwright/lib/Shipwright/Script/Update.pm	(original)
+++ Shipwright/lib/Shipwright/Script/Update.pm	Mon Feb 11 21:43:42 2008
@@ -71,7 +71,23 @@
 
         my @dists;
         if ( $self->follow ) {
-            @dists = find_deps( $self->name );
+            my ( %checked );
+            my $find_deps;
+            $find_deps = sub {
+                my $name = shift;
+
+                return if $checked{$name}++; # we've checked this $name
+
+                my ($require) = $shipwright->backend->require($name);
+                for my $type (qw/requires build_requires recommends/) {
+                    for ( keys %{ $require->{$type} } ) {
+                        $find_deps->( $_ );
+                    }
+                }
+            };
+
+            $find_deps->( $self->name );
+            @dists = keys %checked;
         }
         for ( @dists, $self->name ) {
             update($_);
@@ -128,29 +144,6 @@
 
 }
 
-=head2 find_deps
-
-find all the deps for one dist
-
-=cut
-
-my %found;
-
-sub find_deps {
-    my $name = shift;
-
-    return if $found{$name}++;
-
-    my ($require) = $shipwright->backend->require($name);
-    my @deps;
-    for my $type (qw/requires build_requires recommends/) {
-        for ( keys %{ $require->{$type} } ) {
-            push @deps, find_deps($_), $_;
-        }
-    }
-    return uniq @deps;
-}
-
 1;
 
 __END__



More information about the Bps-public-commit mailing list