#!/usr/bin/perl
#
# countcommits.pl: Count CVS commits from CVS commit emails
#
# Copyright (c) 2001 Paul Warren. All rights reserved.
#
# $Log: countcommits.pl,v $
# Revision 1.1  2001/10/02 20:04:55  pdw
# parrot_html
#
#

use Data::Dumper;

my $file = shift @ARGV;

system("lockfile $file.lock");

my $totals;
open FIN,$file;
my $tfile = join '',<FIN>;
close FIN;
eval $tfile;

my ($cvsroot, $author, $module);

my $inbody = 0;
while (<>) {
# 	print LOG "Got: $_";
    if(m/^$/) {
        $inbody = 1;
    }
    if($inbody) {
        if (!$cvsroot and m/^\s*CVSROOT:\s+(\S+)/i) {
            $cvsroot = $1; 
        }
        if (!$module and m/^\s*Module name:\s+(\S+)/i) {
            $module = $1;
        }
        if (!$author and m/^\s*Changes by:\s+(\S+)/i) {
            $author = $1;
        }
    }
}

$totals->{modules}->{$module}++;
$totals->{authors}->{$author}++;
$totals->{cvsroot}->{$cvsroot}++;

open FOUT,">$file";
print FOUT Data::Dumper->Dump([ $totals ], [ "totals" ]);
close FOUT;

unlink("$file.lock");
