#!/usr/bin/perl use strict; my($HISTORY, $filename, $date, %dateline, $day, $adate, $author, %cols, $newcolnum, @today, @html, $event, $file, $user, $i, $table, %authorcolor, @authorseq, @colors, $newauthnum, %heading, $color, $temp, $revision, $lines, $state, %authorcommits, %tauthorcommits, $nowmonth, $prevmonth, $prevyear, @monthnames, $headerhtml, $loghtml, $nowyear, $comment, $OUTPUT, $INDEX); open HISTORY, "< logout"; # We need some colors for authors -- I only bother to define 10 here $colors[0] = "FF9900"; $colors[1] = "FFFF00"; $colors[2] = "33FF33"; $colors[3] = "66CCCC"; $colors[4] = "6666CC"; $colors[5] = "CC66CC"; $colors[6] = "996633"; $colors[7] = "006600"; $colors[8] = "333399"; $colors[9] = "C0C0C0"; # Some names for the months of the year $monthnames[1] = "Jan"; $monthnames[2] = "Feb"; $monthnames[3] = "Mar"; $monthnames[4] = "Apr"; $monthnames[5] = "May"; $monthnames[6] = "Jun"; $monthnames[7] = "Jul"; $monthnames[8] = "Aug"; $monthnames[9] = "Sep"; $monthnames[10] = "Oct"; $monthnames[11] = "Nov"; $monthnames[12] = "Dec"; # Hoon through the CVS history print STDERR "Reading log\n"; while(){ if(/^Working file: (.*)/){ $filename = $1; print STDERR "File $filename seen\n"; chomp $filename; } elsif(/^date: ([0-9\/]+).*author: (.*);.*state: (.*);(.*)$/){ $date = $1; $author = $2; $state = $3; $comment = ""; $_ = $4; if(/.*lines: \+(.*) -(.*)/){ $lines = int($1) + int($2); if($lines > 100){ $lines = "*"; } else{ $lines = "."; } } elsif($revision eq "1.1"){ $lines = "I"; $revision = ""; } if($state eq "dead"){ $lines = "D"; } } elsif(/^revision (.*)/){ $revision = $1; } elsif((/^--------/) || (/^========/)){ if(($filename eq "") || ($author eq "") || ($lines eq "") || ($date eq "") || ($comment eq "")){ } else{ $_ = $filename; if(/.*docbook.*/){ } else{ $date =~ s/\///g; $comment =~ s/\!//g; $comment =~ s/://g; print STDERR "Adding revision: $date, $author\n"; $dateline{$date} = $dateline{$date} . "$filename!$author!$lines!$comment;"; $date = ""; } } $comment = ""; } else{ s/[\r\n]/ /; $comment = "$comment$_"; } } ############################################################################## # Draw the graph - I now do a graph per month $newcolnum = 0; $newauthnum = 0; $table = ""; $prevmonth = ""; $prevyear = ""; open INDEX, "> $ARGV[0].html"; print INDEX ""; # For each date foreach $adate (sort keys %dateline){ for($i = 0; $i < $newcolnum; $i++){ $html[$i] = ""; } # If this is a new month, then we need to reset ourselves and draw a # new header line $_ = $adate; /([0-9][0-9][0-9][0-9])([0-9][0-9])/; $nowmonth = $2; $nowyear = $1; if($nowmonth ne $prevmonth){ if($prevmonth ne ""){ output(); close OUTPUT; $table = ""; } $loghtml = ""; $prevmonth = $nowmonth; $prevyear = $nowyear; $newcolnum = 0; %cols = (); open OUTPUT, "> $ARGV[0]-$nowyear$nowmonth.html"; print OUTPUT "\n"; } @today = split(/;/, $dateline{$adate}); foreach $event (@today){ $_ = $event; /(.*)!(.*)!(.*)!(.*)/; $file = $1; $user = $2; $lines = $3; $comment = $4; if($lines eq ""){ $lines = " \n"; } if($lines eq "I"){ $lines = "\"$comment\"\n"; } elsif($lines eq "D"){ $lines = "\"$comment\"\n"; } elsif($lines eq "."){ $lines = "\"$comment\"\n"; } elsif($lines eq "*"){ $lines = "\"$comment\"\n"; } # Do we need a new cell number? if($cols{$file} eq ""){ $cols{$file} = $newcolnum; $heading{$newcolnum} = $file; $newcolnum++; } # Do we need a new author color? if($authorcolor{$user} eq ""){ print STDERR "Detected new author: $user\n"; $authorcolor{$user} = $colors[$newauthnum]; # We should check that we allocated a color, otherwise go white if($authorcolor{$user} eq ""){ $authorcolor{$user} = "FFFFFF"; print STDERR "Ran out of user colors to allocate ($newauthnum)\n"; } $authorcommits{$user} = 0; $tauthorcommits{$user} = 0; # This is a hack to make sure the authors appear in the right # order in the output summary $authorseq[$newauthnum] = $user; $newauthnum++; } # Increment the count of commits for this author $authorcommits{$user}++; $tauthorcommits{$user}++; # This could be cleaned up... Build the cell if($html[$cols{$file}] eq " "){ $html[$cols{$file}] = ""; } if($html[$cols{$file}] eq ""){ $html[$cols{$file}] = "\n"; } else{ $html[$cols{$file}] = "" . $html[$cols{$file}]; } } # This should be improved for($i = 0; $i < $newcolnum; $i++){ $html[$i] = "\n"; } $loghtml = $loghtml . "@html\n\n"; } output(); # Finish up the index page print INDEX ""; foreach $user (@authorseq){ $color = $authorcolor{$user}; print INDEX ""; } print INDEX ""; print INDEX ""; foreach $user (@authorseq){ $color = $authorcolor{$user}; print INDEX "" } print INDEX "\n"; print INDEX "
$lines
$lines
" . $html[$i] . "
$adate
 $tauthorcommits{$user}
 "; if(-f authors){ print INDEX `grep $user authors | sed 's/^$user://'`; } else{ print INDEX "$user"; } print INDEX "
