📄 cvs2html
字号:
mkdir($outdirname,0775);mkdir($fulldiffdirname,0775);if(defined($opt_V) && $opt_V>0) { print STDOUT "Processing \#1 $currentdir\n"; }# Get all dirs to search@entirealldirs = find_alldirs();# Only pass along subdirectories that are under version control@alldirs = ();foreach $dir (@entirealldirs) { chop($dir); if ( -d "$dir/CVS" ) { if(defined($opt_V) && $opt_V>1) { print STDOUT " $dir\n"; } push(@alldirs, "$dir\n"); }}if ($frames == 1) { # Write the start of the left lower frame if more than one dir if (($#alldirs > 0) || ($dochrono)) { $llname = $outdirname.'/'.$outfilename."__lfl.html"; open(OUTFILE3,">$llname") or die "Error: The file $llname could not be opened."; @listhtmlnames = (@listhtmlnames,$llname); print OUTFILE3 html_header(""); if ($dochrono) { print OUTFILE3 "<table border=0 cellspacing=1 cellpadding=3 bgcolor=\"$cellcolor\" width=\"100%\">\n"; $coutref = $outdirname."/".$chronooutname; print OUTFILE3 '<tr><td><a href="'.$chronooutname.'" target="rf"><FONT SIZE="-1">Chronological Log'."</font></a></td></tr>\n"; print OUTFILE3 "</table><br>\n"; } print OUTFILE3 "<h3 align=center>Dirs</h3>\n"; print OUTFILE3 "<table border=0 cellspacing=1 cellpadding=3 bgcolor=\"$cellcolor\" width=\"100%\">"; for ($ii=0;$ii<=$#alldirs;$ii++) { $alldirs[$ii] =~ /^\.(.*)$/; $dir = $1; $showdir = "[$rootdir]$dir"; $refname = $dir; $refname =~ tr/\//_/; if (length($refname) == 1) { $refname = $outfilename; } else { $refname = $outfilename.$refname; } print OUTFILE3 '<tr><td><a href="'.$refname.'.html" target="_top"><FONT SIZE="-1">'.$showdir."</font></a></td></tr>\n"; } print OUTFILE3 "</table>\n"; print OUTFILE3 "</body>\n"; print OUTFILE3 "</html>\n"; close(OUTFILE3); }}if ($dochrono) { $chronocounter = -1; @chronoindex=(); @chronoauthor=(); @chrononame=(); @chronotimesince0=(); @chronoversion=(); @chronoshowtime=(); @chronolinknames=();}############################################################## Lets go for each of the directories#############################################################for ($dd=0;$dd<=$#alldirs;$dd++) { # Initialization @otherdnames = (); $lineno = -1; $foundbadone = 0; $fnumber = 1; # Where are we ? # $convdir is the current dir where all / are converted to _ ($currentdir) = $alldirs[$dd] =~ /^\.\/(.*)$/; $convdir = $currentdir; $convdir =~ tr/\//_/; if (length($currentdir)==0) { $currentdirformat2 =""; $currentdir='.'; $convdir = ""; } else { $currentdirformat2 = $currentdir."/"; $convdir = '_'.$convdir; } if(defined($opt_V) && $opt_V>0) { print STDOUT "Processing \#2 $currentdir\n"; } @entiresubdirs = find_subdirs($currentdir); @subdirs = (); foreach $dir (@entiresubdirs) { chop($dir); if ( -d "$dir/CVS" ) { if(defined($opt_V) && $opt_V>1) { print STDOUT " $dir\n"; } push(@subdirs, "$dir\n"); } } if ($frames == 1) { $llname = $outdirname.'/'.$outfilename.$convdir."__lfl.html"; open(OUTFILE3,">$llname") or die "Error: The file $llname could not be opened."; @listhtmlnames = (@listhtmlnames,$llname); print OUTFILE3 html_header(""); if ($dochrono) { print OUTFILE3 "<table border=0 cellspacing=1 cellpadding=3 bgcolor=\"$cellcolor\" width=\"100%\">"; $coutref = $outdirname."/".$chronooutname; print OUTFILE3 '<tr><td><a href="'.$chronooutname.'" target="rf"><font size="-1">Chronological Log'."</font></a></td></tr>\n"; print OUTFILE3 "</table><br>\n"; } if ($#subdirs>=0 || $currentdir ne '.') { print OUTFILE3 "<h3 align=center>Sub Dirs</h3>\n"; print OUTFILE3 "<table border=0 cellspacing=1 cellpadding=3 bgcolor=\"$cellcolor\" width=\"100%\">"; if($currentdir eq '.') { # No parent directory to top } else { $showdir = ".. Parent Dir"; $up = dirname ($currentdir); ($up) = $up =~ /^(.*)$/; if ($up eq ".") { $refname = "/"; } else { $refname = "/$up"; } $refname =~ tr/\//_/; if (length($refname) == 1) { $refname = $outfilename; } else { $refname = $outfilename.$refname; } print OUTFILE3 '<tr><td><a href="'.$refname.'.html" target="_top"><FONT SIZE="-1">'.$showdir."</font></a></td></tr>\n"; } for ($ii=0;$ii<=$#subdirs;$ii++) { $subdirs[$ii] =~ /^\.(.*)$/; $dir = $1; $up = dirname ($subdirs[$ii]); ($up) = $up =~ /^(.*)$/; $up = basename ($up); ($up) = $up =~ /^(.*)$/; $down = basename ($subdirs[$ii]); ($down) = $down =~ /^(.*)$/; $dir = "/$down"; if ($up eq ".\n") { $showdir = "[$rootdir]$dir"; } else { $showdir = "[$up]$dir"; } if($currentdir eq '.') { $refname = $dir; } else { $refname = "/$currentdir$dir"; } $refname =~ tr/\//_/; if (length($refname) == 1) { $refname = $outfilename; } else { $refname = $outfilename.$refname; } print OUTFILE3 '<tr><td><a href="'.$refname.'.html" target="_top"><FONT SIZE="-1">'.$showdir."</font></a></td></tr>\n"; } print OUTFILE3 "</TABLE><br>\n"; } print OUTFILE3 "</body>\n"; print OUTFILE3 "</html>\n"; close(OUTFILE3); } # Should the output have frames then make left lower frame. if ($frames == 1) { # Write the start of the left upper frame $luname = $outdirname.'/'.$outfilename.$convdir."__lfu.html"; open(OUTFILE2,">$luname") or die "Error: The file $luname could not be opened."; @listhtmlnames = (@listhtmlnames,$luname); print OUTFILE2 html_header(""); print OUTFILE2 "<h3 align=\"center\">Log History</h3>\n"; print OUTFILE2 "<table border=0 cellspacing=1 cellpadding=3 bgcolor=\"$cellcolor\" width=\"100%\">"; %outfile2lines=(); } # Should the output have frames ? if ($frames == 1) { $mainname = $outdirname.'/'.$outfilename.$convdir.".html"; # Write the start of the main html file open(OUTFILE4,">$mainname") or die "Error: The file $mainname could not be opened."; @listhtmlnames = (@listhtmlnames,$mainname); print OUTFILE4 "<\!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">\n<html>\n"; print OUTFILE4 "<head><title>CVS2HTML</title></head>\n"; print OUTFILE4 "<frameset cols=\"$leftframewidth,*\">\n"; # only do the left lower frame if subdirs found if (($#alldirs > 0) || ($dochrono)) { print OUTFILE4 "<frameset rows=\"".$leftsplitratio.",*\">\n"; print OUTFILE4 "<frame scrolling=auto src=\"".$outfilename.$convdir."__lfu.html\" name=\"lfu\">\n"; print OUTFILE4 "<frame scrolling=auto src=\"".$outfilename.$convdir."__lfl.html\" name=\"lfl\">\n";# print OUTFILE4 "<frame scrolling=auto src=\"$outfilename"."__lfl.html\" name=\"lfl\">\n"; print OUTFILE4 "</frameset>\n"; } else { print OUTFILE4 "<frame scrolling=auto src=\"$outfilename".$convdir."__lfu.html\" name=\"lfu\">\n"; } # Do right frame link print OUTFILE4 "<frame scrolling=auto src=\"$outfilename".$convdir."__rf.html\" name=\"rf\">\n"; print OUTFILE4 "<noframes>\n"; print OUTFILE4 "<h2 align=center>CVS Directories</h2>\n<hr>\n<br>\n"; } if(defined($opt_V) && $opt_V>0) { print STDOUT "Getting cvs-entries\n"; } $cvsnames = ""; @cvsnameslist = (); $Entryfilename = $currentdir."/CVS/Entries"; open(NAMEFILE,"<$Entryfilename"); $contin = 1; $nooffiles = 0; while ($contin ==1) { $namlin = <NAMEFILE>; ($readnameline) = $namlin =~ /^\/([ a-zA-Z0-9-+_\.(...)]*)\/.*$/; $_ = $readnameline; s/ /~/g; $readnameline = $_; if (length($namlin)>0) { if (length($readnameline)>0) { $nooffiles++; $cvsnames = $cvsnames." ".$currentdir.'/'.$readnameline; push @cvsnameslist, $currentdir.'/'.$readnameline; } } else { $contin=0; } } close(NAMEFILE); # Check for an empty Log (if, e.g., the directory does not contain files # registered with CVS). if (length ($cvsnames) <= 0) { print STDERR "Error 4 : Doing $currentdir: Log is empty.\n"; # We really should make a file here I think if ($frames == 1) { $rfoutname = $outdirname.'/'.$outfilename.$convdir."__rf.html"; open(OUTFILE,">$rfoutname") or die "Error: Could not open $rfoutname\n."; @listhtmlnames = (@listhtmlnames,$rfoutname); } $fnumber=2; if (length($currentdir)==1) { print OUTFILE html_header("--- $rootdir ---"); } else { print OUTFILE html_header("--- $rootdir/$currentdir ---"); } if ($opt_v) { print OUTFILE cvsrootinfo(); } print OUTFILE html_footer(""); print OUTFILE "</body></html>\n"; # Lets open the main file and process if ($frames == 1) { $rfoutname = $outdirname.'/'.$outfilename.$convdir.$fname."__rf.html"; open(OUTFILE,">$rfoutname") or die "Error: Could not open $rfoutname\n."; @listhtmlnames = (@listhtmlnames,$rfoutname); } else { $mainoutname = $outdirname.'/'.$outfilename.$convdir.$fname.".html"; open(OUTFILE,">$mainoutname") or die "Error: Could not open $mainoutname\n."; @listhtmlnames = (@listhtmlnames,$mainoutname); } $fnumber=2; if (length($currentdir)==1) { print OUTFILE html_header("--- $rootdir ---"); } else { print OUTFILE html_header("--- $rootdir/$currentdir ---"); } print OUTFILE "<center>This directory is empty</center>\n"; closemainfile; } next if (length ($cvsnames) <= 0); # Log is empty so proceed to next directory if(defined($opt_V) && $opt_V>0) { print STDOUT "Retrieving logdata\n"; } $_ = join ('" "', sort (split ' ', $cvsnames)); s/~/ /g; $cvsnames = '"'.$_.'"'; @cvslogarray = ();# it would be nice to have just one cvs log <file_1> <file_2> ... <file_n># the filter out invalid branch blocs and re-request them# for this I would need to know how this message looks like foreach $cvsnamesentry (@cvsnameslist) { if(defined($opt_V) && $opt_V>1) { print STDOUT " $cvsnamesentry\n"; } @cvslogarray_sub = `$cvsLocation log $revisionlimiter $cvsnamesentry 2>&1 `; if ($cvslogarray_sub[0] =~ /connection refused/i) { print STDERR "Error 3 : connection to cvs refused for \"$cvsnamesentry\"\n"; @cvslogarray_sub = (); last; } if ($cvslogarray_sub[0] =~ /invalid branch or revision pair/i) { # the end tag was probably the first rev in a branch and "cvs log" # does not tolerate such combination, it needs special handling # retry with '-r:endtag' print "retrying with $revisionlimiter_end\n"; @cvslogarray_sub_branch = `$cvsLocation log $revisionlimiter_end $cvsnamesentry`; @cvslogarray_sub_trunk = `$cvsLocation log $revisionlimiter_startonly $cvsnamesentry`; # find index of log entry separator line in @cvslogarray_sub_trunk $trunk_log_line = 0; while ( $trunk_log_line <= $#cvslogarray_sub_trunk and ! ($cvslogarray_sub_trunk[$trunk_log_line] =~ /^--------*$/) ){ $trunk_log_line++; } # combine both logs @cvslogarray_sub = (@cvslogarray_sub_branch[0 .. $#cvslogarray_sub_branch-1], @cvslogarray_sub_trunk[$trunk_log_line .. $#cvslogarray_sub_trunk]); } push @cvslogarray, @cvslogarray_sub; } if(defined($opt_V) && $opt_V>0) { print STDOUT "Processing logdata\n"; } $line = getnextline; # skip lines starting with "?" while ($line =~ /^\? (.*)$/) { $foundbadone = 1 ; $line = getnextline; } while ($line) { if ($opt_n>0) { $nodiff = $opt_n; } else { $nodiff = -1; } $oldrevnumber=0; if ($line =~ /^\? (.*)/) { print STDERR "The file \"$1\" is not part of cvs\n"; $line = getnextline; } $line = getnextline; # skip lines starting with "?" while ($line =~ /^\? (.*)$/) { $foundbadone = 1 ; $line = getnextline; } # skip empty lines while ($line =~ /^( *)$/) { $line = getnextline; } # found a filename (ends on ",v") if ($line =~ /^.*: (.*),v$/) { $line = getnextline; ($lfilename) = $line =~ /^.*: (.*)$/; ($filename) = $lfilename =~ (/^.*\/([ a-zA-Z0-9-+_\.(...)]*)$/); if (length($filename) == 0) { $filename = $lfilename; } if (length($filename) == 0) { print STDERR "Error 2 in processing the output of cvs log in $currentdir\n"; print STDERR $line; } else { if(defined($opt_V) && $opt_V>1) { print STDOUT " $filename\n"; } } $printfilename = 0; $onlist = 0; } else { print STDERR "Error 1 in processing the output of cvs log in $currentdir\n"; print STDERR $line; print STDERR "\n"; if ($line =~ /nothing known about/) { print STDERR "No log info for file.\n"; last; } } # Find the next separator... while ($line and !($line =~ /^symbolic names:/) and !($line =~ /^--------*$/) and !($line =~ /^========*$/)) { $line = getnextline; } # Find the revision of the startrevision if any: $startrevision=""; if ($line =~ /^symbolic names:/) { $line = getnextline; while (!($line =~ /^[a-z]/)) { if ($line =~ /[ ]*(\S*): (\S*)$/) { if ($1 eq $starttag) { $startrevision=$2; } } $line = getnextline; } # Find the next separator... while (!($line =~ /^--------*$/) and !($line =~ /^========*$/)) { $line = getnextline; } } $newfile=0; # If the separator is a new file separator, flag it. if ($line =~ /^========*$/) { $newfile = 1; # FIXME: We still need to create a index~<filename>__rf.html if ($frames == 1) { $rfoutname = $outdirname.'/'.$outfilename.$convdir."__rf.html"; open(OUTFILE,">$rfoutname") or die "Error: Could not open $rfoutname\n."; @listhtmlnames = (@listhtmlnames,$rfoutname); } $fnumber=2; if (length($currentdir)==1) { print OUTFILE html_header("--- $rootdir ---"); } else { print OUTFILE html_header("--- $rootdir/$currentdir ---"); } if ($opt_v) { print OUTFILE cvsrootinfo(); } print OUTFILE html_footer(""); print OUTFILE "</body></html>\n";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -