Commit | Line | Data |
---|---|---|
daecaf5d GM |
1 | #! /bin/sh |
2 | ||
3 | # RCS to ChangeLog generator | |
4 | ||
5 | # Generate a change log prefix from RCS files (perhaps in the CVS repository) | |
6 | # and the ChangeLog (if any). | |
7 | # Output the new prefix to standard output. | |
8 | # You can edit this prefix by hand, and then prepend it to ChangeLog. | |
9 | ||
10 | # Ignore log entries that start with `#'. | |
11 | # Clump together log entries that start with `{topic} ', | |
12 | # where `topic' contains neither white space nor `}'. | |
13 | ||
14 | Help='The default FILEs are the files registered under the working directory. | |
15 | Options: | |
16 | ||
17 | -c CHANGELOG Output a change log prefix to CHANGELOG (default ChangeLog). | |
18 | -h HOSTNAME Use HOSTNAME in change log entries (default current host). | |
19 | -i INDENT Indent change log lines by INDENT spaces (default 8). | |
20 | -l LENGTH Try to limit log lines to LENGTH characters (default 79). | |
1bd57c39 | 21 | -L FILE Use rlog-format FILE for source of logs. |
daecaf5d GM |
22 | -R If no FILEs are given and RCS is used, recurse through working directory. |
23 | -r OPTION Pass OPTION to subsidiary log command. | |
24 | -t TABWIDTH Tab stops are every TABWIDTH characters (default 8). | |
25 | -u "LOGIN<tab>FULLNAME<tab>MAILADDR" Assume LOGIN has FULLNAME and MAILADDR. | |
26 | -v Append RCS revision to file names in log lines. | |
27 | --help Output help. | |
28 | --version Output version number. | |
29 | ||
30 | Report bugs to <bug-gnu-emacs@gnu.org>.' | |
31 | ||
1bd57c39 | 32 | Id='$Id: rcs2log,v 1.47 2001/07/20 09:05:26 gerd Exp eggert $' |
daecaf5d | 33 | |
1bd57c39 | 34 | # Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2001 |
daecaf5d GM |
35 | # Free Software Foundation, Inc. |
36 | ||
37 | # This program is free software; you can redistribute it and/or modify | |
38 | # it under the terms of the GNU General Public License as published by | |
39 | # the Free Software Foundation; either version 2, or (at your option) | |
40 | # any later version. | |
41 | # | |
42 | # This program is distributed in the hope that it will be useful, | |
43 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
44 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
45 | # GNU General Public License for more details. | |
46 | # | |
47 | # You should have received a copy of the GNU General Public License | |
48 | # along with this program; see the file COPYING. If not, write to the | |
49 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
50 | # Boston, MA 02111-1307, USA. | |
51 | ||
1bd57c39 | 52 | Copyright='Copyright 2001 Free Software Foundation, Inc. |
daecaf5d GM |
53 | This program comes with NO WARRANTY, to the extent permitted by law. |
54 | You may redistribute copies of this program | |
55 | under the terms of the GNU General Public License. | |
56 | For more information about these matters, see the files named COPYING. | |
57 | Author: Paul Eggert <eggert@twinsun.com>' | |
58 | ||
1bd57c39 PE |
59 | # Use the traditional C locale. |
60 | LANG=C | |
61 | LANGUAGE=C | |
62 | LC_ALL=C | |
63 | LC_COLLATE=C | |
64 | LC_CTYPE=C | |
65 | LC_MESSAGES=C | |
66 | LC_NUMERIC=C | |
67 | LC_TIME=C | |
68 | export LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_NUMERIC LC_TIME | |
69 | ||
70 | # These variables each contain a single ASCII character. | |
71 | # Unfortunately, there's no portable way of writing these characters | |
72 | # in older Unix implementations, other than putting them directly into | |
73 | # this text file. | |
74 | SOH='\ 1' # SOH, octal code 001 | |
daecaf5d GM |
75 | tab=' ' |
76 | nl=' | |
77 | ' | |
78 | ||
79 | # Parse options. | |
80 | ||
81 | # defaults | |
82 | : ${AWK=awk} | |
83 | : ${TMPDIR=/tmp} | |
84 | changelog=ChangeLog # change log file name | |
85 | datearg= # rlog date option | |
86 | hostname= # name of local host (if empty, will deduce it later) | |
87 | indent=8 # indent of log line | |
88 | length=79 # suggested max width of log line | |
89 | logins= # login names for people we know fullnames and mailaddrs of | |
90 | loginFullnameMailaddrs= # login<tab>fullname<tab>mailaddr triplets | |
91 | logTZ= # time zone for log dates (if empty, use local time) | |
92 | recursive= # t if we want recursive rlog | |
93 | revision= # t if we want revision numbers | |
94 | rlog_options= # options to pass to rlog | |
1bd57c39 | 95 | rlogfile= # log file to read from |
daecaf5d GM |
96 | tabwidth=8 # width of horizontal tab |
97 | ||
98 | while : | |
99 | do | |
100 | case $1 in | |
101 | -c) changelog=${2?}; shift;; | |
102 | -i) indent=${2?}; shift;; | |
103 | -h) hostname=${2?}; shift;; | |
104 | -l) length=${2?}; shift;; | |
1bd57c39 | 105 | -L) rlogfile=${2?}; shift;; |
daecaf5d GM |
106 | -[nu]) # -n is obsolescent; it is replaced by -u. |
107 | case $1 in | |
108 | -n) case ${2?}${3?}${4?} in | |
109 | *"$tab"* | *"$nl"*) | |
110 | echo >&2 "$0: -n '$2' '$3' '$4': tabs, newlines not allowed" | |
1bd57c39 | 111 | exit 1;; |
daecaf5d | 112 | esac |
1bd57c39 PE |
113 | login=$2 |
114 | lfm=$2$tab$3$tab$4 | |
daecaf5d GM |
115 | shift; shift; shift;; |
116 | -u) | |
117 | # If $2 is not tab-separated, use colon for separator. | |
118 | case ${2?} in | |
119 | *"$nl"*) | |
120 | echo >&2 "$0: -u '$2': newlines not allowed" | |
121 | exit 1;; | |
122 | *"$tab"*) | |
123 | t=$tab;; | |
124 | *) | |
1bd57c39 | 125 | t=':';; |
daecaf5d GM |
126 | esac |
127 | case $2 in | |
128 | *"$t"*"$t"*"$t"*) | |
129 | echo >&2 "$0: -u '$2': too many fields" | |
130 | exit 1;; | |
131 | *"$t"*"$t"*) | |
1bd57c39 PE |
132 | uf="[^$t]*$t" # An unselected field, followed by a separator. |
133 | sf="\\([^$t]*\\)" # The selected field. | |
134 | login=`expr "X$2" : "X$sf"` | |
135 | lfm="$login$tab"` | |
136 | expr "X$2" : "$uf$sf" | |
137 | `"$tab"` | |
138 | expr "X$2" : "$uf$uf$sf" | |
139 | `;; | |
daecaf5d GM |
140 | *) |
141 | echo >&2 "$0: -u '$2': not enough fields" | |
1bd57c39 | 142 | exit 1;; |
daecaf5d | 143 | esac |
1bd57c39 | 144 | shift;; |
daecaf5d GM |
145 | esac |
146 | case $logins in | |
147 | '') logins=$login;; | |
1bd57c39 | 148 | ?*) logins=$logins$nl$login;; |
daecaf5d | 149 | esac |
1bd57c39 PE |
150 | case $loginFullnameMailaddrs in |
151 | '') loginFullnameMailaddrs=$lfm;; | |
152 | ?*) loginFullnameMailaddrs=$loginFullnameMailaddrs$nl$lfm;; | |
153 | esac;; | |
daecaf5d GM |
154 | -r) |
155 | case $rlog_options in | |
156 | '') rlog_options=${2?};; | |
1bd57c39 | 157 | ?*) rlog_options=$rlog_options$nl${2?};; |
daecaf5d GM |
158 | esac |
159 | shift;; | |
160 | -R) recursive=t;; | |
161 | -t) tabwidth=${2?}; shift;; | |
162 | -v) revision=t;; | |
163 | --version) | |
164 | set $Id | |
165 | rcs2logVersion=$3 | |
166 | echo >&2 "rcs2log (GNU Emacs) $rcs2logVersion$nl$Copyright" | |
167 | exit 0;; | |
168 | -*) echo >&2 "Usage: $0 [OPTION]... [FILE ...]$nl$Help" | |
169 | case $1 in | |
170 | --help) exit 0;; | |
1bd57c39 | 171 | *) exit 1;; |
daecaf5d | 172 | esac;; |
1bd57c39 | 173 | *) break;; |
daecaf5d GM |
174 | esac |
175 | shift | |
176 | done | |
177 | ||
178 | month_data=' | |
179 | m[0]="Jan"; m[1]="Feb"; m[2]="Mar" | |
180 | m[3]="Apr"; m[4]="May"; m[5]="Jun" | |
181 | m[6]="Jul"; m[7]="Aug"; m[8]="Sep" | |
182 | m[9]="Oct"; m[10]="Nov"; m[11]="Dec" | |
183 | ' | |
184 | ||
1bd57c39 PE |
185 | logdir=$TMPDIR/rcs2log$$ |
186 | llogout=$logdir/l | |
187 | trap exit 1 2 13 15 | |
188 | trap "rm -fr $logdir 2>/dev/null" 0 | |
189 | (umask 077 && exec mkdir $logdir) || exit | |
daecaf5d | 190 | |
1bd57c39 PE |
191 | # If no rlog-format log file is given, generate one into $rlogfile. |
192 | case $rlogfile in | |
daecaf5d | 193 | '') |
1bd57c39 PE |
194 | rlogfile=$logdir/r |
195 | ||
196 | # If no rlog options are given, | |
197 | # log the revisions checked in since the first ChangeLog entry. | |
198 | # Since ChangeLog is only by date, some of these revisions may be duplicates of | |
199 | # what's already in ChangeLog; it's the user's responsibility to remove them. | |
200 | case $rlog_options in | |
201 | '') | |
202 | if test -s "$changelog" | |
203 | then | |
204 | e=' | |
205 | /^[0-9]+-[0-9][0-9]-[0-9][0-9]/{ | |
206 | # ISO 8601 date | |
207 | print $1 | |
208 | exit | |
209 | } | |
210 | /^... ... [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]+ /{ | |
211 | # old-fashioned date and time (Emacs 19.31 and earlier) | |
212 | '"$month_data"' | |
213 | year = $5 | |
214 | for (i=0; i<=11; i++) if (m[i] == $2) break | |
215 | dd = $3 | |
216 | printf "%d-%02d-%02d\n", year, i+1, dd | |
217 | exit | |
218 | } | |
219 | ' | |
220 | d=`$AWK "$e" <"$changelog"` || exit | |
221 | case $d in | |
222 | ?*) datearg="-d>$d";; | |
223 | esac | |
224 | fi;; | |
225 | esac | |
226 | ||
227 | # Use TZ specified by ChangeLog local variable, if any. | |
daecaf5d GM |
228 | if test -s "$changelog" |
229 | then | |
1bd57c39 PE |
230 | extractTZ=' |
231 | /^.*change-log-time-zone-rule['"$tab"' ]*:['"$tab"' ]*"\([^"]*\)".*/{ | |
232 | s//\1/; p; q | |
daecaf5d | 233 | } |
1bd57c39 PE |
234 | /^.*change-log-time-zone-rule['"$tab"' ]*:['"$tab"' ]*t.*/{ |
235 | s//UTC0/; p; q | |
daecaf5d GM |
236 | } |
237 | ' | |
1bd57c39 PE |
238 | logTZ=`tail "$changelog" | sed -n "$extractTZ"` |
239 | case $logTZ in | |
240 | ?*) TZ=$logTZ; export TZ;; | |
daecaf5d GM |
241 | esac |
242 | fi | |
daecaf5d | 243 | |
1bd57c39 PE |
244 | # If CVS is in use, examine its repository, not the normal RCS files. |
245 | if test ! -f CVS/Repository | |
246 | then | |
247 | rlog=rlog | |
248 | repository= | |
249 | else | |
250 | rlog='cvs -q log' | |
251 | repository=`sed 1q <CVS/Repository` || exit | |
252 | test ! -f CVS/Root || CVSROOT=`cat <CVS/Root` || exit | |
253 | case $CVSROOT in | |
254 | *:/*:/*) | |
255 | echo >&2 "$0: $CVSROOT: CVSROOT has multiple ':/'s" | |
256 | exit 1;; | |
257 | *:/*) | |
258 | # remote repository | |
259 | pository=`expr "X$repository" : '.*:\(/.*\)'`;; | |
260 | *) | |
261 | # local repository | |
262 | case $repository in | |
263 | /*) ;; | |
264 | *) repository=${CVSROOT?}/$repository;; | |
265 | esac | |
266 | if test ! -d "$repository" | |
267 | then | |
268 | echo >&2 "$0: $repository: bad repository (see CVS/Repository)" | |
269 | exit 1 | |
270 | fi | |
271 | pository=$repository;; | |
daecaf5d | 272 | esac |
daecaf5d | 273 | |
1bd57c39 PE |
274 | # Ensure that $pository ends in exactly one slash. |
275 | while : | |
276 | do | |
277 | case $pository in | |
278 | *//) pository=`expr "X$pository" : 'X\(.*\)/'`;; | |
279 | */) break;; | |
280 | *) pository=$pository/; break;; | |
281 | esac | |
282 | done | |
283 | ||
284 | fi | |
285 | ||
286 | # Use $rlog's -zLT option, if $rlog supports it. | |
287 | case `$rlog -zLT 2>&1` in | |
288 | *' option'*) ;; | |
289 | *) | |
290 | case $rlog_options in | |
291 | '') rlog_options=-zLT;; | |
292 | ?*) rlog_options=-zLT$nl$rlog_options;; | |
293 | esac;; | |
daecaf5d | 294 | esac |
daecaf5d | 295 | |
1bd57c39 PE |
296 | # With no arguments, examine all files under the RCS directory. |
297 | case $# in | |
298 | 0) | |
299 | case $repository in | |
300 | '') | |
301 | oldIFS=$IFS | |
302 | IFS=$nl | |
303 | case $recursive in | |
304 | t) | |
305 | RCSdirs=`find . -name RCS -type d -print` | |
306 | filesFromRCSfiles='s|,v$||; s|/RCS/|/|; s|^\./||' | |
307 | files=` | |
308 | { | |
309 | case $RCSdirs in | |
310 | ?*) find $RCSdirs \ | |
311 | -type f \ | |
312 | ! -name '*_' \ | |
313 | ! -name ',*,' \ | |
314 | ! -name '.*_' \ | |
315 | ! -name .rcsfreeze.log \ | |
316 | ! -name .rcsfreeze.ver \ | |
317 | -print;; | |
318 | esac | |
319 | find . -name '*,v' -print | |
320 | } | | |
321 | sort -u | | |
322 | sed "$filesFromRCSfiles" | |
323 | `;; | |
324 | *) | |
325 | files= | |
326 | for file in RCS/.* RCS/* .*,v *,v | |
327 | do | |
328 | case $file in | |
329 | RCS/. | RCS/.. | RCS/,*, | RCS/*_) continue;; | |
330 | RCS/.rcsfreeze.log | RCS/.rcsfreeze.ver) continue;; | |
331 | RCS/.\* | RCS/\* | .\*,v | \*,v) test -f "$file" || continue;; | |
332 | RCS/*,v | RCS/.*,v) ;; | |
333 | RCS/* | RCS/.*) test -f "$file" || continue;; | |
daecaf5d | 334 | esac |
1bd57c39 PE |
335 | case $files in |
336 | '') files=$file;; | |
337 | ?*) files=$files$nl$file;; | |
338 | esac | |
339 | done | |
daecaf5d | 340 | case $files in |
1bd57c39 PE |
341 | '') exit 0;; |
342 | esac;; | |
daecaf5d | 343 | esac |
1bd57c39 PE |
344 | set x $files |
345 | shift | |
346 | IFS=$oldIFS;; | |
347 | esac;; | |
daecaf5d | 348 | esac |
daecaf5d | 349 | |
1bd57c39 PE |
350 | case $datearg in |
351 | ?*) $rlog $rlog_options "$datearg" ${1+"$@"} >$rlogfile;; | |
352 | '') $rlog $rlog_options ${1+"$@"} >$rlogfile;; | |
353 | esac || exit;; | |
354 | esac | |
daecaf5d GM |
355 | |
356 | ||
357 | # Get the full name of each author the logs mention, and set initialize_fullname | |
358 | # to awk code that initializes the `fullname' awk associative array. | |
359 | # Warning: foreign authors (i.e. not known in the passwd file) are mishandled; | |
360 | # you have to fix the resulting output by hand. | |
361 | ||
362 | initialize_fullname= | |
363 | initialize_mailaddr= | |
364 | ||
365 | case $loginFullnameMailaddrs in | |
366 | ?*) | |
367 | case $loginFullnameMailaddrs in | |
368 | *\"* | *\\*) | |
369 | sed 's/["\\]/\\&/g' >$llogout <<EOF || exit | |
370 | $loginFullnameMailaddrs | |
371 | EOF | |
1bd57c39 | 372 | loginFullnameMailaddrs=`cat $llogout`;; |
daecaf5d GM |
373 | esac |
374 | ||
375 | oldIFS=$IFS | |
376 | IFS=$nl | |
377 | for loginFullnameMailaddr in $loginFullnameMailaddrs | |
378 | do | |
1bd57c39 | 379 | IFS=$tab |
daecaf5d GM |
380 | set x $loginFullnameMailaddr |
381 | login=$2 | |
382 | fullname=$3 | |
383 | mailaddr=$4 | |
384 | initialize_fullname="$initialize_fullname | |
385 | fullname[\"$login\"] = \"$fullname\"" | |
386 | initialize_mailaddr="$initialize_mailaddr | |
387 | mailaddr[\"$login\"] = \"$mailaddr\"" | |
388 | done | |
1bd57c39 | 389 | IFS=$oldIFS;; |
daecaf5d GM |
390 | esac |
391 | ||
1bd57c39 PE |
392 | case $logins in |
393 | ?*) | |
394 | sort -u -o $llogout <<EOF | |
daecaf5d GM |
395 | $logins |
396 | EOF | |
1bd57c39 PE |
397 | ;; |
398 | '') | |
399 | : ;; | |
400 | esac >$llogout || exit | |
401 | ||
daecaf5d GM |
402 | output_authors='/^date: / { |
403 | if ($2 ~ /^[0-9]*[-\/][0-9][0-9][-\/][0-9][0-9]$/ && $3 ~ /^[0-9][0-9]:[0-9][0-9]:[0-9][0-9][-+0-9:]*;$/ && $4 == "author:" && $5 ~ /^[^;]*;$/) { | |
404 | print substr($5, 1, length($5)-1) | |
405 | } | |
406 | }' | |
407 | authors=` | |
1bd57c39 | 408 | $AWK "$output_authors" <"$rlogfile" | sort -u | comm -23 - $llogout |
daecaf5d GM |
409 | ` |
410 | case $authors in | |
411 | ?*) | |
412 | cat >$llogout <<EOF || exit | |
413 | $authors | |
414 | EOF | |
415 | initialize_author_script='s/["\\]/\\&/g; s/.*/author[\"&\"] = 1/' | |
416 | initialize_author=`sed -e "$initialize_author_script" <$llogout` | |
417 | awkscript=' | |
418 | BEGIN { | |
419 | alphabet = "abcdefghijklmnopqrstuvwxyz" | |
420 | ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
421 | '"$initialize_author"' | |
422 | } | |
423 | { | |
424 | if (author[$1]) { | |
425 | fullname = $5 | |
426 | if (fullname ~ /[0-9]+-[^(]*\([0-9]+\)$/) { | |
427 | # Remove the junk from fullnames like "0000-Admin(0000)". | |
428 | fullname = substr(fullname, index(fullname, "-") + 1) | |
429 | fullname = substr(fullname, 1, index(fullname, "(") - 1) | |
430 | } | |
431 | if (fullname ~ /,[^ ]/) { | |
432 | # Some sites put comma-separated junk after the fullname. | |
433 | # Remove it, but leave "Bill Gates, Jr" alone. | |
434 | fullname = substr(fullname, 1, index(fullname, ",") - 1) | |
435 | } | |
436 | abbr = index(fullname, "&") | |
437 | if (abbr) { | |
438 | a = substr($1, 1, 1) | |
439 | A = a | |
440 | i = index(alphabet, a) | |
441 | if (i) A = substr(ALPHABET, i, 1) | |
442 | fullname = substr(fullname, 1, abbr-1) A substr($1, 2) substr(fullname, abbr+1) | |
443 | } | |
444 | ||
445 | # Quote quotes and backslashes properly in full names. | |
446 | # Do not use gsub; traditional awk lacks it. | |
447 | quoted = "" | |
448 | rest = fullname | |
449 | for (;;) { | |
450 | p = index(rest, "\\") | |
451 | q = index(rest, "\"") | |
452 | if (p) { | |
453 | if (q && q<p) p = q | |
454 | } else { | |
455 | if (!q) break | |
456 | p = q | |
457 | } | |
458 | quoted = quoted substr(rest, 1, p-1) "\\" substr(rest, p, 1) | |
459 | rest = substr(rest, p+1) | |
460 | } | |
461 | ||
462 | printf "fullname[\"%s\"] = \"%s%s\"\n", $1, quoted, rest | |
463 | author[$1] = 0 | |
464 | } | |
465 | } | |
466 | ' | |
467 | ||
468 | initialize_fullname=` | |
469 | { | |
470 | (getent passwd $authors) || | |
471 | ( | |
472 | cat /etc/passwd | |
473 | for author in $authors | |
474 | do NIS_PATH= nismatch $author passwd.org_dir | |
475 | done | |
476 | ypmatch $authors passwd | |
477 | ) | |
478 | } 2>/dev/null | | |
479 | $AWK -F: "$awkscript" | |
1bd57c39 | 480 | `$initialize_fullname;; |
daecaf5d GM |
481 | esac |
482 | ||
483 | ||
484 | # Function to print a single log line. | |
485 | # We don't use awk functions, to stay compatible with old awk versions. | |
1bd57c39 | 486 | # `Log' is the log message. |
daecaf5d GM |
487 | # `files' contains the affected files. |
488 | printlogline='{ | |
489 | ||
490 | # Following the GNU coding standards, rewrite | |
491 | # * file: (function): comment | |
492 | # to | |
493 | # * file (function): comment | |
494 | if (Log ~ /^\([^)]*\): /) { | |
495 | i = index(Log, ")") | |
1bd57c39 PE |
496 | filefunc = substr(Log, 1, i) |
497 | while ((j = index(filefunc, "\n"))) { | |
498 | files = files " " substr(filefunc, 1, j-1) | |
499 | filefunc = substr(filefunc, j+1) | |
500 | } | |
501 | files = files " " filefunc | |
daecaf5d GM |
502 | Log = substr(Log, i+3) |
503 | } | |
504 | ||
505 | # If "label: comment" is too long, break the line after the ":". | |
506 | sep = " " | |
1bd57c39 PE |
507 | i = index(Log, "\n") |
508 | if ('"$length"' <= '"$indent"' + 1 + length(files) + i) sep = "\n" indent_string | |
daecaf5d GM |
509 | |
510 | # Print the label. | |
511 | printf "%s*%s:", indent_string, files | |
512 | ||
1bd57c39 PE |
513 | # Print each line of the log. |
514 | while (i) { | |
daecaf5d GM |
515 | logline = substr(Log, 1, i-1) |
516 | if (logline ~ /[^'"$tab"' ]/) { | |
517 | printf "%s%s\n", sep, logline | |
518 | } else { | |
519 | print "" | |
520 | } | |
521 | sep = indent_string | |
522 | Log = substr(Log, i+1) | |
1bd57c39 | 523 | i = index(Log, "\n") |
daecaf5d GM |
524 | } |
525 | }' | |
526 | ||
527 | # Pattern to match the `revision' line of rlog output. | |
528 | rlog_revision_pattern='^revision [0-9]+\.[0-9]+(\.[0-9]+\.[0-9]+)*(['"$tab"' ]+locked by: [^'"$tab"' $,.0-9:;@]*[^'"$tab"' $,:;@][^'"$tab"' $,.0-9:;@]*;)?['"$tab"' ]*$' | |
529 | ||
530 | case $hostname in | |
531 | '') | |
532 | hostname=`( | |
533 | hostname || uname -n || uuname -l || cat /etc/whoami | |
534 | ) 2>/dev/null` || { | |
535 | echo >&2 "$0: cannot deduce hostname" | |
536 | exit 1 | |
537 | } | |
538 | ||
539 | case $hostname in | |
540 | *.*) ;; | |
541 | *) | |
542 | domainname=`(domainname) 2>/dev/null` && | |
543 | case $domainname in | |
1bd57c39 PE |
544 | *.*) hostname=$hostname.$domainname;; |
545 | esac;; | |
546 | esac;; | |
daecaf5d GM |
547 | esac |
548 | ||
549 | ||
550 | # Process the rlog output, generating ChangeLog style entries. | |
551 | ||
552 | # First, reformat the rlog output so that each line contains one log entry. | |
1bd57c39 | 553 | # Transliterate \n to SOH so that multiline entries fit on a single line. |
daecaf5d | 554 | # Discard irrelevant rlog output. |
1bd57c39 PE |
555 | $AWK ' |
556 | BEGIN { | |
557 | pository = "'"$pository"'" | |
558 | SOH="'"$SOH"'" | |
559 | } | |
560 | /^RCS file: / { | |
561 | if (pository != "") { | |
562 | filename = substr($0, 11) | |
563 | if (substr(filename, 1, length(pository)) == pository) { | |
564 | filename = substr(filename, length(pository) + 1) | |
daecaf5d GM |
565 | } |
566 | if (filename ~ /,v$/) { | |
567 | filename = substr(filename, 1, length(filename) - 2) | |
568 | } | |
569 | if (filename ~ /(^|\/)Attic\/[^\/]*$/) { | |
570 | i = length(filename) | |
571 | while (substr(filename, i, 1) != "/") i-- | |
572 | filename = substr(filename, 1, i - 6) substr(filename, i + 1) | |
573 | } | |
574 | } | |
575 | rev = "?" | |
576 | } | |
1bd57c39 | 577 | /^Working file: / { if (repository == "") filename = substr($0, 15) } |
daecaf5d GM |
578 | /'"$rlog_revision_pattern"'/, /^(-----------*|===========*)$/ { |
579 | line = $0 | |
580 | if (line ~ /'"$rlog_revision_pattern"'/) { | |
581 | rev = $2 | |
582 | next | |
583 | } | |
584 | if (line ~ /^date: [0-9][- +\/0-9:]*;/) { | |
585 | date = $2 | |
586 | if (date ~ /\//) { | |
587 | # This is a traditional RCS format date YYYY/MM/DD. | |
588 | # Replace "/"s with "-"s to get ISO format. | |
589 | newdate = "" | |
590 | while ((i = index(date, "/")) != 0) { | |
591 | newdate = newdate substr(date, 1, i-1) "-" | |
592 | date = substr(date, i+1) | |
593 | } | |
594 | date = newdate date | |
595 | } | |
596 | time = substr($3, 1, length($3) - 1) | |
597 | author = substr($5, 1, length($5)-1) | |
1bd57c39 | 598 | printf "%s%s%s%s%s%s%s%s%s%s", filename, SOH, rev, SOH, date, SOH, time, SOH, author, SOH |
daecaf5d GM |
599 | rev = "?" |
600 | next | |
601 | } | |
602 | if (line ~ /^branches: /) { next } | |
603 | if (line ~ /^(-----------*|===========*)$/) { print ""; next } | |
604 | if (line == "Initial revision" || line ~ /^file .+ was initially added on branch .+\.$/) { | |
605 | line = "New file." | |
606 | } | |
1bd57c39 | 607 | printf "%s%s", line, SOH |
daecaf5d | 608 | } |
1bd57c39 | 609 | ' <"$rlogfile" | |
daecaf5d GM |
610 | |
611 | # Now each line is of the form | |
1bd57c39 PE |
612 | # FILENAME@REVISION@YYYY-MM-DD@HH:MM:SS[+-TIMEZONE]@AUTHOR@LOG |
613 | # where @ stands for an SOH (octal code 001), | |
614 | # and each line of LOG is terminated by SOH instead of \n. | |
daecaf5d GM |
615 | # Sort the log entries, first by date+time (in reverse order), |
616 | # then by author, then by log entry, and finally by file name and revision | |
617 | # (just in case). | |
1bd57c39 | 618 | sort -t"$SOH" +2 -4r +4 +0 | |
daecaf5d GM |
619 | |
620 | # Finally, reformat the sorted log entries. | |
1bd57c39 | 621 | $AWK -F"$SOH" ' |
daecaf5d GM |
622 | BEGIN { |
623 | logTZ = "'"$logTZ"'" | |
624 | revision = "'"$revision"'" | |
625 | ||
daecaf5d GM |
626 | # Initialize the fullname and mailaddr associative arrays. |
627 | '"$initialize_fullname"' | |
628 | '"$initialize_mailaddr"' | |
629 | ||
630 | # Initialize indent string. | |
631 | indent_string = "" | |
632 | i = '"$indent"' | |
633 | if (0 < '"$tabwidth"') | |
634 | for (; '"$tabwidth"' <= i; i -= '"$tabwidth"') | |
635 | indent_string = indent_string "\t" | |
636 | while (1 <= i--) | |
637 | indent_string = indent_string " " | |
638 | } | |
639 | ||
640 | { | |
1bd57c39 PE |
641 | newlog = "" |
642 | for (i = 6; i < NF; i++) newlog = newlog $i "\n" | |
daecaf5d GM |
643 | |
644 | # Ignore log entries prefixed by "#". | |
645 | if (newlog ~ /^#/) { next } | |
646 | ||
647 | if (Log != newlog || date != $3 || author != $5) { | |
648 | ||
649 | # The previous log and this log differ. | |
650 | ||
651 | # Print the old log. | |
652 | if (date != "") '"$printlogline"' | |
653 | ||
654 | # Logs that begin with "{clumpname} " should be grouped together, | |
655 | # and the clumpname should be removed. | |
656 | # Extract the new clumpname from the log header, | |
657 | # and use it to decide whether to output a blank line. | |
658 | newclumpname = "" | |
659 | sep = "\n" | |
660 | if (date == "") sep = "" | |
661 | if (newlog ~ /^\{[^'"$tab"' }]*}['"$tab"' ]/) { | |
662 | i = index(newlog, "}") | |
663 | newclumpname = substr(newlog, 1, i) | |
664 | while (substr(newlog, i+1) ~ /^['"$tab"' ]/) i++ | |
665 | newlog = substr(newlog, i+1) | |
666 | if (clumpname == newclumpname) sep = "" | |
667 | } | |
668 | printf sep | |
669 | clumpname = newclumpname | |
670 | ||
671 | # Get ready for the next log. | |
672 | Log = newlog | |
673 | if (files != "") | |
674 | for (i in filesknown) | |
675 | filesknown[i] = 0 | |
676 | files = "" | |
677 | } | |
678 | if (date != $3 || author != $5) { | |
679 | # The previous date+author and this date+author differ. | |
680 | # Print the new one. | |
681 | date = $3 | |
682 | time = $4 | |
683 | author = $5 | |
684 | ||
685 | zone = "" | |
686 | if (logTZ && ((i = index(time, "-")) || (i = index(time, "+")))) | |
687 | zone = " " substr(time, i) | |
688 | ||
689 | # Print "date[ timezone] fullname <email address>". | |
690 | # Get fullname and email address from associative arrays; | |
691 | # default to author and author@hostname if not in arrays. | |
692 | if (fullname[author]) | |
693 | auth = fullname[author] | |
694 | else | |
695 | auth = author | |
696 | printf "%s%s %s ", date, zone, auth | |
697 | if (mailaddr[author]) | |
698 | printf "<%s>\n\n", mailaddr[author] | |
699 | else | |
700 | printf "<%s@%s>\n\n", author, "'"$hostname"'" | |
701 | } | |
702 | if (! filesknown[$1]) { | |
703 | filesknown[$1] = 1 | |
704 | if (files == "") files = " " $1 | |
705 | else files = files ", " $1 | |
706 | if (revision && $2 != "?") files = files " " $2 | |
707 | } | |
708 | } | |
709 | END { | |
710 | # Print the last log. | |
711 | if (date != "") { | |
712 | '"$printlogline"' | |
713 | printf "\n" | |
714 | } | |
715 | } | |
716 | ' && | |
717 | ||
718 | ||
719 | # Exit successfully. | |
720 | ||
721 | exec rm -fr $logdir | |
722 | ||
723 | # Local Variables: | |
724 | # tab-width:4 | |
725 | # End: |