#!/usr/bin/perl use strict; use warnings; use HTML::Template; use CGI qw(header param); use CGI::Carp qw(fatalsToBrowser); use CVS::Metrics; my $extract = param('extract'); my $repository = param('repository'); my $module = param('module'); my $viewcvs = param('viewcvs'); my $cvs_root = $extract . '/' . $repository . '/' . $module; chdir $cvs_root or die "can't change dir $cvs_root ($!).\n"; my $cfg = '.cvs_metrics'; our ($title, $regex_tag, @dirs, $start_date, $regex_ignore_tag); if ( -r $cfg) { warn "reading $cfg\n"; require $cfg; } unless (defined $regex_tag) { $regex_tag = '\d+'; } unless (defined $start_date) { $start_date = '2006/01/01'; } my $cvs = FindCvs(); my $cvs_logfile = $cvs . ' log |'; =head1 NAME cgi_cvs_evolq - Extract from cvs log =head1 SYNOPSIS cgi_cvs_evolq =head1 OPTIONS CGI parameters =over 8 =item cvsroot Directory. =back =head1 DESCRIPTION B parses B and produces an HTML form. This form allows to call B. =head2 Configuration file (.cvs_metrics) If present, B reads the configuration file F<.cvs_metrics> in the current directory. The file could contains the following variables : $title = "main"; $regex_tag = '^V\d+'; @dirs = ( "abc", "def" , "def/hij" ); $start_date = "2006/01/01"; =head1 SEE ALSO cvs_activity, cvs_energy, cvs_tklog, cvs_wxlog, cvs_current =head1 COPYRIGHT (c) 2004-2007 Francois PERRAD, France. All rights reserved. This library is distributed under the terms of the Artistic Licence. =head1 AUTHOR Francois PERRAD, francois.perrad@gadz.org =cut our $cvs_log = CVS::Metrics::CvsLog( stream => $cvs_logfile, use_cache => 1, ); if ($cvs_log) { our @tags; my $timed = $cvs_log->getTimedTag($regex_ignore_tag); my %matched; while (my ($tag, $date) = each %{$timed}) { if ($tag =~ /$regex_tag/) { $matched{$date.$tag} = $tag; } } foreach (sort keys %matched) { push @tags, $matched{$_}; } my $tag_from = $tags[-1]; push @tags, 'HEAD'; $cvs_log->insertHead(); GenerateHTML($title, \@tags, \@dirs); } sub FindCvs { my $cvs; if ($^O eq 'MSWin32') { eval 'use File::Which'; $cvs = which('cvs'); unless (defined $cvs) { eval 'use Win32::TieRegistry(Delimiter => "/")'; my $cvs_setting; my $hkey = 'HKEY_CURRENT_USER/Software/WinCvs/wincvs/CVS settings'; eval '$cvs_setting = $Registry->{$hkey}'; $cvs = $cvs_setting->{'/P_WhichCvs'}; if (defined $cvs) { $cvs =~ s/[\000\001]//g; $cvs =~ s/wincvs\.exe\@$//; if ( -e "${cvs}CVSNT\\\\cvs.exe") { $cvs .= "CVSNT\\\\cvs.exe"; } else { $cvs .= 'cvs.exe'; } } } die "cvs not found !\n" unless (defined $cvs); warn "Using CVS : $cvs\n"; return q{"} . $cvs . q{"}; } else { return 'cvs'; } } ####################################################################### sub GenerateHTML { my ($title, $r_tags, $r_dirs) = @_; my $html = q{ cvs_evol <!-- TMPL_VAR NAME=title -->


Evolution Report Query

path :
from tag :
to tag :
Force generation (don't use nightly extract)
Sorry, no tag available.

Generated by cgi_cvs_evolq () }; my $style = q{ body { background-color: #CCFFFF } h1 { text-align: center } h2 { color: red } }; $html =~ s/^\s+//gm; my $template = new HTML::Template( loop_context_vars => 1, scalarref => \$html, ); die "can't create template ($!).\n" unless (defined $template); my $now = localtime(); my $generator = 'cgi_cvs_evolq ' . $CVS::Metrics::VERSION . ' (Perl ' . $] . ')'; my $valid = scalar(@{$r_tags}) >= 2; my @dirs = (); push @dirs, { value => '.', }; foreach (@{$r_dirs}) { push @dirs, { value => $_, } } my @from_tags = (); foreach (@{$r_tags}) { push @from_tags, { value => $_, } } pop @from_tags; my @to_tags = (); foreach (@{$r_tags}) { push @to_tags, { value => $_, } } shift @to_tags; $template->param( style => $style, generator => $generator, date => $now, title => $title, valid => $valid, extract => $extract, repository => $repository, module => $module, viewcvs => $viewcvs, dirs => \@dirs, from_tags => \@from_tags, to_tags => \@to_tags, ); print header( -type => 'text/html', ); print $template->output(); }