#!/usr/bin/perl -w
# -*- perl -*-
use P4CGI ;
use strict ;
#
#################################################################
# CONFIGURATION INFORMATION
# All config info should be in P4CGI.pm
#
#################################################################
#
# View a branch
#
#################################################################
###
### Get branch name
###
my $branch = &P4CGI::cgi()->param("BRANCH") ;
&P4CGI::bail("No branch specified") unless defined $branch ;
$branch = &P4CGI::htmlEncode($branch) ;
###
### Get info about branch
###
my %values ;
my @fields = &P4CGI::p4readform("branch -o '$branch'",\%values) ;
# Get real user names...
my %userCvt ;
&P4CGI::p4user2name(\%userCvt);
# Fix owner field
if (exists $values{"Owner"}) {
my $u = $values{"Owner"} ;
if(exists $userCvt{$u}) {
$values{"Owner"} = &P4CGI::ahref(-url=>"userView.cgi",
"USER=$u",
"HELP=View user info",
"$u") . " (" . $userCvt{$u} . ")" ;
}
else {
$values{"Owner"} = "$u (Unknown user)" ;
}
}
# Fix description field
if(exists $values{"Description"}) {
$values{"Description"} = &P4CGI::formatDescription($values{"Description"});
}
# Fix up view info
my $viewFrom ="";
my $viewTo ="";
my $allfrom ="";
my $allto ="";
foreach (split("\n",$values{"View"})) {
/^\s*\/\/(.+)\s+\/\/(.+)/ ;
my ($from,$to) = ($1,$2) ;
$allfrom .= "//$from" ;
$allto .= "//$to" ;
my @from = split /\//,$from ;
my @to = split /\//,$to ;
my $common = "//" ;
while(@from != 0 and @to != 0 and ($from[0] eq $to[0])) {
$common .= shift @from ;
$common .= "/" ;
shift @to ;
}
my $tmp = join("/",@from) ;
$from = $common . &P4CGI::ahref(-url=>"depotTreeBrowser.cgi",
"HELP=Browse $common"."$tmp",
"FSPC=$common$tmp",
"$tmp") ;
$tmp = join("/",@to) ;
$to = $common . &P4CGI::ahref(-url=>"depotTreeBrowser.cgi",
"HELP=Browse $common"."$tmp",
"FSPC=$common$tmp",
"$tmp") ;
if (length($viewFrom) > 0) {
$viewFrom .= "
" ;
$viewTo .= "
" ;
}
$viewFrom .= "$from " ;
$viewTo .= "$to" ;
} ;
$allto =~ s/^\+// ;
my @frb ;
my @tob ;
push @tob,&P4CGI::buttonCell("changeList.cgi",
"List changes in branch destination",
"FSPC=$allto",
"Changes") ;
push @frb,&P4CGI::buttonCell("changeList.cgi",
"List changes in branch source",
"FSPC=$allfrom",
"Changes") ;
push @tob,&P4CGI::buttonCell("fileOpen.cgi",
"List open files in branch destination",
"FSPC=$allto",
"Open files") ;
push @frb,&P4CGI::buttonCell("fileOpen.cgi",
"List open files in branch source",
"FSPC=$allfrom",
"Open files") ;
push @tob,&P4CGI::buttonCell("findFiles.cgi",
"Fild files in branch destination",
"FSPC=$allto",
"Find files") ;
push @frb,&P4CGI::buttonCell("findFiles.cgi",
"Find files in branch source",
"FSPC=$allfrom",
"Find files") ;
my @labels ;
&P4CGI::p4call(*P4, "labels" );
while() {
chomp ;
/^Label\s+(\S+)\s/ and do { push @labels,$1 ; } ;
}
close P4 ;
my $chnotinlabel= join("\n",(&P4CGI::cgi()->startform(-action => "changeList.cgi",
-method => "GET"),
&P4CGI::cgi()->hidden(-name=>"FSPC",
-value=>"$allto"),
&P4CGI::cgi()->hidden(-name=>"DP",
-value=>&P4CGI::CURR_DEPOT_NO()),
"View changes not in label:
",
&P4CGI::cgi()->popup_menu(-name => "EXLABEL",
-value => \@labels),
&P4CGI::cgi()->submit(-name => "Go",
-value => "Go"),
"",
&P4CGI::cgi()->endform())) ;
$values{"View"} =
join("\n",
(&P4CGI::start_table("border=0 cellspacing=0 cellpadding=0"),
&P4CGI::table_row($viewFrom,$viewTo),
&P4CGI::table_row({ -text => "
In source:".&P4CGI::buttonVMenuTable(@frb),
-valign=>"Top"
},
{ -text => "
In destination:".
&P4CGI::buttonVMenuTable(@tob).
$chnotinlabel,
-valign=>"Top"
}
),
&P4CGI::end_table())) ;
###
### Print html
###
print &P4CGI::start_page("Branch \"$branch\"") ;
print
"
",
&P4CGI::start_framedTable(""),
&P4CGI::start_table("") ;
my $f ;
foreach $f (@fields) {
my %xopt ;
$xopt{"class"} = "Description" if $f eq "Description" ;
print &P4CGI::table_row({-class => "Prompt",
-text => "$f"},
{%xopt,
-text => $values{$f}}) ;
} ;
print
&P4CGI::end_table(),
"
";
print &P4CGI::end_framedTable() ;
print
&P4CGI::end_page() ;
#
# That's all folks
#