update_branches revision f91671c7dc877a52adc06d0a7d0ed1c7f6391e6e
e20788e1216ed720aefa84f3295f7899d9f28c22Mark Andrews#!/usr/local/bin/perl -w
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews#
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# Copyright (C) 2005 Internet Systems Consortium, Inc. ("ISC")
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews#
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# Permission to use, copy, modify, and distribute this software for any
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# purpose with or without fee is hereby granted, provided that the above
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# copyright notice and this permission notice appear in all copies.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews#
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28a8f5b0de57d269cf2845c69cb6abe18cbd3b3aMark Andrews# PERFORMANCE OF THIS SOFTWARE.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# $Id: update_branches,v 1.3 2005/05/16 04:28:59 marka Exp $
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt%branches = ();
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt%whom = ();
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt%comments = ();
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt!system("cvs", "-d", "/proj/cvs/prod", "update", "doc/private/branches") || die "cannot update doc/private/branches: $!";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# load existing content
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntopen(BRANCHES, "<doc/private/branches") || die "can't open util/branches: $!";
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntwhile (<BRANCHES>) {
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt chomp;
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt next if (/----------/);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt next if (/Whom/);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $c = "";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if (m/\(.*\)/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $c = $_;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $c =~ s/.*(\(.*\)).*$/$1/;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt s/\(.*\)//;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt next if (/^\s*$/);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ($branch, $status, $who) = split;
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews #$status = "new" if (!defined($status));
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews $branches{$branch} = $status;
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews #$who = "-" if (!defined($who));
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews $whom{$branch} = $who;
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews $comments{$branch} = $c;
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews}
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Huntclose (BRANCHES);
0cfb24736841b3e98bb25853229a0efabab88bddEvan Hunt
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews#
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews# Search repository for new branches.
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews#
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrewsopen(FILES, "find /proj/cvs/prod/bind9 -type f -name *,v -print |") || die "can't start find: $!";
ce376a81fa674d240197628ceb6113a4fa5a1ab3Mukund Sivaramanwhile (<FILES>) {
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews chomp;
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews # print "file: $_\n"; # debug
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews # $file = $_; # save for branch debug below.
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews open(FILE, "<$_") || die "can't open $_: $!";
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews while (<FILE>) {
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews chomp;
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews next unless m/^symbols$/; # skip until we find the tags
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt while (<FILE>) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt chomp;
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews last if (m/^locks;/); # we are past the tags
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews next unless m/\.0\.\d$/; # skip if not a branch
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews s/\s(.*):.*/$1/; # extract label
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews if (!$branches{$_}) {
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews $branches{$_} = "new";
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews $whom{$_} = "";
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt $comments{$_} = "";
0cfb24736841b3e98bb25853229a0efabab88bddEvan Hunt # print "branch: $_ $file\n"; # debug
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews }
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews }
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews last;
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews }
ce376a81fa674d240197628ceb6113a4fa5a1ab3Mukund Sivaraman close(FILE);
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews}
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrewsclose(FILES);
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews#
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews# Write out updated version.
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrews#
a2ca594252024a7b26d2f6b1984cb6da6f5bd09cMark Andrewsopen(BRANCHES, ">doc/private/newbranches") || die "can't open doc/private/branches: $!";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntprint BRANCHES "\nBranch\t\t\t\tStatus\tWhom\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntprint BRANCHES "-------------------------------------------------------\n\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntforeach $key (sort keys %branches) {
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt next if ($branches{$key} eq "closed");
c3b9fad5e3be639c9b36ff0ac921c30133da395cMar Andrews print BRANCHES "$key";
c3b9fad5e3be639c9b36ff0ac921c30133da395cMar Andrews $len = length($key);
c3b9fad5e3be639c9b36ff0ac921c30133da395cMar Andrews if ($len >= 32) {
b4d8192d210290112e07b0e22b491c45c50ba696Evan Hunt $tabs = 1;
c3b9fad5e3be639c9b36ff0ac921c30133da395cMar Andrews } else {
b4d8192d210290112e07b0e22b491c45c50ba696Evan Hunt $needed = int (32 - $len);
c3b9fad5e3be639c9b36ff0ac921c30133da395cMar Andrews $tabs = int ($needed / 8);
b4d8192d210290112e07b0e22b491c45c50ba696Evan Hunt if ($needed % 8 != 0) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $tabs++;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt for ($i = 0; $i < $tabs; $i++) {
0cfb24736841b3e98bb25853229a0efabab88bddEvan Hunt printf BRANCHES "\t";
0cfb24736841b3e98bb25853229a0efabab88bddEvan Hunt }
0cfb24736841b3e98bb25853229a0efabab88bddEvan Hunt print BRANCHES "$branches{$key}\t";
0cfb24736841b3e98bb25853229a0efabab88bddEvan Hunt print BRANCHES "$whom{$key}";
0cfb24736841b3e98bb25853229a0efabab88bddEvan Hunt print BRANCHES "\t$comments{$key}" if ($comments{$key} ne "");
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt print BRANCHES "\n";
215ef83bbed20727813a52ddcdbcd1455856638bMark Andrews}
215ef83bbed20727813a52ddcdbcd1455856638bMark Andrews
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Huntprint BRANCHES "\n\n";
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Huntforeach $key (sort keys %branches) {
9c03f13e18c1b0c32f62391a17300378605bbc7bEvan Hunt next if ($branches{$key} ne "closed");
9c03f13e18c1b0c32f62391a17300378605bbc7bEvan Hunt print BRANCHES "$key";
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt $len = length($key);
9c03f13e18c1b0c32f62391a17300378605bbc7bEvan Hunt if ($len >= 32) {
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt $tabs = 1;
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews } else {
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews $needed = int (32 - $len);
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt $tabs = int ($needed / 8);
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews if ($needed % 8 != 0) {
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt $tabs++;
42cf2ff7bad81c5a1f5d3be29d06e12504c3af24Evan Hunt }
42cf2ff7bad81c5a1f5d3be29d06e12504c3af24Evan Hunt }
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt for ($i = 0; $i < $tabs; $i++) {
42cf2ff7bad81c5a1f5d3be29d06e12504c3af24Evan Hunt printf BRANCHES "\t";
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt }
5a75f61dd413720c16d229b24ebba6bd6ecdb738Evan Hunt print BRANCHES "$branches{$key}";
5a75f61dd413720c16d229b24ebba6bd6ecdb738Evan Hunt print BRANCHES "\t\t$comments{$key}" if ($comments{$key} ne "");
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt print BRANCHES "\n";
5a75f61dd413720c16d229b24ebba6bd6ecdb738Evan Hunt}
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Huntclose(BRANCHES);
de52784e45e3a7a92c0d8ad843eb4db313bbfd97Mark Andrews
de52784e45e3a7a92c0d8ad843eb4db313bbfd97Mark Andrews#
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt# Update if changed.
de52784e45e3a7a92c0d8ad843eb4db313bbfd97Mark Andrews#
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Huntif (system("cmp", "-s", "doc/private/newbranches", "doc/private/branches")) {
af850c4120c5bee9462de4def85d0b4c1b583963Mark Andrews rename("doc/private/newbranches", "doc/private/branches") || die "Cannot rename: doc/private/newbranches -> doc/private/branches: $!";
af850c4120c5bee9462de4def85d0b4c1b583963Mark Andrews !system("cvs", "-d", "/proj/cvs/prod", "commit", "-m", "auto update", "doc/private/branches") || die "cvs commit failed: $!";
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt} else {
af850c4120c5bee9462de4def85d0b4c1b583963Mark Andrews unlink("doc/private/newbranches");
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt}
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt