update_branches revision 11b07ea523314b123b4e503ce3813443a018c8d3
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj#!/usr/local/bin/perl -w
cfc020d6d6fc9b31d8945915e65a8787a796eb73stoddard#
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj# Copyright (C) 2005 Internet Systems Consortium, Inc. ("ISC")
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj#
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj# Permission to use, copy, modify, and distribute this software for any
2deb319e6b3de239f45c16a3e9e836d44f1f7108rbb# purpose with or without fee is hereby granted, provided that the above
2deb319e6b3de239f45c16a3e9e836d44f1f7108rbb# copyright notice and this permission notice appear in all copies.
bd929c73ef04789b7183b840d8db6e01d03a4d86rbb#
70f6f32765cfaadd6da8de6f0fea97ddd72d8fadmanoj# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
91a71946d0fb28c0866139edef3dd59f36ba5b9cstoddard# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
91a71946d0fb28c0866139edef3dd59f36ba5b9cstoddard# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
91a71946d0fb28c0866139edef3dd59f36ba5b9cstoddard# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
91a71946d0fb28c0866139edef3dd59f36ba5b9cstoddard# PERFORMANCE OF THIS SOFTWARE.
91a71946d0fb28c0866139edef3dd59f36ba5b9cstoddard
bd929c73ef04789b7183b840d8db6e01d03a4d86rbb# $Id: update_branches,v 1.20 2007/01/30 06:29:21 marka Exp $
bd929c73ef04789b7183b840d8db6e01d03a4d86rbb
bd929c73ef04789b7183b840d8db6e01d03a4d86rbb#
bd929c73ef04789b7183b840d8db6e01d03a4d86rbb# Track which branches are still open or not in the bind9 cvs repository.
632b0b53511f3bb9c32aa2869fbc73ee35081b38rbb# This is done so that work that is "in progress" (active) doesn't get
632b0b53511f3bb9c32aa2869fbc73ee35081b38rbb# so easily forgotten about.
632b0b53511f3bb9c32aa2869fbc73ee35081b38rbb#
bd929c73ef04789b7183b840d8db6e01d03a4d86rbb# This script updates doc/private/branches by adding new branches and moving
f6a6245816cd866361da8c576b1f47c7a54b6610fanf# closed branches to the end of the file. New branches are found by walking
f755f06050191550f77c825eff6b0e48a35b3e91dgaudet# the cvs repository and extracting the new branches from the header fields
f755f06050191550f77c825eff6b0e48a35b3e91dgaudet# of the files there.
40a5b7189dbbb28e107bf008ee625f2f0142c2ccdgaudet#
211bf1d44f4653bf753a15740cd5ebbf330b6e93manoj# doc/private/branches has one line per branch in the following field order:
211bf1d44f4653bf753a15740cd5ebbf330b6e93manoj# name, status, to whom the branch belongs and comments. Comments are
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj# in '(',')'. The first three field are single words.
369edcdd0a9c5516c61e736ec2a6fc8fb0d92fe2manoj#
369edcdd0a9c5516c61e736ec2a6fc8fb0d92fe2manoj# Note: this is intended to be run on the machine hosting the CVS repository.
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj#
85cbdc16ac57fa68ce1358a308269abcd417f4d9stoddard
85cbdc16ac57fa68ce1358a308269abcd417f4d9stoddard%branches = ();
85cbdc16ac57fa68ce1358a308269abcd417f4d9stoddard%whom = ();
d208bda4a893cc81ed5d3ed1cdd7d706e012bd42stoddard%comments = ();
d208bda4a893cc81ed5d3ed1cdd7d706e012bd42stoddard%history = ();
d208bda4a893cc81ed5d3ed1cdd7d706e012bd42stoddard%dates = ();
d208bda4a893cc81ed5d3ed1cdd7d706e012bd42stoddard$repository = "/proj/cvs/prod";
d208bda4a893cc81ed5d3ed1cdd7d706e012bd42stoddard$module = "bind9";
d208bda4a893cc81ed5d3ed1cdd7d706e012bd42stoddard
d208bda4a893cc81ed5d3ed1cdd7d706e012bd42stoddard#
d208bda4a893cc81ed5d3ed1cdd7d706e012bd42stoddard# Make sure we have a up to date copy. If the previous ran failed for
d208bda4a893cc81ed5d3ed1cdd7d706e012bd42stoddard# any reason remove it (-C).
75960f20f88dad6bc67892c711c429946063d133stoddard#
75960f20f88dad6bc67892c711c429946063d133stoddard!system("cvs", "-d", $repository, "update", "-C", "doc/private/branches") || die "cannot update doc/private/branches: $!";
75960f20f88dad6bc67892c711c429946063d133stoddard
75960f20f88dad6bc67892c711c429946063d133stoddard#
75960f20f88dad6bc67892c711c429946063d133stoddard# load existing content
75960f20f88dad6bc67892c711c429946063d133stoddard#
75960f20f88dad6bc67892c711c429946063d133stoddardopen(BRANCHES, "<doc/private/branches") || die "can't open util/branches: $!";
75960f20f88dad6bc67892c711c429946063d133stoddardwhile (<BRANCHES>) {
70f6f32765cfaadd6da8de6f0fea97ddd72d8fadmanoj my $branch;
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj my $status;
a9e07e4f90adcc7bc768db3055431c3dcd560cd1manoj my $who;
f6a6245816cd866361da8c576b1f47c7a54b6610fanf chomp;
f6a6245816cd866361da8c576b1f47c7a54b6610fanf next if (/^-/);
a9e07e4f90adcc7bc768db3055431c3dcd560cd1manoj next if (/^Branch/);
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj next if (/^\s/);
cfc020d6d6fc9b31d8945915e65a8787a796eb73stoddard $c = "";
cfc020d6d6fc9b31d8945915e65a8787a796eb73stoddard if (m://.*:) {
cfc020d6d6fc9b31d8945915e65a8787a796eb73stoddard $c = $_;
0b0a5225c5ed94b9f689839a14842ad4a24215e9dgaudet $c =~ s:.*?//\s*(.*)$:$1:;
0b0a5225c5ed94b9f689839a14842ad4a24215e9dgaudet s:(.*?)//.*:$1:;
0b0a5225c5ed94b9f689839a14842ad4a24215e9dgaudet } else {
0b0a5225c5ed94b9f689839a14842ad4a24215e9dgaudet #
0b0a5225c5ed94b9f689839a14842ad4a24215e9dgaudet # look for old style comment
f824925ac58ff729289c017235eeb3bdd21ec3a2stoddard #
f824925ac58ff729289c017235eeb3bdd21ec3a2stoddard if (m/\(.*\)/) {
f824925ac58ff729289c017235eeb3bdd21ec3a2stoddard $c = $_;
f824925ac58ff729289c017235eeb3bdd21ec3a2stoddard $c =~ s/.*\((.*)\).*$/$1/;
2aae6faee508221efbeaba5547ca79b7a20ef047stoddard s/\(.*\)//;
2aae6faee508221efbeaba5547ca79b7a20ef047stoddard }
75960f20f88dad6bc67892c711c429946063d133stoddard }
75960f20f88dad6bc67892c711c429946063d133stoddard s/\s*$//;
a5ed555df952c85bc1b179f5981e8a6c54ba16e6stoddard next if (/^\s*$/);
a5ed555df952c85bc1b179f5981e8a6c54ba16e6stoddard ($branch, $status, $who) = split;
a5ed555df952c85bc1b179f5981e8a6c54ba16e6stoddard $status = "new" if (!defined($status));
a5ed555df952c85bc1b179f5981e8a6c54ba16e6stoddard $branches{$branch} = $status;
a5ed555df952c85bc1b179f5981e8a6c54ba16e6stoddard $who = "" if (!defined($who));
56ca30c968906053ae61acb218420667bb58d996rbb $whom{$branch} = $who;
56ca30c968906053ae61acb218420667bb58d996rbb $comments{$branch} = $c;
56ca30c968906053ae61acb218420667bb58d996rbb}
56ca30c968906053ae61acb218420667bb58d996rbbclose (BRANCHES);
70f6f32765cfaadd6da8de6f0fea97ddd72d8fadmanoj
70f6f32765cfaadd6da8de6f0fea97ddd72d8fadmanoj# T 1999-03-15 21:15 +0000 vixie bind [ietf44:A]
70f6f32765cfaadd6da8de6f0fea97ddd72d8fadmanojopen(HISTORY, "cvs history -T -a 2> /dev/null |") || die("can't get history");
56ca30c968906053ae61acb218420667bb58d996rbbwhile (<HISTORY>) {
0bff2f28ef945280c17099c142126178a78e1e54manoj my $tag;
0bff2f28ef945280c17099c142126178a78e1e54manoj my $date;
0bff2f28ef945280c17099c142126178a78e1e54manoj my $time;
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard my $tz;
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard my $who;
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard my $mod;
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard my $branch;
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard chomp;
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard s/[][]//g;
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard s/:[^ \t]+$//;
9c09943bad734ebd5c7cc10bd6d63b75c4c6e056stoddard s/\s+/ /g;
9c09943bad734ebd5c7cc10bd6d63b75c4c6e056stoddard ($tag, $date, $time, $tz, $who, $mod, $branch) = split;
9c09943bad734ebd5c7cc10bd6d63b75c4c6e056stoddard next if ($mod ne $module );
0bff2f28ef945280c17099c142126178a78e1e54manoj next if ($tag ne "T" );
0bff2f28ef945280c17099c142126178a78e1e54manoj next if (exists($history{$branch}));
0bff2f28ef945280c17099c142126178a78e1e54manoj $history{$branch} = $who;
9c09943bad734ebd5c7cc10bd6d63b75c4c6e056stoddard $dates{$branch} = "$date $time $tz";
75960f20f88dad6bc67892c711c429946063d133stoddard # print "$_\n";
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard}
9c09943bad734ebd5c7cc10bd6d63b75c4c6e056stoddardclose (HISTORY);
aa1faea36e4ae357bc603a2337b6adc54f5daec1manoj
f03d292915be9977eaf74e9be7b0404aec226f84manoj#
f03d292915be9977eaf74e9be7b0404aec226f84manoj# Search repository for new branches.
f03d292915be9977eaf74e9be7b0404aec226f84manoj#
aa1faea36e4ae357bc603a2337b6adc54f5daec1manoj# New branches have the following format "name:<revision>.0.#"
bd929c73ef04789b7183b840d8db6e01d03a4d86rbb# where # is the number of potential branches from this the revision.
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj#
302dc1f7b3feee23a91ad8f3cf3cb2edd95a557bmanojopen(FILES, "find $repository/$module -type f -name *,v -print |") || die "can't start find: $!";
302dc1f7b3feee23a91ad8f3cf3cb2edd95a557bmanojwhile (<FILES>) {
302dc1f7b3feee23a91ad8f3cf3cb2edd95a557bmanoj chomp;
302dc1f7b3feee23a91ad8f3cf3cb2edd95a557bmanoj # print "file: $_\n"; # debug
ff849e4163ed879288f0df15f78b6c9d278ec804fanf # $file = $_; # save for branch debug below.
ff849e4163ed879288f0df15f78b6c9d278ec804fanf s:^$repository/::;
ff849e4163ed879288f0df15f78b6c9d278ec804fanf s:/Attic/([^/]*)$:/$1:;
ff849e4163ed879288f0df15f78b6c9d278ec804fanf s:,v$::;
ff849e4163ed879288f0df15f78b6c9d278ec804fanf #
df4a7c143b27b489dd2d865bb3f6668c8420b3a9fanf # use cvs so that the file is locked.
df4a7c143b27b489dd2d865bb3f6668c8420b3a9fanf #
c03566fa0156d3a1500a42e4fe539e3e0fc8a11dgstein #print "cvs -d $repository rlog -h $_\n";
c03566fa0156d3a1500a42e4fe539e3e0fc8a11dgstein open(FILE, "cvs -d $repository rlog -h $_|") || die "can't start cvs rlog -h $_: $!";
c03566fa0156d3a1500a42e4fe539e3e0fc8a11dgstein while (<FILE>) {
c03566fa0156d3a1500a42e4fe539e3e0fc8a11dgstein chomp;
c03566fa0156d3a1500a42e4fe539e3e0fc8a11dgstein next unless m/^symbolic names:$/; # skip until we find the tags
c03566fa0156d3a1500a42e4fe539e3e0fc8a11dgstein while (<FILE>) {
c03566fa0156d3a1500a42e4fe539e3e0fc8a11dgstein chomp;
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj last if (m/^locks;/); # we are past the tags
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj last if (m/^keyword/); # we are past the tags
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj next unless m/\.0\.\d+$/; # skip if not a branch
d5defd5a0c5cdbaf74b85939484dc2b6c8317d19manoj s/\s(.*):.*/$1/; # extract label
d5defd5a0c5cdbaf74b85939484dc2b6c8317d19manoj if (!$branches{$_}) {
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj $branches{$_} = "new";
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj if (exists($history{$_})) {
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj $whom{$_} = $history{$_};
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj $comments{$_} = $dates{$_};
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj } else {
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj $whom{$_} = "";
0bff2f28ef945280c17099c142126178a78e1e54manoj $comments{$_} = "";
0bff2f28ef945280c17099c142126178a78e1e54manoj }
0bff2f28ef945280c17099c142126178a78e1e54manoj # print "branch: $_ $file\n"; # debug
d6b3cb141f0667101c1bca883ad15b383402c93bfielding }
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj }
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj chomp while (<FILE>); # let cvs rlog exit normally.
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj }
40a5b7189dbbb28e107bf008ee625f2f0142c2ccdgaudet close(FILE);
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj}
dbf0c7bef06259486cd2748a2d0e82f27e099d6efieldingclose(FILES);
dbf0c7bef06259486cd2748a2d0e82f27e099d6efielding
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj#
bd929c73ef04789b7183b840d8db6e01d03a4d86rbb# Write out updated version.
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj#
2a6c49cfaef5979a5a06098f3ce987cd76769409manojopen(BRANCHES, ">doc/private/newbranches") || die "can't open doc/private/branches: $!";
2a6c49cfaef5979a5a06098f3ce987cd76769409manojprint BRANCHES "\nBranch\t\t\t\tStatus\tWhom\t// Comments\n";
2a6c49cfaef5979a5a06098f3ce987cd76769409manojprint BRANCHES "-----------------------------------------------------------\n\n";
f6a6245816cd866361da8c576b1f47c7a54b6610fanfprint BRANCHES "\t\t\t\tnew\t\tnot yet classified\n";
f6a6245816cd866361da8c576b1f47c7a54b6610fanfprint BRANCHES "\t\t\t\topen\t\tdevelopement branch\n";
f6a6245816cd866361da8c576b1f47c7a54b6610fanfprint BRANCHES "\t\t\t\tactive\t\tnot a development branch\n";
f6a6245816cd866361da8c576b1f47c7a54b6610fanfprint BRANCHES "\t\t\t\treview\t\tready for review\n";
f6a6245816cd866361da8c576b1f47c7a54b6610fanfprint BRANCHES "\t\t\t\tprivate\t\tprivate branch\n";
2a6c49cfaef5979a5a06098f3ce987cd76769409manojprint BRANCHES "\t\t\t\tclosed\t\tfinished with\n";
2a6c49cfaef5979a5a06098f3ce987cd76769409manojprint BRANCHES "\n";
2a6c49cfaef5979a5a06098f3ce987cd76769409manojforeach $key (sort keys %branches) {
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj next if ($branches{$key} eq "closed");
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj print BRANCHES "$key";
d6b3cb141f0667101c1bca883ad15b383402c93bfielding $len = length($key);
d6b3cb141f0667101c1bca883ad15b383402c93bfielding if ($len >= 32) {
d6b3cb141f0667101c1bca883ad15b383402c93bfielding $tabs = 1;
d6b3cb141f0667101c1bca883ad15b383402c93bfielding } else {
d6b3cb141f0667101c1bca883ad15b383402c93bfielding $needed = int (32 - $len);
d6b3cb141f0667101c1bca883ad15b383402c93bfielding $tabs = int ($needed / 8);
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj if ($needed % 8 != 0) {
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj $tabs++;
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj }
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj }
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj for ($i = 0; $i < $tabs; $i++) {
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj printf BRANCHES "\t";
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj }
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj print BRANCHES "$branches{$key}\t";
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj print BRANCHES "$whom{$key}";
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj print BRANCHES "\t// $comments{$key}" if ($comments{$key} ne "");
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj print BRANCHES "\n";
d6b3cb141f0667101c1bca883ad15b383402c93bfielding}
d6b3cb141f0667101c1bca883ad15b383402c93bfielding
d6b3cb141f0667101c1bca883ad15b383402c93bfieldingprint BRANCHES "\n\n";
foreach $key (sort keys %branches) {
next if ($branches{$key} ne "closed");
print BRANCHES "$key";
$len = length($key);
if ($len >= 32) {
$tabs = 1;
} else {
$needed = int (32 - $len);
$tabs = int ($needed / 8);
if ($needed % 8 != 0) {
$tabs++;
}
}
for ($i = 0; $i < $tabs; $i++) {
printf BRANCHES "\t";
}
print BRANCHES "$branches{$key}";
print BRANCHES "\t\t// $comments{$key}" if ($comments{$key} ne "");
print BRANCHES "\n";
}
close(BRANCHES);
#
# Update if changed.
#
if (system("cmp", "-s", "doc/private/newbranches", "doc/private/branches")) {
rename("doc/private/newbranches", "doc/private/branches") || die "Cannot rename: doc/private/newbranches -> doc/private/branches: $!";
!system("cvs", "-d", $repository, "commit", "-m", "auto update", "doc/private/branches") || die "cvs commit failed: $!";
} else {
unlink("doc/private/newbranches");
}