=================================================================== RCS file: /cvs/cvsweb/cvsweb.cgi,v retrieving revision 3.36 retrieving revision 3.38 diff -u -p -r3.36 -r3.38 --- cvsweb/cvsweb.cgi 2000/10/20 12:28:45 3.36 +++ cvsweb/cvsweb.cgi 2000/11/02 17:34:35 3.38 @@ -42,8 +42,8 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $zId: cvsweb.cgi,v 1.103 2000/09/20 17:02:29 jumager Exp $ -# $Id: cvsweb.cgi,v 3.36 2000/10/20 12:28:45 knu Exp $ +# $zId: cvsweb.cgi,v 1.104 2000/11/01 22:05:12 hnordstrom Exp $ +# $Id: cvsweb.cgi,v 3.38 2000/11/02 17:34:35 knu Exp $ # ### @@ -52,6 +52,7 @@ use strict; use vars qw ( $config $allow_version_select $verbose %CVSROOT %CVSROOTdescr %MIRRORS %DEFAULTVALUE %ICONS %MTYPES + @DIFFTYPES %DIFFTYPES @LOGSORTKEYS %LOGSORTKEYS %alltags @tabcolors %fileinfo %tags @branchnames %nameprinted %symrev %revsym @allrevisions %date %author @revdisplayorder @revisions %state %difflines %log %branchpoint @revorder @@ -61,7 +62,7 @@ use vars qw ( %funcline_regexp $is_mod_perl $is_links $is_lynx $is_w3m $is_msie $is_mozilla3 $is_textbased %input $query $barequery $sortby $bydate $byrev $byauthor - $bylog $byfile $hr_default $logsort $cvstree $cvsroot + $bylog $byfile $defaultDiffType $logsort $cvstree $cvsroot $mimetype $defaultTextPlain $defaultViewable $allow_compress $GZIPBIN $backicon $diricon $fileicon $fullname $newname $cvstreedefault $body_tag $body_tag_for_src @@ -83,6 +84,8 @@ use vars qw ( ); sub printDiffSelect($); +sub printDiffLinks($$); +sub printLogSortSelect($); sub findLastModifiedSubdirs(@); sub htmlify_sub(&$); sub htmlify($;$); @@ -166,6 +169,49 @@ $tabstop = $use_moddate = $moddate = $gzip_open = unde $LOG_FILESEPARATOR = q/^={77}$/; $LOG_REVSEPARATOR = q/^-{28}$/; +@DIFFTYPES = qw(h H u c s); +@DIFFTYPES{@DIFFTYPES} = ( + { + 'descr' => 'colored', + 'opts' => [ '-u' ], + 'colored' => 1, + }, + { + 'descr' => 'long colored', + 'opts' => [ '--unified=15' ], + 'colored' => 1, + }, + { + 'descr' => 'unified', + 'opts' => [ '-u' ], + 'colored' => 0, + }, + { + 'descr' => 'context', + 'opts' => [ '-c' ], + 'colored' => 0, + }, + { + 'descr' => 'side by side', + 'opts' => [ '--side-by-side', '--width=164' ], + 'colored' => 0, + }, + ); + +@LOGSORTKEYS = qw(cvs date rev); +@LOGSORTKEYS{@LOGSORTKEYS} = ( + { + 'descr' => 'Not sorted', + }, + { + 'descr' => 'Commit date', + }, + { + 'descr' => 'Revision', + }, + ); + + ##### End of configuration variables ##### use Time::Local; @@ -329,7 +375,7 @@ else { $byfile = 1; } -$hr_default = ($input{'f'} eq 'h' || $input{'f'} eq 'H'); +$defaultDiffType = $input{'f'}; $logsort = $input{'logsort'}; @@ -785,12 +831,9 @@ elsif (-d $fullname) { print "Revision"; print "Log message"; print ""; - print "revisions by: \n"; - print "\n"; - print "Not sorted"; - print "Commit date"; - print "Revision"; - print ""; + print "Sort log by: "; + printLogSortSelect(0); + print ""; print "Diff format: "; printDiffSelect(0); print ""; @@ -884,18 +927,43 @@ gzipclose(); sub printDiffSelect($) { my ($use_java_script) = @_; - my ($f) = $input{'f'}; - print "\n"; - print "Colored Diff"; - print "Long Colored Diff"; - print "Unidiff"; - print "Context Diff"; - print "Side by Side"; + my $f = $input{'f'}; + + print ''; + + local $_; + for (@DIFFTYPES) { + printf('%s', + $_, + $f eq $_ ? ' SELECTED' : '', + "\u$DIFFTYPES{$_}{'descr'}" + ); + } + print ""; } +sub printLogSortSelect($) { + my ($use_java_script) = @_; + + print ''; + + local $_; + for (@LOGSORTKEYS) { + printf('%s', + $_, + $logsort eq $_ ? ' SELECTED' : '', + "\u$LOGSORTKEYS{$_}{'descr'}" + ); + } + + print ""; +} + sub findLastModifiedSubdirs(@) { my (@dirs) = @_; my ($dirname, @files); @@ -1529,7 +1597,7 @@ sub viewable($) { sub doDiff($$$$$$) { my($fullname, $r1, $tr1, $r2, $tr2, $f) = @_; my $fh = do {local(*FH);}; - my ($rev1, $rev2, $sym1, $sym2, @difftype, $diffname, $f1, $f2); + my ($rev1, $rev2, $sym1, $sym2, $f1, $f2); if ($r1 =~ /([^:]+)(:(.+))?/) { $rev1 = $1; @@ -1563,36 +1631,18 @@ sub doDiff($$$$$$) { ($rev1, $sym1) = ($rev2, $sym2); ($rev2, $sym2) = ($tmp1, $tmp2); } - my $human_readable = 0; - if ($f eq 'c') { - @difftype = qw{-c}; - $diffname = "Context diff"; - } - elsif ($f eq 's') { - @difftype = qw{--side-by-side --width=164}; - $diffname = "Side by Side"; - } - elsif ($f eq 'H') { - $human_readable = 1; - @difftype = qw{--unified=15}; - $diffname = "Long Human readable"; - } - elsif ($f eq 'h') { - @difftype =qw{-u}; - $human_readable = 1; - $diffname = "Human readable"; - } - elsif ($f eq 'u') { - @difftype = qw{-u}; - $diffname = "Unidiff"; - } - else { + my $difftype = $DIFFTYPES{$f}; + + if (!$difftype) { fatal ("400 Bad arguments", "Diff format $f not understood"); } + my @difftype = @{$difftype->{'opts'}}; + my $human_readable = $difftype->{'colored'}; + # apply special options if ($showfunc) { - push @difftype, '-p' if $f =~ /^[cHhu]$/; + push @difftype, '-p' if $f ne 's'; my($re1, $re2); @@ -1754,7 +1804,7 @@ again: if ($state eq "tags" && /^\S/) { if (defined($tag) && (defined($symrev{$tag}) || $tag eq "HEAD")) { $revwanted = $tag eq "HEAD" ? $symrev{"MAIN"} : $symrev{$tag}; - ($branch = $revwanted) =~ s/\b0\.//; + ($branch = $revwanted) =~ s/\.0\././; ($branchpoint = $branch) =~ s/\.?\d+$//; $revwanted = undef if ($revwanted ne $branch); } @@ -1983,7 +2033,7 @@ sub readLog($;$) { foreach (reverse sort keys %symrev) { $rev = $symrev{$_}; - if ($rev =~ /^((.*)\.)?\b0\.(\d+)$/) { + if ($rev =~ /^((.*)\.)0\.(\d+)$/) { push(@branchnames, $_); # # A revision number of A.B.0.D really translates into @@ -1996,9 +2046,11 @@ sub readLog($;$) { # with the branch number 0.A, with the exception that # it has no head to translate to if there is nothing on # the branch, but I guess this can never happen? - # (the code below gracefully forgets about the branch - # if it should happen) # + # Since some stupid people actually import/check in + # files with version 0.X we assume that the above cannot + # happen, and regard 0.X(.*) as a revision and not a branch. + # $head = defined($2) ? $2 : ""; $branch = $3; $branchrev = $head . ($head ne "" ? "." : "") . $branch; @@ -2028,7 +2080,7 @@ sub readLog($;$) { my ($onlyonbranch, $onlybranchpoint); if ($onlyonbranch = $input{'only_with_tag'}) { $onlyonbranch = $symrev{$onlyonbranch}; - if ($onlyonbranch =~ s/\b0\.//) { + if ($onlyonbranch =~ s/\.0\././) { ($onlybranchpoint = $onlyonbranch) =~ s/\.\d+$//; } else { @@ -2066,6 +2118,20 @@ sub readLog($;$) { } +sub printDiffLinks($$) { + my($text, $url) = @_; + my @extra; + + local $_; + for ($DIFFTYPES{$defaultDiffType}{'colored'} ? qw(u) : qw(h)) { + my $f = $_ eq $defaultDiffType ? '' : $_; + + push @extra, &link(lc $DIFFTYPES{$_}{'descr'}, "$url&f=$f"); + } + + print &link($text, $url), ' (', join(', ', @extra), ')'; +} + sub printLog($;$) { my ($link, $br, $brp); ($_,$link) = @_; @@ -2190,10 +2256,7 @@ sub printLog($;$) { $barequery); print " to previous "; - print &link($prev, $url); - if (!$hr_default) { # offer a human readable version if not default - print ' (', &link('colored', "$url&f=h"), ')'; - } + printDiffLinks($prev, $url); } # # Plus, if it's on a branch, and it's not a vendor branch, @@ -2206,10 +2269,7 @@ sub printLog($;$) { $barequery); print " to branchpoint "; - print &link($brp, $url); - if (!$hr_default) { # offer a human readable version if not default - print ' (', &link('colored', "$url&f=h"), ')'; - } + printDiffLinks($brp, $url); } # # Plus, if it's on a branch, and it's not a vendor branch, @@ -2242,10 +2302,7 @@ sub printLog($;$) { $barequery); print " next main "; - print &link($nextmain, $url); - if (!$hr_default) { # offer a human readable version if not default - print ' (', &link('colored', "$url&f=h"), ')'; - } + printDiffLinks($nextmain, $url); } } # Plus if user has selected only r1, then present a link @@ -2260,10 +2317,7 @@ sub printLog($;$) { $barequery); print " to selected "; - print &link($input{'r1'}, $url); - if (!$hr_default) { # offer a human readable version if not default - print ' (', &link('colored', "$url&f=h"), ')'; - } + printDiffLinks($input{'r1'}, $url); } } print "\n"; @@ -2343,8 +2397,8 @@ sub doLog($) { print "\n"; print ""; print "\n"; - print "Preferred Diff type:"; - print ""; + print "Preferred Diff type:"; + print ""; printDiffSelect($use_java_script); print "\n"; if (@branchnames) { @@ -2379,13 +2433,9 @@ sub doLog($) { print ""; print "\n"; print "Sort log by:"; - print "\n"; - print "Not sorted"; - print "Commit date"; - print "Revision"; - print ""; + print ""; + printLogSortSelect($use_java_script); + print ""; print ""; print "\n"; print ""; @@ -2589,7 +2639,7 @@ sub navigateHeader($$$$$) { $swhere = urlencode($filename) if ($swhere eq ""); print "<\!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"; print "\n\n"; - print ''; + print ''; print "\n$path$filename - $title - $rev\n"; print "$body_tag_for_src\n"; print ""; @@ -2792,7 +2842,7 @@ sub fileSortCmp() { sub download_url($$;$) { my ($url,$revision,$mimetype) = @_; - $revision =~ s/\b0\.//; + $revision =~ s/\.0\././; if (defined($checkoutMagic) && (!defined($mimetype) || $mimetype ne "text/x-cvsweb-markup")) { @@ -2972,7 +3022,7 @@ sub http_header(;$) { sub html_header($) { my ($title) = @_; - my $version = '$zRevision: 1.103 $ $Revision: 3.36 $'; #' + my $version = '$zRevision: 1.104 $ $Revision: 3.38 $'; #' http_header(); print <
\n"; @@ -2343,8 +2397,8 @@ sub doLog($) { print "\n"; print "