#!/usr/bin/perl # # Perl script to create a chronological HTML file from 'cvs log' output # # cvs2chrono v0.2.0, Copyright (C) Dorando 2003 # # 0.2.0 / 14 Apr 2003 / Now XHTML1.1 conform, and takes much less memory # 0.1.0 / 13 Apr 2003 / Initial release # # Permission is granted to redistribute this script under the terms of the # GNU General Public License http://www.gnu.org/copyleft/gpl.html $version="0.2.0"; require 'getopts.pl' &Getopts('d:f:hlo:vw:'); if($opt_h) { print "\n"; print "-d[...] CVS date range\n"; print "-f[...] File to read from, otherwise parses cvs log output. Ignores -dl\n"; print "-h This screen\n"; print "-l Only the current or topmost directory\n"; print "-o[...] Output file without .html\n"; print "-v Verbose\n"; print "-w[...] Creates links to a webcvs\n"; print "\n"; print 'example: cvs2chrono -d ">01 Aug 2002" -o "messlog" -w "http://cvs.mess.org:6502/cgi-bin/viewcvs.cgi/"'; print "\n\nTo get an optimal result you should run 'cvs update' without -P, to include logs of deleted directories\n"; exit; } if($opt_d) { $opt_d='-d"'.$opt_d.'"'; } if($opt_l) { $opt_l="-l"; } if(!$opt_o) { $opt_o="chrono"; } if($opt_f) { open(LOG,$opt_f) or die "Error: Could not open $opt_f"; @lines=; close(LOG) } else { @lines = `cvs log $opt_l $opt_d `; } my $rev, $file, $time, $author, $logtext, @log; for($i=1;$i<(my $length = @lines);$i++) { if(@lines[$i] =~ /RCS/) { @lines[$i]=~/cvs\/mess\/(.+?),v/; $file=$1; print "Processing $file\n"; while(!(@lines[$i-1] =~ /description/)) { $i++; } while(!(@lines[$i] =~ /=============================================================================/)) { if(@lines[$i] =~ "revision ") { $rev=substr(@lines[$i],9);chomp($rev); @lines[$i]=~/revision (..[0-9]+)/; $rev=$1; } elsif(@lines[$i] =~ "date: .+?;") { @lines[$i]=~/date: (.+?);/; $time=$1; @lines[$i]=~/author: (.+?);/; $author=$1; } elsif(!(@lines[$i] =~ /---------------/)) { $logtext.=@lines[$i]."
"; $_=$logtext; s/&/&/g; s//>/g; s/<br \/>/
/g;; $logtext=$_; if($logtext eq "\n
" or $logtext eq "\r\n
") { $logtext=""; } } $i++; if(@lines[$i] =~ /(=====|-----)/) { #print " Logging $rev from $author at $time\n\nlogtext\n";; push(@log,"
$time | $rev | $author | $file
\n$logtext"); $logtext=""; } } } } $hasprevious=""; print "Generating $opt_o.html\n"; @log = reverse(sort(@log)); push(@log,""); open(CHRONO,">$opt_o.html") or die "Error: Could not create $opt_o\n"; print CHRONO <<'HTMLHEADER'; CVS Log
HTMLHEADER for($i=0;$i<(my $length = @log)-1;$i++) { if($opt_w) { @log[$i]=~s/(.+?)$1<\/a>//i; } @log[$i]=~/(.*)<\/pre>\n(.*)/s; $old1=$1;$old2=$2; @log[$i+1]=~/(.*)<\/pre>\n(.*)/s; if($2 eq $old2) { $hasprevious=$hasprevious.$old1.""; if($i+1!=$length-1){next}; } else { @log[$i]=$hasprevious.@log[$i]; $hasprevious=""; } if($opt_v){print $i+1," of ",$length-1,"\n"}; print CHRONO @log[$i]; print CHRONO "
\n"; } print CHRONO "Generated with
cvs2chrono $version\n"; print CHRONO "
"; close(CHRONO);