Meta/cook: format the topic description with indentation

This _might_ make things easier to read, together with an extra blank line between each topic. Adjust Meta/Reintegrate to read and strip the extra indentation to avoid breaking the merge log messages. "Meta/cook -w" also has been adjusted to read and strip the extra indentation before finding the markers for "will-do".

Junio C Hamano committed Sep 13, 2012 at 21:11 UTC 29d334511a22f798b46cb8b5108995b82135d9bd
2 files changed +47 -19
Reintegrate
+9 -6
@@ -26,19 +26,22 @@ annotate_merge () {
26
27 perl -e '
28 my ($branch) = $ARGV[0];
29 - my ($in_section) = 0;
29 + my ($in_section, $in_desc);
30 my @msg = ();
31 while (<STDIN>) {
32 + chomp;
33 if (/^\* $branch /) {
34 $in_section = 1;
35 next;
36 }
36 - if (/^[-*\[]/) {
37 - last if $in_section;
38 - }
37 + last if (/^[-*\[]/ && $in_section);
38 next unless $in_section;
40 - next if (/^ /);
41 - push @msg, $_;
39 + s/^\s+//;
40 + if (/^$/) {
41 + $in_desc = 1;
42 + }
43 + next unless ($in_section && $in_desc);
44 + push @msg, "$_\n";
45 }
46
47 if ($in_section && @msg) {
cook
+38 -13
@@ -302,7 +302,7 @@ EOF
302 }
303
304 my $blurb_match = <<'EOF';
305 -(?i:[a-z]+: .*\n)*?Subject: What's cooking in \S+ \((\w+) (\d+), #(\d+); (\w+), (\d+)\)
305 +(?i:\s*[a-z]+: .*\n)*?Subject: What's cooking in \S+ \((\w+) (\d+), #(\d+); (\w+), (\d+)\)
306 X-master-at: ([0-9a-f]{40})
307 X-next-at: ([0-9a-f]{40})
308
@@ -338,6 +338,7 @@ sub read_previous {
338 open ($fh, '<', $fn) or die "$!: open $fn";
339 while (<$fh>) {
340 chomp;
341 + s/\s+$//;
342 if ($in_unedited_olde) {
343 if (/^>>$/) {
344 $in_unedited_olde = 0;
@@ -390,6 +391,7 @@ sub read_previous {
391 }
392 close($fh);
393
394 + my $lead = " ";
395 for my $branch (keys %description) {
396 my $ary = $description{$branch};
397 if ($branch eq $blurb) {
@@ -407,9 +409,16 @@ sub read_previous {
409 last if ($elem eq '');
410 push @desc, $elem;
411 }
412 + my @txt = map {
413 + s/^\s+//;
414 + $_ = "$lead$_";
415 + s/\s+$//;
416 + $_;
417 + } @{$ary};
418 +
419 $description{$branch} = +{
420 desc => join("\n", @desc),
412 - text => join("\n", @{$ary}),
421 + text => join("\n", @txt),
422 };
423 }
424 }
@@ -435,13 +444,15 @@ sub write_cooking {
444 print $fh "\n";
445 print $fh '-' x 50, "\n";
446 print $fh "[$section_name]\n";
447 + my $lead = "\n";
448 for my $topic (@{$topic_list}) {
449 my $d = $cooking->{'topic_description'}{$topic};
450
441 - print $fh "\n", $d->{'desc'}, "\n";
451 + print $fh $lead, $d->{'desc'}, "\n";
452 if ($d->{'text'}) {
453 print $fh "\n", $d->{'text'}, "\n";
454 }
455 + $lead = "\n\n";
456 }
457 }
458 close($fh);
@@ -644,7 +655,7 @@ sub wildo_match {
655 }
656
657 sub wildo {
647 - my (%what, $topic, $last_merge_to_next, $in_section);
658 + my (%what, $topic, $last_merge_to_next, $in_section, $in_desc);
659 my $too_recent = '9999-99-99';
660 while (<>) {
661 chomp;
@@ -653,7 +664,7 @@ sub wildo {
664 my $old_section = $in_section;
665 $in_section = $1;
666 wildo_flush_topic($old_section, \%what, $topic);
656 - $topic = undef;
667 + $topic = $in_desc = undef;
668 next;
669 }
670
@@ -662,6 +673,7 @@ sub wildo {
673
674 # tip-date, next-date, topic, count, pu-count
675 $topic = [$2, $too_recent, $1, $3, 0];
676 + $in_desc = undef;
677 next;
678 }
679
@@ -674,12 +686,18 @@ sub wildo {
686 if (defined $topic && /^ - /) {
687 $topic->[4]++;
688 }
677 - next if (/^ /);
678 - next unless defined $topic;
689
690 + if (defined $topic && /^$/) {
691 + $in_desc = 1;
692 + next;
693 + }
694 +
695 + next unless defined $topic && $in_desc;
696 +
697 + s/^\s+//;
698 if (wildo_match($_)) {
699 wildo_queue(\%what, $_, $topic);
682 - $topic = undef;
700 + $topic = $in_desc = undef;
701 }
702
703 if (/Originally merged to 'next' on ([-0-9]+)/) {
@@ -738,7 +756,7 @@ sub havedone {
756 my $fh;
757 my %topic = ();
758 my @topic = ();
741 - my ($topic, $to_maint, %to_maint, %merged);
759 + my ($topic, $to_maint, %to_maint, %merged, $in_desc);
760 if (!@ARGV) {
761 open($fh, '-|',
762 qw(git rev-list --first-parent -1 master Documentation/RelNotes))
@@ -765,7 +783,7 @@ sub havedone {
783 chomp;
784 if (/^\[(.*)\]$/) {
785 # section header
768 - $topic = undef;
786 + $in_desc = $topic = undef;
787 next;
788 }
789 if (/^\* (\S+) \([-0-9]+\) \d+ commits?$/) {
@@ -773,11 +791,18 @@ sub havedone {
791 $topic = $1;
792 $to_maint = 0;
793 } else {
776 - $topic = undef;
794 + $in_desc = $topic = undef;
795 }
796 next;
797 }
780 - next if (/^ / || !defined $topic);
798 + if (defined $topic && /^$/) {
799 + $in_desc = 1;
800 + next;
801 + }
802 +
803 + next unless defined $topic && $in_desc;
804 +
805 + s/^\s+//;
806 if (wildo_match($_)) {
807 next;
808 }
@@ -834,7 +859,7 @@ use Getopt::Long;
859 my $wildo;
860 my $havedone;
861 if (!GetOptions("wildo" => \$wildo, "havedone" => \$havedone)) {
837 - print STDERR "$0 [--wildo|--havedone]";
862 + print STDERR "$0 [--wildo|--havedone]\n";
863 exit 1;
864 }
865