#!/usr/local/bin/perl5 # -*- perl -*- use P4CGI ; use strict ; # ##################################################################### ## ## CONFIGURATION INFORMATION ## All config info should be in $configFile (see init() in P4CGI.pm) ## ##################################################################### ## ## List All Branches ## ##################################################################### # Set back references my $homepage="index.cgi"; my $backtohome="Back to Home" ; # Get branches my @branches ; &P4CGI::p4call(\@branches, "branches" ); foreach (@branches) { $_ =~ s/^Branch (\S+).*$/$1/ ; } # Print title and legend print "", &P4CGI::start_page("P4 Branches", &P4CGI::ul_list("Owner: to see P4 user info", "View left-side mapping: to see changes for path", "View right-side mapping: to see changes for branch"), $homepage,$backtohome) ; # Print number of branches print "", "",scalar @branches," branches:
" ; # Print branch info print "", &P4CGI::start_table() ; # Get branch info foreach (@branches) { local *P4 ; my $branch=$_ ; my $update ; my $access ; my $owner ; my $desc ; my @view ; &P4CGI::p4call(*P4, "branch -o $_" ); while() { chomp ; next if /^#/ ; next if /^\s*$/ ; /^Update:\s(.*)$/ and do { $update=$1 ; } ; /^Access:\s(.*)$/ and do { $access=$1 ; } ; /^Owner:\s(.*)$/ and do { $owner=$1 ; } ; last if /^Description:/ ; } my $descWhiteSpace ; while() { chomp ; last if /^View:/ ; next if /^\s*$/ ; unless(defined $descWhiteSpace) { /^(\s*)/ ; $descWhiteSpace = $1 ; } ; s/^$descWhiteSpace// ; if(defined $desc) { $desc .= "
$_" ; } else { $desc .= $_ ; } } while() { next if /^\s*$/ ; push @view,$_ ; } # Fix up data $owner = &P4CGI::ahref(-url => &P4CGI::LU_URL(), "USER=$owner", $owner) ; my $view ; foreach (@view) { s/^\s*(\S+\s+\S+)\s*/$1/ ; my ($from,$to) = split /\s+/ ; $from =~ s/^\/\/// ; $to =~ s/^\/\/// ; my @from = split /\//,$from ; my @to = split /\//,$to ; my $common = "//" ; while($from[0] eq $to[0]) { $common .= shift @from ; $common .= "/" ; shift @to ; } $from = $common . join("/",@from) ; $from = &P4CGI::ahref(-url => &P4CGI::CHB_URL(), "FSPC=$common" . join("/",@from), $from) ; $to = $common . join("/",@to) ; $to = &P4CGI::ahref(-url => &P4CGI::CHB_URL(), "BRANCH=YES", "FSPC=$common" . join("/",@to), $to) ; if (defined $view) { $view .= "
" ; } else { $view .= "" ; } ; $view .= "$from $to" ; } ; print "", &P4CGI::table_row({-type=>"th", -align=>"right", -valign=>"center", -text=>"Branch:"}, "$branch"), &P4CGI::table_row({-type=>"th", -align=>"right", -text=>"Update:"}, "$update"), &P4CGI::table_row({-type=>"th", -align=>"right", -text=>"Access:"}, "$access"), &P4CGI::table_row({-type=>"th", -align=>"right", -text=>"Owner:"}, "$owner"), &P4CGI::table_row({-type=>"th", -align=>"right", -valign=>"top", -text=>"Description:"}, {-bgcolor => "white", -text => "$desc"}), &P4CGI::table_row({-type=>"th", -align=>"right", -valign=>"top", -text=>"View:"}, "$view"), &P4CGI::table_row(undef, "
") ; close P4 ; } # End the table, end the page print &P4CGI::end_table(), &P4CGI::end_page() ;