#!/usr/bin/perl -w # -*- perl -*- use P4CGI ; use strict ; # ################################################################# # CONFIGURATION INFORMATION # All config info should be in P4CGI.pm # ################################################################# # # List all branches # ################################################################# # Get list of all brances my @branches ; &P4CGI::p4call(\@branches, "branches" ); foreach (@branches) { $_ =~ s/^Branch (\S+).*$/$1/ ; } # Print header print "", &P4CGI::start_page("List of branches", &P4CGI::ul_list("owner -- view user info", "view -- View changes for view")) ; print "", scalar @branches," branches" ; print "", &P4CGI::start_table("") ; # &P4CGI::table_row("-type","th", # "-align","left", # "Branch","Date","Owner","Description","View"); foreach (@branches) { # Get branch info local *P4 ; my $branch=$_ ; my $date ; my $owner ; my $desc ; my @view ; &P4CGI::p4call(*P4, "branch -o $_" ); while() { chomp ; next if /^#/ ; next if /^\s*$/ ; /^Date:\s(.*)$/ and do { $date=$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(), "FSPC=$common" . join("/",@to), $to) ; if (defined $view) { $view .= "
" ; } else { $view .= "" ; } ; $view .= "$from $to" ; } ; print "", &P4CGI::table_row(undef,"
"), &P4CGI::table_row({-type=>"th", -align=>"right", -valign=>"center", -text=>"Branch:"}, "$branch"), &P4CGI::table_row({-type=>"th", -align=>"right", -text=>"Date:"}, "$date"), &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") ; close P4 ; } print &P4CGI::end_table(), &P4CGI::end_page() ; # # That's it folks #