"; print INDEX "

$newauthnum committers in total\n"; close INDEX; close OUTPUT; sub output(){ if($prevmonth ne ""){ $table = $table . " $monthnames[$prevmonth] $nowyear\n"; # The funky header thingie $headerhtml = ""; for($i = 0; $i < $newcolnum; $i++){ $temp = $heading{$i}; $temp =~ s/[\/\.]/_/g; $temp =~ s/\r*\n*$//; if(! -e "colheader-$temp.jpg"){ print STDERR "Generating column header colheader-$temp.jpg\n"; `convert -font helvetica -pointsize 10 -draw "text 1,10 $heading{$i}" -rotate -90 blank.jpg colheader-$temp.jpg`; } $headerhtml = $headerhtml . "\n"; } $table = $table . $headerhtml . $loghtml; } print INDEX ""; print INDEX "$monthnames[$prevmonth] $prevyear"; foreach $user (@authorseq){ $color = $authorcolor{$user}; print INDEX "$authorcommits{$user}"; } print INDEX "\n"; print OUTPUT "\n"; print OUTPUT "$table
\n"; print OUTPUT "


Authors: \n"; print OUTPUT "\n"; print STDERR "Author summary\n"; foreach $user (@authorseq){ $color = $authorcolor{$user}; print OUTPUT ""; } print OUTPUT "
$user: "; print STDERR "User \"$user\"\n"; if(-f authors){ print OUTPUT `grep $user authors | sed 's/^$user://'`; } else{ print OUTPUT "$user"; } print OUTPUT " ($authorcommits{$user})"; $authorcommits{$user} = 0; print OUTPUT "
\n"; print OUTPUT "
Key: \n"; print OUTPUT "\n"; print OUTPUT "\n"; print OUTPUT "\n"; print OUTPUT "\n"; print OUTPUT "
: Initial import of a file: File deleted from repository: Minor code change (less than 100 lines): Major code change (more than 100 lines)
"; print OUTPUT "

END OF REPORT\n"; print OUTPUT "\n"; }