[carton] 14/472: Build index from the provides hash.

Lucas Kanashiro kanashiro-guest at moszumanska.debian.org
Fri Jul 24 00:38:26 UTC 2015


This is an automated email from the git hooks/post-receive script.

kanashiro-guest pushed a commit to branch master
in repository carton.

commit 87bdfbb5c90fcb1adb0ab6e717dc0993cf06fe99
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date:   Fri Jun 24 19:46:48 2011 -0700

    Build index from the provides hash.
---
 lib/App/Carton.pm | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/lib/App/Carton.pm b/lib/App/Carton.pm
index f0d3231..0914adb 100644
--- a/lib/App/Carton.pm
+++ b/lib/App/Carton.pm
@@ -170,6 +170,22 @@ sub cmd_show {
     }
 }
 
+sub build_index {
+    my($self, $modules) = @_;
+
+    my $index;
+
+    for my $name (keys %$modules) {
+        my $module   = $modules->{$name};
+        my $provides = $module->{provides};
+        for my $mod (keys %$provides) {
+            $index->{$mod} = { version => $provides->{$mod}, module => $module };
+        }
+    }
+
+    return $index;
+}
+
 sub build_tree {
     my($self, $data) = @_;
 
@@ -177,22 +193,25 @@ sub build_tree {
     my %cached = ();
     my @children = keys %{$data->{roots}};
 
-    $self->_build_tree(\@children, $tree, $data->{modules}, \%cached);
+    my $index = $self->build_index($data->{modules});
+
+    $self->_build_tree(\@children, $tree, $index, \%cached);
 
     return $tree;
 }
 
 sub _build_tree {
-    my($self, $children, $node, $modules, $cached) = @_;
+    my($self, $children, $node, $index, $cached) = @_;
     require Module::CoreList;
     for my $child (@$children) {
         next if $child eq 'perl' or $cached->{$child}++;
-        if (my $mod = $modules->{$child}) {
+        if (my $mod = $index->{$child}) {
+            $mod = $mod->{module};
             push @$node, [ $mod, [] ];
             my %deps = (%{$mod->{requires}{configure}}, %{$mod->{requires}{build}});
-            $self->_build_tree([ keys %deps ], $node->[-1][-1], $modules, $cached);
+            $self->_build_tree([ keys %deps ], $node->[-1][-1], $index, $cached);
         } elsif (!$Module::CoreList::version{$]+0}{$child}) {
-            warn "Can't find $child" if $self->{verbose};
+            warn "Can't find $child\n";
         }
     }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/carton.git



More information about the Pkg-perl-cvs-commits mailing list