update_branches revision 73cac2175470e9068829589476dda8bd6d88036f
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User#!/usr/local/bin/perl -w
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater#
c7ef13f6c9ef4436bc804b150e0a93307b11fa27Tinderbox User# Copyright (C) 2005 Internet Systems Consortium, Inc. ("ISC")
c7ef13f6c9ef4436bc804b150e0a93307b11fa27Tinderbox User#
1167fc7904c5f0a472f8df207ac46dd52c7f1ec8Automatic Updater# Permission to use, copy, modify, and distribute this software for any
0c39b3ed9409ecb277d5e32fa763a4e4d6598df8Automatic Updater# purpose with or without fee is hereby granted, provided that the above
46da3117812814a29432a8d9a9ccf8acdbfdadceAutomatic Updater# copyright notice and this permission notice appear in all copies.
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User#
fe84edc17e0d582cf7b4270f8df9d4742a107b1cAutomatic Updater# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
79b273c187a4aa1016a62181983dfdd0521681aeMark Andrews# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
bed0874e1a09e810575328c4bfc346a47514b69fMark Andrews# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
b253dcf9668f95e141bce9556dc88e30d3305a1dTinderbox User# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User# PERFORMANCE OF THIS SOFTWARE.
1ac49378a458420bc685293d12e567d7222d17b6Tinderbox User
bbde8dc56605130058a1540609264fa109da3b63Automatic Updater# $Id: update_branches,v 1.16 2005/05/17 03:54:26 marka Exp $
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews
6c910bd5e4a85a56e3a61fdf7b237a45bb2553eeTinderbox User#
3cc98b8ecedcbc8465f1cf2740b966b315662430Automatic Updater# Track which branches are still open or not in the bind9 cvs repository.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# This is done so that work that is "in progress" (active) doesn't get
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# so easily forgotten about.
a01aa536188bb3535dfc1107a623e6355a8e6b7cMark Andrews#
89623368b8f662d458d9964b923050f33c5f75b0Tinderbox User# This script updates doc/private/branches by adding new branches and moving
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# closed branches to the end of the file. New branches are found by walking
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# the cvs repository and extracting the new branches from the header fields
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews# of the files there.
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater#
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# doc/private/branches has one line per branch in the following field order:
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# name, status, to whom the branch belongs and comments. Comments are
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# in '(',')'. The first three field are single words.
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson#
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# Note: this is intended to be run on the machine hosting the CVS repository.
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User#
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt%branches = ();
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updater%whom = ();
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater%comments = ();
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt$repository = "/proj/cvs/prod";
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater$module = "bind9";
e6fc17ec5ad5ba1c4bf5730b2b97c82d1f2b8f3cMark Andrews
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater#
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt# Make sure we have a up to date copy. If the previous ran failed for
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updater# any reason remove it (-C).
2d2dc37599979c83495510f8af8d1756753aa2c5Automatic Updater#
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt!system("cvs", "-d", $repository, "update", "-C", "doc/private/branches") || die "cannot update doc/private/branches: $!";
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater#
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# load existing content
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater#
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic Updateropen(BRANCHES, "<doc/private/branches") || die "can't open util/branches: $!";
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic Updaterwhile (<BRANCHES>) {
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater chomp;
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater next if (/^-/);
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater next if (/^Branch/);
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater next if (/^\s/);
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews $c = "";
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews if (m://.*:) {
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews $c = $_;
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User $c =~ s:.*?//\s*(.*)$:$1:;
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User s:(.*?)//.*:$1:;
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews } else {
e5a3fb2b751598fdbcf2cde07a47202aaab93081Tinderbox User #
8e9f3b69914ee02a80b87c97b1f8093edb3e9ae0Automatic Updater # look for old style comment
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews #
a80993946f29ff39df38818ee9b2e58a4e46cb7eTinderbox User if (m/\(.*\)/) {
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $c = $_;
c59750de3ea3c7d5890000fb4606e8f5835a52aaTinderbox User $c =~ s/.*\((.*)\).*$/$1/;
80faf1588895fd26490f82f95a7a1b771df1c324Automatic Updater s/\(.*\)//;
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews }
ec7751119a08c6a7250f3187beed69a8b836d349Tinderbox User }
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews s/\s*$//;
114f7780384371121918624ae2c80ecfce545683Tinderbox User next if (/^\s*$/);
693c4232dfdffaff672197d4b9fea944c64cf80aAutomatic Updater ($branch, $status, $who) = split;
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $status = "new" if (!defined($status));
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater $branches{$branch} = $status;
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson $who = "" if (!defined($who));
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater $whom{$branch} = $who;
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater $comments{$branch} = $c;
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews}
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updaterclose (BRANCHES);
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater#
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# Search repository for new branches.
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson#
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# New branches have the following format "name:<revision>.0.#"
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User# where # is the number of potential branches from this the revision.
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews#
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrewsopen(FILES, "find $repository/$module -type f -name *,v -print |") || die "can't start find: $!";
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox Userwhile (<FILES>) {
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User chomp;
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews # print "file: $_\n"; # debug
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont # $file = $_; # save for branch debug below.
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User s:^$repository/::;
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User s:/Attic/([^/]*)$:/$1:;
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont s:,v$::;
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews #
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User # use cvs so that the file is locked.
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User #
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews #print "cvs -d $repository rlog -h $_\n";
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews open(FILE, "cvs -d $repository rlog -h $_|") || die "can't start cvs rlog -h $_: $!";
bed0874e1a09e810575328c4bfc346a47514b69fMark Andrews while (<FILE>) {
24bf1e02f03577db0feb50b80238c4150c96d05dAutomatic Updater chomp;
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews next unless m/^symbols$/; # skip until we find the tags
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews while (<FILE>) {
7500521cecdff3c00e594ec41d3a17292332ffbcTinderbox User chomp;
a308b69ac66fadf66863484f301314d6e6a3f1d2Automatic Updater last if (m/^locks;/); # we are past the tags
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews last if (m/^keyword/); # we are past the tags
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews next unless m/\.0\.\d$/; # skip if not a branch
a01aa536188bb3535dfc1107a623e6355a8e6b7cMark Andrews s/\s(.*):.*/$1/; # extract label
89623368b8f662d458d9964b923050f33c5f75b0Tinderbox User if (!$branches{$_}) {
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $branches{$_} = "new";
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews $whom{$_} = "";
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews $comments{$_} = "";
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews # print "branch: $_ $file\n"; # debug
01a5c5503482fb3ba52088bf0178a7213273bf96Mark Andrews }
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews }
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews chomp while (<FILE>); # let cvs rlog exit normally.
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater }
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic Updater close(FILE);
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater}
fe80a4909bf62b602feaf246866e9d29f7654194Automatic Updaterclose(FILES);
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater#
fe80a4909bf62b602feaf246866e9d29f7654194Automatic Updater# Write out updated version.
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater#
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updateropen(BRANCHES, ">doc/private/newbranches") || die "can't open doc/private/branches: $!";
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafssonprint BRANCHES "\nBranch\t\t\t\tStatus\tWhom\t// Comments\n";
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updaterprint BRANCHES "-----------------------------------------------------------\n\n";
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrewsprint BRANCHES "\t\t\t\tnew\t\tnot yet classified\n";
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafssonprint BRANCHES "\t\t\t\topen\t\tdevelopement branch\n";
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updaterprint BRANCHES "\t\t\t\tactive\t\tnot a development branch\n";
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updaterprint BRANCHES "\t\t\t\treview\t\tready for review\n";
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updaterprint BRANCHES "\t\t\t\tprivate\t\tprivate branch\n";
133e6d43fa82e80d3798be4de00f4540f485ec6cAutomatic Updaterprint BRANCHES "\t\t\t\tclosed\t\tfinished with\n";
133e6d43fa82e80d3798be4de00f4540f485ec6cAutomatic Updaterprint BRANCHES "\n";
133e6d43fa82e80d3798be4de00f4540f485ec6cAutomatic Updaterforeach $key (sort keys %branches) {
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater next if ($branches{$key} eq "closed");
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson print BRANCHES "$key";
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater $len = length($key);
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User if ($len >= 32) {
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User $tabs = 1;
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User } else {
c7ef13f6c9ef4436bc804b150e0a93307b11fa27Tinderbox User $needed = int (32 - $len);
c7ef13f6c9ef4436bc804b150e0a93307b11fa27Tinderbox User $tabs = int ($needed / 8);
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User if ($needed % 8 != 0) {
f132a836c4e386b1af045dd8fe7106ae61b90bffAutomatic Updater $tabs++;
8f2c45a35dd8c40bcc9caba8f7d40ce64fc27bcdAutomatic Updater }
c6a0f4ae1d7183a16ffb196b86b647f870694796Automatic Updater }
8f2c45a35dd8c40bcc9caba8f7d40ce64fc27bcdAutomatic Updater for ($i = 0; $i < $tabs; $i++) {
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User printf BRANCHES "\t";
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User }
269519eeb959d905ed125f96426e01d725c3b597Tinderbox User print BRANCHES "$branches{$key}\t";
8711e5c73ca872d59810760af0332194cbdd619bAutomatic Updater print BRANCHES "$whom{$key}";
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater print BRANCHES "\t// $comments{$key}" if ($comments{$key} ne "");
8f2c45a35dd8c40bcc9caba8f7d40ce64fc27bcdAutomatic Updater print BRANCHES "\n";
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater}
8f2c45a35dd8c40bcc9caba8f7d40ce64fc27bcdAutomatic Updater
4e0e18467f8ec5a9e5d0c538ce46bf07409ecf9bTinderbox Userprint BRANCHES "\n\n";
e85565067cf73f8cc21ee29b11761659f1d47ee9Automatic Updater
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updaterforeach $key (sort keys %branches) {
bc0a53583d92309bebcf93c408e2f3247ebd3d3cAutomatic Updater next if ($branches{$key} ne "closed");
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater print BRANCHES "$key";
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater $len = length($key);
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater if ($len >= 32) {
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater $tabs = 1;
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater } else {
7f79131f9a8e804b93c57f3c679065cce878b726Automatic Updater $needed = int (32 - $len);
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater $tabs = int ($needed / 8);
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater if ($needed % 8 != 0) {
3f616e6f846be57b1717c6beaba0f74de9d5a7c6Automatic Updater $tabs++;
8f2c45a35dd8c40bcc9caba8f7d40ce64fc27bcdAutomatic Updater }
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater }
19b3dc94bce93fa76bd7e066f9298630dbc9dcb4Automatic Updater for ($i = 0; $i < $tabs; $i++) {
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater printf BRANCHES "\t";
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater }
7f94d9a8162c9a96b56e66176702b66e79d8e1a2Automatic Updater print BRANCHES "$branches{$key}";
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater print BRANCHES "\t\t// $comments{$key}" if ($comments{$key} ne "");
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater print BRANCHES "\n";
5ecad47f69b3fd945472ab2900a9ff826a7ce2f6Automatic Updater}
dbd021853bb1cd6ab128e8da8865f5965030aedcTinderbox Userclose(BRANCHES);
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater
71bd43eebd9d6e42dbcae62b730f5b6508d5acd8Automatic Updater#
82447d835d3ff5c658749b4e9b4f66166407b3eaAutomatic Updater# Update if changed.
7262eb86f2b465822206122921e2f357218f0cfdAutomatic Updater#
96ea71632887c58a9d00f47eb318bf76b35903c3Mark Andrewsif (system("cmp", "-s", "doc/private/newbranches", "doc/private/branches")) {
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater rename("doc/private/newbranches", "doc/private/branches") || die "Cannot rename: doc/private/newbranches -> doc/private/branches: $!";
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater !system("cvs", "-d", $repository, "commit", "-m", "auto update", "doc/private/branches") || die "cvs commit failed: $!";
bbb069be941f649228760edcc241122933c066d2Automatic Updater} else {
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater unlink("doc/private/newbranches");
4cda4fd158d6ded5586bacea8c388445d99611eaAutomatic Updater}
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews