summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki.pm36
-rw-r--r--IkiWiki/Plugin/calendar.pm2
-rw-r--r--IkiWiki/Plugin/inline.pm2
-rw-r--r--IkiWiki/Plugin/map.pm2
-rw-r--r--IkiWiki/Render.pm22
-rw-r--r--doc/todo/should_optimise_pagespecs.mdwn2
-rwxr-xr-xikiwiki-transition2
-rwxr-xr-xt/index.t12
8 files changed, 51 insertions, 29 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 43ffb1fd8..8a8695768 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -661,9 +661,15 @@ sub pagetype ($) {
return;
}
+my %pagename_cache;
+
sub pagename ($) {
my $file=shift;
+ if (exists $pagename_cache{$file}) {
+ return $pagename_cache{$file};
+ }
+
my $type=pagetype($file);
my $page=$file;
$page=~s/\Q.$type\E*$//
@@ -672,6 +678,8 @@ sub pagename ($) {
if ($config{indexpages} && $page=~/(.*)\/index$/) {
$page=$1;
}
+
+ $pagename_cache{$file} = $page;
return $page;
}
@@ -1507,8 +1515,13 @@ sub loadindex () {
$links{$page}=$d->{links};
$oldlinks{$page}=[@{$d->{links}}];
}
- if (exists $d->{depends}) {
- $depends{$page}=$d->{depends};
+ if (exists $d->{dependslist}) {
+ $depends{$page}={
+ map { $_ => 1 } @{$d->{dependslist}}
+ };
+ }
+ elsif (exists $d->{depends}) {
+ $depends{$page}={$d->{depends} => 1};
}
if (exists $d->{state}) {
$pagestate{$page}=$d->{state};
@@ -1554,7 +1567,7 @@ sub saveindex () {
};
if (exists $depends{$page}) {
- $index{page}{$src}{depends} = $depends{$page};
+ $index{page}{$src}{dependslist} = [ keys %{$depends{$page}} ];
}
if (exists $pagestate{$page}) {
@@ -1724,16 +1737,19 @@ sub rcs_receive () {
sub add_depends ($$) {
my $page=shift;
my $pagespec=shift;
-
- return unless pagespec_valid($pagespec);
- if (! exists $depends{$page}) {
- $depends{$page}=$pagespec;
- }
- else {
- $depends{$page}=pagespec_merge($depends{$page}, $pagespec);
+ if (ref $pagespec eq 'ARRAY') {
+ foreach my $ps (@$pagespec) {
+ if (pagespec_valid($ps)) {
+ $depends{$page}{$ps} = 1;
+ }
+ }
+ return;
}
+ return unless pagespec_valid($pagespec);
+
+ $depends{$page}{$pagespec} = 1;
return 1;
}
diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm
index c25893f72..ce0719404 100644
--- a/IkiWiki/Plugin/calendar.pm
+++ b/IkiWiki/Plugin/calendar.pm
@@ -212,7 +212,7 @@ EOF
add_depends($params{page}, $params{pages});
# Explicitly add all currently linked pages as dependencies, so
# that if they are removed, the calendar will be sure to be updated.
- add_depends($params{page}, join(" or ", @list));
+ add_depends($params{page}, \@list);
return $calendar;
}
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index 3a2f4b7bc..b566d960f 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -251,7 +251,7 @@ sub preprocess_inline (@) {
# Explicitly add all currently displayed pages as dependencies, so
# that if they are removed or otherwise changed, the inline will be
# sure to be updated.
- add_depends($params{page}, join(" or ", $#list >= $#feedlist ? @list : @feedlist));
+ add_depends($params{page}, $#list >= $#feedlist ? \@list : \@feedlist);
if ($feeds && exists $params{feedpages}) {
@feedlist=pagespec_match_list(\@feedlist, $params{feedpages}, location => $params{page});
diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm
index 826dbbd66..cc977024d 100644
--- a/IkiWiki/Plugin/map.pm
+++ b/IkiWiki/Plugin/map.pm
@@ -73,7 +73,7 @@ sub preprocess (@) {
add_depends($params{page}, $params{pages});
# Explicitly add all currently shown pages, to detect when pages
# are removed.
- add_depends($params{page}, join(" or ", keys %mapitems));
+ add_depends($params{page}, [keys %mapitems]);
# Create the map.
my $parent="";
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 578142d2e..fb28b6e3b 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -455,20 +455,24 @@ sub refresh () {
my @changed=(keys %rendered, @del);
# rebuild dependant pages
- foreach my $f (@$files) {
+ F: foreach my $f (@$files) {
next if $rendered{$f};
my $p=pagename($f);
if (exists $depends{$p}) {
- # only consider internal files
- # if the page explicitly depends on such files
- foreach my $file (@changed, $depends{$p}=~/internal\(/ ? @internal : ()) {
- next if $f eq $file;
- my $page=pagename($file);
- if (pagespec_match($page, $depends{$p}, location => $p)) {
- debug(sprintf(gettext("building %s, which depends on %s"), $f, $page));
+ foreach my $d (keys %{$depends{$p}}) {
+ # only consider internal files
+ # if the page explicitly depends on such files
+ my @pages = map {
+ pagename($_)
+ } grep {
+ $_ ne $f
+ } (@changed, $d =~ /internal\(/ ? @internal : ());
+ @pages = pagespec_match_list(\@pages, $d, location => $p);
+ if (@pages) {
+ debug(sprintf(gettext("building %s, which depends on %s"), $f, $pages[0]));
render($f);
$rendered{$f}=1;
- last;
+ next F;
}
}
}
diff --git a/doc/todo/should_optimise_pagespecs.mdwn b/doc/todo/should_optimise_pagespecs.mdwn
index 2dd1f7b9e..7a2e7d45f 100644
--- a/doc/todo/should_optimise_pagespecs.mdwn
+++ b/doc/todo/should_optimise_pagespecs.mdwn
@@ -90,6 +90,8 @@ I can think about reducung the size of my wiki source and making it available on
>> rather than a single pagespec. This does turn out to be faster, although
>> not as much as I'd like. --[[smcv]]
+>>> [[Merged|done]] --[[smcv]]
+
>>> I just wanted to note that there is a whole long discussion of dependencies and pagespecs on the [[todo/tracking_bugs_with_dependencies]] page. -- [[Will]]
>>>> Yeah, I had a look at that (as the only other mention of `pagespec_merge`).
diff --git a/ikiwiki-transition b/ikiwiki-transition
index 398b1a3c8..795ab31cb 100755
--- a/ikiwiki-transition
+++ b/ikiwiki-transition
@@ -299,7 +299,7 @@ sub oldloadindex {
$pagemtime{$page}=$items{mtime}[0];
$oldlinks{$page}=[@{$items{link}}];
$links{$page}=[@{$items{link}}];
- $depends{$page}=$items{depends}[0] if exists $items{depends};
+ $depends{$page}={ $items{depends}[0] => 1 } if exists $items{depends};
$destsources{$_}=$page foreach @{$items{dest}};
$renderedfiles{$page}=[@{$items{dest}}];
$pagecase{lc $page}=$page;
diff --git a/t/index.t b/t/index.t
index e79609902..2f23524a7 100755
--- a/t/index.t
+++ b/t/index.t
@@ -32,9 +32,9 @@ $renderedfiles{"bar.png"}=["bar.png"];
$links{"Foo"}=["bar.png"];
$links{"bar"}=["Foo", "new-page"];
$links{"bar.png"}=[];
-$depends{"Foo"}="";
-$depends{"bar"}="foo*";
-$depends{"bar.png"}="";
+$depends{"Foo"}={};
+$depends{"bar"}={"foo*" => 1};
+$depends{"bar.png"}={};
$pagestate{"bar"}{meta}{title}="a page about bar";
$pagestate{"bar"}{meta}{moo}="mooooo";
# only loaded plugins save state, so this should not be saved out
@@ -80,9 +80,9 @@ is_deeply(\%links, {
"bar.png" => [],
}, "%links loaded correctly");
is_deeply(\%depends, {
- Foo => "",
- bar => "foo*",
- "bar.png" => "",
+ Foo => {},
+ bar => {"foo*" => 1},
+ "bar.png" => {},
}, "%depends loaded correctly");
is_deeply(\%pagestate, {
bar => {