2 # Maintain "what's cooking" messages
9 for (my $i = 0; $i < @u; $i++) {
13 } elsif ($i < @u - 2) {
20 sub describe_relation
{
21 my ($topic_info) = @_;
24 if (exists $topic_info->{'used'}) {
25 push @desc, ("is used by " .
26 phrase_these
(@
{$topic_info->{'used'}}));
29 if (exists $topic_info->{'uses'}) {
30 push @desc, ("uses " .
31 phrase_these
(@
{$topic_info->{'uses'}}));
34 if (exists $topic_info->{'shares'}) {
35 push @desc, ("shares commits with " .
36 phrase_these
(@
{$topic_info->{'shares'}}));
43 return "(this branch " . join("; ", @desc) . ".)";
47 my ($topic, $fork, $forkee, @overlap) = @_;
48 my %ovl = map { $_ => 1 } (@overlap, @
{$topic->{$forkee}{'log'}});
50 push @
{$topic->{$fork}{'uses'}}, $forkee;
51 push @
{$topic->{$forkee}{'used'}}, $fork;
52 @
{$topic->{$fork}{'log'}} = (grep { !exists $ovl{$_} }
53 @
{$topic->{$fork}{'log'}});
57 my ($topic, $one, $two) = @_;
61 qw(git log --abbrev=7), "--format=%m %h",
62 "$one...$two", "^master")
63 or die "$!: open log --left-right";
66 my ($sign, $sha1) = /^(.) (.*)/;
69 } elsif ($sign eq '>') {
73 close($fh) or die "$!: close log --left-right";
77 forks_from
($topic, $two, $one);
80 forks_from
($topic, $one, $two);
83 forks_from
($topic, $two, $one, @left);
84 } elsif (@right < @left) {
85 forks_from
($topic, $one, $two, @right);
87 push @
{$topic->{$one}{'shares'}}, $two;
88 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) %(authordate: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 $co->{'branch'}{$branch} = 1;
167 next if (exists $base{$branch});
168 push @
{$topic{$branch}{'log'}}, $sha1;
171 close($fh) or die "$!: close show-branch";
175 for my $sha1 (keys %commit) {
177 my $co = $commit{$sha1};
178 if (exists $co->{'branch'}{'next'}) {
180 } elsif (exists $co->{'branch'}{'pu'}) {
185 $co->{'log'} = $sign . ' ' . $co->{'log'};
186 my @t = (sort grep { !exists $base{$_} }
187 keys %{$co->{'branch'}});
193 for my $combo (keys %shared) {
194 my @combo = split(' ', $combo);
195 for (my $i = 0; $i < @combo - 1; $i++) {
196 for (my $j = $i + 1; $j < @combo; $j++) {
197 topic_relation
(\
%topic, $combo[$i], $combo[$j]);
203 qw(git log --first-parent --abbrev=7),
204 "--format=%ci %h %p :%s", "master..next")
205 or die "$!: open log master..next";
207 my ($date, $commit, $parent, $tips);
208 unless (($date, $commit, $parent, $tips) =
209 /^([-0-9]+) ..:..:.. .\d{4} (\S+) (\S+) ([^:]*):/) {
212 for my $tip (split(' ', $tips)) {
213 my $co = $commit{$tip};
214 $co->{'merged'} = " (merged to 'next' on $date at $commit)";
217 close($fh) or die "$!: close log master..next";
219 for my $branch (keys %topic) {
221 my $n = scalar(@
{$topic{$branch}{'log'}});
223 delete $topic{$branch};
230 my $d = $topic{$branch}{'tipdate'};
231 my $head = "* $branch ($d) $n\n";
233 for (@
{$topic{$branch}{'log'}}) {
234 my $co = $commit{$_};
235 if (exists $co->{'merged'}) {
236 push @desc, $co->{'merged'};
238 push @desc, $commit{$_}->{'log'};
240 my $list = join("\n", map { " " . $_ } @desc);
241 my $relation = describe_relation
($topic{$branch});
242 $topic{$branch}{'desc'} = $head . $list;
244 $topic{$branch}{'desc'} .= "\n $relation";
252 my ($mon, $year, $issue, $dow, $date,
253 $master_at, $next_at, $text) = @_;
255 my $now_string = localtime;
256 my ($current_dow, $current_mon, $current_date, $current_year) =
257 ($now_string =~ /^(\w+) (\w+) (\d+) [\d:]+ (\d+)$/);
259 $mon ||= $current_mon;
260 $year ||= $current_year;
262 $dow ||= $current_dow;
263 $date ||= $current_date;
264 $master_at ||= '0' x
40;
265 $next_at ||= '0' x
40;
267 Here are the topics that have been cooking. Commits prefixed with '-' are
268 only in 'pu' while commits prefixed with '+' are in 'next'. The ones
269 marked with '.' do not appear in any of the integration branches, but I am
270 still holding onto them.
274 To: git\@vger.kernel.org
275 Subject: What's cooking in git.git ($mon $year, #$issue; $dow, $date)
276 X-master-at: $master_at
279 What's cooking in git.git ($mon $year, #$issue; $dow, $date)
280 --------------------------------------------------
284 $text =~ s/\n+\Z/\n/;
288 my $blurb_match = <<'EOF';
290 Subject: What's cooking in \S+ \((\w+) (\d+), #(\d+); (\w+), (\d+)\)
291 X-master-at: ([0-9a-f]{40})
292 X-next-at: ([0-9a-f]{40})
294 What's cooking in \S+ \(\1 \2, #\3; \4, \5\)
299 my $blurb = "b..l..u..r..b";
306 my $last_empty = undef;
307 my (@section, %section, @branch, %branch, %description, @leader);
308 my $in_unedited_olde = 0;
312 'section_list' => [],
313 'section_data' => {},
314 'topic_description' => {
317 text
=> blurb_text
(),
323 open ($fh, '<', $fn) or die "$!: open $fn";
326 if ($in_unedited_olde) {
328 $in_unedited_olde = 0;
332 $in_unedited_olde = 1;
335 if ($in_unedited_olde) {
339 if (defined $section && /^-{20,}$/) {
346 if (/^\[(.*)\]\s*$/) {
349 if (!exists $section{$section}) {
350 push @section, $section;
351 $section{$section} = [];
355 if (defined $section && /^\* (\S+) /) {
358 if (!exists $branch{$branch}) {
359 push @branch, [$branch, $section];
360 $branch{$branch} = 1;
362 push @
{$section{$section}}, $branch;
364 if (defined $branch) {
365 my $was_last_empty = $last_empty;
367 if (!exists $description{$branch}) {
368 $description{$branch} = [];
370 if ($was_last_empty) {
371 push @
{$description{$branch}}, "";
373 push @
{$description{$branch}}, $_;
378 for my $branch (keys %description) {
379 my $ary = $description{$branch};
380 if ($branch eq $blurb) {
381 while (@
{$ary} && $ary->[-1] =~ /^-{30,}$/) {
384 $description{$branch} = +{
386 text
=> join("\n", @
{$ary}),
391 my $elem = shift @
{$ary};
392 last if ($elem eq '');
395 $description{$branch} = +{
396 desc
=> join("\n", @desc),
397 text
=> join("\n", @
{$ary}),
403 section_list
=> \
@section,
404 section_data
=> \
%section,
405 topic_description
=> \
%description,
410 my ($fn, $cooking) = @_;
413 open($fh, '>', $fn) or die "$!: open $fn";
414 print $fh $cooking->{'topic_description'}{$blurb}{'text'};
416 for my $section_name (@
{$cooking->{'section_list'}}) {
417 my $topic_list = $cooking->{'section_data'}{$section_name};
418 next if (!@
{$topic_list});
421 print $fh '-' x
50, "\n";
422 print $fh "[$section_name]\n";
423 for my $topic (@
{$topic_list}) {
424 my $d = $cooking->{'topic_description'}{$topic};
426 print $fh "\n", $d->{'desc'}, "\n";
428 print $fh "\n", $d->{'text'}, "\n";
435 my $graduated = 'Graduated to "master"';
436 my $new_topics = 'New Topics';
437 my $old_new_topics = 'Old New Topics';
441 my ($fh, $master_at, $next_at, $incremental);
444 qw(git for-each-ref),
445 "--format=%(refname:short) %(objectname)",
447 "refs/heads/next") or die "$!: open for-each-ref";
449 my ($branch, $at) = /^(\S+) (\S+)$/;
450 if ($branch eq 'master') { $master_at = $at; }
451 if ($branch eq 'next') { $next_at = $at; }
453 close($fh) or die "$!: close for-each-ref";
455 $incremental = ((-r
"Meta/whats-cooking.txt") &&
456 system("cd Meta && " .
457 "git diff --quiet --no-ext-diff HEAD -- " .
458 "whats-cooking.txt"));
460 my $now_string = localtime;
461 my ($current_dow, $current_mon, $current_date, $current_year) =
462 ($now_string =~ /^(\w+) (\w+) +(\d+) [\d:]+ (\d+)$/);
464 my $btext = $cooking->{'topic_description'}{$blurb}{'text'};
465 if ($btext !~ s/\A$blurb_match//) {
466 die "match pattern broken?";
468 my ($mon, $year, $issue, $dow, $date) = ($1, $2, $3, $4, $5);
470 if ($current_mon ne $mon || $current_year ne $year) {
472 } elsif (!$incremental) {
474 $issue = sprintf "%02d", ($issue + 1);
477 $year = $current_year;
479 $date = $current_date;
481 $cooking->{'topic_description'}{$blurb}{'text'} =
482 blurb_text
($mon, $year, $issue, $dow, $date,
483 $master_at, $next_at, $btext);
486 my $sd = $cooking->{'section_data'};
487 my $sl = $cooking->{'section_list'};
488 # Rename "New" to "Old New" and insert "New".
489 # Move "New" to "Old New"
492 for ($i = 0; $i < @
{$sl}; $i++) {
493 if ($sl->[$i] eq $new_topics) {
494 $sl->[$i] = $old_new_topics;
495 unshift @
{$sl}, $new_topics;
501 $sd->{$old_new_topics} = $sd->{$new_topics};
503 $sd->{$new_topics} = [];
510 my ($cooking, $current) = @_;
511 my $td = $cooking->{'topic_description'};
512 my $sd = $cooking->{'section_data'};
513 my $sl = $cooking->{'section_list'};
514 my (@new_topic, @gone_topic);
516 # Make sure "New Topics" and "Graduated" exists
517 if (!exists $sd->{$new_topics}) {
518 $sd->{$new_topics} = [];
519 unshift @
{$sl}, $new_topics;
522 if (!exists $sd->{$graduated}) {
523 $sd->{$graduated} = [];
524 unshift @
{$sl}, $graduated;
527 my $incremental = update_issue
($cooking);
529 for my $topic (sort keys %{$current}) {
530 if (!exists $td->{$topic}) {
531 push @new_topic, $topic;
534 my $n = $current->{$topic}{'desc'};
535 my $o = $td->{$topic}{'desc'};
537 $td->{$topic}{'desc'} = $n . "\n<<\n" . $o ."\n>>";
541 for my $topic (sort keys %{$td}) {
542 next if ($topic eq $blurb);
543 next if (!$incremental &&
544 grep { $topic eq $_ } @
{$sd->{$graduated}});
545 if (!exists $current->{$topic}) {
546 push @gone_topic, $topic;
551 push @
{$sd->{$new_topics}}, $_;
552 $td->{$_}{'desc'} = $current->{$_}{'desc'};
556 $sd->{$graduated} = [];
560 for my $topic (@gone_topic) {
561 for my $section (@
{$sl}) {
562 my $pre = scalar(@
{$sd->{$section}});
563 @
{$sd->{$section}} = (grep { $_ ne $topic }
565 my $post = scalar(@
{$sd->{$section}});
566 next if ($pre == $post);
570 push @
{$sd->{$graduated}}, $_;
575 ################################################################
578 my $topic = get_commit
();
579 my $cooking = read_previous
('Meta/whats-cooking.txt');
580 merge_cooking
($cooking, $topic);
581 write_cooking
('Meta/whats-cooking.txt', $cooking);