#!/usr/bin/perl
#
# Copyright (c) 1999-2001 John C. Reynolds
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer,
# without modification, immediately at the beginning of the file.
# 2. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Quickie script to reformat CVSup (16) log files into HTML. Links
# references to files, deltas, and committers to the CVS web CGI program
# and the FreeBSD web site.
#
# The idea for this program originated from an 'awk' script created by
# <Dom.Mitchell@palmerharvey.co.uk>, with other ideas and patches submitted
# by Marcel Moolenaar <marcel@scc.nl>.
#
require 'ctime.pl';
$url = 'http://www.freebsd.org/cgi/cvsweb.cgi';
if ($ARGV[0] eq '') {
print "Usage: $0 cvsup-log-file > cvsup-log-file.html\n";
exit 1;
}
# Grab date from file if not coming in from stdin
#
$date = '';
unless ($ARGV[0] eq '-') {
($dev, $ino, $mode, $nlink, $uid, $gid,
$rdev, $size, $atime, $mtime, @junk) = stat ($ARGV[0]);
$date = ctime ($mtime);
chomp ($date);
$date = '(' . $date . ')';
}
if (! open (IN, $ARGV[0])) {
print (STDERR "Could not open '$ARGV[0]' for reading - $!\n");
exit 2;
}
while (<IN>) {
if (/Parsing\s+supfile\s+"(.*?)"/) {
$file = $1;
$fileqm = quotemeta ($file);
s#$fileqm#<A HREF="file:$file">$file</A>#;
}
if (/(Delete|Edit|Checkout)\s+(\S+)/) {
$file = $2;
$fileqm = quotemeta ($file);
($realfile = $file) =~ s/,v$//;
s#$fileqm#<A HREF="$url/$realfile">$file</A>#;
}
if (/Add\s+delta\s+(\S+).*?(\S+)\s*$/) {
$rev = $1;
$committer = $2;
s#$rev#<A HREF="$url/${realfile}?rev=$rev">$rev</A>#;
s#$committer$#<A HREF="mailto:$committer\@freebsd.org">$committer</A>#;
}
if (/Updating\s+collection\s+(\S+)/) {
$collection = $1;
}
push (@lines, $_);
}
close (IN);
print "<HTML>\n<HEAD>\n";
print "<TITLE>CVSup log for '$collection' ${date}</TITLE>\n</HEAD>\n";
print "<BODY>\n<PRE>\n\n";
foreach (@lines) {
print;
}
print "</PRE>\n</BODY>\n</HTML>\n\n";
syntax highlighted by Code2HTML, v. 0.9.1