]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
Merge commit 'smcv/ready/depends-exact'
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 28 Aug 2009 19:10:37 +0000 (15:10 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 28 Aug 2009 19:10:37 +0000 (15:10 -0400)
IkiWiki.pm
IkiWiki/Plugin/inline.pm
IkiWiki/Render.pm
doc/todo/optimize_simple_dependencies.mdwn

index 5563a03af7d028a88c184d8f2ac227284c475f52..8bded8a0e71e0a1f1bedac2525de8ebef882cf52 100644 (file)
@@ -14,7 +14,7 @@ use open qw{:utf8 :std};
 use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase
            %pagestate %wikistate %renderedfiles %oldrenderedfiles
            %pagesources %destsources %depends %hooks %forcerebuild
-           %loaded_plugins};
+           %loaded_plugins %depends_exact};
 
 use Exporter q{import};
 our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
@@ -1475,7 +1475,8 @@ sub loadindex () {
        %oldrenderedfiles=%pagectime=();
        if (! $config{rebuild}) {
                %pagesources=%pagemtime=%oldlinks=%links=%depends=
-               %destsources=%renderedfiles=%pagecase=%pagestate=();
+               %destsources=%renderedfiles=%pagecase=%pagestate=
+               %depends_exact=();
        }
        my $in;
        if (! open ($in, "<", "$config{wikistatedir}/indexdb")) {
@@ -1515,6 +1516,11 @@ sub loadindex () {
                                $links{$page}=$d->{links};
                                $oldlinks{$page}=[@{$d->{links}}];
                        }
+                       if (exists $d->{depends_exact}) {
+                               $depends_exact{$page}={
+                                       map { $_ => 1 } @{$d->{depends_exact}}
+                               };
+                       }
                        if (exists $d->{dependslist}) {
                                $depends{$page}={
                                        map { $_ => 1 } @{$d->{dependslist}}
@@ -1570,6 +1576,10 @@ sub saveindex () {
                        $index{page}{$src}{dependslist} = [ keys %{$depends{$page}} ];
                }
 
+               if (exists $depends_exact{$page}) {
+                       $index{page}{$src}{depends_exact} = [ keys %{$depends_exact{$page}} ];
+               }
+
                if (exists $pagestate{$page}) {
                        foreach my $id (@hookids) {
                                foreach my $key (keys %{$pagestate{$page}{$id}}) {
@@ -1738,6 +1748,13 @@ sub add_depends ($$) {
        my $page=shift;
        my $pagespec=shift;
 
+       if ($pagespec =~ /$config{wiki_file_regexp}/ &&
+               $pagespec !~ /[\s*?()!]/) {
+               # a simple dependency, which can be matched by string eq
+               $depends_exact{$page}{lc $pagespec} = 1;
+               return 1;
+       }
+
        return unless pagespec_valid($pagespec);
 
        $depends{$page}{$pagespec} = 1;
index a501566b554d11cd1894878637aaf5d2204089d4..d5ad11d438ce2b4b43a9d913cdf489ec0d34e779 100644 (file)
@@ -195,10 +195,10 @@ sub preprocess_inline (@) {
 
                @list = map { bestlink($params{page}, $_) }
                        split ' ', $params{pagenames};
-
-               $params{pages} = join(" or ", @list);
        }
        else {
+               add_depends($params{page}, $params{pages});
+
                @list = pagespec_match_list(
                        [ grep { $_ ne $params{page} } keys %pagesources ],
                        $params{pages}, location => $params{page});
@@ -247,7 +247,6 @@ sub preprocess_inline (@) {
                @list=@list[0..$params{show} - 1];
        }
 
-       add_depends($params{page}, $params{pages});
        # 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.
index da2d7b4ccc1adc480c2acc20f6b5d167a8fc7ff2..85ae0f8e95df8f6da5fe4968d7998b1dde7bb98c 100644 (file)
@@ -210,6 +210,7 @@ sub render ($) {
        if (defined $type) {
                my $page=pagename($file);
                delete $depends{$page};
+               delete $depends_exact{$page};
                will_render($page, htmlpage($page), 1);
                return if $type=~/^_/;
                
@@ -224,6 +225,7 @@ sub render ($) {
        }
        else {
                delete $depends{$file};
+               delete $depends_exact{$file};
                will_render($file, $file, 1);
                
                if ($config{hardlink}) {
@@ -431,6 +433,7 @@ sub refresh () {
                # internal pages are not rendered
                my $page=pagename($file);
                delete $depends{$page};
+               delete $depends_exact{$page};
                foreach my $old (@{$renderedfiles{$page}}) {
                        delete $destsources{$old};
                }
@@ -454,12 +457,25 @@ sub refresh () {
        if (%rendered || @del || @internal) {
                my @changed=(keys %rendered, @del);
 
+               my %lcchanged = map { lc(pagename($_)) => 1 } @changed;
                # rebuild dependant pages
-               F: foreach my $f (@$files) {
+               foreach my $f (@$files) {
                        next if $rendered{$f};
                        my $p=pagename($f);
-                       if (exists $depends{$p}) {
-                               foreach my $d (keys %{$depends{$p}}) {
+                       my $reason = undef;
+
+                       if (exists $depends_exact{$p}) {
+                               foreach my $d (keys %{$depends_exact{$p}}) {
+                                       if (exists $lcchanged{$d}) {
+                                               $reason = $d;
+                                               last;
+                                       }
+                               }
+                       }
+
+                       if (exists $depends{$p} && ! defined $reason) {
+                               D: foreach my $d (keys %{$depends{$p}}) {
                                        my $sub=pagespec_translate($d);
                                        next if $@ || ! defined $sub;
 
@@ -470,14 +486,18 @@ sub refresh () {
                                                next if $file eq $f;
                                                my $page=pagename($file);
                                                if ($sub->($page, location => $p)) {
-                                                       debug(sprintf(gettext("building %s, which depends on %s"), $f, $page));
-                                                       render($f);
-                                                       $rendered{$f}=1;
-                                                       next F;
+                                                       $reason = $page;
+                                                       last D;
                                                }
                                        }
                                }
                        }
+
+                       if (defined $reason) {
+                               debug(sprintf(gettext("building %s, which depends on %s"), $f, $reason));
+                               render($f);
+                               $rendered{$f}=1;
+                       }
                }
                
                # handle backlinks; if a page has added/removed links,
index da75ff17754d7700f4c08ee3f9ae957ada24e8b2..91e184c292309154db69fef6379a42c2b671aa0f 100644 (file)
@@ -47,6 +47,10 @@ equally valid.)
 
 --[[smcv]]
 
+> Now [[merged|done]] --[[smcv]]
+
+----
+
 > We discussed this on irc; I had some worries that things may have been
 > switched to `add_depends_exact` that were not pure page names. My current
 > feeling is it's all safe, but who knows. It's easy to miss something.