| @@ -1,16 +1,16 @@ | | | @@ -1,16 +1,16 @@ |
1 | #!@PERL5@ | | 1 | #!@PERL5@ |
2 | # | | 2 | # |
3 | # $NetBSD: patchdiff.pl,v 1.9 2008/02/16 22:21:35 apb Exp $ | | 3 | # $NetBSD: patchdiff.pl,v 1.10 2008/11/05 23:18:18 wiz Exp $ |
4 | # | | 4 | # |
5 | # patchdiff: compares a set of patches patch-aa, patch-ab, ... in | | 5 | # patchdiff: compares a set of patches patch-aa, patch-ab, ... in |
6 | # $WRKDIR/.newpatches in the with another set in patches. | | 6 | # $WRKDIR/.newpatches in the with another set in patches. |
7 | # | | 7 | # |
8 | # Copyright (c) 2000 by Dieter Baron <dillo@giga.or.at> and | | 8 | # Copyright (c) 2000 by Dieter Baron <dillo@giga.or.at> and |
9 | # Thomas Klausner <wiz@NetBSD.org> | | 9 | # Thomas Klausner <wiz@NetBSD.org> |
10 | # All Rights Reserved. Absolutely no warranty. | | 10 | # All Rights Reserved. Absolutely no warranty. |
11 | | | 11 | |
12 | use Getopt::Std; | | 12 | use Getopt::Std; |
13 | use Cwd; | | 13 | use Cwd; |
14 | use File::Spec; | | 14 | use File::Spec; |
15 | | | 15 | |
16 | my $oldpatchdir, $newpatchdir; | | 16 | my $oldpatchdir, $newpatchdir; |
| @@ -86,22 +86,37 @@ if ( ! -d $oldpatchdir) { | | | @@ -86,22 +86,37 @@ if ( ! -d $oldpatchdir) { |
86 | if ( ! -d $newpatchdir ) { | | 86 | if ( ! -d $newpatchdir ) { |
87 | print "No new patches found (directory $newpatchdir not found)\n"; | | 87 | print "No new patches found (directory $newpatchdir not found)\n"; |
88 | exit(0); | | 88 | exit(0); |
89 | } | | 89 | } |
90 | putinhash(\%orig,"$oldpatchdir/patch-*"); | | 90 | putinhash(\%orig,"$oldpatchdir/patch-*"); |
91 | putinhash(\%new,"$newpatchdir/patch-*"); | | 91 | putinhash(\%new,"$newpatchdir/patch-*"); |
92 | foreach $patch (keys%orig) { | | 92 | foreach $patch (keys%orig) { |
93 | print "Only in old: $orig{$patch} ($patch)\n" unless defined($new{$patch}); | | 93 | print "Only in old: $orig{$patch} ($patch)\n" unless defined($new{$patch}); |
94 | } | | 94 | } |
95 | foreach $patch (keys%new) { | | 95 | foreach $patch (keys%new) { |
96 | if (defined($orig{$patch})) { | | 96 | if (defined($orig{$patch})) { |
97 | # system("diff",$orig{$patch},$new{$patch}); | | 97 | # system("diff",$orig{$patch},$new{$patch}); |
98 | $diff=`diff $orig{$patch} $new{$patch}`; | | 98 | $diff=`diff $orig{$patch} $new{$patch}`; |
99 | $diff=~s/^\dc\d\n..\$[N]etBSD.*\$\n---\n..\$[N]etBSD.*\$\n//m; | | 99 | # the following regex try to eliminate uninteresting differences |
100 | $diff=~s/^\dc\d\n..\+\+\+.*\n---\n..\+\+\+.*\n//m; | | 100 | # The general structure of the diffs-to-be-removed is: |
| | | 101 | # 25c25 |
| | | 102 | # < --- something.orig 2008-08-08 08:08 |
| | | 103 | # --- |
| | | 104 | # > --- something.orig 2008-08-08 18:08 |
| | | 105 | # |
| | | 106 | # In particular, remove hunks with: |
| | | 107 | # . NetBSD RCS Id tag differences |
| | | 108 | $diff=~s/^\d+c\d+\n..\$[N]etBSD.*\$\n---\n..\$[N]etBSD.*\$\n//m; |
| | | 109 | # . only the name or date of the output file changed |
| | | 110 | $diff=~s/^\d+c\d+\n..\+\+\+.*\n---\n..\+\+\+.*\n//m; |
| | | 111 | # . only the name or date of the input file changed |
| | | 112 | $diff=~s/^\d+c\d+\n.\s---\s.*\.orig\s.*\n---\n.\s---\s.*\n//m; |
| | | 113 | $diff=~s/^\d+c\d+\n.\s---\s.*\n---\n.\s---\s.*\.orig\s.*\n//m; |
| | | 114 | # . only line numbers changed |
| | | 115 | $diff=~s/^\d+c\d+\n.\s@@\s.*\s@@.*\n---\n.\s@@\s.*\s@@.*\n//mg; |
101 | if ($diff) { | | 116 | if ($diff) { |
102 | print "Comparing $orig{$patch} to $new{$patch}\n$diff"; | | 117 | print "Comparing $orig{$patch} to $new{$patch}\n$diff"; |
103 | } | | 118 | } |
104 | } else { | | 119 | } else { |
105 | print "Only in new: $new{$patch} ($patch)\n" | | 120 | print "Only in new: $new{$patch} ($patch)\n" |
106 | } | | 121 | } |
107 | } | | 122 | } |