From: Ian Jackson Date: Sat, 25 Feb 2012 22:57:18 +0000 (+0000) Subject: wip new metadata X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topbloke.git;a=commitdiff_plain;h=2799df8533bddff6feeee7c1b9d31cc6583e04f9 wip new metadata --- diff --git a/FORMAT b/FORMAT index 8e061cf..42f7fa4 100644 --- a/FORMAT +++ b/FORMAT @@ -49,7 +49,7 @@ In-tree, there are metadata files in .topbloke have names starting with "+": +included actual included deps, one per line - format as for deps + format as for deps, only includes topbloke patches exists in tip and base branches +ends list of ends E(C,Px+) diff --git a/Topbloke.pm b/Topbloke.pm index 741cecb..23024fd 100644 --- a/Topbloke.pm +++ b/Topbloke.pm @@ -228,15 +228,15 @@ sub setup_config () { my $want = "topbloke-".$drvname->($file); $attrs .= "$pat\tmerge=$want\n"; my $current = run_git_1line(qw(check-attr merge), $check); - $current =~ s#^\Q$path\E: merge: ## or die "$file $current ?"; + $current =~ s#^\Q$check\E: merge: ## or die "$file $current ?"; next if $current eq $want; die "$file $current ?" unless $current eq 'unspecified'; - push @needupdate, $file; + push @needupdate, "$file=$current"; } if (@needupdate) { my $newattrsf = new IO::File "$attrsfile.tmp", 'w' or die "$attrsfile.tmp: $!"; - die "@needupdate $current ?" if $iteration; + die "@needupdate ?" if $iteration; $attrsfile = git_dir()."/info/attributes"; if (!open OA, '<', "$attrsfile") { die "$attrsfile $!" unless $!==ENOENT; @@ -388,14 +388,16 @@ sub patch_matches_spec ($$) { sub foreach_patch ($$$$) { my ($spec, $deleted_ok, $want, $body) = @_; - # runs $body->($patch, $parsedname, \%props) - # where $props{} is, for in @$want: + # runs $body->($patch, $parsedname, \%meta) + # where $meta{} is, for in @$want: # undefined if metadata file doesn't exist # defined with contents of file # and $parsedname is only valid if $spec is not undef # (say $spec { } if you want the name parsed but no restrictions) # entries in want may also be "_" - # which means "strip trailing newlines" (result key in %props is the same) + # which means "strip trailing newlines" (result key in %meta is the same) + # may instead be "B_" + # which means to look in the corresponding base branch my @want = @$want; my $atfront = sub { my $thing = @_; @@ -407,48 +409,44 @@ sub foreach_patch ($$$$) { debug("foreach_patch considering $_"); m/ / or die "$_ ?"; my $objname = $`; - my %props; + my %meta; my $parsedname; my $patch = substr($',19); #'); my $wantix = 0; foreach my $wantent (@want) { my $file = $wantent; my $stripnl = ($file =~ s/_$//); + my $inbase = ($file =~ s/^B_//); if ($file eq ' patch') { if ($spec) { $parsedname = parse_patch_name($patch); - debug("foreach_patch mismatch"), return - unless patch_matches_spec($parsedname, $spec); + if (!patch_matches_spec($parsedname, $spec)) { + debug("foreach_patch mismatch"); + return; + } } next; } - my ($got, $data) = git_get_object("$objname:.topbloke/$file"); - -xxx up to here new foreach_patch api -xxx up to here new metadata in this function - - die "$patch $file ?" unless defined $data; - my %data; - if ($file !~ m/props/) { - $data{$_}=1 foreach split /\n/, $data; - } elseif { - foreach (split /\n/, $data) { - m/ / or m/$/; - $data{$`} = $'; #'; + my $objkey = (!$inbase ? "$objname" : + "refs/topbloke-bases/$patch").":.topbloke/$file"; + my ($got, $data) = git_get_object($objkey); + if ($got eq 'missing') { + $meta{$file} = undef; + } elsif ($got eq 'blob') { + $meta{$file} = $data; + if ($file eq 'deleted' && !$deleted_ok) { + debug("foreach_patch Deleted"); + return; } + } else { + warn "patch $patch object $objkey has unexpected type $got!\n"; + return; } - - if ($file eq 'props') { - debug("foreach_patch Deleted"), return - if !$deleted_ok && $data{Deleted}; - } - - push @out, \%data; } - debug("foreach_patch YES ".(join '', map { 0+defined } @out)), return - $body->($patch, @out); + debug("foreach_patch YES $patch"); + $body->($patch, $parsedname, \%meta); }, qw(for-each-ref --format), '%(objectname) %(refname)', qw(refs/topbloke-tips)); @@ -456,31 +454,6 @@ xxx up to here new metadata in this function #----- updating topbloke metadata ----- -xxx this section needs updating for new metadata - -sub propsfile_set_prop ($$$) { - # set $value to undef to delete; returns old value - my ($propsfile, $prop, $value) = @_; - my $wf = wf_start(".topbloke/$propsfile"); - my $oldvalue; - open FI, '<', ".topbloke/$propsfile" or die $!; - while () { - chomp or die; - m/ / or m/$/; - if ($` eq $prop) { - die "prop $prop repeated in $propsfile ?!" if defined $oldvalue; - $oldvalue = $'; #'; - } else { - wf($wf, "$_\n"); - } - } - FI->error and die $!; - close FI or die $!; - wf($wf, "$prop $value\n") if defined $value; - wf_done($wf); - return $oldvalue; -} - sub depssfile_add_dep ($$) { my ($depsfile, $depspec) = @_; my $wf = wf_start(".topbloke/$depsfile"); diff --git a/tb-list.pl b/tb-list.pl index 8b23d6d..8fc3c3b 100755 --- a/tb-list.pl +++ b/tb-list.pl @@ -2,8 +2,6 @@ # usage: tb-list [] # lists all patches matching and other criteria -xxx needs updating for new metadata and new theory - use warnings; use strict; @@ -60,13 +58,17 @@ foreach $sort (@sort) { our %patches; foreach_patch($relatedto || $leaves || !$spec ? { } : $spec, -xxx new api for foreach_patch $deleted || $deleted_only, - [0, !!$leaves, 0, $toposort || !!$relatedto], + [qw(B_deps +included)], sub { - my ($patch,$parsedname,@info) = @_; - $patches{$patch}{Info} = \@info; + my ($patch,$parsedname,$meta) = @_; + $patches{$patch}{Meta} = $meta; $patches{$patch}{ParsedName} = $parsedname; + $patches{$patch}{Deps} = + grep { m/^[^-]/ } split /\n/, $meta->{'B_deps'}; + $patches{$patch}{Included} = { }; + $patches{$patch}{Included}{$_} = 1 + foreach split /\n/, $meta->{'+included'}; }); #----- selection ----- @@ -76,8 +78,8 @@ if ($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] }) { + next if defined $v->{Meta}{'deleted'}; + foreach my $dep (@{ $v->{Deps} }) { debug("leaves $p $dep"); next unless exists $patches{$dep}; $patches{$dep}{NotLeaf} = 1; @@ -89,7 +91,7 @@ if ($relatedto) { foreach my $p (keys %patches) { my $v = $patches{$p}; # mark Related=1 if any patch matching $relatedto includes us - foreach my $dep (keys %{ $v->{Info}[3] }) { + foreach my $dep (keys %{ $v->{Included} }) { next unless exists $patches{$dep}; my $depv = $patches{$dep}; next unless patch_matches_spec($depv->{ParsedName}, $relatedto); @@ -98,7 +100,7 @@ if ($relatedto) { } if (patch_matches_spec($v->{ParsedName}, $relatedto)) { # if we match $relatedto, mark all our inclusions as Related=1 - foreach my $dep (keys %{ $v->{Info}[3] }) { + foreach my $dep (keys %{ $v->{Included} }) { next unless exists $patches{$dep}; $patches{$dep}{Related} = 1; } @@ -112,8 +114,8 @@ our @output; foreach my $p (keys %patches) { my $v = $patches{$p}; - next if !$deleted && $v->{Info}[0]{Deleted}; - next if $deleted_only && !$v->{Info}[0]{Deleted}; + next if !$deleted && defined $v->{Meta}{'deleted'}; + next if $deleted_only && !defined $v->{Meta}{'deleted'}; next if $leaves && $v->{NotLeaf}; next if $relatedto && !$v->{Related}; next if $spec && !patch_matches_spec($v->{ParsedName}, $spec); @@ -154,7 +156,7 @@ sub sortsub () { my $ab = (qw(a b))[$ix]; my $ba = (qw(b a))[$ix]; my $r = (qw(1 -1))[$ix]; - $txt .= " return $r if \$v${ab}->{Info}[3]{\$$ba};\n"; + $txt .= " return $r if \$v${ab}->{Included}{\$$ba};\n"; } } else { die $sort; @@ -191,7 +193,7 @@ foreach my $p (@output) { ? $1 : "[no subject]"; printf("%1s%1s %s\@%s/%s/%-20s %s\n", $p eq $current_patch ? $ifcurrent : '', - $v->{Info}[0]{Deleted} ? 'D' : '', + defined $v->{Meta}{'deleted'} ? 'D' : '', $pa->{Email}, $pa->{Domain}, $pa->{Date}, $pa->{Nick}, $subject) or die $!;