#!/usr/bin/perl -w
#
# recent-commits-txt: show a list of files recently committed to CVS
#
# this script serves both http://cvs.w3.org/recent-commits
#                     and http://dev.w3.org/recent-commits
#
# Gerald Oskoboiny, 29 Oct 1999 and 24 Feb 2000
# Adapted for use on stats.w3.org by olivier Thereaux - March 2004

# $Id: recent-commits.pl,v 1.1 2004/03/28 22:46:36 ot Exp $

use strict;
use Getopt::Long qw(GetOptions);


my $luser="*"; # all users by default
GetOptions('u|user=s' => \$luser); # override user choice 

my $tac		= "/usr/bin/tac";
my $head	= "/usr/bin/head";

my $maxlines	= 100;

my (%seen, $history, $audit_text, $base_uri, $cvsweb_uri, $stylesheet);

$history = "/w3ccvs/CVSROOT/history";


# look for lines starting with A, M == added, modified
open( HISTORY, "$tac $history | $head -100000 |")
    or die "couldn't open pipe to tac because $!";

my $count = 0;
while (<HISTORY>) {
    next unless /^[AM]/;	# only want added, modified entries
    chomp;
    my ($hexdate,$user,$wtf,$dir,$version,$file) = split(/\|/);

    next unless defined $file;

   if ( $luser ne "*" ) {
        next unless $luser eq $user;
    }

    next if $seen{"$user.$dir.$file"};

    $seen{"$user.$dir.$file"}++;

    my $webpath = $dir;
       $webpath =~ s/^WWW/http:\/\/www.w3.org/;

    print "$webpath/$file \n";
    $count++;
    last if $count >= $maxlines;

}

close( HISTORY ) or warn "couldn't close history because $!";

exit;
