X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=tb-list.pl;h=e88b17d93d9c0c691ae472770251f498176bf85c;hb=2d2110b455da97362135d27bc694693e7cd763e9;hp=6a4466b5fdb4102f71bd82f31472ddb41535d2ba;hpb=3c335920aa5b82002d6abb9530af37c466483246;p=topbloke.git diff --git a/tb-list.pl b/tb-list.pl index 6a4466b..e88b17d 100755 --- a/tb-list.pl +++ b/tb-list.pl @@ -8,6 +8,8 @@ use strict; use Getopt::Long; use Topbloke; +#----- option parsing ----- + Getopt::Long::Configure(qw(bundling)); our $deleted=0; @@ -43,6 +45,10 @@ foreach $sort (@sort) { $toposort=1 if $sort eq $toposort; } +$relatedto = $relatedto ? parse_patch_spec($relatedto) : undef; + +#----- list patches ----- + our %patches; foreach_patch($relatedto || $leaves || !$spec ? { } : $spec, @@ -54,11 +60,16 @@ foreach_patch($relatedto || $leaves || !$spec ? { } : $spec, $patches{$patch}{ParsedName} = $parsedname; }); +#----- selection ----- + if ($leaves) { + debug("leaves"); foreach my $p (keys %patches) { + debug("leaves $p"); my $v = $patches{$p}; next if $v->{Info}[0]{Deleted}; foreach my $dep (keys %{ $v->{Info}[1] }) { + debug("leaves $p $dep"); next unless exists $patches{$dep}; $patches{$dep}{NotLeaf} = 1; } @@ -82,6 +93,8 @@ if ($relatedto) { next unless exists $patches{$dep}; $patches{$dep}{Related} = 1; } + # oh, and mark ourselves as Related=1 too! + $v->{Related} = 1; } } } @@ -94,9 +107,12 @@ foreach my $p (keys %patches) { next if $deleted_only && !$v->{Info}[0]{Deleted}; next if $leaves && $v->{NotLeaf}; next if $relatedto && !$v->{Related}; + next if $spec && !patch_matches_spec($v->{ParsedName}, $spec); push @output, $p; } +#----- sorting ----- + sub sortsub () { my $txt = "sub sort_cmp {\n my \$r;\n"; debug("@sort"); @@ -143,9 +159,26 @@ eval sortsub()." 1;" or die "$@ ?"; @output = sort sort_cmp @output; -use Data::Dumper; +#----- printing ----- + +my $current_branch = current_branch(); +my $current_patch = $current_branch->{Kind} eq 'tip' + ? $current_branch->{Fullname} : ''; foreach my $p (@output) { my $v = $patches{$p}; - print Dumper($p, $v); + my $pa = $v->{ParsedName}; + my ($msgkind, $msg) = git_get_object("$pa->{Ref}:.topbloke/msg"); + die "$p $msgkind ?" unless $msgkind eq 'blob'; + my $subject = + $msg =~ m/^Subject:\s*(?:\[[^][]*\]\s*)?(.*\S)\s*$/mi + ? $1 : "[no subject]"; + printf("%1s%1s %s\@%s/%s/%-20s %s\n", + $p eq $current_patch ? '>' : '', + $v->{Info}[0]{Deleted} ? 'D' : '', + $pa->{Email}, $pa->{Domain}, $pa->{Date}, $pa->{Nick}, + $subject) + or die $!; } + +closeout();