Add support to incrementally updating "What's in" report

If the result of previous run is in the filesystem but not committed yet, use that as a template. This mode needs to behave slightly differently in that the topics that appeared in the template file's "New Topics" section need to be kept, and "New Topics" section should not get renamed to "Old New Topics". The sections need to be kept together after this change, and also the handling of the Graduated to "master" psuedo section should also be straightened out, but that can come later.

Junio C Hamano committed Aug 23, 2009 at 16:10 UTC 6d5ccc480b87796316117f12c46c492278936b18
1 file changed +24 -17
cook.sh
+24 -17
@@ -204,6 +204,14 @@ last=$(
204 git ls-tree -r --name-only HEAD "whats/cooking" | tail -n 1
205 )
206
207 +# We may have a half-written one already.
208 +incremental=no
209 +if test -f "Meta/$lead/$issue.txt"
210 +then
211 + last="$lead/$issue.txt"
212 + incremental=yes
213 +fi
214 +
215 master_at=$(git rev-parse --verify refs/heads/master)
216 next_at=$(git rev-parse --verify refs/heads/next)
217 cat >"$tmp.output.0" <<EOF
@@ -233,6 +241,7 @@ perl -w -e '
241 my $serial = 1;
242 my $branch = "b:l:u:r:b";
243 my $tmp = $ARGV[0];
244 + my $incremental = $ARGV[1] eq "yes";
245 my $last_empty = undef;
246
247 open TOC, ">$tmp.template.toc";
@@ -249,6 +258,9 @@ perl -w -e '
258 if (/^\[(.*)\]\s*$/) {
259 $section = $1;
260 $branch = undef;
261 + if ($section eq "New Topics" && !$incremental) {
262 + $section = "Old New Topics";
263 + }
264 next;
265 }
266 if (defined $section && /^\* (\S+) /) {
@@ -264,7 +276,11 @@ perl -w -e '
276 print O "$_";
277 }
278 }
267 -' <"$template" "$tmp"
279 +' <"$template" "$tmp" "$incremental"
280 +
281 +tmpserial=$(
282 + tail -n 1 "$tmp.template.toc" | read branch serial section && echo $serial
283 +)
284
285 # Assemble them all
286
@@ -281,20 +297,13 @@ else
297 cat "$tmp.output.0"
298 fi | sed -e '$d'
299
284 -current='--------------------------------------------------
285 -[New Topics]
286 -'
300 while read branch serial
301 do
302 grep "^$branch " "$tmp.template.toc" >/dev/null && continue
290 - if test -n "$current"
291 - then
292 - echo "$current"
293 - current=
294 - else
295 - echo
296 - fi
297 - cat "$tmp.output.$serial"
303 +
304 + tmpserial=$(( $tmpserial + 1 ))
305 + echo "$branch $tmpserial New Topics" >>"$tmp.template.toc"
306 + cp "$tmp.output.$serial" "$tmp.template.$tmpserial"
307 done <"$tmp.output.toc"
308
309 current='--------------------------------------------------
@@ -302,7 +311,9 @@ current='--------------------------------------------------
311 '
312 while read branch oldserial section
313 do
305 - test "$section" = 'Graduated to "master"' && continue
314 + test "$section" = 'Graduated to "master"' &&
315 + test "$incremental" = no && continue
316 +
317 tip=$(git rev-parse --quiet --verify "refs/heads/$branch")
318 mb=$(git merge-base master $tip)
319 test "$mb" = "$tip" || continue
@@ -321,10 +332,6 @@ while read branch oldserial section
332 do
333 found=$(grep "^$branch " "$tmp.output.toc") || continue
334 newserial=$(expr "$found" : '[^ ]* \(.*\)')
324 - if test "$section" = "New Topics"
325 - then
326 - section="Old New Topics"
327 - fi
335 if test "$current" != "$section"
336 then
337 current=$section