aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-10-09 14:27:11 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-10-09 14:27:11 -0400
commit4ef0b2d77b6aa9db0a45e69c1db29998e4cc06fb (patch)
treee7dc148d5dda63797561ad51fc4b8110416928a2
parent9eb229bfc73066e5d12d5a199c77f63d5881dfb7 (diff)
downloadikiwiki-4ef0b2d77b6aa9db0a45e69c1db29998e4cc06fb.tar
ikiwiki-4ef0b2d77b6aa9db0a45e69c1db29998e4cc06fb.tar.gz
rework influence calculation
Thought of a cleaner way to accumulate all influences in pagespec_match_list, using the pagespec_match result object as an accumulator. (This also accumulates all influences from failed matches, rather than just one failed match. I'm not sure if the old method was correct.)
-rw-r--r--IkiWiki.pm36
1 files changed, 10 insertions, 26 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 232d3e77b..c67a1e138 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -2032,41 +2032,25 @@ sub pagespec_match_list ($$;@) {
my @matches;
my $firstfail;
my $count=0;
+ my $accum=IkiWiki::SuccessReason->new();
foreach my $p (@candidates) {
my $r=$sub->($p, %params, location => $page);
+ error(sprintf(gettext("cannot match pages: %s"), $r))
+ if $r->isa("IkiWiki::ErrorReason");
+ $accum |= $r;
if ($r) {
- push @matches, [$p, $r];
+ push @matches, $p;
last if defined $num && ++$count == $num;
}
- elsif (! defined $firstfail) {
- $firstfail=$r;
- }
- }
-
- my @ret;
- if (@matches) {
- # Add all influences from successful matches.
- foreach my $m (@matches) {
- push @ret, $m->[0];
- my %i=$m->[1]->influences;
- foreach my $i (keys %i) {
- $depends_simple{$page}{lc $i} |= $i{$i};
- }
- }
}
- elsif (defined $firstfail) {
- # Add influences from one failure. (Which one should not
- # matter; all should have the same influences.)
- my %i=$firstfail->influences;
- foreach my $i (keys %i) {
- $depends_simple{$page}{lc $i} |= $i{$i};
- }
- error(sprintf(gettext("cannot match pages: %s"), $firstfail))
- if $firstfail->isa("IkiWiki::ErrorReason");
+ # Add simple dependencies for accumulated influences.
+ my %i=$accum->influences;
+ foreach my $i (keys %i) {
+ $depends_simple{$page}{lc $i} |= $i{$i};
}
- return @ret;
+ return @matches;
}
sub pagespec_valid ($) {