0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Copyright (C) 2005, 2007, 2012, 2016 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# file, You can obtain one at http://mozilla.org/MPL/2.0/.
95317501208f3bf5b159e6a40801b7069f68c486Mark Andrews# Track which branches are still open or not in the bind9 cvs repository.
95317501208f3bf5b159e6a40801b7069f68c486Mark Andrews# This is done so that work that is "in progress" (active) doesn't get
95317501208f3bf5b159e6a40801b7069f68c486Mark Andrews# so easily forgotten about.
95317501208f3bf5b159e6a40801b7069f68c486Mark Andrews# This script updates doc/private/branches by adding new branches and moving
95317501208f3bf5b159e6a40801b7069f68c486Mark Andrews# closed branches to the end of the file. New branches are found by walking
95317501208f3bf5b159e6a40801b7069f68c486Mark Andrews# the cvs repository and extracting the new branches from the header fields
95317501208f3bf5b159e6a40801b7069f68c486Mark Andrews# of the files there.
95317501208f3bf5b159e6a40801b7069f68c486Mark Andrews# doc/private/branches has one line per branch in the following field order:
95317501208f3bf5b159e6a40801b7069f68c486Mark Andrews# name, status, to whom the branch belongs and comments. Comments are
95317501208f3bf5b159e6a40801b7069f68c486Mark Andrews# in '(',')'. The first three field are single words.
73cac2175470e9068829589476dda8bd6d88036fMark Andrews# Note: this is intended to be run on the machine hosting the CVS repository.
514f6f14245f42c96f3d5e90462ce2ebe0597d2eMark Andrews%history = ();
01163d188b89911c3a23fe1125a4cab6764a408cMark Andrews# Make sure we have a up to date copy. If the previous ran failed for
01163d188b89911c3a23fe1125a4cab6764a408cMark Andrews# any reason remove it (-C).
b08e3be5dbfba22719ae9c428bd6853ac6f09798Mark Andrews!system("cvs", "-d", $repository, "update", "-C", "doc/private/branches") || die "cannot update doc/private/branches: $!";
d9b4174233b951f25cd53a2787b9f14314258c2fMark Andrews# load existing content
d9b4174233b951f25cd53a2787b9f14314258c2fMark Andrewsopen(BRANCHES, "<doc/private/branches") || die "can't open util/branches: $!";
514f6f14245f42c96f3d5e90462ce2ebe0597d2eMark Andrews# T 1999-03-15 21:15 +0000 vixie bind [ietf44:A]
514f6f14245f42c96f3d5e90462ce2ebe0597d2eMark Andrewsopen(HISTORY, "cvs history -T -a 2> /dev/null |") || die("can't get history");
514f6f14245f42c96f3d5e90462ce2ebe0597d2eMark Andrews s/:[^ \t]+$//;
514f6f14245f42c96f3d5e90462ce2ebe0597d2eMark Andrews ($tag, $date, $time, $tz, $who, $mod, $branch) = split;
d9b4174233b951f25cd53a2787b9f14314258c2fMark Andrews# Search repository for new branches.
d6dc0d4f584352d2e4305435599ae8c93776d9b4Mark Andrews# New branches have the following format "name:<revision>.0.#"
d6dc0d4f584352d2e4305435599ae8c93776d9b4Mark Andrews# where # is the number of potential branches from this the revision.
b08e3be5dbfba22719ae9c428bd6853ac6f09798Mark Andrewsopen(FILES, "find $repository/$module -type f -name *,v -print |") || die "can't start find: $!";
b08e3be5dbfba22719ae9c428bd6853ac6f09798Mark Andrews open(FILE, "cvs -d $repository rlog -h $_|") || die "can't start cvs rlog -h $_: $!";
8f8634e66351e292925dde8ab6b0418a0141f86aMark Andrews next unless m/^symbolic names:$/; # skip until we find the tags
68843c99b695bf194b019d465f6d33e6297fd02aMark Andrews next unless m/\.0\.\d+$/; # skip if not a branch
b08e3be5dbfba22719ae9c428bd6853ac6f09798Mark Andrews chomp while (<FILE>); # let cvs rlog exit normally.
d9b4174233b951f25cd53a2787b9f14314258c2fMark Andrews# Write out updated version.
d9b4174233b951f25cd53a2787b9f14314258c2fMark Andrewsopen(BRANCHES, ">doc/private/newbranches") || die "can't open doc/private/branches: $!";
b08e3be5dbfba22719ae9c428bd6853ac6f09798Mark Andrewsprint BRANCHES "\nBranch\t\t\t\tStatus\tWhom\t// Comments\n";
d6dc0d4f584352d2e4305435599ae8c93776d9b4Mark Andrewsprint BRANCHES "-----------------------------------------------------------\n\n";
d6dc0d4f584352d2e4305435599ae8c93776d9b4Mark Andrewsprint BRANCHES "\t\t\t\tnew\t\tnot yet classified\n";
d6dc0d4f584352d2e4305435599ae8c93776d9b4Mark Andrewsprint BRANCHES "\t\t\t\topen\t\tdevelopement branch\n";
d6dc0d4f584352d2e4305435599ae8c93776d9b4Mark Andrewsprint BRANCHES "\t\t\t\tactive\t\tnot a development branch\n";
d6dc0d4f584352d2e4305435599ae8c93776d9b4Mark Andrewsprint BRANCHES "\t\t\t\treview\t\tready for review\n";
d6dc0d4f584352d2e4305435599ae8c93776d9b4Mark Andrewsprint BRANCHES "\t\t\t\tprivate\t\tprivate branch\n";
d6dc0d4f584352d2e4305435599ae8c93776d9b4Mark Andrewsprint BRANCHES "\t\t\t\tclosed\t\tfinished with\n";
b08e3be5dbfba22719ae9c428bd6853ac6f09798Mark Andrews print BRANCHES "\t// $comments{$key}" if ($comments{$key} ne "");
b08e3be5dbfba22719ae9c428bd6853ac6f09798Mark Andrews print BRANCHES "\t\t// $comments{$key}" if ($comments{$key} ne "");
d9b4174233b951f25cd53a2787b9f14314258c2fMark Andrews# Update if changed.
d9b4174233b951f25cd53a2787b9f14314258c2fMark Andrewsif (system("cmp", "-s", "doc/private/newbranches", "doc/private/branches")) {
d9b4174233b951f25cd53a2787b9f14314258c2fMark Andrews rename("doc/private/newbranches", "doc/private/branches") || die "Cannot rename: doc/private/newbranches -> doc/private/branches: $!";
b08e3be5dbfba22719ae9c428bd6853ac6f09798Mark Andrews !system("cvs", "-d", $repository, "commit", "-m", "auto update", "doc/private/branches") || die "cvs commit failed: $!";