Mercurial > emacs
comparison lib-src/grep-changelog @ 89909:68c22ea6027c
Sync to HEAD
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 16 Apr 2004 12:51:06 +0000 |
parents | 375f2633d815 |
children | f9a65d7ebd29 |
comparison
equal
deleted
inserted
replaced
89908:ee1402f7b568 | 89909:68c22ea6027c |
---|---|
1 #! /usr/bin/perl | 1 #! /usr/bin/perl |
2 | 2 |
3 # Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | 3 # Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc. |
4 # | 4 # |
5 # This file is part of GNU Emacs. | 5 # This file is part of GNU Emacs. |
6 # | 6 # |
7 # GNU Emacs is free software; you can redistribute it and/or modify | 7 # GNU Emacs is free software; you can redistribute it and/or modify |
8 # it under the terms of the GNU General Public License as published by | 8 # it under the terms of the GNU General Public License as published by |
54 | 54 |
55 # Print usage information and exit when necessary. | 55 # Print usage information and exit when necessary. |
56 | 56 |
57 if ($result == 0 || $help) { | 57 if ($result == 0 || $help) { |
58 print <<USAGE; | 58 print <<USAGE; |
59 | |
59 Usage: $0 [options] [CHANGELOG...] | 60 Usage: $0 [options] [CHANGELOG...] |
60 Print entries in ChangeLogs matching various criteria. Valid options | 61 |
61 are | 62 Print entries in ChangeLogs matching various criteria. |
62 | 63 Valid options are: |
63 --author=AUTHOR match entries whose author line matches | 64 |
65 --author=AUTHOR Match entries whose author line matches | |
64 regular expression AUTHOR | 66 regular expression AUTHOR |
65 --text=TEXT match entries whose text matches regular | 67 --text=TEXT Match entries whose text matches regular |
66 expression TEXT. | 68 expression TEXT |
67 --exclude=TEXT exclude entries matching TEXT. | 69 --exclude=TEXT Exclude entries matching TEXT |
68 --from-date=YYYY-MM-DD match entries not older than given date | 70 --from-date=YYYY-MM-DD Match entries not older than given date |
69 --to-date=YYYY-MM-DD match entries not younger than given date | 71 --to-date=YYYY-MM-DD Match entries not younger than given date |
70 --rcs-log format output suitable for RCS log entries. | 72 --rcs-log Format output suitable for RCS log entries |
71 --with-date print short date line in RCS log | 73 --with-date Print short date line in RCS log |
72 --reverse show entries in reverse (chronological) order | 74 --reverse Show entries in reverse (chronological) order |
73 --version print version info | 75 --version Print version info |
74 --help print this help | 76 --help Print this help |
75 | 77 |
76 If no CHANGELOG is specified scan the files "ChangeLog" and | 78 If no CHANGELOG is specified scan the files "ChangeLog" and |
77 "ChangeLog.[9-1]" in the current directory. Old-style dates in ChangeLogs | 79 "ChangeLog.1+" in the current directory. Old-style dates in ChangeLogs |
78 are not recognized. | 80 are not recognized. |
79 USAGE | 81 USAGE |
80 exit $help ? 0 : 1; | 82 exit !$help; |
81 } | 83 } |
82 | 84 |
83 # Print version info and exit if `--version' was specified. | 85 # Print version info and exit if `--version' was specified. |
84 | 86 |
85 if ($version) { | 87 if ($version) { |
86 print "0.1\n"; | 88 print "0.2\n"; |
87 exit 0; | 89 exit 0; |
88 } | 90 } |
89 | 91 |
90 | 92 |
91 # Value is non-zero if HEADER matches according to command line | 93 # Value is non-zero if HEADER matches according to command line |
92 # options specified, i.e. it matches $author, and its date is in | 94 # options specified, i.e. it matches $author, and its date is in |
93 # the range $from_date <= date <= $to_date. | 95 # the range $from_date <= date <= $to_date. |
94 | 96 |
95 sub header_match_p ($) { | 97 sub header_match_p { |
96 my $header = shift; | 98 my $header = shift; |
97 | 99 |
98 return 0 unless $header; | 100 return 0 unless $header; |
99 | 101 |
100 # No match if AUTHOR-regexp specified and doesn't match. | 102 # No match if AUTHOR-regexp specified and doesn't match. |
120 | 122 |
121 # Value is non-zero if ENTRY matches the criteria specified on the | 123 # Value is non-zero if ENTRY matches the criteria specified on the |
122 # command line, i.e. it matches $regexp, and it doesn't match | 124 # command line, i.e. it matches $regexp, and it doesn't match |
123 # $exclude. | 125 # $exclude. |
124 | 126 |
125 sub entry_match_p ($) { | 127 sub entry_match_p { |
126 my $entry = shift; | 128 my $entry = shift; |
127 | 129 |
128 return 0 unless $entry; | 130 return 0 unless $entry; |
129 | 131 |
130 if ($regexp) { | 132 if ($regexp) { |
141 # Print HEADER and/or ENTRY in a format suitable for what was | 143 # Print HEADER and/or ENTRY in a format suitable for what was |
142 # specified on the command line. If $rcs_log is specified, author | 144 # specified on the command line. If $rcs_log is specified, author |
143 # lines are not printed, and leading spaces and file names are removed | 145 # lines are not printed, and leading spaces and file names are removed |
144 # from ChangeLog entries. | 146 # from ChangeLog entries. |
145 | 147 |
146 sub print_log ($$) { | 148 sub print_log { |
147 my ($header, $entry) = @_; | 149 my ($header, $entry) = @_; |
148 my $output = ''; | 150 my $output = ''; |
149 | 151 |
150 if ($rcs_log) { | 152 if ($rcs_log) { |
151 # Remove leading whitespace from entry. | 153 # Remove leading whitespace from entry. |
170 } | 172 } |
171 } | 173 } |
172 | 174 |
173 # Scan LOG for matching entries, and print them to standard output. | 175 # Scan LOG for matching entries, and print them to standard output. |
174 | 176 |
175 sub parse_changelog ($) { | 177 sub parse_changelog { |
176 my $log = shift; | 178 my $log = shift; |
177 my $entry = undef; | 179 my $entry = undef; |
178 my $header = undef; | 180 my $header = undef; |
179 | 181 |
180 @entries = () if $reverse; | 182 @entries = () if $reverse; |
217 if header_match_p ($header) && entry_match_p ($entry); | 219 if header_match_p ($header) && entry_match_p ($entry); |
218 | 220 |
219 close IN; | 221 close IN; |
220 | 222 |
221 if ($reverse) { | 223 if ($reverse) { |
222 while (defined (my $entry = pop @entries)) { | 224 for (my $entry = @entries; $entry; $entry--) { |
223 print $entry; | 225 print $entries[$entry-1]; |
224 } | 226 } |
225 } | 227 } |
226 } | 228 } |
227 | 229 |
228 | 230 |
229 # Main program. Process ChangeLogs. | 231 # Main program. Process ChangeLogs. |
230 | 232 |
231 # If files were specified on the command line, parse those files in the | 233 # If files were specified on the command line, parse those files in the |
232 # order supplied by the user; otherwise parse default files ChangeLog and | 234 # order supplied by the user; otherwise parse default files ChangeLog and |
233 # ChangeLog.9...ChangeLog.1 according to $reverse. | 235 # ChangeLog.1+ according to $reverse. |
234 unless (@ARGV > 0) { | 236 unless (@ARGV > 0) { |
235 @ARGV = ("ChangeLog", map {"ChangeLog.$_"} reverse 1..9); | 237 @ARGV = ("ChangeLog"); |
238 | |
239 push @ARGV, | |
240 map {"ChangeLog.$_"} | |
241 sort {$b <=> $a} | |
242 map {/\.(\d+)$/; $1} | |
243 do { | |
244 opendir D, '.'; | |
245 grep /^ChangeLog\.\d+$/, readdir D; | |
246 }; | |
247 | |
236 @ARGV = reverse @ARGV if $reverse; | 248 @ARGV = reverse @ARGV if $reverse; |
237 } | 249 } |
238 | 250 |
239 while (defined (my $log = shift @ARGV)) { | 251 while (defined (my $log = shift @ARGV)) { |
240 parse_changelog ($log) if -f $log; | 252 parse_changelog ($log) if -f $log; |
241 } | 253 } |
242 | 254 |
243 | 255 |
256 # arch-tag: 9e4f6749-e053-4bb7-b3ad-11947318418e | |
244 # grep-changelog ends here. | 257 # grep-changelog ends here. |