diff options
author | Gerald Carter <jerry@samba.org> | 2001-03-25 06:05:57 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2001-03-25 06:05:57 +0000 |
commit | 9305a8f71029054c89bc876b6d5c17015be2bc51 (patch) | |
tree | f3d8b09b1bb981e52c5711eb046efeb748503e33 /source3/script | |
parent | 194a87bf7691aa8338a6625c0ad604e6b0569684 (diff) | |
download | samba-9305a8f71029054c89bc876b6d5c17015be2bc51.tar.gz samba-9305a8f71029054c89bc876b6d5c17015be2bc51.tar.bz2 samba-9305a8f71029054c89bc876b6d5c17015be2bc51.zip |
merge from 2.2
(This used to be commit b6227751f117ad507838db0cf0032093f6251646)
Diffstat (limited to 'source3/script')
-rwxr-xr-x | source3/script/scancvslog.pl | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/source3/script/scancvslog.pl b/source3/script/scancvslog.pl new file mode 100755 index 0000000000..6e05c4c3d6 --- /dev/null +++ b/source3/script/scancvslog.pl @@ -0,0 +1,96 @@ +#!/usr/bin/perl +require"timelocal.pl"; + +# +# usage scancvslog.pl logfile starttime tag +# +# this will extract all entries from the specified cvs log file +# that have a date later than or equal to starttime and a tag +# value of tag. If starttime is not specified, all entries are +# extracted. If tag is not specified then entries for all +# branches are extracted. starttime must be specified as +# "monthname day, year" +# +# Example to extract all entries for SAMBA_2_2 branch from the +# log file named cvs.log +# +# scancvslog.pl cvs.log "" SAMBA_2_2 +# +# +# To extract all log entries after Jan 10, 1999 (Note month name +# must be spelled out completely). +# +# scancvslog.pl cvs.log "January 10, 1999" +# + +open(INFILE,@ARGV[0]) || die "Unable to open @ARGV[0]\n"; + +%Monthnum = ( + "January", 0, + "February", 1, + "March", 2, + "April", 3, + "May", 4, + "June", 5, + "July", 6, + "August", 7, + "September", 8, + "October", 9, + "November", 10, + "December", 11 +); + +$Starttime = (@ARGV[1]) ? &make_time(@ARGV[1]) : 0; +$Tagvalue = @ARGV[2]; + +while (&get_entry) { + $_=$Entry[0]; + s/^Date:\s*\w*\s*(\w*)\s*(\w*),\s*(\w*).*/$1 $2 $3/; + $Testtime = &make_time($_); + $Testtag = &get_tag; + if (($Testtime >= $Starttime) && ($Tagvalue eq $Testtag)) { + print join("\n",@Entry),"\n"; + } +} +close(INFILE); + +sub make_time { + $_ = @_[0]; + s/,//; + ($month, $day, $year) = split(" ",$_); + if (($year < 1900)||($day < 1)||($day > 31)||not length($Monthnum{$month})) { + print "Bad date format @_[0]\n"; + print "Date needs to be specified as \"Monthname day, year\"\n"; + print "eg: \"January 10, 1999\"\n"; + exit 1; + } + $year = ($year == 19100) ? 2000 : $year; + $month = $Monthnum{$month}; + $Mytime=&timelocal((0,0,0,$day,$month,$year)); +} + +sub get_tag { + @Mytag = grep (/Tag:/,@Entry); + $_ = @Mytag[0]; + s/^.*Tag:\s*(\w*).*/$1/; + return $_; +} + +sub get_entry { + @Entry=(); + if (not eof(INFILE)) { + while (not eof(INFILE)) { + $_ = <INFILE>; + chomp $_; + next if (not ($_)); + if (/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/) { + next if ($#Entry == -1); + push(Entry,$_); + return @Entry; + } else { + push(Entry,$_); + } + } + } + return @Entry; +} |