#!/usr/bin/perl -w
# -*- perl -*-
use P4CGI ;
use strict ;
#
#################################################################
# CONFIGURATION INFORMATION
# All config info should be in P4CGI.pm
#
#################################################################
#
# P4 change viewer
# View a change by number
#
#################################################################
# Get file spec argument
my $change = P4CGI::cgi()->param("CH") ;
&P4CGI::bail("No change number specified") unless defined $change ;
$change =~ /^\d+$/ or &P4CGI::bail("\"$change\" is not a positive number");
my @desc ;
my $currlev = &P4CGI::CURRENT_CHANGE_LEVEL() ;
if($change > $currlev or $change < 1) {
&P4CGI::bail("\"$change\" is not a valid change number
(0 < change <= $currlev)");
} ;
&P4CGI::p4call(\@desc, "describe -s $change");
$_ = &P4CGI::fixSpecChar(shift @desc) ;
/^Change (\d+) by (\S+)@(\S+) on (\S+) (\d\d:\d\d:\d\d)(.*)$/ or &P4CGI::bail("Illegal syntax on line returned");
my ($chn, $user, $client, $date, $time, $status) = ($1,$2,$3,$4,$5,$6) ;
my $statstr = "" ;
my $pending ;
if ( defined $status and $status =~ /pending/) {
$statstr=" (pending change)" ;
$pending = "yes" ;
} ;
# Create title
print "", &P4CGI::start_page("Change $change$statstr","") ;
my $description="" ;
my $leadDescSpace ;
while(@desc > 0) {
$_ = &P4CGI::fixSpecChar(shift @desc) ;
chomp ;
next if /^\s*$/;
last if /^Jobs fixed/;
last if /^Affected files/;
if($_ !~ /^\s*$/) {
if(defined $leadDescSpace) {
s/^$leadDescSpace// ;
}
else {
s/^(\s+)// ;
$leadDescSpace = $1 ;
};
$description .= "\n$_";
}
}
my $jobsFixed="-" ;
if( /^Jobs fixed/ )
{
$jobsFixed = "\n" ;
shift @desc ;
while (@desc > 0) {
$_ = &P4CGI::fixSpecChar(shift @desc) ;
my( $job, $time, $user, $client );
while( ( $job, $time, $user, $client ) =
/(\S*) fixed on (\S*) by (\S*)@(\S*)/ )
{
$jobsFixed .= &P4CGI::ahref("-url","vj.cgi...",
"JOB=$job",
$job) . "\n
";
shift @desc ;
while(@desc > 0){
$_ = &P4CGI::fixSpecChar(shift @desc) ;
last if /^\S/;
$jobsFixed .= $_;
}
}
$jobsFixed .= "\n";
last if /^Affected files/;
}
$jobsFixed .= "\n" ;
}
print
"",
&P4CGI::start_table(""),
&P4CGI::table_row("-valign","top",{"-type","th", "-align","right", "-text","Author"},
&P4CGI::ahref(-url => &P4CGI::LU_URL(),
"USER=$user",
$user)),
&P4CGI::table_row("-valign","top",{"-type","th", "-align","right", "-text","Client"},
$client),
&P4CGI::table_row("-valign","top",{"-type","th", "-align","right", "-text","Date"},
"$time $date"),
&P4CGI::table_row("-valign","top",
{"-type","th", "-align","right", "-text","Description"},
{"-text","
".&P4CGI::magic($description)."","-bgcolor","white"}) ; if ( ! defined $pending ) { print "", &P4CGI::table_row("-valign","top",{"-type","th", "-align","right", "-text","Jobs fixed"}, "$jobsFixed") ; } ; print "", &P4CGI::end_table(), "
" ; if($cnt > 1) { print "", &P4CGI::ahref("-url",P4CGI::FDV_URL(), "FSPC=$allfiles", "REV=$allrevs", "ACT=$allmodes", "CH=$change", "Diff for all files in change") ; } ; } else { print "
" ; } ; print &P4CGI::end_page(); # # That's it folks #