aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorErik Naggum1996-08-24 21:11:14 +0000
committerErik Naggum1996-08-24 21:11:14 +0000
commit7b8b6c7ad97e193faad229a96a6ab06f7efb5ec2 (patch)
treedaf272052018367f2d65a977050dc98a38ba768c /lib-src
parent085e9fcbb4e7906f9f7e4c424850ea75e0c0ef87 (diff)
downloademacs-7b8b6c7ad97e193faad229a96a6ab06f7efb5ec2.tar.gz
emacs-7b8b6c7ad97e193faad229a96a6ab06f7efb5ec2.zip
Use ISO 8601 date format, with time zone appended if
change-log-time-zone-rule is non-nil, instead of traditional Unix date format. (datearg): When computing default from ChangeLog, handle ISO format dates in addition to old-fashioned dates from Emacs 19.31 and earlier. Don't worry about hh:mm:ss since the resolution is now by day. Use emtpy datearg, not empty rlog_options, to decide whether to pass "$datearg" option to $rlog. (logTZ): New variable, set to TZ specified by change-log-time-zone-rule. (month_data): Remove `mo'; no longer needed. (rlog_options): Use -zLT for localltime output, if `rlog' supports it. (extractTZ): Use UTC if the zone is t. Match `revision' line of rlog output more accurately. Add -c, -v options.
Diffstat (limited to 'lib-src')
-rwxr-xr-xlib-src/rcs2log181
1 files changed, 91 insertions, 90 deletions
diff --git a/lib-src/rcs2log b/lib-src/rcs2log
index dcc8f472030..e9474f65ade 100755
--- a/lib-src/rcs2log
+++ b/lib-src/rcs2log
@@ -12,7 +12,7 @@
12 12
13# Author: Paul Eggert <eggert@twinsun.com> 13# Author: Paul Eggert <eggert@twinsun.com>
14 14
15# $Id: rcs2log,v 1.27 1996/01/15 01:17:56 eggert Exp kwzh $ 15# $Id: rcs2log,v 1.28 1996/07/20 18:08:03 kwzh Exp erik $
16 16
17# Copyright 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. 17# Copyright 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
18 18
@@ -20,12 +20,12 @@
20# it under the terms of the GNU General Public License as published by 20# it under the terms of the GNU General Public License as published by
21# the Free Software Foundation; either version 2, or (at your option) 21# the Free Software Foundation; either version 2, or (at your option)
22# any later version. 22# any later version.
23# 23#
24# This program is distributed in the hope that it will be useful, 24# This program is distributed in the hope that it will be useful,
25# but WITHOUT ANY WARRANTY; without even the implied warranty of 25# but WITHOUT ANY WARRANTY; without even the implied warranty of
26# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27# GNU General Public License for more details. 27# GNU General Public License for more details.
28# 28#
29# You should have received a copy of the GNU General Public License 29# You should have received a copy of the GNU General Public License
30# along with GNU Emacs; see the file COPYING. If not, write to the 30# along with GNU Emacs; see the file COPYING. If not, write to the
31# Free Software Foundation, Inc., 59 Temple Place - Suite 330, 31# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
@@ -40,18 +40,23 @@ nl='
40# defaults 40# defaults
41: ${AWK=awk} 41: ${AWK=awk}
42: ${TMPDIR=/tmp} 42: ${TMPDIR=/tmp}
43changelog=ChangeLog # change log file name
44datearg= # rlog date option
43hostname= # name of local host (if empty, will deduce it later) 45hostname= # name of local host (if empty, will deduce it later)
44indent=8 # indent of log line 46indent=8 # indent of log line
45length=79 # suggested max width of log line 47length=79 # suggested max width of log line
46logins= # login names for people we know fullnames and mailaddrs of 48logins= # login names for people we know fullnames and mailaddrs of
47loginFullnameMailaddrs= # login<tab>fullname<tab>mailaddr triplets 49loginFullnameMailaddrs= # login<tab>fullname<tab>mailaddr triplets
50logTZ= # time zone for log dates (if empty, use local time)
48recursive= # t if we want recursive rlog 51recursive= # t if we want recursive rlog
52revision= # t if we want revision numbers
49rlog_options= # options to pass to rlog 53rlog_options= # options to pass to rlog
50tabwidth=8 # width of horizontal tab 54tabwidth=8 # width of horizontal tab
51 55
52while : 56while :
53do 57do
54 case $1 in 58 case $1 in
59 -c) changelog=${2?}; shift;;
55 -i) indent=${2?}; shift;; 60 -i) indent=${2?}; shift;;
56 -h) hostname=${2?}; shift;; 61 -h) hostname=${2?}; shift;;
57 -l) length=${2?}; shift;; 62 -l) length=${2?}; shift;;
@@ -93,10 +98,12 @@ do
93 -r) rlog_options=$rlog_options$nl${2?}; shift;; 98 -r) rlog_options=$rlog_options$nl${2?}; shift;;
94 -R) recursive=t;; 99 -R) recursive=t;;
95 -t) tabwidth=${2?}; shift;; 100 -t) tabwidth=${2?}; shift;;
101 -v) revision=t;;
96 -*) echo >&2 "$0: usage: $0 [options] [file ...] 102 -*) echo >&2 "$0: usage: $0 [options] [file ...]
97Options: 103Options:
98 [-h hostname] [-i indent] [-l length] [-R] [-r rlog_option] 104 [-c changelog] [-h hostname] [-i indent] [-l length] [-R]
99 [-t tabwidth] [-u 'login<TAB>fullname<TAB>mailaddr']..." 105 [-r rlog_option] [-t tabwidth] [-v]
106 [-u 'login<TAB>fullname<TAB>mailaddr']..."
100 exit 1;; 107 exit 1;;
101 *) break 108 *) break
102 esac 109 esac
@@ -108,12 +115,6 @@ month_data='
108 m[3]="Apr"; m[4]="May"; m[5]="Jun" 115 m[3]="Apr"; m[4]="May"; m[5]="Jun"
109 m[6]="Jul"; m[7]="Aug"; m[8]="Sep" 116 m[6]="Jul"; m[7]="Aug"; m[8]="Sep"
110 m[9]="Oct"; m[10]="Nov"; m[11]="Dec" 117 m[9]="Oct"; m[10]="Nov"; m[11]="Dec"
111
112 # days in non-leap year thus far, indexed by month (0-12)
113 mo[0]=0; mo[1]=31; mo[2]=59; mo[3]=90
114 mo[4]=120; mo[5]=151; mo[6]=181; mo[7]=212
115 mo[8]=243; mo[9]=273; mo[10]=304; mo[11]=334
116 mo[12]=365
117' 118'
118 119
119 120
@@ -121,50 +122,30 @@ month_data='
121 122
122# If no rlog options are given, 123# If no rlog options are given,
123# log the revisions checked in since the first ChangeLog entry. 124# log the revisions checked in since the first ChangeLog entry.
125# Since ChangeLog is only by date, some of these revisions may be duplicates of
126# what's already in ChangeLog; it's the user's responsibility to remove them.
124case $rlog_options in 127case $rlog_options in
125'') 128'')
126 date=1970 129 date=1970
127 if test -s ChangeLog 130 if test -s "$changelog"
128 then 131 then
129 # Add 1 to seconds to avoid duplicating most recent log.
130 e=' 132 e='
133 /^[0-9]+-[0-9][0-9]-[0-9][0-9]/{
134 # ISO 8601 date
135 print $1
136 exit
137 }
131 /^... ... [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]+ /{ 138 /^... ... [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]+ /{
139 # old-fashioned date and time (Emacs 19.31 and earlier)
132 '"$month_data"' 140 '"$month_data"'
133 year = $5 141 year = $5
134 for (i=0; i<=11; i++) if (m[i] == $2) break 142 for (i=0; i<=11; i++) if (m[i] == $2) break
135 dd = $3 143 dd = $3
136 hh = substr($0,12,2) 144 printf "%d-%02d-%02d\n", year, i+1, dd
137 mm = substr($0,15,2)
138 ss = substr($0,18,2)
139 ss++
140 if (ss == 60) {
141 ss = 0
142 mm++
143 if (mm == 60) {
144 mm = 0
145 hh++
146 if (hh == 24) {
147 hh = 0
148 dd++
149 monthdays = mo[i+1] - mo[i]
150 if (i == 1 && year%4 == 0 && (year%100 != 0 || year%400 == 0)) monthdays++
151 if (dd == monthdays + 1) {
152 dd = 1
153 i++
154 if (i == 12) {
155 i = 0
156 year++
157 }
158 }
159 }
160 }
161 }
162 # Output comma instead of space to avoid CVS 1.5 bug.
163 printf "%d/%02d/%02d,%02d:%02d:%02d\n", year,i+1,dd,hh,mm,ss
164 exit 145 exit
165 } 146 }
166 ' 147 '
167 d=`$AWK "$e" <ChangeLog` || exit 148 d=`$AWK "$e" <"$changelog"` || exit
168 case $d in 149 case $d in
169 ?*) date=$d 150 ?*) date=$d
170 esac 151 esac
@@ -172,6 +153,29 @@ case $rlog_options in
172 datearg="-d>$date" 153 datearg="-d>$date"
173esac 154esac
174 155
156# Use rlog's -zLT option, if rlog supports it.
157case `rlog -zLT 2>&1` in
158*'unknown option'*) ;;
159*) rlog_options=-zLT$nl$rlog_options
160esac
161
162# Use TZ specified by ChangeLog local variable, if any.
163if test -s "$changelog"
164then
165 extractTZ='
166 /^.*change-log-time-zone-rule['"$tab"' ]*:['"$tab"' ]*"\([^"]*\)".*/{
167 s//\1/; p; q
168 }
169 /^.*change-log-time-zone-rule['"$tab"' ]*:['"$tab"' ]*t.*/{
170 s//UTC0/; p; q
171 }
172 '
173 logTZ=`tail "$changelog" | sed -n "$extractTZ"`
174 case $logTZ in
175 ?*) TZ=$logTZ; export TZ
176 esac
177fi
178
175# If CVS is in use, examine its repository, not the normal RCS files. 179# If CVS is in use, examine its repository, not the normal RCS files.
176if test ! -f CVS/Repository 180if test ! -f CVS/Repository
177then 181then
@@ -245,9 +249,9 @@ rlogout=$TMPDIR/rcs2log$$r
245trap exit 1 2 13 15 249trap exit 1 2 13 15
246trap "rm -f $llogout $rlogout; exit 1" 0 250trap "rm -f $llogout $rlogout; exit 1" 0
247 251
248case $rlog_options in 252case $datearg in
249?*) $rlog $rlog_options ${1+"$@"} >$rlogout;; 253?*) $rlog $rlog_options "$datearg" ${1+"$@"} >$rlogout;;
250'') $rlog "$datearg" ${1+"$@"} >$rlogout 254'') $rlog $rlog_options ${1+"$@"} >$rlogout
251esac || exit 255esac || exit
252 256
253 257
@@ -413,6 +417,9 @@ printlogline='{
413 } 417 }
414}' 418}'
415 419
420# Pattern to match the `revision' line of rlog output.
421rlog_revision_pattern='^revision [0-9]+\.[0-9]+(\.[0-9]+\.[0-9]+)*(['"$tab"' ]+locked by: [^'"$tab"' $,.0-9:;@]*[^'"$tab"' $,:;@][^'"$tab"' $,.0-9:;@]*;)?['"$tab"' ]*$'
422
416case $hostname in 423case $hostname in
417'') 424'')
418 hostname=`( 425 hostname=`(
@@ -450,43 +457,53 @@ $AWK <$rlogout '
450 filename = substr(filename, 1, length(filename) - 2) 457 filename = substr(filename, 1, length(filename) - 2)
451 } 458 }
452 } 459 }
460 rev = "?"
453 } 461 }
454 /^Working file:/ { if (repository == "") filename = $3 } 462 /^Working file:/ { if (repository == "") filename = $3 }
455 /^date: /, /^(-----------*|===========*)$/ { 463 /'"$rlog_revision_pattern"'/, /^(-----------*|===========*)$/ {
456 if ($0 ~ /^branches: /) { next } 464 if ($0 ~ /'"$rlog_revision_pattern"'/) {
465 rev = $2
466 next
467 }
457 if ($0 ~ /^date: [0-9][- +\/0-9:]*;/) { 468 if ($0 ~ /^date: [0-9][- +\/0-9:]*;/) {
458 date = $2 469 date = $2
459 if (date ~ /-/) { 470 if (date ~ /\//) {
460 # An ISO format date. Replace all "-"s with "/"s. 471 # This is a traditional RCS format date YYYY/MM/DD.
472 # Replace "/"s with "-"s to get ISO format.
461 newdate = "" 473 newdate = ""
462 while ((i = index(date, "-")) != 0) { 474 while ((i = index(date, "/")) != 0) {
463 newdate = newdate substr(date, 1, i-1) "/" 475 newdate = newdate substr(date, 1, i-1) "-"
464 date = substr(date, i+1) 476 date = substr(date, i+1)
465 } 477 }
466 date = newdate date 478 date = newdate date
467 } 479 }
468 # Ignore any time zone; ChangeLog has no room for it. 480 time = substr($3, 1, length($3) - 1)
469 time = substr($3, 1, 8)
470 author = substr($5, 1, length($5)-1) 481 author = substr($5, 1, length($5)-1)
471 printf "%s %s %s %s %c", filename, date, time, author, 13 482 printf "%s %s %s %s %s %c", filename, rev, date, time, author, 13
483 rev = "?"
472 next 484 next
473 } 485 }
486 if ($0 ~ /^branches: /) { next }
474 if ($0 ~ /^(-----------*|===========*)$/) { print ""; next } 487 if ($0 ~ /^(-----------*|===========*)$/) { print ""; next }
475 printf "%s%c", $0, 13 488 printf "%s%c", $0, 13
476 } 489 }
477' | 490' |
478 491
479# Now each line is of the form 492# Now each line is of the form
480# FILENAME YYYY/MM/DD HH:MM:SS AUTHOR \rLOG 493# FILENAME REVISION YYYY-MM-DD HH:MM:SS[+-TIMEZONE] AUTHOR \rLOG
481# where \r stands for a carriage return, 494# where \r stands for a carriage return,
482# and each line of the log is terminated by \r instead of \n. 495# and each line of the log is terminated by \r instead of \n.
483# Sort the log entries, first by date+time (in reverse order), 496# Sort the log entries, first by date+time (in reverse order),
484# then by author, then by log entry, and finally by file name (just in case). 497# then by author, then by log entry, and finally by file name and revision
485sort +1 -3r +3 +0 | 498# (just in case).
499sort +2 -4r +4 +0 |
486 500
487# Finally, reformat the sorted log entries. 501# Finally, reformat the sorted log entries.
488$AWK ' 502$AWK '
489 BEGIN { 503 BEGIN {
504 logTZ = "'"$logTZ"'"
505 revision = "'"$revision"'"
506
490 # Some awk variants do not understand "\r" or "\013", so we have to 507 # Some awk variants do not understand "\r" or "\013", so we have to
491 # put a carriage return directly in the file. 508 # put a carriage return directly in the file.
492 CR=" " # <-- There is a single CR between the " chars here. 509 CR=" " # <-- There is a single CR between the " chars here.
@@ -503,19 +520,6 @@ $AWK '
503 indent_string = indent_string "\t" 520 indent_string = indent_string "\t"
504 while (1 <= i--) 521 while (1 <= i--)
505 indent_string = indent_string " " 522 indent_string = indent_string " "
506
507 # Set up date conversion tables.
508 # RCS uses a nice, clean, sortable format,
509 # but ChangeLog wants the traditional, ugly ctime format.
510
511 # January 1, 0 AD (Gregorian) was Saturday = 6
512 EPOCH_WEEKDAY = 6
513 # Of course, there was no 0 AD, but the algorithm works anyway.
514
515 w[0]="Sun"; w[1]="Mon"; w[2]="Tue"; w[3]="Wed"
516 w[4]="Thu"; w[5]="Fri"; w[6]="Sat"
517
518 '"$month_data"'
519 } 523 }
520 524
521 { 525 {
@@ -524,7 +528,7 @@ $AWK '
524 # Ignore log entries prefixed by "#". 528 # Ignore log entries prefixed by "#".
525 if (newlog ~ /^#/) { next } 529 if (newlog ~ /^#/) { next }
526 530
527 if (Log != newlog || date != $2 || author != $4) { 531 if (Log != newlog || date != $3 || author != $5) {
528 532
529 # The previous log and this log differ. 533 # The previous log and this log differ.
530 534
@@ -555,33 +559,25 @@ $AWK '
555 filesknown[i] = 0 559 filesknown[i] = 0
556 files = "" 560 files = ""
557 } 561 }
558 if (date != $2 || author != $4) { 562 if (date != $3 || author != $5) {
559 # The previous date+author and this date+author differ. 563 # The previous date+author and this date+author differ.
560 # Print the new one. 564 # Print the new one.
561 date = $2 565 date = $3
562 author = $4 566 time = $4
563 567 author = $5
564 # Convert nice RCS date like "1992/01/03 00:03:44" 568
565 # into ugly ctime date like "Fri Jan 3 00:03:44 1992". 569 zone = ""
566 # Calculate day of week from Gregorian calendar. 570 if (logTZ && ((i = index(time, "-")) || (i = index(time, "+"))))
567 i = index($2, "/") 571 zone = " " substr(time, i)
568 year = substr($2, 1, i-1) + 0 572
569 monthday = substr($2, i+1) 573 # Print "date[ timezone] fullname <email address>".
570 i = index(monthday, "/")
571 month = substr(monthday, 1, i-1) + 0
572 day = substr(monthday, i+1) + 0
573 leap = 0
574 if (2 < month && year%4 == 0 && (year%100 != 0 || year%400 == 0)) leap = 1
575 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
576
577 # Print "date fullname (email address)".
578 # Get fullname and email address from associative arrays; 574 # Get fullname and email address from associative arrays;
579 # default to author and author@hostname if not in arrays. 575 # default to author and author@hostname if not in arrays.
580 if (fullname[author]) 576 if (fullname[author])
581 auth = fullname[author] 577 auth = fullname[author]
582 else 578 else
583 auth = author 579 auth = author
584 printf "%s %s %2d %s %d %s ", w[days_since_Sunday_before_epoch%7], m[month-1], day, $3, year, auth 580 printf "%s%s %s ", date, zone, auth
585 if (mailaddr[author]) 581 if (mailaddr[author])
586 printf "<%s>\n\n", mailaddr[author] 582 printf "<%s>\n\n", mailaddr[author]
587 else 583 else
@@ -591,6 +587,7 @@ $AWK '
591 filesknown[$1] = 1 587 filesknown[$1] = 1
592 if (files == "") files = " " $1 588 if (files == "") files = " " $1
593 else files = files ", " $1 589 else files = files ", " $1
590 if (revision && $2 != "?") files = files " " $2
594 } 591 }
595 } 592 }
596 END { 593 END {
@@ -606,3 +603,7 @@ $AWK '
606# Exit successfully. 603# Exit successfully.
607 604
608exec rm -f $llogout $rlogout 605exec rm -f $llogout $rlogout
606
607# Local Variables:
608# tab-width:4
609# End: