2 # Maintain "what's cooking" messages
6 my %reverts = ('next' => {
27 for (my $i = 0; $i < @u; $i++) {
31 } elsif ($i < @u - 2) {
38 sub describe_relation
{
39 my ($topic_info) = @_;
42 if (exists $topic_info->{'used'}) {
43 push @desc, ("is used by " .
44 phrase_these
(@
{$topic_info->{'used'}}));
47 if (exists $topic_info->{'uses'}) {
48 push @desc, ("uses " .
49 phrase_these
(@
{$topic_info->{'uses'}}));
52 if (exists $topic_info->{'shares'}) {
53 push @desc, ("is tangled with " .
54 phrase_these
(@
{$topic_info->{'shares'}}));
61 return "(this branch " . join("; ", @desc) . ".)";
65 my ($topic, $fork, $forkee, @overlap) = @_;
66 my %ovl = map { $_ => 1 } (@overlap, @
{$topic->{$forkee}{'log'}});
68 push @
{$topic->{$fork}{'uses'}}, $forkee;
69 push @
{$topic->{$forkee}{'used'}}, $fork;
70 @
{$topic->{$fork}{'log'}} = (grep { !exists $ovl{$_} }
71 @
{$topic->{$fork}{'log'}});
75 my ($topic, $one, $two) = @_;
79 qw(git log --abbrev=7), "--format=%m %h",
80 "$one...$two", "^master")
81 or die "$!: open log --left-right";
84 my ($sign, $sha1) = /^(.) (.*)/;
87 } elsif ($sign eq '>') {
91 close($fh) or die "$!: close log --left-right";
95 forks_from
($topic, $two, $one);
98 forks_from
($topic, $one, $two);
100 push @
{$topic->{$one}{'shares'}}, $two;
101 push @
{$topic->{$two}{'shares'}}, $one;
106 Inspect the current set of topics
112 'tipdate' => date of the tip commit,
113 'desc' => description string,
114 'log' => [ $commit,... ],
121 my (@base) = qw(master next pu);
124 qw(git for-each-ref),
125 "--format=%(refname:short) %(authordate:iso8601)",
127 or die "$!: open for-each-ref";
133 my ($branch, $date) = /^(\S+) (.*)$/;
134 push @topic, $branch;
141 close($fh) or die "$!: close for-each-ref";
143 my %base = map { $_ => undef } @base;
145 my $show_branch_batch = 20;
148 my @t = (@base, splice(@topic, 0, $show_branch_batch));
149 my $header_delim = '-' x
scalar(@t);
150 my $contain_pat = '.' x
scalar(@t);
151 open($fh, '-|', qw(git show-branch --sparse --sha1-name),
152 map { "refs/heads/$_" } @t)
153 or die "$!: open show-branch";
157 if (/^$header_delim$/) {
158 $header_delim = undef;
162 my ($contain, $sha1, $log) =
163 ($_ =~ /^($contain_pat) \[([0-9a-f]+)\] (.*)$/);
165 for (my $i = 0; $i < @t; $i++) {
167 my $sign = substr($contain, $i, 1);
168 next if ($sign eq ' ');
169 next if (substr($contain, 0, 1) ne ' ');
171 if (!exists $commit{$sha1}) {
177 my $co = $commit{$sha1};
178 if (!exists $reverts{$branch}{$sha1}) {
179 $co->{'branch'}{$branch} = 1;
181 next if (exists $base{$branch});
182 push @
{$topic{$branch}{'log'}}, $sha1;
185 close($fh) or die "$!: close show-branch";
189 for my $sha1 (keys %commit) {
191 my $co = $commit{$sha1};
192 if (exists $co->{'branch'}{'next'}) {
194 } elsif (exists $co->{'branch'}{'pu'}) {
199 $co->{'log'} = $sign . ' ' . $co->{'log'};
200 my @t = (sort grep { !exists $base{$_} }
201 keys %{$co->{'branch'}});
207 for my $combo (keys %shared) {
208 my @combo = split(' ', $combo);
209 for (my $i = 0; $i < @combo - 1; $i++) {
210 for (my $j = $i + 1; $j < @combo; $j++) {
211 topic_relation
(\
%topic, $combo[$i], $combo[$j]);
217 qw(git log --first-parent --abbrev=7),
218 "--format=%ci %h %p :%s", "master..next")
219 or die "$!: open log master..next";
221 my ($date, $commit, $parent, $tips);
222 unless (($date, $commit, $parent, $tips) =
223 /^([-0-9]+) ..:..:.. .\d{4} (\S+) (\S+) ([^:]*):/) {
226 for my $tip (split(' ', $tips)) {
227 my $co = $commit{$tip};
228 next unless ($co->{'branch'}{'next'});
229 $co->{'merged'} = " (merged to 'next' on $date at $commit)";
232 close($fh) or die "$!: close log master..next";
234 for my $branch (keys %topic) {
236 my $n = scalar(@
{$topic{$branch}{'log'}});
238 delete $topic{$branch};
245 my $d = $topic{$branch}{'tipdate'};
246 my $head = "* $branch ($d) $n\n";
248 for (@
{$topic{$branch}{'log'}}) {
249 my $co = $commit{$_};
250 if (exists $co->{'merged'}) {
251 push @desc, $co->{'merged'};
253 push @desc, $commit{$_}->{'log'};
255 my $list = join("\n", map { " " . $_ } @desc);
256 my $relation = describe_relation
($topic{$branch});
257 $topic{$branch}{'desc'} = $head . $list;
259 $topic{$branch}{'desc'} .= "\n $relation";
267 my ($mon, $year, $issue, $dow, $date,
268 $master_at, $next_at, $text) = @_;
270 my $now_string = localtime;
271 my ($current_dow, $current_mon, $current_date, $current_year) =
272 ($now_string =~ /^(\w+) (\w+) (\d+) [\d:]+ (\d+)$/);
274 $mon ||= $current_mon;
275 $year ||= $current_year;
277 $dow ||= $current_dow;
278 $date ||= $current_date;
279 $master_at ||= '0' x
40;
280 $next_at ||= '0' x
40;
282 Here are the topics that have been cooking. Commits prefixed with '-' are
283 only in 'pu' while commits prefixed with '+' are in 'next'. The ones
284 marked with '.' do not appear in any of the integration branches, but I am
285 still holding onto them.
289 To: git\@vger.kernel.org
290 Subject: What's cooking in git.git ($mon $year, #$issue; $dow, $date)
291 X-master-at: $master_at
294 What's cooking in git.git ($mon $year, #$issue; $dow, $date)
295 --------------------------------------------------
299 $text =~ s/\n+\Z/\n/;
303 my $blurb_match = <<'EOF';
305 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";
341 if ($in_unedited_olde) {
343 $in_unedited_olde = 0;
347 $in_unedited_olde = 1;
350 if ($in_unedited_olde) {
354 if (defined $section && /^-{20,}$/) {
361 if (/^\[(.*)\]\s*$/) {
364 if (!exists $section{$section}) {
365 push @section, $section;
366 $section{$section} = [];
370 if (defined $section && /^\* (\S+) /) {
373 if (!exists $branch{$branch}) {
374 push @branch, [$branch, $section];
375 $branch{$branch} = 1;
377 push @
{$section{$section}}, $branch;
379 if (defined $branch) {
380 my $was_last_empty = $last_empty;
382 if (!exists $description{$branch}) {
383 $description{$branch} = [];
385 if ($was_last_empty) {
386 push @
{$description{$branch}}, "";
388 push @
{$description{$branch}}, $_;
393 for my $branch (keys %description) {
394 my $ary = $description{$branch};
395 if ($branch eq $blurb) {
396 while (@
{$ary} && $ary->[-1] =~ /^-{30,}$/) {
399 $description{$branch} = +{
401 text
=> join("\n", @
{$ary}),
406 my $elem = shift @
{$ary};
407 last if ($elem eq '');
410 $description{$branch} = +{
411 desc
=> join("\n", @desc),
412 text
=> join("\n", @
{$ary}),
418 section_list
=> \
@section,
419 section_data
=> \
%section,
420 topic_description
=> \
%description,
425 my ($fn, $cooking) = @_;
428 open($fh, '>', $fn) or die "$!: open $fn";
429 print $fh $cooking->{'topic_description'}{$blurb}{'text'};
431 for my $section_name (@
{$cooking->{'section_list'}}) {
432 my $topic_list = $cooking->{'section_data'}{$section_name};
433 next if (!@
{$topic_list});
436 print $fh '-' x
50, "\n";
437 print $fh "[$section_name]\n";
438 for my $topic (@
{$topic_list}) {
439 my $d = $cooking->{'topic_description'}{$topic};
441 print $fh "\n", $d->{'desc'}, "\n";
443 print $fh "\n", $d->{'text'}, "\n";
450 my $graduated = 'Graduated to "master"';
451 my $new_topics = 'New Topics';
452 my $old_new_topics = 'Old New Topics';
456 my ($fh, $master_at, $next_at, $incremental);
459 qw(git for-each-ref),
460 "--format=%(refname:short) %(objectname)",
462 "refs/heads/next") or die "$!: open for-each-ref";
464 my ($branch, $at) = /^(\S+) (\S+)$/;
465 if ($branch eq 'master') { $master_at = $at; }
466 if ($branch eq 'next') { $next_at = $at; }
468 close($fh) or die "$!: close for-each-ref";
470 $incremental = ((-r
"Meta/whats-cooking.txt") &&
471 system("cd Meta && " .
472 "git diff --quiet --no-ext-diff HEAD -- " .
473 "whats-cooking.txt"));
475 my $now_string = localtime;
476 my ($current_dow, $current_mon, $current_date, $current_year) =
477 ($now_string =~ /^(\w+) (\w+) +(\d+) [\d:]+ (\d+)$/);
479 my $btext = $cooking->{'topic_description'}{$blurb}{'text'};
480 if ($btext !~ s/\A$blurb_match//) {
481 die "match pattern broken?";
483 my ($mon, $year, $issue, $dow, $date) = ($1, $2, $3, $4, $5);
485 if ($current_mon ne $mon || $current_year ne $year) {
487 } elsif (!$incremental) {
489 $issue = sprintf "%02d", ($issue + 1);
492 $year = $current_year;
494 $date = $current_date;
496 $cooking->{'topic_description'}{$blurb}{'text'} =
497 blurb_text
($mon, $year, $issue, $dow, $date,
498 $master_at, $next_at, $btext);
501 my $sd = $cooking->{'section_data'};
502 my $sl = $cooking->{'section_list'};
503 # Rename "New" to "Old New" and insert "New".
504 # Move "New" to "Old New"
507 for ($i = 0; $i < @
{$sl}; $i++) {
508 if ($sl->[$i] eq $new_topics) {
509 $sl->[$i] = $old_new_topics;
510 unshift @
{$sl}, $new_topics;
516 $sd->{$old_new_topics} = $sd->{$new_topics};
518 $sd->{$new_topics} = [];
525 my ($topic_desc) = @_;
526 for my $line (split(/\n/, $topic_desc)) {
527 if ($line =~ /^ [+-] /) {
535 my ($cooking, $current) = @_;
536 my $td = $cooking->{'topic_description'};
537 my $sd = $cooking->{'section_data'};
538 my $sl = $cooking->{'section_list'};
539 my (@new_topic, @gone_topic);
541 # Make sure "New Topics" and "Graduated" exists
542 if (!exists $sd->{$new_topics}) {
543 $sd->{$new_topics} = [];
544 unshift @
{$sl}, $new_topics;
547 if (!exists $sd->{$graduated}) {
548 $sd->{$graduated} = [];
549 unshift @
{$sl}, $graduated;
552 my $incremental = update_issue
($cooking);
554 for my $topic (sort keys %{$current}) {
555 if (!exists $td->{$topic}) {
556 # Ignore new topics without anything merged
557 if (topic_in_pu
($current->{$topic}{'desc'})) {
558 push @new_topic, $topic;
562 my $n = $current->{$topic}{'desc'};
563 my $o = $td->{$topic}{'desc'};
565 $td->{$topic}{'desc'} = $n . "\n<<\n" . $o ."\n>>";
569 for my $topic (sort keys %{$td}) {
570 next if ($topic eq $blurb);
571 next if (!$incremental &&
572 grep { $topic eq $_ } @
{$sd->{$graduated}});
573 if (!exists $current->{$topic}) {
574 push @gone_topic, $topic;
579 push @
{$sd->{$new_topics}}, $_;
580 $td->{$_}{'desc'} = $current->{$_}{'desc'};
584 $sd->{$graduated} = [];
588 for my $topic (@gone_topic) {
589 for my $section (@
{$sl}) {
590 my $pre = scalar(@
{$sd->{$section}});
591 @
{$sd->{$section}} = (grep { $_ ne $topic }
593 my $post = scalar(@
{$sd->{$section}});
594 next if ($pre == $post);
598 push @
{$sd->{$graduated}}, $_;
603 ################################################################
606 my $topic = get_commit
();
607 my $cooking = read_previous
('Meta/whats-cooking.txt');
608 merge_cooking
($cooking, $topic);
609 write_cooking
('Meta/whats-cooking.txt', $cooking);