]> sipb.mit.edu Git - ikiwiki.git/blob - doc/patchqueue/pruning_is_too_strict.mdwn
web commit by EthanGlasserCamp: use a real patch format rather than just doing svn diff
[ikiwiki.git] / doc / patchqueue / pruning_is_too_strict.mdwn
1 Preliminary patch for a feature wishlist item: [[bugs/pruning_is_too_strict]].
2
3     diff --git a/IkiWiki.pm b/IkiWiki.pm
4     index 1a00f2d..0119a26 100644
5     --- a/IkiWiki.pm
6     +++ b/IkiWiki.pm
7     @@ -20,6 +20,8 @@ our $VERSION = 1.00;
8      # Optimisation.
9      use Memoize;
10      memoize("abs2rel");
11     +memoize("basefile");
12     +memoize("is_prune");
13      memoize("pagespec_translate");
14      
15      my $installdir=''; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE
16     @@ -318,6 +320,22 @@ sub baseurl (;$) { #{{{
17         return $page;
18      } #}}}
19      
20     +sub basefile ($;$) { #{{{
21     +   my $file=shift;
22     +   my $base=shift || $config{srcdir};
23     +
24     +   require File::Spec;
25     +   $base=File::Spec->canonpath($base);
26     +   my $ret=File::Spec->canonpath($file);
27     +
28     +   $ret=~s#^$base/*##;
29     +   return $ret;
30     +} #}}}
31     +
32     +sub is_prune ($;$) { #{{{
33     +   return basefile($_[0], $_[1])=~m/$config{wiki_file_prune_regexp}/;
34     +} #}}}
35     +
36      sub abs2rel ($$) { #{{{
37         # Work around very innefficient behavior in File::Spec if abs2rel
38         # is passed two relative paths. It's much faster if paths are
39     diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
40     index f550b67..5d1991d 100644
41     --- a/IkiWiki/CGI.pm
42     +++ b/IkiWiki/CGI.pm
43     @@ -386,7 +386,7 @@ sub cgi_editpage ($$) { #{{{
44         my ($page)=$form->field('page');
45         $page=titlepage(possibly_foolish_untaint($page));
46         if (! defined $page || ! length $page ||
47     -       $page=~/$config{wiki_file_prune_regexp}/ || $page=~/^\//) {
48     +       is_prune($page) || $page=~/^\//) {
49                 error("bad page name");
50         }
51         
52     @@ -476,8 +476,7 @@ sub cgi_editpage ($$) { #{{{
53                         my $best_loc;
54                         if (! defined $from || ! length $from ||
55                             $from ne $form->field('from') ||
56     -                       $from=~/$config{wiki_file_prune_regexp}/ ||
57     -                       $from=~/^\// ||
58     +                       is_prune($from) || $from=~/^\// ||
59                             $form->submitted eq "Preview") {
60                                 @page_locs=$best_loc=$page;
61                         }
62     diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
63     index 48a25be..a083d3f 100644
64     --- a/IkiWiki/Render.pm
65     +++ b/IkiWiki/Render.pm
66     @@ -202,7 +202,7 @@ sub refresh () { #{{{
67                 no_chdir => 1,
68                 wanted => sub {
69                         $_=decode_utf8($_);
70     -                   if (/$config{wiki_file_prune_regexp}/) {
71     +                   if (is_prune($_)) {
72                                 $File::Find::prune=1;
73                         }
74                         elsif (! -d $_ && ! -l $_) {
75     @@ -222,7 +222,7 @@ sub refresh () { #{{{
76                 no_chdir => 1,
77                 wanted => sub {
78                         $_=decode_utf8($_);
79     -                   if (/$config{wiki_file_prune_regexp}/) {
80     +                   if (is_prune($_, $config{underlaydir})) {
81                                 $File::Find::prune=1;
82                         }
83                         elsif (! -d $_ && ! -l $_) {