Mercurial > emacs
comparison lib-src/rcs2log @ 602:d2de231ee7f5
Don't duplicate most recent logs. Fix bug in dates after Feb 29 in leap year.
author | Paul Eggert <eggert@twinsun.com> |
---|---|
date | Wed, 01 Apr 1992 08:57:55 +0000 |
parents | efa0c124c178 |
children | dce8cdbac0ea |
comparison
equal
deleted
inserted
replaced
601:3db1540d4b97 | 602:d2de231ee7f5 |
---|---|
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 # RCS to ChangeLog generator | 3 # RCS to ChangeLog generator |
4 | 4 |
5 # $Id: rcs2clog,v 1.3 1992/02/05 17:25:10 eggert Exp eggert $ | 5 # $Id: rcs2log,v 1.4 1992/03/21 05:58:05 eggert Exp eggert $ |
6 | 6 |
7 # Generate a change log prefix from RCS/* and the existing ChangeLog (if any). | 7 # Generate a change log prefix from RCS/* and the existing ChangeLog (if any). |
8 # Output the new prefix to standard output. | 8 # Output the new prefix to standard output. |
9 # You can edit this prefix by hand, and then prepend it to ChangeLog. | 9 # You can edit this prefix by hand, and then prepend it to ChangeLog. |
10 | 10 |
30 done | 30 done |
31 | 31 |
32 | 32 |
33 # Log into $rlogout the revisions checked in since the first ChangeLog entry. | 33 # Log into $rlogout the revisions checked in since the first ChangeLog entry. |
34 | 34 |
35 datearg=-d'>1970' | 35 date=1970 |
36 if test -s ChangeLog | 36 if test -s ChangeLog |
37 then | 37 then |
38 e='s/^\(...\) \(...\) \(..\) \(..:..:..\) \(....\) .*/\1 \2 \3 \4 \5/p; 1q' | 38 # Add 1 to seconds to avoid duplicating most recent log. |
39 date=`sed -n "$e" <ChangeLog` || exit | 39 # It's a good thing `rlog' doesn't mind a time ending in `:60'. |
40 case $date in | 40 e=' |
41 ?*) datearg="-d>$date" | 41 /^... ... [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]+ /{ |
42 printf "%s%.2d %s\n", substr($0,1,17), substr($0,18,2)+1, $5 | |
43 exit | |
44 } | |
45 ' | |
46 d=`awk "$e" <ChangeLog` || exit | |
47 case $d in | |
48 ?*) date=$d | |
42 esac | 49 esac |
43 fi | 50 fi |
51 datearg="-d>$date" | |
44 | 52 |
45 rlogout=/tmp/chg$$ | 53 rlogout=/tmp/chg$$ |
46 trap exit 1 2 13 15 | 54 trap exit 1 2 13 15 |
47 trap 'rm -f $rlogout; exit 1' 0 | 55 trap 'rm -f $rlogout; exit 1' 0 |
48 | 56 |
151 # FILENAME YYYY/MM/DD HH:MM:SS AUTHOR \rLOG | 159 # FILENAME YYYY/MM/DD HH:MM:SS AUTHOR \rLOG |
152 # where \r stands for a carriage return, | 160 # where \r stands for a carriage return, |
153 # and each line of the log is terminated by \r instead of \n. | 161 # and each line of the log is terminated by \r instead of \n. |
154 # Sort the log entries, first by date (in reverse order), | 162 # Sort the log entries, first by date (in reverse order), |
155 # then by author, then by log entry, and finally by file name (just in case). | 163 # then by author, then by log entry, and finally by file name (just in case). |
156 sort +1 -2r +3 +0 | | 164 sort +1 -3r +3 +0 | |
157 | 165 |
158 # Finally, reformat the sorted log entries. | 166 # Finally, reformat the sorted log entries. |
159 awk ' | 167 awk ' |
160 BEGIN { | 168 BEGIN { |
161 | 169 |
206 # and the clumpname should be removed. | 214 # and the clumpname should be removed. |
207 # Extract the new clumpname from the log header, | 215 # Extract the new clumpname from the log header, |
208 # and use it to decide whether to output a blank line. | 216 # and use it to decide whether to output a blank line. |
209 newclumpname = "" | 217 newclumpname = "" |
210 sep = "\n" | 218 sep = "\n" |
219 if (date == "") sep = "" | |
211 if (newlog ~ /^{[^ }]+}[ ]/) { | 220 if (newlog ~ /^{[^ }]+}[ ]/) { |
212 i = index(newlog, "}") | 221 i = index(newlog, "}") |
213 newclumpname = substr(newlog, 1, i) | 222 newclumpname = substr(newlog, 1, i) |
214 while (substr(newlog, i+1) ~ /^[ ]/) i++ | 223 while (substr(newlog, i+1) ~ /^[ ]/) i++ |
215 newlog = substr(newlog, i+1) | 224 newlog = substr(newlog, i+1) |
233 | 242 |
234 # Convert nice RCS date like "1992/01/03 00:03:44" | 243 # Convert nice RCS date like "1992/01/03 00:03:44" |
235 # into ugly ctime date like "Fri Jan 3 00:03:44 1992". | 244 # into ugly ctime date like "Fri Jan 3 00:03:44 1992". |
236 # Calculate day of week from Gregorian calendar. | 245 # Calculate day of week from Gregorian calendar. |
237 i = index($2, "/") | 246 i = index($2, "/") |
238 year = substr($2, 1, i-1) | 247 year = substr($2, 1, i-1) + 0 |
239 monthday = substr($2, i+1) | 248 monthday = substr($2, i+1) |
240 i = index(monthday, "/") | 249 i = index(monthday, "/") |
241 month = substr(monthday, 1, i-1) | 250 month = substr(monthday, 1, i-1) + 0 |
242 day = substr(monthday, i+1) | 251 day = substr(monthday, i+1) + 0 |
243 leap = 0 | 252 leap = 0 |
244 if (2 <= month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1 | 253 if (2 < month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1 |
245 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 | 254 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 |
246 | 255 |
247 # Print "date fullname (email address)" if the fullname is known; | 256 # Print "date fullname (email address)" if the fullname is known; |
248 # print "date author" otherwise. | 257 # print "date author" otherwise. |
249 # Get the fullname from the associative array. | 258 # Get the fullname from the associative array. |