#!/usr/bin/perl
# rlogview script
# written by Adam Graffunder
# agraf@u.washinton.edu
# 02/18/2004
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
use Date::Format;
use Time::ParseDate;
use strict;
my $cvsroot = "/data/cvs"; # set this
my $repository = "rlogview"; # set this
my $file = `rlog -zLT \`find $cvsroot/$repository/\``;
my $viewcvs = "sorry, no.";
#my $viewcvs = "qna-dev.cac.washington.edu/mikeg/viewcvs/viewcvs.cgi";
# use for inserting an rlog file into the script
#my $file = `cat /data/www/rlogfaq`;
my %dates;
print "Content-type: text/html\n\n
Changes to $repository
\n";
processRlog();
printDates();
print "
";
sub processRlog {
# notes the filename as the loop descends into each date in the log.
while($file =~ /^RCS file: .*?\/$repository\/(.*?\/?(\w|\.)+),v(.*?={77})/msg) {
my $rcsfile = $1;
my $changes = $3;
# separates the changes into a list of revisions
while ($changes =~ /revision\ (.*?)date:\ (\d\d\d\d[\/-]\d\d[\/-]\d\d)\ (\d\d:\d\d):\d\d-\d\d;\ \ author:\ (\w*?);.*?$(.*?)(-{28}|={77})/msg){
my $revision = $1;
my $date = $2;
my $time = $3;
my $author = $4;
my $comment = $5;
$comment =~ s/branches: .*?;//;
my $unixtime = parsedate($time, TIME_REQUIRED => 1, TIMEFIRST => 1);
# this is the hashing section, where the rlog output is parsed about so we can output it however we want.
# hashes on dates and times (to the minute) and then comments. presumes that any
# duplicate comments in the same two minutes are the same update. If a commit splits
# across multiple minute boundaries, this will fail, displaying repeated comments on
# different lines. (i think)
if (!exists $dates{$date}) {
# new date case (includes new time and new comment cases)
$dates{$date} = {};
$dates{$date}{$time} = {};
$dates{$date}{$time}{$comment} = "$comment (by $author) -
$rcsfile";
}else{
# existant date case
my $nextmin = time2str("%R", $unixtime+60);
my $lastmin = time2str("%R", $unixtime-60);
if(exists $dates{$date}{$nextmin} || exists $dates{$date}{$lastmin}){$time = $lastmin;}
if (!exists $dates{$date}{$time}) {
# new time case (includes new comment case)
$dates{$date}{$time} = {};
$dates{$date}{$time}{$comment} = "$comment (by $author) -
$rcsfile";
}else{
# existant time case
if (!exists $dates{$date}{$time}{$comment}) {
# new comment case
$dates{$date}{$time}{$comment} = "$comment (by $author) -
$rcsfile";
}else{
# existant comment case
$dates{$date}{$time}{$comment} = $dates{$date}{$time}{$comment}.
", $rcsfile";
}
}
}
}
}
}
# prints out dates containing times with associated comments, authors, and filenames.
sub printDates {
my @datekeys = sort {$b cmp $a} keys %dates;
foreach my $date (@datekeys) {
my $unixdate = parsedate($date);
my $nicedate = time2str("%A, %Y-%b-%d", $unixdate);
print "$nicedate \n";
my @timekeys = sort {$b cmp $a} keys %{ $dates{$date} };
foreach my $time (@timekeys) {
my @commentkeys = keys %{ $dates{$date}{$time} };
foreach my $comment (@commentkeys) {
my $unixtime = parsedate($time, TIME_REQUIRED => 1, TIMEFIRST => 1);
my $nicetime = time2str("%l:%M %p", $unixtime);
print " |
| $nicetime | $dates{$date}{$time}{$comment} \n";
}
}
}
}
|