- foreach my $link (keys %linkchanged) {
- my $linkfile=$pagesources{$link};
- if (defined $linkfile) {
- next if $rendered{$linkfile};
- debug(sprintf(gettext("building %s, to update its backlinks"), $linkfile));
- render($linkfile);
- $rendered{$linkfile}=1;
+ # only consider internal files
+ # if the page explicitly depends
+ # on such files
+ my $internal_dep=$dep =~ /internal\(/;
+
+ my $in=sub {
+ my $list=shift;
+ my $type=shift;
+ foreach my $file (@$list) {
+ next if $file eq $f;
+ my $page=pagename($file);
+ if ($sub->($page, location => $p)) {
+ if ($type == $IkiWiki::DEPEND_LINKS) {
+ next unless $linkchangers->{lc($page)};
+ }
+ return $page;
+ }
+ }
+ return undef;
+ };
+
+ if ($depends{$p}{$dep} & $IkiWiki::DEPEND_CONTENT) {
+ last if $reason =
+ $in->(\@changed, $IkiWiki::DEPEND_CONTENT);
+ last if $internal_dep && ($reason =
+ $in->($internal_new, $IkiWiki::DEPEND_CONTENT) ||
+ $in->($internal_del, $IkiWiki::DEPEND_CONTENT) ||
+ $in->($internal_changed, $IkiWiki::DEPEND_CONTENT));
+ }
+ if ($depends{$p}{$dep} & $IkiWiki::DEPEND_PRESENCE) {
+ last if $reason =
+ $in->(\@exists_changed, $IkiWiki::DEPEND_PRESENCE);
+ last if $internal_dep && ($reason =
+ $in->($internal_new, $IkiWiki::DEPEND_PRESENCE) ||
+ $in->($internal_del, $IkiWiki::DEPEND_PRESENCE));
+ }
+ if ($depends{$p}{$dep} & $IkiWiki::DEPEND_LINKS) {
+ last if $reason =
+ $in->(\@changed, $IkiWiki::DEPEND_LINKS);
+ last if $internal_dep && ($reason =
+ $in->($internal_new, $IkiWiki::DEPEND_LINKS) ||
+ $in->($internal_del, $IkiWiki::DEPEND_LINKS) ||
+ $in->($internal_changed, $IkiWiki::DEPEND_LINKS));
+ }