- #!/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::signalError("\"$change\" is not a valid change number (0 < change <= $currlev)");
- } ;
- my $filespec = &P4CGI::cgi()->param("FSPC") ;
- $filespec = "//..." unless defined $filespec ;
- $filespec = &P4CGI::htmlEncode($filespec) ;
- my $nextChange ;
- my $prevChange ;
- {
- my $max = $currlev - $change + 3 ;
- my %chs ;
- local *F ;
- &P4CGI::p4call(*F, "changes -m $max $filespec" );
- while(<F>) {
- /Change (\d+)/ and do {
- $chs{$1} = 1 ;
- }
- }
- close *F ;
- my $p ;
- my @c = sort { $b <=> $a } keys %chs ;
- while(@c) {
- my $n = shift @c ;
- if($n == $change) {
- $nextChange = $p ;
- $n = shift @c and do {
- $prevChange = $n ;
- } ;
- last ;
- }
- $p = $n ;
- }
- } ;
- my @legendList ;
- if($nextChange) {
- push @legendList,
- &P4CGI::buttonCell("changeView.cgi",
- "View next change for $filespec",
- "FSPC=$filespec",
- "CH=$nextChange",
- "Next change ($nextChange)") ;
- }
- if($prevChange) {
- push @legendList,
- &P4CGI::buttonCell("changeView.cgi",
- "View previous change for $filespec",
- "FSPC=$filespec",
- "CH=$prevChange",
- "Previous change ($prevChange)") ;
- }
- my %values ;
- my @fields = &P4CGI::p4readform("change -o $change",\%values) ;
- # Fix user field
- {
- # Get real user names...
- my %userCvt ;
- &P4CGI::p4user2name(\%userCvt) ;
- if (exists $values{"User"}) {
- my $u = $values{"User"} ;
- if(exists $userCvt{$u}) {
- $values{"User"} = &P4CGI::ahref(-url=>"userView.cgi",
- "USER=$u",
- "HELP=View user info",
- "$u") . " (" . $userCvt{$u} . ")" ;
- }
- else {
- $values{"User"} = "$u (Unknown user)" ;
- }
- }
- }
- # fix client field
- if(exists $values{"Client"}) {
- # Get clients
- my %clients = &P4CGI::p4clients() ;
- if(exists $clients{$values{"Client"}}) {
- $values{"Client"} = &P4CGI::ahref(-url=>"clientView.cgi",
- "CLIENT=$values{Client}",
- "HELP=View client info",
- $values{"Client"}) ;
- }
- }
- # Fix description field
- if(exists $values{"Description"}) {
- my @referenced ;
- $values{"Description"} = &P4CGI::formatDescription($values{"Description"},
- \@referenced) ;
- while(@referenced) {
- my $c = shift @referenced ;
- next if $c >= $change ;
- if(!exists $values{"References in Desc."}) {
- $values{"References in Desc."} = "" ;
- push @fields,"Referenced" ;
- } ;
- my %data ;
- &P4CGI::p4readform("change -o $c",\%data) ;
- if(exists $data{"Description"}) {
- my $d = &P4CGI::formatDescription($data{"Description"}) ;
- $c = &P4CGI::ahref("-url" => "changeView.cgi",
- "-class" => "Title",
- "CH=$c",
- "HELP=View change",
- "Change $c") ;
- $values{"Referenced"} .=
- join("\n",
- ("<span>$c:</span>",
- "<table class=\"Titled2\"><tr>",
- "<td class=\"Description\">$d</td>",
- "</tr></table>")) ;
- }
- }
- }
- if(exists $values{"Jobs"}) {
- my @jobs = map { s/\s+\#.*$// ; $_ ; } split("\n",$values{"Jobs"}) ;
- my $jobs = "" ;
- my $j ;
- foreach $j (@jobs) {
- my %data ;
- &P4CGI::p4readform("job -o '$j'",\%data) ;
- my $desc = $data{"Description"} ;
- $desc = "" unless defined $desc ;
- $desc = &P4CGI::formatDescription($desc);
- $jobs .= "<span>" . &P4CGI::ahref(-url=>"jobView.cgi",
- -class=>"Title",
- "JOB=$j",
- "HELP=View Job $j",
- $j) . "</span>" ;
- $jobs .=
- "<table class=\"Titled2\"><tr><td class=\"Description\">".
- $desc .
- "</td></tr></table>\n" ;
- }
- $values{"Jobs"} = $jobs ;
- }
- # Start page
- &P4CGI::start_page("Change $change",@legendList),
- &P4CGI::start_framedTable("Change data") ;
- print &P4CGI::start_table("") ;
- my $fld ;
- foreach $fld (@fields) {
- my $val = $values{$fld} ;
- my %xopt ;
- $xopt{"class"} = "Description" if $fld eq "Description" ;
- print &P4CGI::table_row({-class => "Prompt",
- -text => "$fld"},
- {%xopt,
- -text => $val}) ;
- } ;
- #
- # Read p4 describe command output
- #
- local *F ;
- &P4CGI::p4call(*F, "describe -s $change");
- my @files ;
- my $allfiles ;
- my $allrevs ;
- my $allmodes ;
- my $cnt = 0 ;
- while(<F>) {
- /^\.\.\. (.*)\#(\d+) (\w+)$/ and do {
- my ($file,$rev,$action) = ($1,$2,$3) ;
- if(($action ne "add") and ($action ne "delete") and ($action ne "branch")) {
- if(defined $allfiles) {
- $allfiles .= ",$file" ;
- $allrevs .= " $rev" ;
- $allmodes .= " $action" ;
- }
- else {
- $allfiles = "$file" ;
- $allrevs = "$rev" ;
- $allmodes = "$action" ;
- }
- $cnt++ ;
- }
- my ($ofile,$orev,$oaction) = ($file,$rev,$action) ;
- $file = &P4CGI::ahref("-url","fileLogView.cgi",
- "FSPC=$ofile",
- "HELP=View file log",
- "$ofile") ;
- if($action ne "delete") {
- $rev = &P4CGI::ahref("-url","fileViewer.cgi",
- "FSPC=$ofile",
- "REV=$orev",
- "HELP=View file revision $orev",
- "$orev") ;
- if($action ne "add") {
- $action = &P4CGI::ahref("-url","fileDiffView.cgi",
- "FSPC=$ofile",
- "REV=$orev",
- "ACT=$oaction",
- "HELP=View diff",
- "$oaction")
- }
- }
- push @files,&P4CGI::table_row({-class=>"ListC",
- -text => $action},
- {-class=>"List",
- -text => $file},
- {-class=>"ListC",
- -text => $rev}) ;
- }
- }
- close F ;
- if($cnt > 1) {
- my $cell = &P4CGI::buttonCell("fileDiffView.cgi",
- "View diff for all files in change",
- "FSPC=$allfiles",
- "REV=$allrevs",
- "ACT=$allmodes",
- "CH=$change",
- "View diff for all") ;
- push @files,&P4CGI::buttonHMenuTable($cell) ;
- } ;
- print &P4CGI::table_row({-class => "Prompt",
- -text => "Files"},
- &P4CGI::start_table("").
- &P4CGI::table_header("Action","File","Rev") .
- join("\n",@files) .
- &P4CGI::end_table()) ;
- &P4CGI::end_table(),
- &P4CGI::end_framedTable(),
- &P4CGI::end_page();
- #
- # That's all folks
- #
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#12 | 4998 | Fredric Fredricson | P4DB: cleaned up some code. Added p4users(), p4client() and p4user2name() to P4CGI.pm and... modified all cgi:s to use these, « |
20 years ago | |
#11 | 4306 | Fredric Fredricson | P4DB: Hardened P4DB against malicious parameters (cross site scripting), performed some c...leanup and increased version to 3.1.1. « |
21 years ago | |
#10 | 4240 | Fredric Fredricson | P4DB: Fixed small problem with job list in change view | 21 years ago | |
#9 | 4238 | Fredric Fredricson | P4DB: Small bugfix in change view | 21 years ago | |
#8 | 4237 | Fredric Fredricson | P4DB: Maybe the final submit for P4DB 3.1.0 | 21 years ago | |
#7 | 4152 | Fredric Fredricson | P4DB: Some more work on tha way to version 3.1.... | 21 years ago | |
#6 | 4071 | Fredric Fredricson | P4DB: Updated changeView for 3.1 | 21 years ago | |
#5 | 2942 | Fredric Fredricson | P4DB: Fixed bug: Can now handle spaces in label names etc.... | 22 years ago | |
#4 | 2875 | Fredric Fredricson | P4DB 3.0 first beta... | 22 years ago | |
#3 | 1928 | Fredric Fredricson |
P4DB: Fixed bug: empty lines are now correctly displayed in change view. |
23 years ago | |
#2 | 1920 | Fredric Fredricson | P4DB: Mainly some user interface fixes: * Added a small arrow that points to selection in... list of options * Added tooltip help * Added user prefereces to turn the above off (or on) * Some other user interface fixes And fixed a bug in jobList.cgi and some minor bugs in label and branch viewers. « |
23 years ago | |
#1 | 1638 | Fredric Fredricson | P4DB: Added all (I think) files for P4DB | 23 years ago |