check-pullups.pl revision 70e5a7403f0e0a3bd292b8287c5fed5772c15270
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley#!/usr/bin/perl
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley#
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# Copyright (C) 2001-2003 Internet Software Consortium.
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley#
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# Permission to use, copy, modify, and/or distribute this software for any
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# purpose with or without fee is hereby granted, provided that the above
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# copyright notice and this permission notice appear in all copies.
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley#
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# PERFORMANCE OF THIS SOFTWARE.
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# $Id: check-pullups.pl,v 1.12 2007/06/19 23:47:24 tbox Exp $
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# Given two CHANGES files, list [bug] entries present in the
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# first one but not in the second one.
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley#
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleyuse FileHandle;
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# $/ = "";
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# Read the CHANGES file $fn and return a hash of change
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley# texts and categories indexed by change number.
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleysub readfile {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley my ($fn) = @_;
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley my $fh = new FileHandle($fn, "r")
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley or die "open: $fn: $!";
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley my $changes = { };
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley my ($changeid, $category);
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $changeid = "none";
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $category = "none";
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley while (<$fh>) {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley if (m/^\s*(\d+)\.\s+\[(\w+)\]/) {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $changeid = $1;
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $category = $2;
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley # print "*** $1 $2\n";
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley } elsif (m/---.* released ---/) {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $changeid = "none";
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $category = "none";
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley next;
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley } elsif (m/^# /) {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $changeid = "none";
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $category = "none";
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley next;
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley }
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley if ($changeid eq "none") {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley next;
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley }
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $changes->{$changeid}->{text} .= $_;
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $changes->{$changeid}->{category} = $category;
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley }
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley return $changes;
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley}
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley@ARGV == 2 || @ARGV == 3 or die "usage: $0 changes-file-1 changes-file-2\n";
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleymy $c1 = readfile($ARGV[0]);
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleymy $c2 = readfile($ARGV[1]);
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleyif (@ARGV == 3) {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $c3 = readfile($ARGV[2]);
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley} else {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley my $c3 = { };
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley}
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleymy $msg = "";
c7ddab7655021d96211a26f99d9f694396c53284Bob Halleyforeach my $c (sort {$a <=> $b} keys %$c1) {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley my $category = $c1->{$c}->{category};
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley my $text = $c1->{$c}->{text};
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley if ($category ne "func" && $category ne "placeholder" &&
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley !exists($c2->{$c}) && !exists($c3->{$c})) {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley if ($msg ne "MISSING\n") {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $msg = "MISSING\n";
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley print $msg;
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley }
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley print $c1->{$c}->{text};
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley }
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley if (exists($c2->{$c}) && $category ne "placeholder" &&
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $c2->{$c}->{text} ne $text) {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley if ($msg ne "TEXT\n") {
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley $msg = "TEXT\n";
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley print $msg;
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley }
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley print $c2->{$c}->{text};
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley print $c1->{$c}->{text};
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley }
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley}
c7ddab7655021d96211a26f99d9f694396c53284Bob Halley