SkÃ¥ne Sjælland Linux User Group - http://www.sslug.dk Förstasida   Anmälning   Postarkiv   Forum   Kalender   Sök
MhonArc Dato: [Date Prev] [Kronologisk oversigt] [Date Next]   TrÃ¥d: [Date Prev] [Oversigt trÃ¥de] [Date Next]   MhonArc
 

Re: [CVS2HTML] Date generalisation



I poked around on CPAN and came up with DateManip (Date::Manip?? I'm
not very familiar with perl usage) by Sullivan Beck. The patch below
uses DateManip instead of hacking getdate.y.

I've made two related changes:

(1) remove -D

(2) when generating differences (-a and -d), include the diff between
    the earliest shown version and the latest unshown version (ie, how
    did we get here?)

-a and -d won't work too well together if there are revisions on more
than one branch within the timespan, I think!

I hope this version will be more to your liking ..

Another point: the help message implies that -w takes an argument in
pixels, it seems to be just like -s and you can give a percentage too
..

Regards,

-Simon

===================================================================
RCS file: /u1/cvsroot/external/cvs/cvs2html,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 cvs2html
--- cvs2html	1999/01/24 12:18:31	1.1.1.2
+++ cvs2html	1999/01/31 17:00:08
@@ -98,6 +98,8 @@
 use File::Basename;
 use File::Find;
 
+use Date::Manip;
+
 $v = '$Revision: 1.47 $';
 
 ($dummy,$version) = $v =~ /^\$(\w+): (.*) \$$/;
@@ -127,7 +129,7 @@
 $differencebackground = "#AABBAA";
 
 # Get the options. The ones with a colon means the an extra argument follows.
-&Getopts('abc:C:d:efhkl:n:N:s:vo:D:E:L:O:w:');
+&Getopts('abc:C:d:efhkl:n:N:s:vo:E:L:O:w:');
 
 # Colors and font to show the diff type of code changes when using -a
 $diffcolorHeading='#909090';  # color of 'Line'-heading of each diffed file
@@ -166,7 +168,7 @@
   print OUTFILE "<a href=\"$URL\" target=\"_top\">cvs2html</a> by ";
 
   printf OUTFILE "%s at %2d-%02d-%02d %2d:%02d",getlogin,  $year, $mon+1, $mday,$hour,$min;
-  if ($cutdate>"00000000")
+  if ($cutdate gt "1900010100:00:00")
   {
     printf OUTFILE " leaving out any log message prior to $cutyearformat2";
   }
@@ -189,7 +191,7 @@
 
   print "Usage of cvs2html\n\n";
   print "cvs2html [-a [-b][-k]] [-n NUMDIF] [-l FTPHOME] [-L FTPHOME -E EXTENSION]\n";
-  print "         [-e] [-f] [-d \"MMM DD [YYYY]\"] [-D DD]  [-h]\n";
+  print "         [-e] [-f] [-d \"MMM DD [YYYY]\"] [-h]\n";
   print "         [-v] [-w FRAMEWIDTH] [-s PERCENTAGE] [-N MAXCRONO]\n";
   print "         [-c/-C CFILENAME] -O/o HTMLNAME\n";
 }
@@ -237,10 +239,10 @@
   print " substitutes file extension with .html (-l and -L works together)\n";
   print " and -L requires that the -E option is used.\n";
 
-  print " If an option -d \"month day year\" is given (year optional) any\n";
-  print " log message prior to that date is omitted. The three first \n";
-  print " letters of the name of the month is used, e.g., Jun 5.\n";
-  print " A -D DD option will drop any log DD days ago or earlier\n";
+  print " If an option -d \"<date>\" is given, only log messages\n";
+  print " created after that date are reported. The date specification\n";
+  print " is extremely flexible; we use Sullivan Beck's DateManip\n";
+  print " package from CPAN.\n";
   print "\n";
 
   print " If -o and -w FRAMEWIDTH is used the left frame will have\n";
@@ -255,8 +257,8 @@
   print "\n";
 
   print " Example :\n";
