Meta/cook -w: give default action to each seciton
Junio C Hamano committed
Feb 6, 2012 at 09:08 UTC
379607b8424cb9a975b3a8b4206bed930f6f4dda
1 file changed
+33
-18
cook
+33
-18
@@ -628,29 +628,49 @@ sub wildo_queue {
628
push @{$what->{$action}}, $topic;
629
}
630
631
+sub section_action {
632
+ my ($section) = @_;
633
+ if ($section) {
634
+ for ($section) {
635
+ return if (/^Graduated to/ || /^Discarded$/);
636
+ return $_ if (/^Stalled$/);
637
+ }
638
+ }
639
+ return "Undecided";
640
+}
641
+
642
+sub wildo_flush_topic {
643
+ my ($in_section, $what, $topic) = @_;
644
+ if (defined $topic) {
645
+ my $action = section_action($in_section);
646
+ if ($action) {
647
+ wildo_queue($what, $action, $topic);
648
+ }
649
+ }
650
+}
651
+
652
sub wildo {
632
- my (%what, $topic, $last_merge_to_next, $in_stalled);
653
+ my (%what, $topic, $last_merge_to_next, $in_section);
654
my $too_recent = '9999-99-99';
655
while (<>) {
656
chomp;
657
637
- next if (/^\[Graduated to/../^-{20,}$/);
638
- next if (/^\[Discarded\]/../^-{20,}$/);
639
-
640
- if (/^\[Stalled\]/../^-{20,}$/) {
641
- $in_stalled = 1;
642
- } else {
643
- $in_stalled = 0;
658
+ if (/^\[(.*)\]$/) {
659
+ my $old_section = $in_section;
660
+ $in_section = $1;
661
+ wildo_flush_topic($old_section, \%what, $topic);
662
+ $topic = undef;
663
+ next;
664
}
665
666
if (/^\* (\S+) \(([-0-9]+)\) (\d+) commits?$/) {
647
- if (defined $topic) {
648
- wildo_queue(\%what, "Undecided", $topic);
649
- }
667
+ wildo_flush_topic($in_section, \%what, $topic);
668
+
669
# tip-date, next-date, topic, count, pu-count
670
$topic = [$2, $too_recent, $1, $3, 0];
671
next;
672
}
673
+
674
if (defined $topic &&
675
($topic->[1] eq $too_recent) &&
676
($topic->[4] == 0) &&
@@ -663,10 +683,6 @@ sub wildo {
683
next if (/^ /);
684
next unless defined $topic;
685
666
- if ($in_stalled) {
667
- wildo_queue(\%what, "Stalled", $topic);
668
- $topic = undef;
669
- }
686
if (/^Will (?:\S+ ){0,2}(keep|merge|drop|discard|cook|kick|defer)[,. ]/ ||
687
/^Not urgent/ || /^Not ready/ || /^Waiting for / ||
688
/^Needs? / || /Expecting /) {
@@ -681,9 +697,8 @@ sub wildo {
697
$topic->[1] = $1;
698
}
699
}
684
- if (defined $topic) {
685
- wildo_queue(\%what, "Undecided", $topic);
686
- }
700
+ wildo_flush_topic($in_section, \%what, $topic);
701
+
702
my $ipbl = "";
703
for my $what (sort keys %what) {
704
print "$ipbl$what\n";