Fix obsolete comment regarding FSM truncation.
[PostgreSQL.git] / src / tools / pgcvslog
blob258d99fd30aa4e548558ddc2682c81197a08a5f8
1 #!/bin/sh
3 # $PostgreSQL$
5 # This utility is used to generate a compact list of changes
6 # for each release, bjm 2000-02-22
8 # Usage: pgcvslog [-d] [-h]
9 # -d delete commits that include back branches
10 # -h is HTML output
11 # "-d" is useful for generating release notes for major releases
13 # This program basically takes a cvs log, groups it by commit timestamp
14 # and line number, then compares adjacent messages. If they have the same
15 # commit message, they are assumed to be part of the same commit and
16 # appear as one commit message with multiple file names
18 # All branches:
19 # cvs log -d'>1999-06-14 00:00:00 GMT' . > log
21 # HEAD:
22 # cvs log -d'>2000-05-29 00:00:00 GMT' -b .
24 # Branch:
25 # cvs log -d'>2000-05-29 00:00:00 GMT' -rREL8_0_STABLE .
27 # Date range
28 # cvs log -d'2005-05-08<2005-05-29' -rREL8_0_STABLE .
30 # To find branch time, look for "branches:" tag in CVS commit logs
31 # e.g. "branches: 1.398.4;" matches "REL8_0_STABLE: 1.398.0.4".
33 # Remove these from the log file before processing to reduce the number
34 # of unneeded log entries:
36 # /cvsroot/pgsql/doc/TODO
37 # /cvsroot/pgsql/doc/FAQ
38 # /cvsroot/pgsql/doc/src/FAQ/TODO.html
39 # /cvsroot/pgsql/doc/src/FAQ/FAQ.html
42 HTML="N"
43 DEL="N"
44 if [ "X$1" = "X-h" ]
45 then HTML="Y"
46 shift
49 if [ "X$1" = "X-d" ]
50 then DEL="Y"
51 shift
54 if [ "X$1" = "X-h" ]
55 then HTML="Y"
56 shift
59 if [ "$HTML" = "Y" -a "$DEL" = "Y" ]
60 then echo "Cannot use -d and -h together" 1>&2
61 exit 1
64 cat "$@" |
66 # protect HTML input if in HTML mode
67 if [ "$HTML" = "Y" ]
68 then sed -e 's/\&/\&amp;/g' \
69 -e 's/</\&lt;/g' \
70 -e 's/>/\&gt;/g' \
71 -e 's/"/\&quot;/g'
72 else cat
73 fi |
75 # mark each line with a datetime and line number, for sorting and merging
76 # we are just pre-processing the file at this point
77 # We don't print anything from the -- or == line and the date:
79 awk ' BEGIN {html="'"$HTML"'"; lineno = 0;}
80 # store working directory
81 $0 ~ /^Working file:/ {workingfile = "/" $3}
83 # no need to show TODO or FAQ changes in the output
84 $0 !~ /^====*$/ &&
85 (workingfile == "/doc/TODO" || workingfile == "/doc/src/FAQ/TODO.html" ||
86 workingfile == "/doc/FAQ" || workingfile == "/doc/src/FAQ/FAQ.html") \
87 {next}
89 ($0 ~ /^====*$/ || $0 ~ /^----*$/) \
91 # print blank line to separate entries
92 if (datetime != "")
94 if (html != "Y")
95 printf ("%s| %10d|%s\n", datetime, lineno++, "");
96 printf ("%s| %10d|", datetime, lineno++);
97 if (html != "Y")
98 printf ("%s\n", "---");
99 else printf ("<HR>\n");
101 datetime="";
104 # if we have a saved datetime, print filename, date line, and committer
105 datetime != "" && $1 != "branches:" {printf ("%s| %10d| %s\n", datetime, lineno++, $0);}
107 $1 == "date:" \
109 # get entry date
110 datetime=$2"-"$3
111 if (workingfile != "")
113 printf ("%s| %10d|", datetime, lineno++);
114 if (html != "Y")
115 printf ("%s%s\n", workingfile, back_branch);
116 else printf ("<SMALL><FONT COLOR=\"red\">%s%s</FONT></SMALL>\n", workingfile, back_branch);
118 # output name of committer
119 # remove semicolon from committers name
120 gsub("/", "-", $2);
121 gsub(";", "", $3);
122 gsub(";", "", $5);
123 printf ("%s| %10d|", datetime, lineno++);
124 if (html != "Y")
125 printf ("%78s\n", $5);
126 else printf ("<DIV ALIGN=\"right\"><SMALL><FONT COLOR=\"teal\">%s</FONT> <FONT COLOR=\"green\">%s</FONT></SMALL></DIV>\n", $5, $2);
130 # mark back branches
131 $1 == "revision" \
133 # back branches have +2 periods in revision number
134 if ($2 ~ /\..*\./)
135 back_branch=" <branch>"
136 else back_branch = ""
139 /* clear working file */
140 $0 ~ /^====*$/ {workingfile=""}' |
142 sort | cut -d'|' -f3 |
144 # collect duplicate narratives
145 # print file names as we get them, then print narrative when a new
146 # narrative appears
147 # have to save two narratives to compare them
149 awk ' BEGIN { narr_slot = 0; oldnarr_slot=0; save_working = "";
150 html="'"$HTML"'"}
152 # We have a filename, so we look at the previous
153 # narrative to see if it is new narrative text.
154 if ($0 ~ "^/")
156 # If there are a different number of narrative
157 # lines, they cannot possibly be the same.
158 if (narr_slot != oldnarr_slot)
159 same = "N";
160 else
162 same = "Y";
163 for (i=1; i <= narr_slot; i++)
165 if (oldnarr[i] != narr[i])
167 same = "N";
168 break;
173 # dump out the old narrative if it is new
174 if (same == "N")
176 if (oldnarr_slot)
177 for (i=1; i <= oldnarr_slot; i++)
179 print oldnarr[i];
180 if (html == "Y" &&
181 oldnarr[i] != "<HR>" &&
182 oldnarr[i] !~ "^<DIV ")
183 print "<BR>";
186 # save the current narrative
187 for (i=1; i <= narr_slot; i++)
188 oldnarr[i] = narr[i];
189 oldnarr_slot = narr_slot;
191 narr_slot = 0;
193 # dump out the previous filename
194 print save_working;
196 if (html == "Y")
197 print "<BR>";
199 # store the current filename for later printing
200 save_working = $0;
202 else
203 # we have a narrative line
205 # accumulate narrative
206 narr[++narr_slot] = $0;
209 END \
211 # If there are a different number of narrative
212 # lines, they can not possibly be the same.
213 if (narr_slot != oldnarr_slot)
214 same = "N";
215 else
217 same = "Y";
218 for (i=1; i <= narr_slot; i++)
220 if (oldnarr[i] != narr[i])
222 same = "N";
223 break;
228 # dump out the old narrative if it is new
229 if (same == "N")
231 if (oldnarr_slot)
232 for (i=1; i <= oldnarr_slot; i++)
234 print oldnarr[i];
235 if (html == "Y" &&
236 oldnarr[i] != "<HR>" &&
237 oldnarr[i] !~ "^<DIV ")
238 print "<BR>";
242 # dump out the last filename
243 print save_working;
245 if (html == "Y")
246 print "<BR>";
248 # dump out the last narrative
249 for (i=1; i <= narr_slot; i++)
251 print narr[i];
252 if (html == "Y" &&
253 narr[i] != "<HR>" &&
254 narr[i] !~ "^<DIV ")
255 print "<BR>";
257 }' |
259 # add HTML wrapper
260 if [ "$HTML" = "Y" ]
261 then echo "<HTML>"
262 echo "<HEAD>"
263 echo "<TITLE>CVS</TITLE>"
264 echo "</HEAD>"
265 echo "<BODY>"
267 echo "</BODY>"
268 echo "</HTML>"
269 else cat
270 fi |
272 # if requested, remove any commit that has the "<branch>" text
273 if [ "$DEL" = "Y" ]
274 then awk 'BEGIN \
276 slot = 0;
280 # new commit?
281 if ($0 ~ "^---$")
283 skip = "N";
284 for (i=1; i <= slot; i++)
285 if (commit[i] ~ "<branch>")
286 skip = "Y";
287 if (skip == "N")
288 for (i=1; i <= slot; i++)
289 print commit[i];
290 slot = 0;
293 # accumulate commit
294 commit[++slot] = $0;
297 END \
299 skip = "N";
300 for (i=1; i <= slot; i++)
301 if (commit[i] ~ "<branch>")
302 skip = "Y";
303 if (skip == "N")
304 for (i=1; i <= slot; i++)
305 print commit[i];
307 else cat