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'};
244 my $list = join("\n", map { " " . $_ } @desc);
245 my $relation = describe_relation
($topic{$branch});
246 $topic{$branch}{'desc'} = $head . $list;
248 $topic{$branch}{'desc'} .= "\n $relation";
256 my ($mon, $year, $issue, $dow, $date,
257 $master_at, $next_at, $text) = @_;
259 my $now_string = localtime;
260 my ($current_dow, $current_mon, $current_date, $current_year) =
261 ($now_string =~ /^(\w+) (\w+) (\d+) [\d:]+ (\d+)$/);
263 $mon ||= $current_mon;
264 $year ||= $current_year;
266 $dow ||= $current_dow;
267 $date ||= $current_date;
268 $master_at ||= '0' x
40;
269 $next_at ||= '0' x
40;
271 Here are the topics that have been cooking. Commits prefixed with '-' are
272 only in 'pu' (proposed updates) while commits prefixed with '+' are in 'next'.
273 The ones marked with '.' do not appear in any of the integration branches,
274 but I am still holding onto them.
276 You can find the changes described here in the integration branches of the
277 repositories listed at
279 http://git-blame.blogspot.com/p/git-public-repositories.html
283 To: git\@vger.kernel.org
284 Subject: What's cooking in git.git ($mon $year, #$issue; $dow, $date)
285 X-master-at: $master_at
288 What's cooking in git.git ($mon $year, #$issue; $dow, $date)
289 --------------------------------------------------
293 $text =~ s/\n+\Z/\n/;
297 my $blurb_match = <<'EOF';
299 Subject: What's cooking in \S+ \((\w+) (\d+), #(\d+); (\w+), (\d+)\)
300 X-master-at: ([0-9a-f]{40})
301 X-next-at: ([0-9a-f]{40})
303 What's cooking in \S+ \(\1 \2, #\3; \4, \5\)
308 my $blurb = "b..l..u..r..b";
315 my $last_empty = undef;
316 my (@section, %section, @branch, %branch, %description, @leader);
317 my $in_unedited_olde = 0;
321 'section_list' => [],
322 'section_data' => {},
323 'topic_description' => {
326 text
=> blurb_text
(),
332 open ($fh, '<', $fn) or die "$!: open $fn";
335 if ($in_unedited_olde) {
337 $in_unedited_olde = 0;
341 $in_unedited_olde = 1;
344 if ($in_unedited_olde) {
348 if (defined $section && /^-{20,}$/) {
355 if (/^\[(.*)\]\s*$/) {
358 if (!exists $section{$section}) {
359 push @section, $section;
360 $section{$section} = [];
364 if (defined $section && /^\* (\S+) /) {
367 if (!exists $branch{$branch}) {
368 push @branch, [$branch, $section];
369 $branch{$branch} = 1;
371 push @
{$section{$section}}, $branch;
373 if (defined $branch) {
374 my $was_last_empty = $last_empty;
376 if (!exists $description{$branch}) {
377 $description{$branch} = [];
379 if ($was_last_empty) {
380 push @
{$description{$branch}}, "";
382 push @
{$description{$branch}}, $_;
387 for my $branch (keys %description) {
388 my $ary = $description{$branch};
389 if ($branch eq $blurb) {
390 while (@
{$ary} && $ary->[-1] =~ /^-{30,}$/) {
393 $description{$branch} = +{
395 text
=> join("\n", @
{$ary}),
400 my $elem = shift @
{$ary};
401 last if ($elem eq '');
404 $description{$branch} = +{
405 desc
=> join("\n", @desc),
406 text
=> join("\n", @
{$ary}),
412 section_list
=> \
@section,
413 section_data
=> \
%section,
414 topic_description
=> \
%description,
419 my ($fn, $cooking) = @_;
422 open($fh, '>', $fn) or die "$!: open $fn";
423 print $fh $cooking->{'topic_description'}{$blurb}{'text'};
425 for my $section_name (@
{$cooking->{'section_list'}}) {
426 my $topic_list = $cooking->{'section_data'}{$section_name};
427 next if (!@
{$topic_list});
430 print $fh '-' x
50, "\n";
431 print $fh "[$section_name]\n";
432 for my $topic (@
{$topic_list}) {
433 my $d = $cooking->{'topic_description'}{$topic};
435 print $fh "\n", $d->{'desc'}, "\n";
437 print $fh "\n", $d->{'text'}, "\n";
444 my $graduated = 'Graduated to "master"';
445 my $new_topics = 'New Topics';
446 my $discarded = 'Discarded';
447 my $old_new_topics = 'Old New Topics';
451 my ($fh, $master_at, $next_at, $incremental);
454 qw(git for-each-ref),
455 "--format=%(refname:short) %(objectname)",
457 "refs/heads/next") or die "$!: open for-each-ref";
459 my ($branch, $at) = /^(\S+) (\S+)$/;
460 if ($branch eq 'master') { $master_at = $at; }
461 if ($branch eq 'next') { $next_at = $at; }
463 close($fh) or die "$!: close for-each-ref";
465 $incremental = ((-r
"Meta/whats-cooking.txt") &&
466 system("cd Meta && " .
467 "git diff --quiet --no-ext-diff HEAD -- " .
468 "whats-cooking.txt"));
470 my $now_string = localtime;
471 my ($current_dow, $current_mon, $current_date, $current_year) =
472 ($now_string =~ /^(\w+) (\w+) +(\d+) [\d:]+ (\d+)$/);
474 my $btext = $cooking->{'topic_description'}{$blurb}{'text'};
475 if ($btext !~ s/\A$blurb_match//) {
476 die "match pattern broken?";
478 my ($mon, $year, $issue, $dow, $date) = ($1, $2, $3, $4, $5);
480 if ($current_mon ne $mon || $current_year ne $year) {
482 } elsif (!$incremental) {
484 $issue = sprintf "%02d", ($issue + 1);
487 $year = $current_year;
489 $date = $current_date;
491 $cooking->{'topic_description'}{$blurb}{'text'} =
492 blurb_text
($mon, $year, $issue, $dow, $date,
493 $master_at, $next_at, $btext);
496 my $sd = $cooking->{'section_data'};
497 my $sl = $cooking->{'section_list'};
498 # Rename "New" to "Old New" and insert "New".
499 # Move "New" to "Old New"
502 for ($i = 0; $i < @
{$sl}; $i++) {
503 if ($sl->[$i] eq $new_topics) {
504 $sl->[$i] = $old_new_topics;
505 unshift @
{$sl}, $new_topics;
511 $sd->{$old_new_topics} = $sd->{$new_topics};
513 $sd->{$new_topics} = [];
520 my ($topic_desc) = @_;
521 for my $line (split(/\n/, $topic_desc)) {
522 if ($line =~ /^ [+-] /) {
530 my ($cooking, $current) = @_;
531 my $td = $cooking->{'topic_description'};
532 my $sd = $cooking->{'section_data'};
533 my $sl = $cooking->{'section_list'};
534 my (@new_topic, @gone_topic);
536 # Make sure "New Topics" and "Graduated" exists
537 if (!exists $sd->{$new_topics}) {
538 $sd->{$new_topics} = [];
539 unshift @
{$sl}, $new_topics;
542 if (!exists $sd->{$graduated}) {
543 $sd->{$graduated} = [];
544 unshift @
{$sl}, $graduated;
547 my $incremental = update_issue
($cooking);
549 for my $topic (sort keys %{$current}) {
550 if (!exists $td->{$topic}) {
551 # Ignore new topics without anything merged
552 if (topic_in_pu
($current->{$topic}{'desc'})) {
553 push @new_topic, $topic;
557 # Annotate if the contents of the topic changed
558 my $n = $current->{$topic}{'desc'};
559 my $o = $td->{$topic}{'desc'};
561 $td->{$topic}{'desc'} = $n . "\n<<\n" . $o ."\n>>";
565 for my $topic (sort keys %{$td}) {
566 next if ($topic eq $blurb);
567 next if (!$incremental &&
568 grep { $topic eq $_ } @
{$sd->{$graduated}});
569 next if (grep { $topic eq $_ } @
{$sd->{$discarded}});
570 if (!exists $current->{$topic}) {
571 push @gone_topic, $topic;
576 push @
{$sd->{$new_topics}}, $_;
577 $td->{$_}{'desc'} = $current->{$_}{'desc'};
581 $sd->{$graduated} = [];
585 for my $topic (@gone_topic) {
586 for my $section (@
{$sl}) {
587 my $pre = scalar(@
{$sd->{$section}});
588 @
{$sd->{$section}} = (grep { $_ ne $topic }
590 my $post = scalar(@
{$sd->{$section}});
591 next if ($pre == $post);
595 push @
{$sd->{$graduated}}, $_;
600 ################################################################
603 my ($what, $action, $topic) = @_;
604 if (!exists $what->{$action}) {
605 $what->{$action} = [];
607 push @
{$what->{$action}}, $topic;
614 return if (/^Graduated to/ || /^Discarded$/);
615 return $_ if (/^Stalled$/);
621 sub wildo_flush_topic
{
622 my ($in_section, $what, $topic) = @_;
623 if (defined $topic) {
624 my $action = section_action
($in_section);
626 wildo_queue
($what, $action, $topic);
632 my (%what, $topic, $last_merge_to_next, $in_section);
633 my $too_recent = '9999-99-99';
638 my $old_section = $in_section;
640 wildo_flush_topic
($old_section, \
%what, $topic);
645 if (/^\* (\S+) \(([-0-9]+)\) (\d+) commits?$/) {
646 wildo_flush_topic
($in_section, \
%what, $topic);
648 # tip-date, next-date, topic, count, pu-count
649 $topic = [$2, $too_recent, $1, $3, 0];
653 if (defined $topic &&
654 ($topic->[1] eq $too_recent) &&
655 ($topic->[4] == 0) &&
656 (/^ \(merged to 'next' on ([-0-9]+)/)) {
659 if (defined $topic && /^ - /) {
663 next unless defined $topic;
665 if (/^Will (?:\S+ ){0,2}(keep|merge|drop|discard|cook|kick|defer)[,. ]/ ||
666 /^Not urgent/ || /^Not ready/ || /^Waiting for / ||
667 /^Needs? / || /Expecting /) {
668 wildo_queue
(\
%what, $_, $topic);
671 if (/^Not urgent;/) {
672 wildo_queue
(\
%what, $_, $topic);
675 if (/Originally merged to 'next' on ([-0-9]+)/) {
679 wildo_flush_topic
($in_section, \
%what, $topic);
682 for my $what (sort keys %what) {
683 print "$ipbl$what\n";
684 for $topic (sort { (($a->[1] cmp $b->[1]) ||
685 ($a->[0] cmp $b->[0])) }
687 my ($tip, $next, $name, $count, $pu) = @
$topic;
690 if (($next eq $too_recent) || (0 < $pu)) {
695 $next =~ s
|^\d
{4}-|/|;
698 printf " %s %-60s %s%s %5s\n", $sign, $name, $tip, $next, $count;
704 ################################################################
708 my $topic = get_commit
();
709 my $cooking = read_previous
('Meta/whats-cooking.txt');
710 merge_cooking
($cooking, $topic);
711 write_cooking
('Meta/whats-cooking.txt', $cooking);
714 ################################################################
720 if (!GetOptions
("wildo" => \
$wildo)) {
721 print STDERR
"$0 [--wildo]";
727 push @ARGV, "Meta/whats-cooking.txt";