#!/usr/bin/perl -w

my @dirdates = ( 
		 ["1/1/02", ["Event/ITEvent","IT/ITAlgorithms"]],
		 ["7/1/02", ["Event/ITEvent","IT/ITAlgorithms","IT/ITAssociators"]],
		 ["1/1/03", ["Event/ITEvent","Det/ITDet","IT/ITAlgorithms","IT/ITAssociators","IT/ITCheckers"]],
		 ["7/1/03", ["Event/ITEvent","Det/ITDet","IT/ITAlgorithms","IT/ITAssociators","IT/ITCheckers"]],
		 ["1/1/04", ["Event/ITEvent","Det/ITDet","IT/ITAlgorithms","IT/ITAssociators","IT/ITCheckers"]],
		 ["7/1/04", ["Event/ITEvent","Det/STDet","IT/ITAlgorithms","IT/ITAssociators","IT/ITCheckers"]],
		 ["1/1/05", ["Event/ITEvent","Det/STDet","IT/ITAlgorithms","IT/ITAssociators","IT/ITCheckers"]],
		 ["7/1/05", ["Event/ITEvent","Det/STDet","IT/ITAlgorithms","IT/ITAssociators","IT/ITCheckers"]],
		 ["1/1/06", ["Event/STEvent","Det/STDet","ST/STAlgorithms","ST/STAssociators","ST/STCheckers","ST/STDAQ","ST/STTools","Si/SiDAQ"]],
		 ["7/1/06", ["Det/STDet","ST/STAlgorithms","ST/STAssociators","ST/STCheckers","ST/STDAQ","ST/STTools","Si/SiDAQ","Si/SiTools"]],
		 ["1/1/07", ["Det/STDet","ST/STAlgorithms","ST/STAssociators","ST/STCheckers","ST/STDAQ","ST/STTools","Si/SiDAQ","Si/SiTools"]],
		 ["7/1/07", ["Det/STDet","ST/STAlgorithms","ST/STAssociators","ST/STCheckers","ST/STDAQ","ST/STTools","Si/SiDAQ","Si/SiTools"]],
		 ["1/1/08", ["Det/STDet","ST/STAlgorithms","ST/STAssociators","ST/STCheckers","ST/STDAQ","ST/STTools","Si/SiDAQ","Si/SiTools","ST/STTELL1Event","ST/STKernel","ST/STOnline","ST/STRawAnalysis"]],
		 ["7/1/08", ["Det/STDet","ST/STAlgorithms","ST/STAssociators","ST/STCheckers","ST/STDAQ","ST/STTools","Si/SiDAQ","Si/SiTools","ST/STTELL1Event","ST/STKernel","ST/STOnline","ST/STRawAnalysis", "ST/STTELL1Algorithms","ST/STTELL1Kernel","ST/STVetraAnalysis"]],
		 ["1/1/09", ["Det/STDet","ST/STAlgorithms","ST/STDigiAlgorithms","ST/STAssociators","ST/STCheckers","ST/STDAQ","ST/STTools","Si/SiDAQ","Si/SiTools","ST/STTELL1Event","ST/STKernel","ST/STOnline","ST/STRawAnalysis", "ST/STTELL1Algorithms","ST/STTELL1Kernel","ST/STVetraAnalysis"]],
		 ["3/3/09", ["ST/STKernel","Det/STDet","ST/STTELL1Event","ST/STDigiAlgorithms","ST/STAlgorithms","Si/SiTools","ST/STTools","ST/STAssociators","ST/STCheckers","ST/STMonitors","Si/SiDAQ","ST/STDAQ","ST/STTELL1Algorithms","ST/STVetraAnalysis"]]
    );


@dirdates = ( 
		 ["3/3/09", ["ST/STKernel","Det/STDet","ST/STTELL1Event","ST/STDigiAlgorithms","ST/STAlgorithms","Si/SiTools","ST/STTools","ST/STAssociators","ST/STCheckers","ST/STMonitors","Si/SiDAQ","ST/STDAQ","ST/STTELL1Algorithms","ST/STVetraAnalysis"]]
		 );


for ( my $i=0; $i <= $#dirdates; ++$i ) {
    my $date = $dirdates[$i][0];
    my @dirs = @{ $dirdates[$i][1] };
    my $lines = 0;
    foreach my $dir ( @dirs ) {
	#my $line = `cvs -q co -D $date -p $dir | wc -l`;    	
	system("cvs -d isscvs.cern.ch:/local/reps/lhcb -Q co -f -P -D $date -d tmp $dir");    	
	my $line = `find tmp -type f -regex \'.*.[cpp,h,xml]\' -exec cat {} \\; | wc -l`;
	system("find tmp -type f -regex \'*.[notes]\'");
	print "     $dir \t $line";
	$lines += $line;
	system("rm -r tmp");
    }
    print "  $date \t $lines\n";
}

