diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-09-29 18:05:39 -0400 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-09-29 18:05:39 -0400 |
commit | bb4211e326bd16099cb353353055497f2fb5a0c9 (patch) | |
tree | 29a81680dd8d1e212774e2e16d6daec74be9cde2 /IkiWiki/Plugin | |
parent | 1f1867a6fc52daa26b4bfe0aa597df8edee24595 (diff) |
avoid unnecessarily rebuilding pages with complex conditionals
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.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r-- | IkiWiki/Plugin/conditional.pm | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/conditional.pm b/IkiWiki/Plugin/conditional.pm index 7716fce1b..e787424aa 100644 --- a/IkiWiki/Plugin/conditional.pm +++ b/IkiWiki/Plugin/conditional.pm @@ -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}, |