📄 cvs2html
字号:
print " path.\n"; print "\n"; print " Use -V VERBOSITY to make cvs2html report what it is doing. A\n"; print " value of 0 means be quiet and bigger numbers means more output.\n"; print " This is especially useful, when something went wrong.\n"; print "\n"; print " Use -R CVSWEBROOT to make reports intergrated with cvsweb.\n"; print " The argument should be the symbolic_name in cvsweb.conf.\n"; print " The html file also contains anchors, if a file foo.html\n"; print " containing a file e.g., foofoo.m is generated then it is\n"; print " possible to search http://CORRECT_URL/foo.html#foofoo.m\n"; print "\n"; print " Example :\n"; print " cvs2html -l http://cvs.sslug.dk/linuxbog -f -p \\\\ \n"; print " -o cvs2html/index.html -v -a -b -n 6 -C crono.html\n"; print " makes cvs2html/ with individual log data for each file \n"; print " with links relative to \"http://cvs.sslug.dk/linuxbog\"\n"; print " and creates a chronological log file \"crono.html\".\n"; print "\n"; print " cvs2html with no arguments displays this help\n"; print " Peter Toft et al, Technical University of Denmark, 1997\n"; exit(0);}# This function will set the date after which the log info is shown.# Any log info before the date is NOT shown.sub date_control { %months= ( 'Jan','01', 'Feb','02', 'Mar','03', 'Apr','04', 'May','05', 'Jun','06', 'Jul','07', 'Aug','08', 'Sep','09', 'Oct','10', 'Nov','11', 'Dec','12', ); &ctime(time) =~/^(\w+) (\w+) (\d+) (\d+):(\d+):(\d+) (\d+)$/; $currentyear=$7; if (($opt_d)||($opt_D)) { if ($opt_d) { ($cutmonthtxt,$cutdatetxt,$cutyeartxt)= $opt_d =~ /^(\w+) (\d+) (\d+)$/; } if ($opt_D) { $cd = localtime(time-3600*24*$opt_D); $cd =~ /^(\w+) (\w+)[ ]*(\d+)[ ]*(\d+):(\d+):(\d+) (\d+)$/; $cutyeartxt = $7; $cutmonthtxt = $2; $cutdatetxt = $3; } if (length($cutyeartxt)==0) { ($cutmonthtxt,$cutdatetxt)= $opt_d =~ /^(\w+) (\d+)$/; $cutyeartxt=$currentyear; } $cutyearformat2="$cutmonthtxt $cutdatetxt $cutyeartxt"; if (length($cutdatetxt)==1) { $cutdatetxt="0".$cutdatetxt; } $m=$months{$cutmonthtxt}; if (length($m)==0) { print "The option -d \"month day [year]\" was used with a wrong month ($cutmonthtxt).\n"; print "First three letters is used\n"; exit(0); } $cutdate = $cutyeartxt.$m.$cutdatetxt; } else { $cutdate = "00000000"; } # Anything before year 0000 - I dont think so...........}# Function to read the next line from cvslogarraysub getnextline { $lineno++; if($lineno<=scalar(@cvslogarray)) { # DEBUG #print STDOUT " cvslogarray[$lineno]=$cvslogarray[$lineno]"; # DEBUG return($cvslogarray[$lineno]); } else { return(undef); }}sub flush_diff_rows ($$$$) { local $j; my ($leftColRef,$rightColRef,$leftRow,$rightRow) = @_; if ($state eq "PreChangeRemove") { # we just got remove-lines before for ($j = 0 ; $j < $leftRow; $j++) { print DIFFFILE "<tr><td bgcolor=\"$diffcolorRemove\">@$leftColRef[$j]</td>"; print DIFFFILE "<td bgcolor=\"$backcolor\"> </td>"; print DIFFFILE "<td bgcolor=\"$diffcolorEmpty\"> </td></tr>\n"; } } elsif ($state eq "PreChange") { # state eq "PreChange" # we got removes with subsequent adds for ($j = 0; $j < $leftRow || $j < $rightRow ; $j++) { # dump out both cols print DIFFFILE "<tr>"; if ($j < $leftRow) { print DIFFFILE "<td bgcolor=\"$diffcolorChange\">@$leftColRef[$j]</td>"; } else { print DIFFFILE "<td bgcolor=\"$diffcolorDarkChange\"> </td>"; } print DIFFFILE "<td bgcolor=\"$backcolor\"> </td>"; if ($j < $rightRow) { print DIFFFILE "<td bgcolor=\"$diffcolorChange\">@$rightColRef[$j]</td>"; } else { print DIFFFILE "<td bgcolor=\"$diffcolorDarkChange\"> </td>"; } print DIFFFILE "</tr>\n"; } }}# Function to generate diff-filessub generate_diff_file { local ( $ii,$difftxt,@diffar ); $diffname = $outdirname.'/'.$diffdirname.'/'."diff$convdir\_$filename\_$oldrevnumber\_$revnumber.html"; stat($diffname); if (-e _) { if ($diffwarning == 1) { print "WARNING; cvs2html does not generate $diffname\n"; } } else { @listhtmlnames = (@listhtmlnames,$diffname); open(DIFFFILE,">$diffname") or die "Error: Could not open ; $diffname"; print DIFFFILE html_header("Difference for $currentdir/$filename from version $revnumber to $oldrevnumber"); if ($opt_k) { $kkon = "-kk"; } @diffar = `$cvsLocation diff $kkon $whitespace -u -r $revnumber -r $oldrevnumber $currentdir/$filename\n`; print DIFFFILE "<table border=0 cellspacing=0 cellpadding=0 width=\"100%\">\n"; print DIFFFILE "<tr bgcolor=\"#ffffff\"><th width=\"50%\">version $revnumber</th><th bgcolor=\"$backcolor\"> </th><th width=\"50%\">version $oldrevnumber</th></tr>"; $fs="<font"; if(defined($difffontface) && length($difffontface)>0) { $fs.=" face=\"$difffontface\""; } if(defined($difffontsize) && length($difffontsize)>0) { $fs.=" size=\"$difffontsize\""; } $fs.=">"; $fe="</font>"; $leftRow = 0; $rightRow = 0; # the first 8 lines are garbage for us for ($ii=8;$ii<=$#diffar;$ii++) { chop($difftxt = $diffar[$ii]); if ($difftxt =~ /^@@/) { ($oldline,$newline) = $difftxt =~ /@@ \-([0-9]+).*\+([0-9]+).*@@/; print DIFFFILE "<tr bgcolor=\"$diffcolorHeading\"><td width=\"50%\">"; print DIFFFILE "<table width=\"100%\" border=0 cellpadding=5><tr><td><b>Line $oldline</b></td></tr></table>"; print DIFFFILE "</td><td bgcolor=\"$backcolor\"> </td><td width=\"50%\">"; print DIFFFILE "<table width=\"100%\" border=0 cellpadding=5><tr><td><b>Line $newline</b></td></tr></table>"; print DIFFFILE "</td></tr>\n"; $state = "dump"; $leftRow = 0; $rightRow = 0; } else { ($diffcode,$rest) = $difftxt =~ /^([-+ ])(.*)/; $_= $rest;######### quote special characters# according to RFC 1866,Hypertext Markup Language 2.0,# 9.7.1. Numeric and Special Graphic Entity Set# (Hen)####### s/&/&/g; s/\"/"/g; s/</</g; s/>/>/g; # replace <tab> and <space> if ($opt_b) { # make every other space 'breakable' s/ / /g; # <tab> s/ / /g; # 3 * <space> s/ / /g; # 2 * <space> # leave single space as it is } else { s/ / /g; s/ / /g; } # Add fontface, size $_ = "$fs $_$fe"; ######### # little state machine to parse unified-diff output (Hen, zeller@think.de) # in order to get some nice 'ediff'-mode output # states: # "dump" - just dump the value # "PreChangeRemove" - we began with '-' .. so this could be the start of a 'change' area or just remove # "PreChange" - okey, we got several '-' lines and moved to '+' lines -> this is a change block ########## if ($diffcode eq '+') { if ($state eq "dump") { # 'change' never begins with '+': just dump out value print DIFFFILE "<tr><td bgcolor=\"$diffcolorEmpty\"> </td><td bgcolor=\"$backcolor\"> </td><td bgcolor=\"$diffcolorAdd\">$_</td></tr>\n"; } else { # we got minus before $state = "PreChange"; $rightCol[$rightRow++] = $_; } } elsif ($diffcode eq '-') { $state = "PreChangeRemove"; $leftCol[$leftRow++] = $_; } else { # empty diffcode flush_diff_rows \@leftCol, \@rightCol, $leftRow, $rightRow; print DIFFFILE "<tr><td bgcolor=\"$diffcolorNormal\">$_</td><td bgcolor=\"$backcolor\"> </td><td bgcolor=\"$diffcolorNormal\">$_</td></tr>\n"; $state = "dump"; $leftRow = 0; $rightRow = 0; } } } flush_diff_rows \@leftCol, \@rightCol, $leftRow, $rightRow; print DIFFFILE "</table>"; # print legend print DIFFFILE "<br><hr><table border=0><tr><td>"; print DIFFFILE "Legend:<br><table border=0 cellspacing=0 cellpadding=1>\n"; print DIFFFILE "<tr><td align=center bgcolor=\"$diffcolorRemove\">$fs"."line(s) removed in v.$revnumber"."$fe</td><td bgcolor=\"$diffcolorEmpty\">$fs"." "."$fe</td></tr>"; print DIFFFILE "<tr bgcolor=\"$diffcolorChange\"><td align=center colspan=2>$fs"."line(s) changed"."$fe</td></tr>"; print DIFFFILE "<tr><td bgcolor=\"$diffcolorEmpty\">$fs"." "."$fe</td><td align=center bgcolor=\"$diffcolorAdd\">$fs"."line(s) added in v.$oldrevnumber"."$fe</td></tr>"; print DIFFFILE "</table></td></tr></table>\n"; print DIFFFILE html_footer(""); print DIFFFILE "</body>\n</html>\n"; close(DIFFFILE); }}sub find_alldirs { my @dirs = (); find( sub { if (-d && ! -l && ! /CVS$/) { if ($File::Find::dir eq "." && $_ eq ".") { push @dirs, "./"; } else { push @dirs, "$File::Find::dir/$_"; } } }, '.' ); @dirs = map { $_ . "\n" } @dirs; return @dirs;}sub find_subdirs { my $currentdir = shift; my @dirs = (); finddepth( sub { if (-d && ! -l && ! /CVS$/ && $File::Find::dir eq $currentdir) { if ( ! ($File::Find::dir eq $currentdir && $_ eq ".") ) { push @dirs, "$File::Find::dir/$_"; } } }, $currentdir ); @dirs = map { $_ . "\n" } @dirs; return @dirs;}sub kill_log_header { @llcvslog = (); $headerstill = -1; foreach $ii (0 .. ($#lcvslog-1)) { if ($headerstill == 0) { @llcvslog = (@llcvslog,$lcvslog[$ii]); } else { $headerstill = $headerstill - 1; if ($lcvslog[$ii] =~ '----------------------------') { $headerstill = 2; } } }}############################################################## Lets set up the basics############################################################## Always enforce restrictions on dates. If no date is given# a very early one is used.date_control;# Set the width of the left frame.# Default value has been set above.if ($opt_w) { $leftframewidth = $opt_w;}# Set the splitratio of the left frame.# Default value has been set above.if ($opt_s) { $leftsplitratio = $opt_s;}# I want help!if ($opt_h) { shorthelp; showhelp; exit(0);}# The user must give a filename for the HTML-file(s)if ((!(($opt_O) || ($opt_o))) || (($opt_O) && ($opt_o))) { shorthelp; print "\nMade by Peter Toft (pto\@sslug.dk).\ncvs2html is protected by the GPL.\n"; exit(0);}$dochrono="";if($opt_c) { $dochrono=$opt_c;}if($opt_C) { $dochrono=$opt_C;}# Is -c followed by a "valid" filename ?if (length($dochrono)>5) { $chronooutname = $dochrono;}else { $chronooutname = "cvs2html_chrono_log.html";}# Want to write to a file with frames?if ($opt_o) { $frames = 1; $outname = $opt_o;}# Do you want to limit to certain revisions$revisionlimiter="";$revisionlimitertext="";$starttag="";if ($opt_r) { $revisionlimiter = "-r".$opt_r; $revisionlimitertext=" and only showing data between revisions $opt_r"; if ($opt_r =~ /^(\S*):(\S*)/) { $starttag=$1; $endtag=$2; } $revisionlimiter_end = "-r:".$endtag; $revisionlimiter_startonly = "-r".$starttag;}# Want to write to a file without frames?if ($opt_O) { $frames = 0; $outname = $opt_O;}$linkrel = "";# Want to link to external fileif ($opt_l) { $linkrel = $opt_l;}# Explicit path to cvsif ($opt_P) { $cvsLocation = $opt_P;}# Get the environment variable CVSROOT for this CVS repositoryopen(INFILE,"<./CVS/Root") or die "Error: The file ./CVS/Root is missing - this directory does not seem to be under CVS-control.";($fullcvsroot) = <INFILE> =~/^(.*)$/;close INFILE;# Split CVSROOT in machine and dir if possible.@spl = split(':',$fullcvsroot);if ($#spl == 3) {# @spl[0] is empty because client/server root starts with ':' -> ":pserver" or ":ext" $protocol =$spl[1]; # client/server ($cvsuser,$machine) = split('@',$spl[2]); $cvsroot = $spl[3];}elsif ($#spl == 1) { $protocol = "rsh/ssh"; ($cvsuser,$machine) = split('@',$spl[0]); $cvsroot = $spl[1];}else { $protocol = "local"; $cvsuser = ""; $machine = "localhost"; $cvsroot = $spl[0];}# Get the name of the repositoryopen(INFILE,"<./CVS/Repository") or die "Error: The file ./CVS/Repository is missing.";#($rootdir) = <INFILE> =~/^\Q$fullcvsroot\E(.*)$/;($rootdir) = <INFILE>;$rootdir = basename($rootdir);($rootdir) = $rootdir =~ /^(.*)$/;close INFILE;# Strip a .html from the outname if any (pasted on later)($outnamem) = $outname =~ /^(.*)\.html$/;if (length($outnamem)>0) { $outname = $outnamem;}# If an outputname is a directory a file named after the repository# is generated (and others if using frames).if (-d $outname) { $outname = $outname."/".$rootdir;}# Split the outname from a possible directory full path$outfilename = basename($outname);$outdirname = dirname($outname);($outfilename) = $outfilename =~ /^(.*)$/;($outdirname) = $outdirname =~ /^(.*)$/;$fulldiffdirname = $outdirname."/".$diffdirname;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -