2 # Maintain "what's cooking" messages
6 my %reverts = ('next' => {
14 my (@u) = grep { $uniq{$_}++ == 0 } sort @_;
16 for (my $i = 0; $i < @u; $i++) {
20 } elsif ($i < @u - 2) {
27 sub describe_relation
{
28 my ($topic_info) = @_;
31 if (exists $topic_info->{'used'}) {
32 push @desc, ("is used by " .
33 phrase_these
(@
{$topic_info->{'used'}}));
36 if (exists $topic_info->{'uses'}) {
37 push @desc, ("uses " .
38 phrase_these
(@
{$topic_info->{'uses'}}));
41 if (exists $topic_info->{'shares'}) {
42 push @desc, ("is tangled with " .
43 phrase_these
(@
{$topic_info->{'shares'}}));
50 return "(this branch " . join("; ", @desc) . ".)";
54 my ($topic, $fork, $forkee, @overlap) = @_;
55 my %ovl = map { $_ => 1 } (@overlap, @
{$topic->{$forkee}{'log'}});
57 push @
{$topic->{$fork}{'uses'}}, $forkee;
58 push @
{$topic->{$forkee}{'used'}}, $fork;
59 @
{$topic->{$fork}{'log'}} = (grep { !exists $ovl{$_} }
60 @
{$topic->{$fork}{'log'}});
64 my ($topic, $one, $two) = @_;
68 qw(git log --abbrev=7), "--format=%m %h",
69 "$one...$two", "^master")
70 or die "$!: open log --left-right";
73 my ($sign, $sha1) = /^(.) (.*)/;
76 } elsif ($sign eq '>') {
80 close($fh) or die "$!: close log --left-right";
84 forks_from
($topic, $two, $one);
87 forks_from
($topic, $one, $two);
89 push @
{$topic->{$one}{'shares'}}, $two;
90 push @
{$topic->{$two}{'shares'}}, $one;
95 Inspect the current set of topics
101 'tipdate' => date of the tip commit,
102 'desc' => description string,
103 'log' => [ $commit,... ],
110 my (@base) = qw(master next pu);
113 qw(git for-each-ref),
114 "--format=%(refname:short) %(committerdate:iso8601)",
116 or die "$!: open for-each-ref";
122 my ($branch, $date) = /^(\S+) (.*)$/;
123 push @topic, $branch;
130 close($fh) or die "$!: close for-each-ref";
132 my %base = map { $_ => undef } @base;
134 my $show_branch_batch = 20;
137 my @t = (@base, splice(@topic, 0, $show_branch_batch));
138 my $header_delim = '-' x
scalar(@t);
139 my $contain_pat = '.' x
scalar(@t);
140 open($fh, '-|', qw(git show-branch --sparse --sha1-name),
141 map { "refs/heads/$_" } @t)
142 or die "$!: open show-branch";
146 if (/^$header_delim$/) {
147 $header_delim = undef;
151 my ($contain, $sha1, $log) =
152 ($_ =~ /^($contain_pat) \[([0-9a-f]+)\] (.*)$/);
154 for (my $i = 0; $i < @t; $i++) {
156 my $sign = substr($contain, $i, 1);
157 next if ($sign eq ' ');
158 next if (substr($contain, 0, 1) ne ' ');
160 if (!exists $commit{$sha1}) {
166 my $co = $commit{$sha1};
167 if (!exists $reverts{$branch}{$sha1}) {
168 $co->{'branch'}{$branch} = 1;
170 next if (exists $base{$branch});
171 push @
{$topic{$branch}{'log'}}, $sha1;
174 close($fh) or die "$!: close show-branch";
178 for my $sha1 (keys %commit) {
180 my $co = $commit{$sha1};
181 if (exists $co->{'branch'}{'next'}) {
183 } elsif (exists $co->{'branch'}{'pu'}) {
188 $co->{'log'} = $sign . ' ' . $co->{'log'};
189 my @t = (sort grep { !exists $base{$_} }
190 keys %{$co->{'branch'}});
196 for my $combo (keys %shared) {
197 my @combo = split(' ', $combo);
198 for (my $i = 0; $i < @combo - 1; $i++) {
199 for (my $j = $i + 1; $j < @combo; $j++) {
200 topic_relation
(\
%topic, $combo[$i], $combo[$j]);
206 qw(git log --first-parent --abbrev=7),
207 "--format=%ci %h %p :%s", "master..next")
208 or die "$!: open log master..next";
210 my ($date, $commit, $parent, $tips);
211 unless (($date, $commit, $parent, $tips) =
212 /^([-0-9]+) ..:..:.. .\d{4} (\S+) (\S+) ([^:]*):/) {
215 for my $tip (split(' ', $tips)) {
216 my $co = $commit{$tip};
217 next unless ($co->{'branch'}{'next'});
218 $co->{'merged'} = " (merged to 'next' on $date at $commit)";
221 close($fh) or die "$!: close log master..next";
223 for my $branch (keys %topic) {
225 my $n = scalar(@
{$topic{$branch}{'log'}});
227 delete $topic{$branch};
234 my $d = $topic{$branch}{'tipdate'};
235 my $head = "* $branch ($d) $n\n";
237 for (@
{$topic{$branch}{'log'}}) {
238 my $co = $commit{$_};
239 if (exists $co->{'merged'}) {
240 push @desc, $co->{'merged'};
242 push @desc, $commit{$_}->{'log'};
250 my $list = join("\n", map { " " . $_ } @desc);
251 my $relation = describe_relation
($topic{$branch});
252 $topic{$branch}{'desc'} = $head . $list;
254 $topic{$branch}{'desc'} .= "\n $relation";
262 my ($mon, $year, $issue, $dow, $date,
263 $master_at, $next_at, $text) = @_;
265 my $now_string = localtime;
266 my ($current_dow, $current_mon, $current_date, $current_year) =
267 ($now_string =~ /^(\w+) (\w+) (\d+) [\d:]+ (\d+)$/);
269 $mon ||= $current_mon;
270 $year ||= $current_year;
272 $dow ||= $current_dow;
273 $date ||= $current_date;
274 $master_at ||= '0' x
40;
275 $next_at ||= '0' x
40;
277 Here are the topics that have been cooking. Commits prefixed with '-' are
278 only in 'pu' (proposed updates) while commits prefixed with '+' are in 'next'.
279 The ones marked with '.' do not appear in any of the integration branches,
280 but I am still holding onto them.
282 You can find the changes described here in the integration branches of the
283 repositories listed at
285 http://git-blame.blogspot.com/p/git-public-repositories.html
289 To: git\@vger.kernel.org
291 Subject: What's cooking in git.git ($mon $year, #$issue; $dow, $date)
292 X-master-at: $master_at
295 What's cooking in git.git ($mon $year, #$issue; $dow, $date)
296 --------------------------------------------------
300 $text =~ s/\n+\Z/\n/;
304 my $blurb_match = <<'EOF';
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})
309 What's cooking in \S+ \(\1 \2, #\3; \4, \5\)
314 my $blurb = "b..l..u..r..b";
321 my $last_empty = undef;
322 my (@section, %section, @branch, %branch, %description, @leader);
323 my $in_unedited_olde = 0;
327 'section_list' => [],
328 'section_data' => {},
329 'topic_description' => {
332 text
=> blurb_text
(),
338 open ($fh, '<', $fn) or die "$!: open $fn";
342 if ($in_unedited_olde) {
344 $in_unedited_olde = 0;
348 $in_unedited_olde = 1;
351 if ($in_unedited_olde) {
355 if (defined $section && /^-{20,}$/) {
362 if (/^\[(.*)\]\s*$/) {
365 if (!exists $section{$section}) {
366 push @section, $section;
367 $section{$section} = [];
371 if (defined $section && /^\* (\S+) /) {
374 if (!exists $branch{$branch}) {
375 push @branch, [$branch, $section];
376 $branch{$branch} = 1;
378 push @
{$section{$section}}, $branch;
380 if (defined $branch) {
381 my $was_last_empty = $last_empty;
383 if (!exists $description{$branch}) {
384 $description{$branch} = [];
386 if ($was_last_empty) {
387 push @
{$description{$branch}}, "";
389 push @
{$description{$branch}}, $_;
395 for my $branch (keys %description) {
396 my $ary = $description{$branch};
397 if ($branch eq $blurb) {
398 while (@
{$ary} && $ary->[-1] =~ /^-{30,}$/) {
401 $description{$branch} = +{
403 text
=> join("\n", @
{$ary}),
408 my $elem = shift @
{$ary};
409 last if ($elem eq '');
419 $description{$branch} = +{
420 desc
=> join("\n", @desc),
421 text
=> join("\n", @txt),
427 section_list
=> \
@section,
428 section_data
=> \
%section,
429 topic_description
=> \
%description,
434 my ($fn, $cooking) = @_;
437 open($fh, '>', $fn) or die "$!: open $fn";
438 print $fh $cooking->{'topic_description'}{$blurb}{'text'};
440 for my $section_name (@
{$cooking->{'section_list'}}) {
441 my $topic_list = $cooking->{'section_data'}{$section_name};
442 next if (!@
{$topic_list});
445 print $fh '-' x
50, "\n";
446 print $fh "[$section_name]\n";
448 for my $topic (@
{$topic_list}) {
449 my $d = $cooking->{'topic_description'}{$topic};
451 print $fh $lead, $d->{'desc'}, "\n";
453 print $fh "\n", $d->{'text'}, "\n";
461 my $graduated = 'Graduated to "master"';
462 my $new_topics = 'New Topics';
463 my $discarded = 'Discarded';
464 my $old_new_topics = 'Old New Topics';
468 my ($fh, $master_at, $next_at, $incremental);
471 qw(git for-each-ref),
472 "--format=%(refname:short) %(objectname)",
474 "refs/heads/next") or die "$!: open for-each-ref";
476 my ($branch, $at) = /^(\S+) (\S+)$/;
477 if ($branch eq 'master') { $master_at = $at; }
478 if ($branch eq 'next') { $next_at = $at; }
480 close($fh) or die "$!: close for-each-ref";
482 $incremental = ((-r
"Meta/whats-cooking.txt") &&
483 system("cd Meta && " .
484 "git diff --quiet --no-ext-diff HEAD -- " .
485 "whats-cooking.txt"));
487 my $now_string = localtime;
488 my ($current_dow, $current_mon, $current_date, $current_year) =
489 ($now_string =~ /^(\w+) (\w+) +(\d+) [\d:]+ (\d+)$/);
491 my $btext = $cooking->{'topic_description'}{$blurb}{'text'};
492 if ($btext !~ s/\A$blurb_match//) {
493 die "match pattern broken?";
495 my ($mon, $year, $issue, $dow, $date) = ($1, $2, $3, $4, $5);
497 if ($current_mon ne $mon || $current_year ne $year) {
499 } elsif (!$incremental) {
501 $issue = sprintf "%02d", ($issue + 1);
504 $year = $current_year;
506 $date = $current_date;
508 $cooking->{'topic_description'}{$blurb}{'text'} =
509 blurb_text
($mon, $year, $issue, $dow, $date,
510 $master_at, $next_at, $btext);
513 my $sd = $cooking->{'section_data'};
514 my $sl = $cooking->{'section_list'};
515 # Rename "New" to "Old New" and insert "New".
516 # Move "New" to "Old New"
519 for ($i = 0; $i < @
{$sl}; $i++) {
520 if ($sl->[$i] eq $new_topics) {
521 $sl->[$i] = $old_new_topics;
522 unshift @
{$sl}, $new_topics;
528 $sd->{$old_new_topics} = $sd->{$new_topics};
530 $sd->{$new_topics} = [];
537 my ($topic_desc) = @_;
538 for my $line (split(/\n/, $topic_desc)) {
539 if ($line =~ /^ [+-] /) {
547 my ($cooking, $current) = @_;
548 my $td = $cooking->{'topic_description'};
549 my $sd = $cooking->{'section_data'};
550 my $sl = $cooking->{'section_list'};
551 my (@new_topic, @gone_topic);
553 # Make sure "New Topics" and "Graduated" exists
554 if (!exists $sd->{$new_topics}) {
555 $sd->{$new_topics} = [];
556 unshift @
{$sl}, $new_topics;
559 if (!exists $sd->{$graduated}) {
560 $sd->{$graduated} = [];
561 unshift @
{$sl}, $graduated;
564 my $incremental = update_issue
($cooking);
566 for my $topic (sort keys %{$current}) {
567 if (!exists $td->{$topic}) {
568 # Ignore new topics without anything merged
569 if (topic_in_pu
($current->{$topic}{'desc'})) {
570 push @new_topic, $topic;
574 # Annotate if the contents of the topic changed
575 my $n = $current->{$topic}{'desc'};
576 my $o = $td->{$topic}{'desc'};
578 $td->{$topic}{'desc'} = $n . "\n<<\n" . $o ."\n>>";
582 for my $topic (sort keys %{$td}) {
583 next if ($topic eq $blurb);
584 next if (!$incremental &&
585 grep { $topic eq $_ } @
{$sd->{$graduated}});
586 next if (grep { $topic eq $_ } @
{$sd->{$discarded}});
587 if (!exists $current->{$topic}) {
588 push @gone_topic, $topic;
593 push @
{$sd->{$new_topics}}, $_;
594 $td->{$_}{'desc'} = $current->{$_}{'desc'};
598 $sd->{$graduated} = [];
602 for my $topic (@gone_topic) {
603 for my $section (@
{$sl}) {
604 my $pre = scalar(@
{$sd->{$section}});
605 @
{$sd->{$section}} = (grep { $_ ne $topic }
607 my $post = scalar(@
{$sd->{$section}});
608 next if ($pre == $post);
612 push @
{$sd->{$graduated}}, $_;
617 ################################################################
620 my ($what, $action, $topic) = @_;
621 if (!exists $what->{$action}) {
622 $what->{$action} = [];
624 push @
{$what->{$action}}, $topic;
631 return if (/^Graduated to/ || /^Discarded$/);
632 return $_ if (/^Stalled$/);
638 sub wildo_flush_topic
{
639 my ($in_section, $what, $topic) = @_;
640 if (defined $topic) {
641 my $action = section_action
($in_section);
643 wildo_queue
($what, $action, $topic);
649 if (/^Will (?:\S+ ){0,2}(fast-track|keep|merge|drop|discard|cook|kick|defer|be re-?rolled)[,. ]/ ||
650 /^Not urgent/ || /^Not ready/ || /^Waiting for / ||
651 /^Needs? / || /^Expecting / || /^May want to /) {
658 my (%what, $topic, $last_merge_to_next, $in_section, $in_desc);
659 my $too_recent = '9999-99-99';
664 my $old_section = $in_section;
666 wildo_flush_topic
($old_section, \
%what, $topic);
667 $topic = $in_desc = undef;
671 if (/^\* (\S+) \(([-0-9]+)\) (\d+) commits?$/) {
672 wildo_flush_topic
($in_section, \
%what, $topic);
674 # tip-date, next-date, topic, count, pu-count
675 $topic = [$2, $too_recent, $1, $3, 0];
680 if (defined $topic &&
681 ($topic->[1] eq $too_recent) &&
682 ($topic->[4] == 0) &&
683 (/^ \(merged to 'next' on ([-0-9]+)/)) {
686 if (defined $topic && /^ - /) {
690 if (defined $topic && /^$/) {
695 next unless defined $topic && $in_desc;
698 if (wildo_match
($_)) {
699 wildo_queue
(\
%what, $_, $topic);
700 $topic = $in_desc = undef;
703 if (/Originally merged to 'next' on ([-0-9]+)/) {
707 wildo_flush_topic
($in_section, \
%what, $topic);
710 for my $what (sort keys %what) {
711 print "$ipbl$what\n";
712 for $topic (sort { (($a->[1] cmp $b->[1]) ||
713 ($a->[0] cmp $b->[0])) }
715 my ($tip, $next, $name, $count, $pu) = @
$topic;
718 if (($next eq $too_recent) || (0 < $pu)) {
723 $next =~ s
|^\d
{4}-|/|;
726 printf " %s %-60s %s%s %5s\n", $sign, $name, $tip, $next, $count;
732 ################################################################
742 for $str (split(/\n/, $str)) {
743 print "$prefix$str\n";
750 my $cnt = `git rev-list --count @range`;
759 my ($topic, $to_maint, %to_maint, %merged, $in_desc);
762 qw(git rev-list --first-parent -1 master Documentation/RelNotes))
763 or die "$!: open rev-list";
765 close($fh) or die "$!: close rev-list";
767 @ARGV = ("$rev..master");
770 qw(git log --first-parent --oneline --reverse), @ARGV)
771 or die "$!: open log --first-parent";
773 my ($sha1, $branch) = /^([0-9a-f]+) Merge branch '(.*)'$/;
775 $topic{$branch} = "";
776 $merged{$branch} = $sha1;
777 push @topic, $branch;
779 close($fh) or die "$!: close log --first-parent";
780 open($fh, "<", "Meta/whats-cooking.txt")
781 or die "$!: open whats-cooking";
786 $in_desc = $topic = undef;
789 if (/^\* (\S+) \([-0-9]+\) \d+ commits?$/) {
790 if (exists $topic{$1}) {
794 $in_desc = $topic = undef;
798 if (defined $topic && /^$/) {
803 next unless defined $topic && $in_desc;
806 if (wildo_match
($_)) {
809 $topic{$topic} .= "$_\n";
811 close($fh) or die "$!: close whats-cooking";
813 for $topic (@topic) {
814 my $merged = $merged{$topic};
815 my $in_master = havedone_count
("$merged^1..$merged^2");
816 my $not_in_maint = havedone_count
("maint..$merged^2");
817 if ($in_master == $not_in_maint) {
818 $to_maint{$topic} = 1;
823 for $topic (@topic) {
824 next if (exists $to_maint{$topic});
825 havedone_show
($topic, $topic{$topic});
831 print "-" x
64, "\n";
834 for $topic (@topic) {
835 next unless (exists $to_maint{$topic});
836 havedone_show
($topic, $topic{$topic});
837 my $sha1 = `git rev-parse --short $topic`;
839 print " (merge $sha1 $topic later to maint).\n";
844 ################################################################
848 my $topic = get_commit
();
849 my $cooking = read_previous
('Meta/whats-cooking.txt');
850 merge_cooking
($cooking, $topic);
851 write_cooking
('Meta/whats-cooking.txt', $cooking);
854 ################################################################
861 if (!GetOptions
("wildo" => \
$wildo, "havedone" => \
$havedone)) {
862 print STDERR
"$0 [--wildo|--havedone]\n";
868 push @ARGV, "Meta/whats-cooking.txt";
871 } elsif ($havedone) {