1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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;
}
|