Meta/cook --havedone to help updating RelNotes

Junio C Hamano committed Jul 9, 2012 at 11:11 UTC f479eb6714ee2f8fdfdf30820fc2848d95b26ffc
1 file changed +120 -5
cook
+120 -5
@@ -634,6 +634,15 @@ sub wildo_flush_topic {
634 }
635 }
636
637 +sub wildo_match {
638 + if (/^Will (?:\S+ ){0,2}(keep|merge|drop|discard|cook|kick|defer|be re-?rolled)[,. ]/ ||
639 + /^Not urgent/ || /^Not ready/ || /^Waiting for / ||
640 + /^Needs? / || /^Expecting / || /^May want to /) {
641 + return 1;
642 + }
643 + return 0;
644 +}
645 +
646 sub wildo {
647 my (%what, $topic, $last_merge_to_next, $in_section);
648 my $too_recent = '9999-99-99';
@@ -668,9 +677,7 @@ sub wildo {
677 next if (/^ /);
678 next unless defined $topic;
679
671 - if (/^Will (?:\S+ ){0,2}(keep|merge|drop|discard|cook|kick|defer)[,. ]/ ||
672 - /^Not urgent/ || /^Not ready/ || /^Waiting for / ||
673 - /^Needs? / || /^Expecting / || /^May want to /) {
680 + if (wildo_match($_)) {
681 wildo_queue(\%what, $_, $topic);
682 $topic = undef;
683 }
@@ -704,6 +711,111 @@ sub wildo {
711 }
712 }
713
714 +################################################################
715 +# HavDone
716 +sub havedone_show {
717 + my $topic = shift;
718 + my $str = shift;
719 + my $prefix = " * ";
720 + $str =~ s/\A\n+//;
721 + $str =~ s/\n+\Z//;
722 +
723 + print "($topic)\n";
724 + for $str (split(/\n/, $str)) {
725 + print "$prefix$str\n";
726 + $prefix = " ";
727 + }
728 +}
729 +
730 +sub havedone_count {
731 + my @range = @_;
732 + my $cnt = `git rev-list --count @range`;
733 + chomp $cnt;
734 + return $cnt;
735 +}
736 +
737 +sub havedone {
738 + my $fh;
739 + my %topic = ();
740 + my @topic = ();
741 + my ($topic, $to_maint, %to_maint, %merged);
742 + if (!@ARGV) {
743 + open($fh, '-|',
744 + qw(git rev-list --first-parent -1 master Documentation/RelNotes))
745 + or die "$!: open rev-list";
746 + my ($rev) = <$fh>;
747 + close($fh) or die "$!: close rev-list";
748 + chomp $rev;
749 + @ARGV = ("$rev..master");
750 + }
751 + open($fh, '-|',
752 + qw(git log --first-parent --oneline --reverse), @ARGV)
753 + or die "$!: open log --first-parent";
754 + while (<$fh>) {
755 + my ($sha1, $branch) = /^([0-9a-f]+) Merge branch '(.*)'$/;
756 + next unless $branch;
757 + $topic{$branch} = "";
758 + $merged{$branch} = $sha1;
759 + push @topic, $branch;
760 + }
761 + close($fh) or die "$!: close log --first-parent";
762 + open($fh, "<", "Meta/whats-cooking.txt")
763 + or die "$!: open whats-cooking";
764 + while (<$fh>) {
765 + chomp;
766 + if (/^\[(.*)\]$/) {
767 + # section header
768 + $topic = undef;
769 + next;
770 + }
771 + if (/^\* (\S+) \([-0-9]+\) \d+ commits?$/) {
772 + if (exists $topic{$1}) {
773 + $topic = $1;
774 + $to_maint = 0;
775 + } else {
776 + $topic = undef;
777 + }
778 + next;
779 + }
780 + next if (/^ / || !defined $topic);
781 + if (wildo_match($_)) {
782 + next;
783 + }
784 + $topic{$topic} .= "$_\n";
785 + }
786 + close($fh) or die "$!: close whats-cooking";
787 +
788 + for $topic (@topic) {
789 + my $merged = $merged{$topic};
790 + my $in_master = havedone_count("$merged^1..$merged^2");
791 + my $not_in_maint = havedone_count("maint..$merged^2");
792 + if ($in_master == $not_in_maint) {
793 + $to_maint{$topic} = 1;
794 + }
795 + }
796 +
797 + my $shown = 0;
798 + for $topic (@topic) {
799 + next if (exists $to_maint{$topic});
800 + havedone_show($topic, $topic{$topic});
801 + print "\n";
802 + $shown++;
803 + }
804 +
805 + if ($shown) {
806 + print "-" x 64, "\n";
807 + }
808 +
809 + for $topic (@topic) {
810 + next unless (exists $to_maint{$topic});
811 + havedone_show($topic, $topic{$topic});
812 + my $sha1 = `git rev-parse --short $topic`;
813 + chomp $sha1;
814 + print " (merge $sha1 $topic later to maint).\n";
815 + print "\n";
816 + }
817 +}
818 +
819 ################################################################
820 # WhatsCooking
821
@@ -720,8 +832,9 @@ sub doit {
832 use Getopt::Long;
833
834 my $wildo;
723 -if (!GetOptions("wildo" => \$wildo)) {
724 - print STDERR "$0 [--wildo]";
835 +my $havedone;
836 +if (!GetOptions("wildo" => \$wildo, "havedone" => \$havedone)) {
837 + print STDERR "$0 [--wildo|--havedone]";
838 exit 1;
839 }
840
@@ -730,6 +843,8 @@ if ($wildo) {
843 push @ARGV, "Meta/whats-cooking.txt";
844 }
845 wildo();
846 +} elsif ($havedone) {
847 + havedone();
848 } else {
849 doit();
850 }