This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move finding perl versions from mktodo to devtools.pl
authorKarl Williamson <khw@cpan.org>
Sat, 20 Jul 2019 22:55:37 +0000 (16:55 -0600)
committerNicolas R <atoomic@cpan.org>
Fri, 27 Sep 2019 22:39:31 +0000 (16:39 -0600)
This is in preparation for this calculation to be done from a second
place.

(cherry picked from commit 0cca64a344d7e677ed62e307aa8183fecb63f5ea)
Signed-off-by: Nicolas R <atoomic@cpan.org>
dist/Devel-PPPort/devel/devtools.pl
dist/Devel-PPPort/devel/mktodo

index a60c6f3..ee68e89 100644 (file)
@@ -122,4 +122,50 @@ sub eta
   return sprintf "%02d:%02d:%02d", $h, $m, $s;
 }
 
+sub get_and_sort_perls($)
+{
+    my $opt = shift;
+
+    # Get blead and all other perls
+    my @perls = $opt->{blead};
+    for my $dir (split ",", $opt->{install}) {
+        push @perls, grep !/-RC\d+/, glob "$dir/bin/perl5.*";
+    }
+
+    # Sort in descending version order.  Each element is a hash describing a perl,
+    # with keys 'version' and 'path'
+    @perls = sort { $b->{version} <=> $a->{version} }
+
+                                # Call the perl to get it to print out it's $]
+                                # version
+                map { { version => `$_ -e 'printf "%.6f", \$]'`,
+                        path => $_ }
+                    }
+                @perls;
+
+    # Override blead's version if specified.
+    if (exists $opt->{'blead-version'}) {
+        $perls[0]{version} = $opt->{'blead-version'};
+    }
+
+    my %seen;
+
+    # blead's todo is its version plus 1.  Otherwise, each todo is the
+    # previous one's.  Also get rid of duplicate versions.
+    $perls[0]{todo} = $perls[0]{version} + 1;
+    $seen{$perls[0]{version}} = 1;
+    for my $i (1 .. $#perls) {
+        last unless defined $perls[$i];
+        if (    exists $seen{$perls[$i]{version}}) {
+            splice @perls, $i, 1;
+            redo;
+        }
+
+        $seen{$perls[$i]{version}} = 1;
+        $perls[$i]{todo} = $perls[$i-1]{version};
+    }
+
+    return \@perls;
+}
+
 1;
index 228e3a2..6e5b6ea 100755 (executable)
@@ -54,52 +54,14 @@ identify();
 
 my $outdir = 'parts/todo';
 
-
-# Get blead and all other perls
-my @perls = $opt{blead};
-for my $dir (split ",", $opt{install}) {
-    push @perls, grep !/-RC\d+/, glob "$dir/bin/perl5.*";
-}
-
-# Sort in descending version order.  Each element is a hash describing a perl,
-# with keys 'version' and 'path'
-@perls = sort { $b->{version} <=> $a->{version} }
-
-                               # Call the perl to get it to print out it's $]
-                               # version
-            map { { version => `$_ -e 'printf "%.6f", \$]'`,
-                    path => $_ }
-                }
-            @perls;
-
-# Override blead's version if specified.
-if (exists $opt{'blead-version'}) {
-  $perls[0]{version} = $opt{'blead-version'};
-}
-
-my %seen;
-
-# blead's todo is its version plus 1.  Otherwise, each todo is the previous
-# one's version.  Also get rid of duplicate versions.
-$perls[0]{todo} = $perls[0]{version} + 1;
-$seen{$perls[0]{version}} = 1;
-for my $i (1 .. $#perls) {
-    last unless defined $perls[$i];
-  if (    exists $seen{$perls[$i]{version}}
-  ) {
-    splice @perls, $i, 1;
-    redo;
-  }
-  $seen{$perls[$i]{version}} = 1;
-  $perls[$i]{todo} = $perls[$i-1]{version};
-}
+my $perls_ref = get_and_sort_perls(\%opt);
 
 # Go through all the perls, creating a todo file for it.
-for (@perls) {
+for (@${perls_ref}) {
   my $todo = do { my $v = $_->{todo}; $v =~ s/\D+//g; $v };
   my @args = ('--perl', $_->{path}, '--version', "$_->{todo}");
 
-  push @args, '--blead' if $_ == $perls[0]; # First one is blead
+  push @args, '--blead' if $_ == $perls_ref->[0];   # First one is blead
   push @args, '--todo', $_->{'todo'};
   push @args, '--base' if $opt{base};
   push @args, '--verbose' if $opt{verbose};