#!/usr/bin/perl # # Perl script to create a chronological HTML file from 'cvs log' output # # cvs2chrono Copyright (C) Dorando 2003 # # 0.3.0 / 15 Apr 2003 / New parser, generates smaller and better output # 0.2.2 / 14 Apr 2003 / Can now use a namefile, direct link to revisions # 0.2.1 / 14 Apr 2003 / Removes Attic/ in displayed dir, smaller output # 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.3.0"; use Getopt::Std; getopts('d:f:hlMn:o:rsV:w:'); if($opt_h) { print <<"ENDOFHELP"; -d "" CVS date range. See rlog(1). -f "" If set, parses this instead of cvs output. Renders -d -and -l useless. -h :-P -l Only the current or topmost directories. -M Predefined variables for MESS. -n "" Includes Namefile. -o "" File to output to. -r Reverses output. Normal output is from newsest to oldest. -s Generates smaller file list output. -V1 Prints current file. -V2 Prints current file and progression of html creation. -w "" Generates links to a webcvs. example: cvs2chrono -d ">01 Aug 2002" -o "messlog" -w "http://cvs.mess.org:6502/cgi-bin/viewcvs.cgi/" Note: cvs outputs only logs for directories that are also in the working dir, so you may want to run 'cvs update' without -P to get logs for deleted directories. ENDOFHELP exit; } if($opt_M) { $opt_d=">01 Aug 2002"; # $opt_f="cvslog"; $opt_o="wip.html"; $opt_n="cvsnames"; $opt_s="-s"; $opt_w="http://cvs.mess.org:6502/cgi-bin/viewcvs.cgi/"; } if($opt_d) { $opt_d='-d"'.$opt_d.'"'; } if($opt_l) { $opt_l="-l"; } if(!$opt_o) { $opt_o="chrono.html"; } 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\/.+?\/(.+?),v/; $file=$1; $file=~s/Attic\///; if($opt_V>0){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] =~ /(=====|-----)/) { push(@log,"$time | $rev | $author | $file\n$logtext"); $logtext=""; } } } } print "Generating $opt_o\n"; if($opt_r){@log = sort(@log);}else{@log = reverse(sort(@log));} push(@log,""); open(CHRONO,">$opt_o") or die "Error: Could not create $opt_o\n"; print CHRONO <<"HTMLHEADER"; CVS Log
HTMLHEADER if($opt_n){require $opt_n}; for($i=0;$i<(my $length = @log)-1;$i++) { @log[$i]=~/(.+?) \| (.+?) \| (.+?) \| (.+?)\n(.*)/s; $time=$1; $rev=$2; $author=$3; $file=$4; if($opt_w){$file="$file";} if($files){if(!$opt_s){$files.="
"}$files.="\n$file";}else{$files.=$file}; $logtext=$5; @log[$i+1]=~/.+?\n(.*)/s; if($logtext eq $1){next} for($ii=1;$ii<$names-1;$ii=$ii+2) { $author=~s/@names[$ii]/@names[$ii+1]/; } print CHRONO "$time | $author\n
$logtext
$files

\n"; $files=""; if($opt_V>1) { $progression=int($i / ($length-2) * 100)."%\n"; if($oldprogression!=$progression) { $oldprogression=$progression; print $progression; } } } print CHRONO "Generated with cvs2chrono $version\n"; print CHRONO "
"; close(CHRONO);