]> sipb.mit.edu Git - ikiwiki.git/commitdiff
avoid unnecessarily rebuilding pages with complex conditionals
authorJoey Hess <joey@kodama.kitenet.net>
Mon, 29 Sep 2008 22:05:39 +0000 (18:05 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Mon, 29 Sep 2008 22:05:39 +0000 (18:05 -0400)
I noticed that ikiwiki/formatting was beilg rebuilt when any page changed.
This turned out to be because it contained a complex conditional
"enabled(foo) or enabled(bar)", and the conditional plugin did not notice
that this consisted only of enabled() tests, and copied it unchanged into
add_depends. Thus, the page's dependencies were satisfied by any page
change.

The fix is to beef up the parser so that it can handle that and more
complex conditionals, and detect if they consist only of such tests.

IkiWiki/Plugin/conditional.pm
po/ikiwiki.pot

index 7716fce1b4be7a612a84d71386c11f92adff51b3..e787424aaee5ca0e01c58f236a87f32c2d493e02 100644 (file)
@@ -33,8 +33,8 @@ sub preprocess_if (@) { #{{{
                # An optimisation to avoid needless looping over every page
                # and adding of dependencies for simple uses of some of the
                # tests.
-               $params{test} =~ /^\s*\!?\s*(enabled|sourcepage|destpage|included)\((.*)\)\s*$/) {
-               add_depends($params{page}, "$params{test} and $params{page}");
+               $params{test} =~ /^([\s\!()]*((enabled|sourcepage|destpage|included)\([^)]*\)|(and|or))[\s\!()]*)+$/) {
+               add_depends($params{page}, "($params{test}) and $params{page}");
                $result=pagespec_match($params{page}, $params{test},
                                location => $params{page},
                                sourcepage => $params{page},
index b0206e45a3511f4fddb6587ce61c7e2692e300ba..6614bfd87dbf295c5d9860ddb15299269840ff2b 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-09-29 17:12-0400\n"
+"POT-Creation-Date: 2008-09-29 18:05-0400\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -48,7 +48,7 @@ msgstr ""
 msgid "You are banned."
 msgstr ""
 
-#: ../IkiWiki/CGI.pm:385 ../IkiWiki/CGI.pm:386 ../IkiWiki.pm:1153
+#: ../IkiWiki/CGI.pm:385 ../IkiWiki/CGI.pm:386 ../IkiWiki.pm:1143
 msgid "Error"
 msgstr ""
 
@@ -904,25 +904,25 @@ msgstr ""
 msgid "refreshing wiki.."
 msgstr ""
 
-#: ../IkiWiki.pm:458
+#: ../IkiWiki.pm:451
 msgid "Must specify url to wiki with --url when using --cgi"
 msgstr ""
 
-#: ../IkiWiki.pm:504
+#: ../IkiWiki.pm:497
 msgid "cannot use multiple rcs plugins"
 msgstr ""
 
-#: ../IkiWiki.pm:533
+#: ../IkiWiki.pm:526
 #, perl-format
 msgid "failed to load external plugin needed for %s plugin: %s"
 msgstr ""
 
-#: ../IkiWiki.pm:1136
+#: ../IkiWiki.pm:1126
 #, perl-format
 msgid "preprocessing loop detected on %s at depth %i"
 msgstr ""
 
-#: ../IkiWiki.pm:1645
+#: ../IkiWiki.pm:1635
 msgid "yes"
 msgstr ""