Mercurial > emacs
annotate lib-src/=rcs2log @ 1112:1dba066c1e0a
*** empty log message ***
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sun, 13 Sep 1992 10:54:38 +0000 |
parents | 36e7f4e402bd |
children | 8abf83cc14b1 |
rev | line source |
---|---|
527 | 1 #!/bin/sh |
2 | |
3 # RCS to ChangeLog generator | |
4 | |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
5 # $Id: rcs2log,v 1.6 1992/05/08 21:45:00 eggert Exp eggert $ |
527 | 6 |
7 # Generate a change log prefix from RCS/* and the existing ChangeLog (if any). | |
8 # Output the new prefix to standard output. | |
9 # You can edit this prefix by hand, and then prepend it to ChangeLog. | |
10 | |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
11 # Ignore log entries that start with `#'. |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
12 # Clump together log entries that start with `{topic} ', |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
13 # where `topic' contains neither white space nor `}'. |
527 | 14 |
534 | 15 # Parse options. |
16 | |
17 # defaults | |
18 indent=8 # indent of log line | |
19 length=79 # suggested max width of log line | |
20 tabwidth=8 # width of horizontal tab | |
21 | |
22 while : | |
23 do | |
24 case $1 in | |
25 -i) indent=${2?};; | |
26 -l) length=${2?};; | |
27 -t) tabwidth=${2?};; | |
28 -*) echo >&2 "$0: usage: $0 [-i indent] [-l length] [-t tabwidth] [file ...]" | |
29 exit 1;; | |
30 *) break | |
31 esac | |
32 shift; shift | |
33 done | |
34 | |
35 | |
527 | 36 # Log into $rlogout the revisions checked in since the first ChangeLog entry. |
37 | |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
38 date=1970 |
527 | 39 if test -s ChangeLog |
40 then | |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
41 # Add 1 to seconds to avoid duplicating most recent log. |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
42 # It's a good thing `rlog' doesn't mind a time ending in `:60'. |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
43 e=' |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
44 /^... ... [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]+ /{ |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
45 printf "%s%.2d %s\n", substr($0,1,17), substr($0,18,2)+1, $5 |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
46 exit |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
47 } |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
48 ' |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
49 d=`awk "$e" <ChangeLog` || exit |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
50 case $d in |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
51 ?*) date=$d |
535
4b75abb93479
Don't munge $* when getting date from ChangeLog.
Paul Eggert <eggert@twinsun.com>
parents:
534
diff
changeset
|
52 esac |
527 | 53 fi |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
54 datearg="-d>$date" |
527 | 55 |
56 rlogout=/tmp/chg$$ | |
57 trap exit 1 2 13 15 | |
58 trap 'rm -f $rlogout; exit 1' 0 | |
59 | |
534 | 60 case $# in |
61 0) set RCS/* | |
62 esac | |
63 | |
64 rlog "$datearg" "$@" >$rlogout || exit | |
527 | 65 |
66 | |
67 # Get the full name of each author the logs mention, and set initialize_fullname | |
68 # to awk code that initializes the `fullname' awk associative array. | |
69 # Warning: foreign authors (i.e. not known in the passwd file) are mishandled; | |
70 # you have to fix the resulting output by hand. | |
71 | |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
72 initialize_fullname= |
527 | 73 authors=` |
74 sed -n 's|^date: *[0-9]*/[0-9][0-9]/[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]; *author: *\([^; ]*\).*|\1|p' <$rlogout | | |
75 sort -u | |
76 ` | |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
77 case $authors in |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
78 ?*) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
79 initialize_author= |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
80 for author in $authors |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
81 do |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
82 initialize_author="$initialize_author |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
83 author[\"$author\"] = 1 |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
84 " |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
85 done |
527 | 86 |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
87 awkscript=' |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
88 BEGIN { |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
89 alphabet = "abcdefghijklmnopqrstuvwxyz" |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
90 ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
91 '"$initialize_author"' |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
92 } |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
93 { |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
94 if (author[$1]) { |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
95 fullname = $5 |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
96 abbr = index(fullname, "&") |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
97 if (abbr) { |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
98 a = substr($1, 1, 1) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
99 A = a |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
100 i = index(alphabet, a) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
101 if (i) A = substr(ALPHABET, i, 1) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
102 fullname = substr(fullname, 1, abbr-1) A substr($1, 2) substr(fullname, abbr+1) |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
103 } |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
104 printf "fullname[\"%s\"] = \"%s\"\n", $1, fullname |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
105 author[$1] = 0 |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
106 } |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
107 } |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
108 ' |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
109 |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
110 initialize_fullname=` |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
111 (cat /etc/passwd; ypmatch $authors passwd) 2>/dev/null | |
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
112 awk -F: "$awkscript" |
527 | 113 ` |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
114 esac |
527 | 115 |
116 | |
117 # Function to print a single log line. | |
118 # We don't use awk functions, to stay compatible with old awk versions. | |
119 # `Log' is the log message (with \n replaced by \r). | |
594 | 120 # `files' contains the affected files. |
527 | 121 printlogline='{ |
122 | |
123 # Following the GNU coding standards, rewrite | |
124 # * file: (function): comment | |
125 # to | |
126 # * file (function): comment | |
127 if (Log ~ /^\([^)]*\): /) { | |
128 i = index(Log, ")") | |
129 files = files " " substr(Log, 1, i) | |
130 Log = substr(Log, i+3) | |
131 } | |
132 | |
133 # If "label: comment" is too long, break the line after the ":". | |
134 sep = " " | |
534 | 135 if ('"$length"' <= '"$indent"' + 1 + length(files) + index(Log, "\r")) sep = "\n" indent_string |
527 | 136 |
137 # Print the label. | |
534 | 138 printf "%s*%s:", indent_string, files |
527 | 139 |
140 # Print each line of the log, transliterating \r to \n. | |
141 while ((i = index(Log, "\r")) != 0) { | |
142 printf "%s%s\n", sep, substr(Log, 1, i-1) | |
534 | 143 sep = indent_string |
527 | 144 Log = substr(Log, i+1) |
145 } | |
146 }' | |
147 | |
148 hostname=`( | |
149 hostname || cat /etc/whoami || uuname -l || uname -n | |
150 ) 2>/dev/null` || { | |
151 echo >&2 "$0: cannot deduce hostname" | |
152 exit 1 | |
153 } | |
154 | |
155 | |
156 # Process the rlog output, generating ChangeLog style entries. | |
157 | |
158 # First, reformat the rlog output so that each line contains one log entry. | |
159 # Transliterate \n to \r so that multiline entries fit on a single line. | |
160 # Discard irrelevant rlog output. | |
161 awk <$rlogout ' | |
162 /^Working file:/ { filename = $3 } | |
163 /^date: /, /^(-----------*|===========*)$/ { | |
164 if ($0 ~ /^branches: /) { next } | |
165 if ($0 ~ /^date: [0-9][ /0-9:]*;/) { | |
166 time = substr($3, 1, length($3)-1) | |
167 author = substr($5, 1, length($5)-1) | |
168 printf "%s %s %s %s \r", filename, $2, time, author | |
169 next | |
170 } | |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
171 if ($0 ~ /^(-----------*|===========*)$/) { print ""; next } |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
172 printf "%s\r", $0 |
527 | 173 } |
174 ' | | |
175 | |
176 # Now each line is of the form | |
177 # FILENAME YYYY/MM/DD HH:MM:SS AUTHOR \rLOG | |
178 # where \r stands for a carriage return, | |
179 # and each line of the log is terminated by \r instead of \n. | |
640
36e7f4e402bd
Call ypmatch at most once.
Paul Eggert <eggert@twinsun.com>
parents:
636
diff
changeset
|
180 # Sort the log entries, first by date+time (in reverse order), |
527 | 181 # then by author, then by log entry, and finally by file name (just in case). |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
182 sort +1 -3r +3 +0 | |
527 | 183 |
184 # Finally, reformat the sorted log entries. | |
185 awk ' | |
186 BEGIN { | |
187 | |
188 # Initialize the fullname associative array. | |
189 '"$initialize_fullname"' | |
190 | |
534 | 191 # Initialize indent string. |
192 indent_string = "" | |
193 i = '"$indent"' | |
194 if (0 < '"$tabwidth"') | |
195 for (; '"$tabwidth"' <= i; i -= '"$tabwidth"') | |
196 indent_string = indent_string "\t" | |
197 while (1 <= i--) | |
198 indent_string = indent_string " " | |
199 | |
527 | 200 # Set up date conversion tables. |
201 # RCS uses a nice, clean, sortable format, | |
202 # but ChangeLog wants the traditional, ugly ctime format. | |
203 | |
204 # January 1, 0 AD (Gregorian) was Saturday = 6 | |
205 EPOCH_WEEKDAY = 6 | |
206 # Of course, there was no 0 AD, but the algorithm works anyway. | |
207 | |
208 w[0]="Sun"; w[1]="Mon"; w[2]="Tue"; w[3]="Wed" | |
209 w[4]="Thu"; w[5]="Fri"; w[6]="Sat" | |
210 | |
211 m[0]="Jan"; m[1]="Feb"; m[2]="Mar" | |
212 m[3]="Apr"; m[4]="May"; m[5]="Jun" | |
213 m[6]="Jul"; m[7]="Aug"; m[8]="Sep" | |
214 m[9]="Oct"; m[10]="Nov"; m[11]="Dec" | |
215 | |
216 # days in non-leap year thus far, indexed by month (0-12) | |
217 mo[0]=0; mo[1]=31; mo[2]=59; mo[3]=90 | |
218 mo[4]=120; mo[5]=151; mo[6]=181; mo[7]=212 | |
219 mo[8]=243; mo[9]=273; mo[10]=304; mo[11]=334 | |
220 mo[12]=365 | |
221 } | |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
222 |
527 | 223 { |
224 newlog = substr($0, 1 + index($0, "\r")) | |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
225 |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
226 # Ignore log entries prefixed by "#". |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
227 if (newlog ~ /^#/) { next } |
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
228 |
527 | 229 if (Log != newlog || date != $2 || author != $4) { |
594 | 230 |
527 | 231 # The previous log and this log differ. |
594 | 232 |
233 # Print the old log. | |
527 | 234 if (date != "") '"$printlogline"' |
235 | |
594 | 236 # Logs that begin with "{clumpname} " should be grouped together, |
237 # and the clumpname should be removed. | |
238 # Extract the new clumpname from the log header, | |
239 # and use it to decide whether to output a blank line. | |
240 newclumpname = "" | |
241 sep = "\n" | |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
242 if (date == "") sep = "" |
636
dce8cdbac0ea
Ignore log messages that start with `#'.
Paul Eggert <eggert@twinsun.com>
parents:
602
diff
changeset
|
243 if (newlog ~ /^{[^ }]*}[ ]/) { |
594 | 244 i = index(newlog, "}") |
245 newclumpname = substr(newlog, 1, i) | |
246 while (substr(newlog, i+1) ~ /^[ ]/) i++ | |
247 newlog = substr(newlog, i+1) | |
248 if (clumpname == newclumpname) sep = "" | |
249 } | |
250 printf sep | |
251 clumpname = newclumpname | |
252 | |
527 | 253 # Get ready for the next log. |
254 Log = newlog | |
534 | 255 if (files != "") |
256 for (i in filesknown) | |
257 filesknown[i] = 0 | |
527 | 258 files = "" |
259 } | |
260 if (date != $2 || author != $4) { | |
261 # The previous date+author and this date+author differ. | |
262 # Print the new one. | |
263 date = $2 | |
264 author = $4 | |
265 | |
266 # Convert nice RCS date like "1992/01/03 00:03:44" | |
267 # into ugly ctime date like "Fri Jan 3 00:03:44 1992". | |
268 # Calculate day of week from Gregorian calendar. | |
269 i = index($2, "/") | |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
270 year = substr($2, 1, i-1) + 0 |
527 | 271 monthday = substr($2, i+1) |
272 i = index(monthday, "/") | |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
273 month = substr(monthday, 1, i-1) + 0 |
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
274 day = substr(monthday, i+1) + 0 |
527 | 275 leap = 0 |
602
d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
Paul Eggert <eggert@twinsun.com>
parents:
594
diff
changeset
|
276 if (2 < month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1 |
527 | 277 days_since_Sunday_before_epoch = EPOCH_WEEKDAY + year * 365 + int((year + 3) / 4) - int((year + 99) / 100) + int((year + 399) / 400) + mo[month-1] + leap + day - 1 |
278 | |
534 | 279 # Print "date fullname (email address)" if the fullname is known; |
280 # print "date author" otherwise. | |
527 | 281 # Get the fullname from the associative array. |
282 # The email address is just author@thishostname. | |
534 | 283 printf "%s %s %2d %s %d ", w[days_since_Sunday_before_epoch%7], m[month-1], day, $3, year |
284 if (fullname[author]) | |
285 printf "%s (%s@%s)\n\n", fullname[author], author, "'"$hostname"'" | |
286 else | |
287 printf "%s\n\n", author | |
527 | 288 } |
534 | 289 if (! filesknown[$1]) { |
290 filesknown[$1] = 1 | |
594 | 291 if (files == "") files = " " $1 |
292 else files = files ", " $1 | |
534 | 293 } |
527 | 294 } |
295 END { | |
296 # Print the last log. | |
594 | 297 if (date != "") { |
298 '"$printlogline"' | |
299 printf "\n" | |
300 } | |
527 | 301 } |
302 ' && | |
303 | |
304 | |
305 # Exit successfully. | |
306 | |
307 exec rm -f $rlogout |