2 # Maintain "what's cooking" messages
6 my %reverts = ('next' => {
15 for (my $i = 0; $i < @u; $i++) {
19 } elsif ($i < @u - 2) {
26 sub describe_relation
{
27 my ($topic_info) = @_;
30 if (exists $topic_info->{'used'}) {
31 push @desc, ("is used by " .
32 phrase_these
(@
{$topic_info->{'used'}}));
35 if (exists $topic_info->{'uses'}) {
36 push @desc, ("uses " .
37 phrase_these
(@
{$topic_info->{'uses'}}));
40 if (exists $topic_info->{'shares'}) {
41 push @desc, ("is tangled with " .
42 phrase_these
(@
{$topic_info->{'shares'}}));
49 return "(this branch " . join("; ", @desc) . ".)";
53 my ($topic, $fork, $forkee, @overlap) = @_;
54 my %ovl = map { $_ => 1 } (@overlap, @
{$topic->{$forkee}{'log'}});
56 push @
{$topic->{$fork}{'uses'}}, $forkee;
57 push @
{$topic->{$forkee}{'used'}}, $fork;
58 @
{$topic->{$fork}{'log'}} = (grep { !exists $ovl{$_} }
59 @
{$topic->{$fork}{'log'}});
63 my ($topic, $one, $two) = @_;
67 qw(git log --abbrev=7), "--format=%m %h",
68 "$one...$two", "^master")
69 or die "$!: open log --left-right";
72 my ($sign, $sha1) = /^(.) (.*)/;
75 } elsif ($sign eq '>') {
79 close($fh) or die "$!: close log --left-right";
83 forks_from
($topic, $two, $one);
86 forks_from
($topic, $one, $two);
88 push @
{$topic->{$one}{'shares'}}, $two;
89 push @
{$topic->{$two}{'shares'}}, $one;
94 Inspect the current set of topics
100 'tipdate' => date of the tip commit,
101 'desc' => description string,
102 'log' => [ $commit,... ],
109 my (@base) = qw(master next pu);
112 qw(git for-each-ref),
113 "--format=%(refname:short) %(committerdate:iso8601)",
115 or die "$!: open for-each-ref";
121 my ($branch, $date) = /^(\S+) (.*)$/;
122 push @topic, $branch;
129 close($fh) or die "$!: close for-each-ref";
131 my %base = map { $_ => undef } @base;
133 my $show_branch_batch = 20;
136 my @t = (@base, splice(@topic, 0, $show_branch_batch));
137 my $header_delim = '-' x
scalar(@t);
138 my $contain_pat = '.' x
scalar(@t);
139 open($fh, '-|', qw(git show-branch --sparse --sha1-name),
140 map { "refs/heads/$_" } @t)
141 or die "$!: open show-branch";
145 if (/^$header_delim$/) {
146 $header_delim = undef;
150 my ($contain, $sha1, $log) =
151 ($_ =~ /^($contain_pat) \[([0-9a-f]+)\] (.*)$/);
153 for (my $i = 0; $i < @t; $i++) {
155 my $sign = substr($contain, $i, 1);
156 next if ($sign eq ' ');
157 next if (substr($contain, 0, 1) ne ' ');
159 if (!exists $commit{$sha1}) {
165 my $co = $commit{$sha1};
166 if (!exists $reverts{$branch}{$sha1}) {
167 $co->{'branch'}{$branch} = 1;
169 next if (exists $base{$branch});
170 push @
{$topic{$branch}{'log'}}, $sha1;
173 close($fh) or die "$!: close show-branch";
177 for my $sha1 (keys %commit) {
179 my $co = $commit{$sha1};
180 if (exists $co->{'branch'}{'next'}) {
182 } elsif (exists $co->{'branch'}{'pu'}) {
187 $co->{'log'} = $sign . ' ' . $co->{'log'};
188 my @t = (sort grep { !exists $base{$_} }
189 keys %{$co->{'branch'}});
195 for my $combo (keys %shared) {
196 my @combo = split(' ', $combo);
197 for (my $i = 0; $i < @combo - 1; $i++) {
198 for (my $j = $i + 1; $j < @combo; $j++) {
199 topic_relation
(\
%topic, $combo[$i], $combo[$j]);
205 qw(git log --first-parent --abbrev=7),
206 "--format=%ci %h %p :%s", "master..next")
207 or die "$!: open log master..next";
209 my ($date, $commit, $parent, $tips);
210 unless (($date, $commit, $parent, $tips) =
211 /^([-0-9]+) ..:..:.. .\d{4} (\S+) (\S+) ([^:]*):/) {
214 for my $tip (split(' ', $tips)) {
215 my $co = $commit{$tip};
216 next unless ($co->{'branch'}{'next'});
217 $co->{'merged'} = " (merged to 'next' on $date at $commit)";
220 close($fh) or die "$!: close log master..next";
222 for my $branch (keys %topic) {
224 my $n = scalar(@
{$topic{$branch}{'log'}});
226 delete $topic{$branch};
233 my $d = $topic{$branch}{'tipdate'};
234 my $head = "* $branch ($d) $n\n";
236 for (@
{$topic{$branch}{'log'}}) {
237 my $co = $commit{$_};
238 if (exists $co->{'merged'}) {
239 push @desc, $co->{'merged'};
241 push @desc, $commit{$_}->{'log'};
243 my $list = join("\n", map { " " . $_ } @desc);
244 my $relation = describe_relation
($topic{$branch});
245 $topic{$branch}{'desc'} = $head . $list;
247 $topic{$branch}{'desc'} .= "\n $relation";
255 my ($mon, $year, $issue, $dow, $date,
256 $master_at, $next_at, $text) = @_;
258 my $now_string = localtime;
259 my ($current_dow, $current_mon, $current_date, $current_year) =
260 ($now_string =~ /^(\w+) (\w+) (\d+) [\d:]+ (\d+)$/);
262 $mon ||= $current_mon;
263 $year ||= $current_year;
265 $dow ||= $current_dow;
266 $date ||= $current_date;
267 $master_at ||= '0' x
40;
268 $next_at ||= '0' x
40;
270 Here are the topics that have been cooking. Commits prefixed with '-' are
271 only in 'pu' while commits prefixed with '+' are in 'next'. The ones
272 marked with '.' do not appear in any of the integration branches, but I am
273 still holding onto them.
277 To: git\@vger.kernel.org
278 Subject: What's cooking in git.git ($mon $year, #$issue; $dow, $date)
279 X-master-at: $master_at
282 What's cooking in git.git ($mon $year, #$issue; $dow, $date)
283 --------------------------------------------------
287 $text =~ s/\n+\Z/\n/;
291 my $blurb_match = <<'EOF';
293 Subject: What's cooking in \S+ \((\w+) (\d+), #(\d+); (\w+), (\d+)\)
294 X-master-at: ([0-9a-f]{40})
295 X-next-at: ([0-9a-f]{40})
297 What's cooking in \S+ \(\1 \2, #\3; \4, \5\)
302 my $blurb = "b..l..u..r..b";
309 my $last_empty = undef;
310 my (@section, %section, @branch, %branch, %description, @leader);
311 my $in_unedited_olde = 0;
315 'section_list' => [],
316 'section_data' => {},
317 'topic_description' => {
320 text
=> blurb_text
(),
326 open ($fh, '<', $fn) or die "$!: open $fn";
329 if ($in_unedited_olde) {
331 $in_unedited_olde = 0;
335 $in_unedited_olde = 1;
338 if ($in_unedited_olde) {
342 if (defined $section && /^-{20,}$/) {
349 if (/^\[(.*)\]\s*$/) {
352 if (!exists $section{$section}) {
353 push @section, $section;
354 $section{$section} = [];
358 if (defined $section && /^\* (\S+) /) {
361 if (!exists $branch{$branch}) {
362 push @branch, [$branch, $section];
363 $branch{$branch} = 1;
365 push @
{$section{$section}}, $branch;
367 if (defined $branch) {
368 my $was_last_empty = $last_empty;
370 if (!exists $description{$branch}) {
371 $description{$branch} = [];
373 if ($was_last_empty) {
374 push @
{$description{$branch}}, "";
376 push @
{$description{$branch}}, $_;
381 for my $branch (keys %description) {
382 my $ary = $description{$branch};
383 if ($branch eq $blurb) {
384 while (@
{$ary} && $ary->[-1] =~ /^-{30,}$/) {
387 $description{$branch} = +{
389 text
=> join("\n", @
{$ary}),
394 my $elem = shift @
{$ary};
395 last if ($elem eq '');
398 $description{$branch} = +{
399 desc
=> join("\n", @desc),
400 text
=> join("\n", @
{$ary}),
406 section_list
=> \
@section,
407 section_data
=> \
%section,
408 topic_description
=> \
%description,
413 my ($fn, $cooking) = @_;
416 open($fh, '>', $fn) or die "$!: open $fn";
417 print $fh $cooking->{'topic_description'}{$blurb}{'text'};
419 for my $section_name (@
{$cooking->{'section_list'}}) {
420 my $topic_list = $cooking->{'section_data'}{$section_name};
421 next if (!@
{$topic_list});
424 print $fh '-' x
50, "\n";
425 print $fh "[$section_name]\n";
426 for my $topic (@
{$topic_list}) {
427 my $d = $cooking->{'topic_description'}{$topic};
429 print $fh "\n", $d->{'desc'}, "\n";
431 print $fh "\n", $d->{'text'}, "\n";
438 my $graduated = 'Graduated to "master"';
439 my $new_topics = 'New Topics';
440 my $old_new_topics = 'Old New Topics';
444 my ($fh, $master_at, $next_at, $incremental);
447 qw(git for-each-ref),
448 "--format=%(refname:short) %(objectname)",
450 "refs/heads/next") or die "$!: open for-each-ref";
452 my ($branch, $at) = /^(\S+) (\S+)$/;
453 if ($branch eq 'master') { $master_at = $at; }
454 if ($branch eq 'next') { $next_at = $at; }
456 close($fh) or die "$!: close for-each-ref";
458 $incremental = ((-r
"Meta/whats-cooking.txt") &&
459 system("cd Meta && " .
460 "git diff --quiet --no-ext-diff HEAD -- " .
461 "whats-cooking.txt"));
463 my $now_string = localtime;
464 my ($current_dow, $current_mon, $current_date, $current_year) =
465 ($now_string =~ /^(\w+) (\w+) +(\d+) [\d:]+ (\d+)$/);
467 my $btext = $cooking->{'topic_description'}{$blurb}{'text'};
468 if ($btext !~ s/\A$blurb_match//) {
469 die "match pattern broken?";
471 my ($mon, $year, $issue, $dow, $date) = ($1, $2, $3, $4, $5);
473 if ($current_mon ne $mon || $current_year ne $year) {
475 } elsif (!$incremental) {
477 $issue = sprintf "%02d", ($issue + 1);
480 $year = $current_year;
482 $date = $current_date;
484 $cooking->{'topic_description'}{$blurb}{'text'} =
485 blurb_text
($mon, $year, $issue, $dow, $date,
486 $master_at, $next_at, $btext);
489 my $sd = $cooking->{'section_data'};
490 my $sl = $cooking->{'section_list'};
491 # Rename "New" to "Old New" and insert "New".
492 # Move "New" to "Old New"
495 for ($i = 0; $i < @
{$sl}; $i++) {
496 if ($sl->[$i] eq $new_topics) {
497 $sl->[$i] = $old_new_topics;
498 unshift @
{$sl}, $new_topics;
504 $sd->{$old_new_topics} = $sd->{$new_topics};
506 $sd->{$new_topics} = [];
513 my ($topic_desc) = @_;
514 for my $line (split(/\n/, $topic_desc)) {
515 if ($line =~ /^ [+-] /) {
523 my ($cooking, $current) = @_;
524 my $td = $cooking->{'topic_description'};
525 my $sd = $cooking->{'section_data'};
526 my $sl = $cooking->{'section_list'};
527 my (@new_topic, @gone_topic);
529 # Make sure "New Topics" and "Graduated" exists
530 if (!exists $sd->{$new_topics}) {
531 $sd->{$new_topics} = [];
532 unshift @
{$sl}, $new_topics;
535 if (!exists $sd->{$graduated}) {
536 $sd->{$graduated} = [];
537 unshift @
{$sl}, $graduated;
540 my $incremental = update_issue
($cooking);
542 for my $topic (sort keys %{$current}) {
543 if (!exists $td->{$topic}) {
544 # Ignore new topics without anything merged
545 if (topic_in_pu
($current->{$topic}{'desc'})) {
546 push @new_topic, $topic;
550 my $n = $current->{$topic}{'desc'};
551 my $o = $td->{$topic}{'desc'};
553 $td->{$topic}{'desc'} = $n . "\n<<\n" . $o ."\n>>";
557 for my $topic (sort keys %{$td}) {
558 next if ($topic eq $blurb);
559 next if (!$incremental &&
560 grep { $topic eq $_ } @
{$sd->{$graduated}});
561 if (!exists $current->{$topic}) {
562 push @gone_topic, $topic;
567 push @
{$sd->{$new_topics}}, $_;
568 $td->{$_}{'desc'} = $current->{$_}{'desc'};
572 $sd->{$graduated} = [];
576 for my $topic (@gone_topic) {
577 for my $section (@
{$sl}) {
578 my $pre = scalar(@
{$sd->{$section}});
579 @
{$sd->{$section}} = (grep { $_ ne $topic }
581 my $post = scalar(@
{$sd->{$section}});
582 next if ($pre == $post);
586 push @
{$sd->{$graduated}}, $_;
591 ################################################################
594 my ($what, $action, $topic) = @_;
595 if (!exists $what->{$action}) {
596 $what->{$action} = [];
598 push @
{$what->{$action}}, $topic;
602 my (%what, $topic, $last_merge_to_next);
603 my $too_recent = '9999-99-99';
607 next if (/^\[Graduated to/../^-{20,}$/);
608 next if (/^\[Stalled\]/../^-{20,}$/);
609 next if (/^\[Discarded\]/../^-{20,}$/);
611 if (/^\* (\S+) \(([-0-9]+)\) (\d+) commits?$/) {
612 if (defined $topic) {
613 wildo_queue
(\
%what, "Undecided", $topic);
615 # tip-date, next-date, topic, count, pu-count
616 $topic = [$2, $too_recent, $1, $3, 0];
619 if (defined $topic &&
620 ($topic->[1] eq $too_recent) &&
621 ($topic->[4] == 0) &&
622 (/^ \(merged to 'next' on ([-0-9]+)/)) {
625 if (defined $topic && /^ - /) {
629 if (defined $topic &&
630 /Will (?:\S+ )?(merge|drop|discard|cook)[. ]/i) {
631 wildo_queue
(\
%what, $_, $topic);
635 if (defined $topic) {
636 wildo_queue
(\
%what, "Undecided", $topic);
639 for my $what (sort keys %what) {
640 print "$ipbl$what\n";
641 for $topic (sort { (($a->[1] cmp $b->[1]) ||
642 ($a->[0] cmp $b->[0])) }
644 my ($tip, $next, $name, $count, $pu) = @
$topic;
647 if (($next eq $too_recent) || (0 < $pu)) {
652 $next =~ s
|^\d
{4}-|/|;
655 printf " %s %-60s %s%s %5s\n", $sign, $name, $tip, $next, $count;
661 ################################################################
665 my $topic = get_commit
();
666 my $cooking = read_previous
('Meta/whats-cooking.txt');
667 merge_cooking
($cooking, $topic);
668 write_cooking
('Meta/whats-cooking.txt', $cooking);
671 ################################################################
677 if (!GetOptions
("wildo" => \
$wildo)) {
678 print STDERR
"$0 [--wildo]";
684 push @ARGV, "Meta/whats-cooking.txt";