]> granicus.if.org Git - postgresql/blob - src/tools/pgcvslog
35191cd8cf29b4a7f8ac4fbddba75031dabbac2a
[postgresql] / src / tools / pgcvslog
1 :
2 # This utility is used to generate a compact list of changes
3 # for each release, bjm 2000-02-22
4
5 # Usage $0 file
6
7 # no branches:  # cvs log -d '>1999-06-14 00:00:00 GMT' . > log
8 #
9 # pre and post-branch logs:
10 # find . -name CVS -type d -exec touch '{}/Entries.Static' \;
11 #
12 # cvs log -d'2000-05-08 00:00:00 GMT<2000-05-29 00:00:00 GMT'
13 # cvs log -d'>2000-05-29 00:00:00 GMT' -rREL7_1_STABLE
14 # cvs log -d'>1999-06-14 00:00:00 GMT' . > log
15 #
16 # find . -name CVS -type d -exec rm '{}/Entries.Static' \;
17 #
18
19 if [ "X$1" == "X-h" ]
20 then    HTML="Y"
21         shift
22 else    HTML="N"
23 fi
24
25 cat "$@" |
26
27 # protect HTML input if in HTML mode
28 if [ "$HTML" = "Y" ]
29 then    sed     -e 's/\&/\&amp;/g' \
30                 -e 's/</\&lt;/g' \
31                 -e 's/>/\&gt;/g' \
32                 -e 's/"/\&quot;/g'
33 else    cat
34 fi |
35
36 # mark each line with a datetime and line number, for sorting and merging
37 # We don't print anything from the -- or == line and the date:
38
39 awk '   BEGIN   {html="'"$HTML"'"; lineno = 0;}
40         # store working directory
41         $0 ~ /^Working file:/   {workingfile = "/" $3}
42
43         ($0 ~ /^====*$/ || $0 ~ /^----*$/) \
44         {
45                 # print blank line to separate entries
46                 if (datetime != "")
47                 {
48                         if (html != "Y")
49                                 printf ("%s| %10d|%s\n", datetime, lineno++, "");
50                         printf ("%s| %10d|", datetime, lineno++);
51                         if (html != "Y")
52                                 printf ("%s\n", "---");
53                         else    printf ("<HR>\n");
54                 }
55                 datetime="";
56         }
57
58         # if we have a saved datetime, print filename, date line, and committer
59         datetime != "" {printf ("%s| %10d| %s\n", datetime, lineno++, $0);}
60
61         $1 == "date:" \
62         {
63                 # get entry date
64                 datetime=$2"-"$3
65                 if (workingfile != "")
66                 {
67                         printf ("%s| %10d|", datetime, lineno++);
68                         if (html != "Y")
69                                 printf ("%s\n", workingfile);
70                         else    printf ("<SMALL><FONT COLOR=\"red\">%s</FONT></SMALL>\n", workingfile);
71
72                         # output name of committer
73                         # remove semicolon from committers name
74                         gsub("/", "-", $2);
75                         gsub(";", "", $3);
76                         gsub(";", "", $5);
77                         printf ("%s| %10d|", datetime, lineno++);
78                         if (html != "Y")
79                                 printf ("%78s\n", $5);
80                         else    printf ("<DIV ALIGN=\"right\"><SMALL><FONT COLOR=\"teal\">%s</FONT> <FONT COLOR=\"green\">%s</FONT></SMALL></DIV>\n", $5, $2);
81                 }
82         }
83
84         /* clear working file */
85         $0 ~ /^====*$/  {workingfile=""}' |
86
87 sort | cut -d'|' -f3 | cat |
88
89 # collect duplicate narratives
90
91 awk '   BEGIN   { slot = 0; oldslot=0; save_working = ""; html="'"$HTML"'"}
92         {
93                 # We have a filename, so we look at the previous
94                 # narrative to see if it is new narrative text.
95                 if ($0 ~ /^\// || $0 ~ />\//)
96                 {
97                         # If there are a different number of narrative
98                         # lines, they can not possibly be the same.
99                         if (slot != oldslot)
100                                 same = "N";
101                         else
102                         {
103                                 same = "Y";
104                                 for (i=1; i <= slot; i++)
105                                 {
106                                         if (oldnarr[i] != narr[i])
107                                         {
108                                                 same = "N";
109                                                 break;
110                                         }
111                                 }
112                         }
113
114                         # dump out the old narrative if it is new
115                         if (same == "N")
116                         {
117                                 if (oldslot)
118                                         for (i=1; i <= oldslot; i++)
119                                         {
120                                                 print oldnarr[i];
121                                                 if (html == "Y" && 
122                                                     oldnarr[i] != "<HR>" &&
123                                                     oldnarr[i] !~ "^<DIV ")
124                                                         print "<BR>";
125                                         }
126
127                                 # save the current narrative
128                                 for (i=1; i <= slot; i++)
129                                         oldnarr[i] = narr[i];
130                                 oldslot = slot;
131                         }
132                         slot = 0;
133
134                         # dump out the previous filename
135                         print save_working;
136                         if (html == "Y")
137                                 print "<BR>";
138
139                         # store the current filename for later printing
140                         save_working = $0;
141                 }
142                 else
143                 # we have a narrative line
144                 {
145                         # accumulate narrative
146                         narr[++slot] = $0;
147                 }
148         }
149         END     {
150                         # dump out the last filename
151
152                         print save_working;
153                         if (html == "Y")
154                                 print "<BR>";
155
156                         # dump out the last narrative
157                         for (i=1; i <= slot; i++)
158                         {
159                                 print narr[i];
160                                 if (html == "Y" && 
161                                     oldnarr[i] != "<HR>" &&
162                                     oldnarr[i] !~ "^<DIV ")
163                                         print "<BR>";
164                         }
165                 }' |
166
167 # add HTML wrapper
168 if [ "$HTML" = "Y" ]
169 then    echo "<HTML>"
170         echo "<HEAD>"
171         echo "<TITLE>CVS</TITLE>"
172         echo "</HEAD>"
173         echo "<BODY>"
174         cat
175         echo "</BODY>"
176         echo "</HTML>"
177 else    cat
178 fi