summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorRicardo Signes <rjbs@cpan.org>2012-05-10 15:08:21 -0400
committerRicardo Signes <rjbs@cpan.org>2012-05-10 15:08:25 -0400
commit797ced9432a4f576879a5f08356fc5dc21113d21 (patch)
tree87705227116863d5cad17f2a88c2de49c3fe29c9 /dist
parentb7f87eaf73269868bae45510d6e24e6b3dac919e (diff)
downloadperl-797ced9432a4f576879a5f08356fc5dc21113d21.tar.gz
add a changes_between function in Module::CoreList
Diffstat (limited to 'dist')
-rw-r--r--dist/Module-CoreList/corelist26
-rw-r--r--dist/Module-CoreList/lib/Module/CoreList.pm30
-rw-r--r--dist/Module-CoreList/lib/Module/CoreList.pod21
3 files changed, 65 insertions, 12 deletions
diff --git a/dist/Module-CoreList/corelist b/dist/Module-CoreList/corelist
index adf0fb0df9..9cd0e8f21f 100644
--- a/dist/Module-CoreList/corelist
+++ b/dist/Module-CoreList/corelist
@@ -193,21 +193,23 @@ if ($Opts{diff}) {
my ($old_ver, $new_ver) = @ARGV;
- my $old = $Module::CoreList::version{ numify_version($old_ver) };
- my $new = $Module::CoreList::version{ numify_version($new_ver) };
+ my $old = numify_version($old_ver);
+ my $new = numify_version($new_ver);
- my %uniq = (%$old, %$new);
- for my $lib (sort keys %uniq) {
- my $old = exists $old->{ $lib }
- ? (defined $old->{ $lib } ? $old->{ $lib } : '(undef)')
- : '(absent)';
- my $new = exists $new->{ $lib }
- ? (defined $new->{ $lib } ? $new->{ $lib } : '(undef)')
- : '(absent)';
+ my %diff = Module::CoreList::changes_between($old, $new);
- next if $old eq $new;
+ for my $lib (sort keys %diff) {
+ my $diff = $diff{$lib};
- printf "%-35s %10s %10s\n", $lib, $old, $new;
+ my $was = ! exists $diff->{left} ? '(absent)'
+ : ! defined $diff->{left} ? '(undef)'
+ : $diff->{left};
+
+ my $now = ! exists $diff->{right} ? '(absent)'
+ : ! defined $diff->{right} ? '(undef)'
+ : $diff->{right};
+
+ printf "%-35s %10s %10s\n", $lib, $was, $now;
}
exit(0);
}
diff --git a/dist/Module-CoreList/lib/Module/CoreList.pm b/dist/Module-CoreList/lib/Module/CoreList.pm
index 6a118be178..6078dfdd7d 100644
--- a/dist/Module-CoreList/lib/Module/CoreList.pm
+++ b/dist/Module-CoreList/lib/Module/CoreList.pm
@@ -97,6 +97,36 @@ sub removed_raw {
return @removed;
}
+sub changes_between {
+ my ($left_ver, $right_ver) = @_;
+
+ my $left = $version{ $left_ver };
+ my $right = $version{ $right_ver };
+
+ my %uniq = (%$left, %$right);
+
+ my %changes;
+ for my $lib (keys %uniq) {
+ my $lhs = exists $left->{ $lib }
+ ? (defined $left->{ $lib } ? $left->{ $lib } : '(undef)')
+ : '(absent)';
+ my $rhs = exists $right->{ $lib }
+ ? (defined $right->{ $lib } ? $right->{ $lib } : '(undef)')
+ : '(absent)';
+
+ next if $lhs eq $rhs;
+
+ my $change = {
+ (exists $left->{$lib} ? (left => $left->{$lib}) : ()),
+ (exists $right->{$lib} ? (right => $right->{$lib}) : ()),
+ };
+
+ $changes{$lib} = $change;
+ }
+
+ return %changes;
+}
+
# When things escaped.
# NB. If you put version numbers with trailing zeroes here, you
# should also add an alias for the numerical ($]) version; see
diff --git a/dist/Module-CoreList/lib/Module/CoreList.pod b/dist/Module-CoreList/lib/Module/CoreList.pod
index 77485dcdb5..342e4b5d14 100644
--- a/dist/Module-CoreList/lib/Module/CoreList.pod
+++ b/dist/Module-CoreList/lib/Module/CoreList.pod
@@ -94,6 +94,27 @@ Takes a module name as an argument, returns the first perl version by release da
was removed from core. Returns undef if the given module was never in core or remains
in core.
+=item C<changes_between( PERL_VERSION, PERL_VERSION )>
+
+Available in version 2.66 and above.
+
+Given two perl versions, this returns a list of pairs describing the changes in
+core module content betweent hem. The list is suitable for storing in a hash.
+The keys are library names and the values are hashrefs. Each hashref has an
+entry for one or both of C<left> and C<right>, giving the versions of the
+library in each of the left and right perl distributions.
+
+For example, it might return these data (among others) for the the difference
+between 5.008000 and 5.008001:
+
+ 'Pod::ParseLink' => { left => '1.05', right => '1.06' },
+ 'Pod::ParseUtils' => { left => '0.22', right => '0.3' },
+ 'Pod::Perldoc' => { right => '3.10' },
+ 'Pod::Perldoc::BaseTo' => { right => undef },
+
+This shows us two libraries being updated and two being added, one of which has
+an undefined version in the right-hand side version.
+
=back
=head1 DATA STRUCTURES