-  print " cvs2html -l ftp://eivind.imm.dtu.dk/pub/utils -D 5 -c crono.html \\";
-  print " -v -o ~/utils.html\n";
+  print " cvs2html -l ftp://eivind.imm.dtu.dk/pub/utils -D 5 -c crono.html \\\n";
+  print "   -v -o ~/utils.html\n";
   print " makes ~/utils.html with log data for the 5 most recent days.\n";
   print " with links relative to ftp://eivind.imm.dtu.dk/pub/utils\n";;
   print " and makes the cronological log file.\n\n";
@@ -270,64 +272,16 @@
 # 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;
+  if ($opt_d) {
+    $cutdate = &ParseDate("$opt_d") or die "Date error\n";
+    $cutyearformat2 = &UnixDate($cutdate, "%b %e, %Y %T");
   }
   else
   {
-    $cutdate = "00000000";
+    $cutdate = "1900010100:00:00";
   }
-  # Anything before year 0000 - I dont think so...........
+
+  # default is the UNIX epoch, what would this do on other systems?
 }
 
 # Function to read the next line from cvslogarray
@@ -1092,11 +1046,10 @@
         $line = getnextline;
       }
 
-      ($rd1,$rd2,$rd3,$rdrest) = $revdate =~ /^(\d+)\/(\d+)\/(\d+) (.*)$/;
-      $revdateformat2 = $rd1.$rd2.$rd3;
-      ($rt1,$rt2,$rt3) = $rdrest =~/(\d+)\:(\d+)\:(\d+)/;
+      $revdate =~ /^(\d+)\/(\d+)\/(\d+) (.*)$/;
+      $revdateformat2 = &ParseDate("$revdate") or die "Date error";
+      $revdateformat3 = $revdateformat2;
 
-      $revdateformat3 = 3600*$rt1+60*$rt2+$rt3+86400*$revdateformat2;
       $printfilename = $printfilename + 1;
 
       $fname="";
@@ -1210,7 +1163,7 @@
         print OUTFILE $Ls.$filename.$Le;
         print OUTFILE "</font></B><br></td><tr>\n";
       }
-      if ($revdateformat2 >= $cutdate)
+      if ($revdateformat2 gt $cutdate)
       {
         $onlist = 1;
         if (($opt_o) && ($leftfill == 0))
@@ -1257,6 +1210,18 @@
           @cronolinknames = (@cronolinknames,$cronolinker);
         }
       }
+      elsif (($opt_a) && ($nodiff!=0) && ($oldrevnumber!=0))
+      {
+	# This log entry is for a revision before the cutdate, and we
+	# are generating differences, and we haven't exhausted the
+        # specified number of differences, and oldrevnumber hasn't been
+        # reset to 0; so this is the first such log entry, and we
+        # generate the differences output.
+        print OUTFILE "<tr><td colspan=4 BGCOLOR=\"$differencebackground\"><i>Show difference between <a href=\"$filename$convdir\_diff\_$oldrevnumber\_$revnumber.html\">Revision $revnumber and $oldrevnumber </a></i>\n";
+        generate_diff_file;
+        $nodiff--;
+	$oldrevnumber = 0;
+      }
 
       # While more log read and process
       $morelog=1;
@@ -1283,7 +1248,7 @@
             $line=$_;
             if ($line =~ /^(.*)$/)
             {
-              if ($revdateformat2 >= $cutdate)
+              if ($revdateformat2 gt $cutdate)
               {
                 if ($opt_e) {
                   print OUTFILE "<code>$1</code><br>\n";
@@ -1495,7 +1460,7 @@
   print CRONOFILE "<a href=\"$URL\" target=\"_top\">cvs2html</a> by ";
 
   printf CRONOFILE "%s at %2d-%02d-%02d %2d:%02d",getlogin,  $year, $mon+1, $mday,$hour,$min;
-  if ($cutdate>"00000000")
+  if ($cutdate gt "1900010100:00:00")
   {
     printf CRONOFILE " leaving out any log message prior to $cutyearformat2";
   }


 
Förstasida   Anmälning   Postarkiv   Översikt   Kalender   Sök

 
 
Fel och synpunkter angående webb-sidorna skickas till <www_admin>. Senaste ändring 2005-08-10, klockan 20:48
Denna sidan underholds av MHonArc .