--- pkgsrc/pkgtools/pkgdiff/files/patchdiff.pl 2004/01/10 05:40:40 1.6 +++ pkgsrc/pkgtools/pkgdiff/files/patchdiff.pl 2010/07/04 22:20:04 1.12 @@ -1,12 +1,12 @@ #!@PERL5@ # -# $NetBSD: patchdiff.pl,v 1.6 2004/01/10 05:40:40 jlam Exp $ +# $NetBSD: patchdiff.pl,v 1.12 2010/07/04 22:20:04 sbd Exp $ # # patchdiff: compares a set of patches patch-aa, patch-ab, ... in # $WRKDIR/.newpatches in the with another set in patches. # # Copyright (c) 2000 by Dieter Baron and -# Thomas Klausner +# Thomas Klausner # All Rights Reserved. Absolutely no warranty. use Getopt::Std; @@ -23,10 +23,11 @@ sub getfilename { local *handle; open(handle, $fname); while () { - next unless m/^\+\+\+[ ]([^ ]*)/; + next unless m/^\+\+\+[ ]([^ ]*)/; close(handle); $_ = $1; chomp(); + s/^\.\///; # ignore leading "./", if any. return $_; } close(handle); @@ -95,8 +96,24 @@ foreach $patch (keys%new) { if (defined($orig{$patch})) { # system("diff",$orig{$patch},$new{$patch}); $diff=`diff $orig{$patch} $new{$patch}`; - $diff=~s/^\dc\d\n..\$NetBSD.*\$\n---\n..\$NetBSD.*\$\n//m; - $diff=~s/^\dc\d\n..\+\+\+.*\n---\n..\+\+\+.*\n//m; + # the following regex try to eliminate uninteresting differences + # The general structure of the diffs-to-be-removed is: + # 25c25 + # < --- something.orig 2008-08-08 08:08 + # --- + # > --- something.orig 2008-08-08 18:08 + # + # In particular, remove hunks with: + # . NetBSD RCS Id tag differences + $diff=~s/^[\d,]+c[\d,]+\n..\$[N]etBSD.*\$\n---\n..\$[N]etBSD.*\$\n//m; + # . the name of the input file changed + # (if the name of the output file has changed values in $orig{$patch} + # and $new{$patch} won't match so the files don't get compared) + # . time of the input and/or output file changed + # . line numbers changed + $diff=~s/^[\d,]+c[\d,]+\n(?:.\s---\s(:?\S*).*\n)?(?:.\s\+\+\+\s(\S*).*\n)?(?:.\s@@\s(?:.*)\s@@.*\n)?---\n(?:.\s---\s.*\n)?(?:.\s\+\+\+\s\1.*\n)?(?:.\s@@\s.*\s@@.*\n)?//m; + # . only line numbers changed + $diff=~s/^[\d,]+c[\d,]+\n.\s@@\s.*\s@@.*\n---\n.\s@@\s.*\s@@.*\n//mg; if ($diff) { print "Comparing $orig{$patch} to $new{$patch}\n$diff"; }