summaryrefslogtreecommitdiff
path: root/Porting/cmpVERSION.pl
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2009-01-03 14:19:00 +0000
committerDavid Mitchell <davem@iabyn.com>2009-01-03 14:19:00 +0000
commit2547c837a73d50421f898a78d070bf820ac97f12 (patch)
tree23dac5cddd600225bc452388febc4467615e97b4 /Porting/cmpVERSION.pl
parenta7d002a11216fa10d2d93aff87fec9eea46a32ff (diff)
downloadperl-2547c837a73d50421f898a78d070bf820ac97f12.tar.gz
add -d option to Porting/cmpVERSION.pl to display diffs
Diffstat (limited to 'Porting/cmpVERSION.pl')
-rw-r--r--Porting/cmpVERSION.pl43
1 files changed, 33 insertions, 10 deletions
diff --git a/Porting/cmpVERSION.pl b/Porting/cmpVERSION.pl
index 8c23649daa..0f808c87da 100644
--- a/Porting/cmpVERSION.pl
+++ b/Porting/cmpVERSION.pl
@@ -4,6 +4,8 @@
# cmpVERSION - compare two Perl source trees for modules
# that have identical version numbers but different contents.
#
+# withg -d option, output the diffs too
+#
# Original by slaven@rezic.de, modified by jhi.
#
@@ -13,8 +15,17 @@ use ExtUtils::MakeMaker;
use File::Compare;
use File::Find;
use File::Spec::Functions qw(rel2abs abs2rel catfile catdir curdir);
+use Getopt::Std;
+
+sub usage {
+die <<'EOF';
+usage: $0 [ -d ] source_dir1 source_dir2
+EOF
+}
-@ARGV == 2 or die "usage: $0 source_dir1 source_dir2\n";
+my %opts;
+getopts('d', \%opts) or usage;
+@ARGV == 2 or usage;
for (@ARGV[0, 1]) {
die "$0: '$_' does not look like Perl directory\n"
@@ -35,6 +46,7 @@ my %skip;
my $skip_dirs = qr|^\./t/lib|;
my @wanted;
+my @diffs;
find(
sub { /\.pm$/ &&
$File::Find::dir !~ $skip_dirs &&
@@ -44,18 +56,29 @@ find(
catfile(catdir($dir2, $File::Find::dir), $_);
(my $xs_file1 = $_) =~ s/\.pm$/.xs/;
(my $xs_file2 = $file2) =~ s/\.pm$/.xs/;
+ my $eq1 = compare($_, $file2) == 0;
+ my $eq2 = 1;
if (-e $xs_file1 && -e $xs_file2) {
- return if compare($_, $file2) == 0 &&
- compare($xs_file1, $xs_file2) == 0;
- } else {
- return if compare($_, $file2) == 0;
+ $eq2 = compare($xs_file1, $xs_file2) == 0;
}
+ return if $eq1 && $eq2;
my $version1 = eval {MM->parse_version($_)};
my $version2 = eval {MM->parse_version($file2)};
- push @wanted, $File::Find::name
- if defined $version1 &&
- defined $version2 &&
- $version1 eq $version2
+ return unless
+ defined $version1 &&
+ defined $version2 &&
+ $version1 eq $version2;
+ push @wanted, $File::Find::name;
+ push @diffs, [ "$File::Find::dir/$_", $file2 ] unless $eq1;
+ push @diffs, [ "$File::Find::dir/$xs_file1", $xs_file2 ]
+ unless $eq2;
} }, curdir);
-print map { $_, "\n" } sort @wanted;
+for (sort @wanted) {
+ print "$_\n";
+}
+exit unless $opts{d};
+for (sort { $a->[0] cmp $b->[0] } @diffs) {
+ print "\n";
+ system "diff -du '$_->[0]' '$_->[1]'";
+}