#!/usr/bin/perl -w # -*- perl -*- use P4CGI ; use strict ; # ################################################################# # CONFIGURATION INFORMATION # All config info should be in P4CGI.pm # ################################################################# # # P4 depot tree browser # ################################################################# # * Get path from argument my $arg = P4CGI::cgi()->param("FSPC") ; # canonicalize to either "/depot/..." or "" $arg = "" unless defined $arg ; $arg =~ s|^/*||; $arg = "/$arg" if $arg; # * Get HIDEDEL argument (Hide deleted files) my $hidedel = P4CGI::cgi()->param("HIDEDEL") ; $hidedel = "NO" unless defined $hidedel ; $hidedel = "YES" unless $hidedel eq "NO" ; # * Create link to changes for all files below my $argnosp = &P4CGI::fixspaces($arg) ; my $linkToAllbelow = "View changes for all files below this point"; # * Some variables... my @subdirs ; # directories information my @files ; # files information # ** read dirs my @tmp ; &P4CGI::p4call(\@tmp,"dirs \"/$arg/*\" 2>/dev/null") ; my $dir ; foreach $dir (@tmp) { my $nosp = &P4CGI::fixspaces($dir) ; my $dirname ; ($dirname = $dir) =~ s/^.*\/// ; push @subdirs,"$dirname/
" ; } ; &P4CGI::p4call(\@tmp,"files \"/$arg/*\" 2>/dev/null") ; foreach (@tmp) { /([^\#]+)\#(.*)/ ; my $filename=$1 ; my $info=$2 ; $filename =~ s/^.*\/// ; my ($rev,$inf) = split / - /,$info ; my $file = $filename ; if($inf =~ /^delete/) { if($hidedel eq "YES") { next ; } ; $file= "$filename"; } ; $filename = &P4CGI::fixspaces($filename) ; push @files, "$file\#$rev - $inf
" ; } ; my $toggleHide = "Show deleted files" ; } else { $toggleHide .= "YES\">Hide deleted files" ; } print "", &P4CGI::start_page("Depot tree browser
/$arg", &P4CGI::ul_list("Subdir -- Descend to subdir", "File -- Show file log", "$linkToAllbelow", $toggleHide)) ; # ** create a "file found" flag and set it to NO my $fileFound = "N" ; print "", &P4CGI::start_table(""), &P4CGI::table_row("-type","th", "-align","left", undef,"Subdirs",undef,"Files") ; # ** Create 1 or 2 colums for subdirs my $subdirsC1 ; my $subdirsC2 ; if(@subdirs > 30) { my $all = scalar(@subdirs) ; my $half = int($all/2) ; $subdirsC1 = join("\n",@subdirs[0..$half]) ; $subdirsC2 = join("\n",@subdirs[$half+1..$all]) ; } else { $subdirsC2 = join("\n",@subdirs) ; } # ** Create 1 or 2 colums for files my $filesC1 ; my $filesC2 ; if(@files > 30) { my $half = @files/2 ; $filesC1 = join("\n",@files[0..$half]) ; $filesC2 = join("\n",@files[$half+1..@files]) ; } else { $filesC2 = join("\n",@files) ; } # ** print data print "", &P4CGI::table_row("-valign","top", $subdirsC1,$subdirsC2,$filesC1,$filesC2), &P4CGI::end_table(); print "", &P4CGI::end_page() ; # # That's it folks #