]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
Reorganize index file, add a format version field.
authorJoey Hess <joey@kodama.kitenet.net>
Sat, 27 Sep 2008 20:34:09 +0000 (16:34 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Sat, 27 Sep 2008 20:35:56 +0000 (16:35 -0400)
Upgrades to the new index format should be transparent.

The version field is 3, because 1 was the old textual index, 2 was the
pre-versioned format.

This also includes some efficiency improvements to index loading, by
not copying a hash and using a reference.

IkiWiki.pm
IkiWiki/Plugin/edittemplate.pm
debian/changelog
po/ikiwiki.pot

index c15ec38220b8680b87e9dfbba0d88deb829d0280..9a81c7da4caaf635cfe111afa807ebea30401b76 100644 (file)
@@ -1309,31 +1309,40 @@ sub loadindex () { #{{{
                        return;
                }
        }
-       my $ret=Storable::fd_retrieve($in);
-       if (! defined $ret) {
+
+       my $index=Storable::fd_retrieve($in);
+       if (! defined $index) {
                return 0;
        }
-       my %index=%$ret;
-       foreach my $src (keys %index) {
-               my %d=%{$index{$src}};
+
+       my $pages;
+       if (exists $index->{version} && ! ref $index->{version}) {
+               $pages=$index->{page};
+       }
+       else {
+               $pages=$index;
+       }
+
+       foreach my $src (keys %$pages) {
+               my $d=$pages->{$src};
                my $page=pagename($src);
-               $pagectime{$page}=$d{ctime};
+               $pagectime{$page}=$d->{ctime};
                if (! $config{rebuild}) {
                        $pagesources{$page}=$src;
-                       $pagemtime{$page}=$d{mtime};
-                       $renderedfiles{$page}=$d{dest};
-                       if (exists $d{links} && ref $d{links}) {
-                               $links{$page}=$d{links};
-                               $oldlinks{$page}=[@{$d{links}}];
+                       $pagemtime{$page}=$d->{mtime};
+                       $renderedfiles{$page}=$d->{dest};
+                       if (exists $d->{links} && ref $d->{links}) {
+                               $links{$page}=$d->{links};
+                               $oldlinks{$page}=[@{$d->{links}}];
                        }
-                       if (exists $d{depends}) {
-                               $depends{$page}=$d{depends};
+                       if (exists $d->{depends}) {
+                               $depends{$page}=$d->{depends};
                        }
-                       if (exists $d{state}) {
-                               $pagestate{$page}=$d{state};
+                       if (exists $d->{state}) {
+                               $pagestate{$page}=$d->{state};
                        }
                }
-               $oldrenderedfiles{$page}=[@{$d{dest}}];
+               $oldrenderedfiles{$page}=[@{$d->{dest}}];
        }
        foreach my $page (keys %pagesources) {
                $pagecase{lc $page}=$page;
@@ -1364,7 +1373,7 @@ sub saveindex () { #{{{
                next unless $pagemtime{$page};
                my $src=$pagesources{$page};
 
-               $index{$src}={
+               $index{page}{$src}={
                        ctime => $pagectime{$page},
                        mtime => $pagemtime{$page},
                        dest => $renderedfiles{$page},
@@ -1372,17 +1381,18 @@ sub saveindex () { #{{{
                };
 
                if (exists $depends{$page}) {
-                       $index{$src}{depends} = $depends{$page};
+                       $index{page}{$src}{depends} = $depends{$page};
                }
 
                if (exists $pagestate{$page}) {
                        foreach my $id (@hookids) {
                                foreach my $key (keys %{$pagestate{$page}{$id}}) {
-                                       $index{$src}{state}{$id}{$key}=$pagestate{$page}{$id}{$key};
+                                       $index{page}{$src}{state}{$id}{$key}=$pagestate{$page}{$id}{$key};
                                }
                        }
                }
        }
+       $index{version}="3";
        my $ret=Storable::nstore_fd(\%index, $out);
        return if ! defined $ret || ! $ret;
        close $out || error("failed saving to $newfile: $!", $cleanup);
index 846b4e7c832c499a0755860b2c277b282a2b2f1d..189a066d83040a744be6a58efec6d626d140659b 100644 (file)
@@ -16,6 +16,8 @@ sub import { #{{{
                call => \&preprocess);
        hook(type => "formbuilder", id => "edittemplate",
                call => \&formbuilder);
+       hook(type => "refresh", id => "edittemplate",
+               call => \&refresh);
 } #}}}
 
 sub getsetup () { #{{{
@@ -138,4 +140,8 @@ sub filltemplate ($$) { #{{{
        return $template->output;
 } #}}}
 
+sub refresh () {
+       
+}
+
 1
index 1483bec64ffb439f231883a694567bad768cf26a..2ea92c4c3e4ff04101ef6dffce4a04b76e0631f4 100644 (file)
@@ -19,6 +19,10 @@ ikiwiki (2.66) UNRELEASED; urgency=low
     untidied content if tidy crashes. In either case, it seems best to tidy
     the content to nothing.
   * htmltidy: Avoid spewing tidy errors to stderr.
+  * Add %wikistate, which is like %pagestate except not specific to a given
+    page, and is preserved across rebuilds.
+  * Reorganize index file, add a format version field. Upgrades to the new
+    index format should be transparent.
 
  -- Joey Hess <joeyh@debian.org>  Thu, 25 Sep 2008 13:45:55 -0400
 
index f8796acfed04ee1e71e9c2cfaa1b1f73ae3238a3..f338750eadf23108a7a60e13a9c310a0d9761953 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-09-27 14:12-0400\n"
+"POT-Creation-Date: 2008-09-27 16:35-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"
@@ -220,20 +220,20 @@ msgstr ""
 msgid "editing %s"
 msgstr ""
 
-#: ../IkiWiki/Plugin/edittemplate.pm:51
+#: ../IkiWiki/Plugin/edittemplate.pm:53
 msgid "template not specified"
 msgstr ""
 
-#: ../IkiWiki/Plugin/edittemplate.pm:54
+#: ../IkiWiki/Plugin/edittemplate.pm:56
 msgid "match not specified"
 msgstr ""
 
-#: ../IkiWiki/Plugin/edittemplate.pm:62
+#: ../IkiWiki/Plugin/edittemplate.pm:64
 #, perl-format
 msgid "edittemplate %s registered for %s"
 msgstr ""
 
-#: ../IkiWiki/Plugin/edittemplate.pm:133
+#: ../IkiWiki/Plugin/edittemplate.pm:135
 msgid "failed to process"
 msgstr ""
 
@@ -910,7 +910,7 @@ msgstr ""
 msgid "preprocessing loop detected on %s at depth %i"
 msgstr ""
 
-#: ../IkiWiki.pm:1614
+#: ../IkiWiki.pm:1624
 msgid "yes"
 msgstr ""