]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
automatically run --gettime, and optimise it for git
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 16 Apr 2010 22:29:45 +0000 (18:29 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 16 Apr 2010 22:30:56 +0000 (18:30 -0400)
* Automatically run --gettime the first time ikiwiki is run on
  a given srcdir.
* Optimise --gettime for git, so it's appropriatly screamingly
  fast. (This could be done for other backends too.)
* However, --gettime for git no longer follows renames.
* Use above to fix up timestamps on docwiki, as well as ensure that
  timestamps on basewiki files shipped in the deb are sane.

IkiWiki.pm
IkiWiki/Plugin/git.pm
IkiWiki/Render.pm
debian/changelog
debian/control
doc/plugins/write.mdwn
doc/usage.mdwn
docwiki.setup
ikiwiki.in

index 7655dada5705b16583fe1412eabfd5e2a5413e05..b37b1f34485b6301dfd7847d75ebb625e8c6295d 100644 (file)
@@ -442,7 +442,6 @@ sub getsetup () {
        },
        gettime => {
                type => "internal",
        },
        gettime => {
                type => "internal",
-               default => 0,
                description => "running in gettime mode",
                safe => 0,
                rebuild => 0,
                description => "running in gettime mode",
                safe => 0,
                rebuild => 0,
@@ -1512,6 +1511,7 @@ sub loadindex () {
                        open ($in, "<", "$config{wikistatedir}/indexdb") || return;
                }
                else {
                        open ($in, "<", "$config{wikistatedir}/indexdb") || return;
                }
                else {
+                       $config{gettime}=1; # first build
                        return;
                }
        }
                        return;
                }
        }
index 86d80186f3f8671140dc01a00706e2d265545779..aa402c04f4e461b9450a0192313de1dda8726f49 100644 (file)
@@ -616,27 +616,51 @@ sub rcs_diff ($) {
        }
 }
 
        }
 }
 
-sub rcs_getctime ($) {
+{
+my %time_cache;
+
+sub findtimes ($$) {
        my $file=shift;
        my $file=shift;
+       my $id=shift; # 0 = mtime ; 1 = ctime
+
        # Remove srcdir prefix
        $file =~ s/^\Q$config{srcdir}\E\/?//;
 
        # Remove srcdir prefix
        $file =~ s/^\Q$config{srcdir}\E\/?//;
 
-       my @raw_lines = run_or_die('git', 'log', 
-               '--follow', '--no-merges',
-               '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c',
-               '-r', '--', $file);
-       my @ci;
-       while (my $parsed = parse_diff_tree("", \@raw_lines)) {
-               push @ci, $parsed;
+       if (! keys %time_cache) {
+               my $date;
+               foreach my $line (run_or_die('git', 'log',
+                               '--pretty=format:%ct',
+                               '--name-only', '--relative')) {
+                       if (! defined $date && $line =~ /^(\d+)$/) {
+                               $date=$line;
+                       }
+                       elsif (! length $line) {
+                               $date=undef;
+                       }
+                       else {
+                               if (! $time_cache{$line}) {
+                                       $time_cache{$line}[0]=$date; # mtime
+                               }
+                               $time_cache{$line}[1]=$date; # ctime
+                       }
+               }
        }
        }
-       my $ctime = $ci[$#ci]->{'author_epoch'};
-       debug("ctime for '$file': ". localtime($ctime));
 
 
-       return $ctime;
+       return exists $time_cache{$file} ? $time_cache{$file}[$id] : 0;
+}
+
+}
+
+sub rcs_getctime ($) {
+       my $file=shift;
+
+       return findtimes($file, 1);
 }
 
 sub rcs_getmtime ($) {
 }
 
 sub rcs_getmtime ($) {
-       error "rcs_getmtime is not implemented for git\n"; # TODO
+       my $file=shift;
+
+       return findtimes($file, 0);
 }
 
 sub rcs_receive () {
 }
 
 sub rcs_receive () {
index e1cb68462611c1107a78c4bf84ed0cb8aab33986..a6b0f0617256db4aff42a38c92da43d0c3085b72 100644 (file)
@@ -352,6 +352,8 @@ sub find_new_files ($) {
        my @new;
        my @internal_new;
 
        my @new;
        my @internal_new;
 
+       my $times_noted;
+
        foreach my $file (@$files) {
                my $page=pagename($file);
                if (exists $pagesources{$page} && $pagesources{$page} ne $file) {
        foreach my $file (@$files) {
                my $page=pagename($file);
                if (exists $pagesources{$page} && $pagesources{$page} ne $file) {
@@ -363,7 +365,12 @@ sub find_new_files ($) {
                        if (isinternal($page)) {
                                push @internal_new, $file;
                        }
                        if (isinternal($page)) {
                                push @internal_new, $file;
                        }
-                       else {
+                       elsif ($config{rcs}) {
+                               if (! $times_noted) {
+                                       debug(sprintf(gettext("querying %s for file creation and modification times.."), $config{rcs}));
+                                       $times_noted=1;
+                               }
+
                                push @new, $file;
                                if ($config{gettime} && -e "$config{srcdir}/$file") {
                                        eval {
                                push @new, $file;
                                if ($config{gettime} && -e "$config{srcdir}/$file") {
                                        eval {
@@ -377,7 +384,7 @@ sub find_new_files ($) {
                                        }
                                        my $mtime;
                                        eval {
                                        }
                                        my $mtime;
                                        eval {
-                                               my $mtime=rcs_getmtime("$config{srcdir}/$file");
+                                               $mtime=rcs_getmtime("$config{srcdir}/$file");
                                        };
                                        if ($@) {
                                                print STDERR $@;
                                        };
                                        if ($@) {
                                                print STDERR $@;
index 615d5916fec4d2b0c47688f78244efcb95a61af9..60a67cbe3b618e23e210d2b856f9753bf38d38a0 100644 (file)
@@ -47,8 +47,15 @@ ikiwiki (3.20100415) UNRELEASED; urgency=low
   * Rename --getctime to --gettime. (The old name still works for
     backwards compatability.)
   * --gettime now also looks up last modification time.
   * Rename --getctime to --gettime. (The old name still works for
     backwards compatability.)
   * --gettime now also looks up last modification time.
+  * Automatically run --gettime the first time ikiwiki is run on 
+    a given srcdir.
   * Add rcs_getmtime to plugin API; currently only implemented
     for git.
   * Add rcs_getmtime to plugin API; currently only implemented
     for git.
+  * Optimise --gettime for git, so it's appropriatly screamingly
+    fast. (This could be done for other backends too.)
+  * However, --gettime for git no longer follows renames.
+  * Use above to fix up timestamps on docwiki, as well as ensure that
+    timestamps on basewiki files shipped in the deb are sane.
 
  -- Joey Hess <joeyh@debian.org>  Sun, 04 Apr 2010 12:17:11 -0400
 
 
  -- Joey Hess <joeyh@debian.org>  Sun, 04 Apr 2010 12:17:11 -0400
 
index 87f7d82096c1e9961e9f4ab6f2931375e40fec8f..ae06f32b094867d1070de18a27bf0b059bca7134 100644 (file)
@@ -7,7 +7,7 @@ Build-Depends-Indep: dpkg-dev (>= 1.9.0), libxml-simple-perl,
   libtimedate-perl, libhtml-template-perl,
   libhtml-scrubber-perl, wdg-html-validator,
   libhtml-parser-perl, liburi-perl, perlmagick, po4a (>= 0.34),
   libtimedate-perl, libhtml-template-perl,
   libhtml-scrubber-perl, wdg-html-validator,
   libhtml-parser-perl, liburi-perl, perlmagick, po4a (>= 0.34),
-  libfile-chdir-perl
+  libfile-chdir-perl,
 Maintainer: Joey Hess <joeyh@debian.org>
 Uploaders: Josh Triplett <josh@freedesktop.org>
 Standards-Version: 3.8.4
 Maintainer: Joey Hess <joeyh@debian.org>
 Uploaders: Josh Triplett <josh@freedesktop.org>
 Standards-Version: 3.8.4
index cf7044b2cbea60c63e3b85b806b7c5170017a2ab..0bf6fcf48ff17b48c60a9cad37a0ded3cd60f0c9 100644 (file)
@@ -1085,6 +1085,8 @@ it up in the history.
 
 It's ok if this is not implemented, and throws an error.
 
 
 It's ok if this is not implemented, and throws an error.
 
+If the RCS cannot determine a ctime for the file, return 0.
+
 #### `rcs_getmtime($)`
 
 This is used to get the page modification time for a file from the RCS, by
 #### `rcs_getmtime($)`
 
 This is used to get the page modification time for a file from the RCS, by
@@ -1092,6 +1094,8 @@ looking it up in the history.
 
 It's ok if this is not implemented, and throws an error.
 
 
 It's ok if this is not implemented, and throws an error.
 
+If the RCS cannot determine a mtime for the file, return 0.
+
 #### `rcs_receive()`
 
 This is called when ikiwiki is running as a pre-receive hook (or
 #### `rcs_receive()`
 
 This is called when ikiwiki is running as a pre-receive hook (or
index 553fef01ef447fff557ca997db1871b8c8a8619c..2e12517ea9105ab17e6e792a78271cc59f149a77 100644 (file)
@@ -320,7 +320,7 @@ also be configured using a setup file.
   intercepted. If you enable this option then you must run at least the 
   CGI portion of ikiwiki over SSL.
 
   intercepted. If you enable this option then you must run at least the 
   CGI portion of ikiwiki over SSL.
 
-* --gettime
+* --gettime, --no-gettime
 
   Extract creation and modification times for each new page from the
   the revision control's log. This is done automatically when building a
 
   Extract creation and modification times for each new page from the
   the revision control's log. This is done automatically when building a
index 8278b73ea5c95ea44b16a690a996a9286db20fe2..6bc200066fe565007cb6cc3228c0ac74e4ee19c5 100644 (file)
@@ -1,6 +1,18 @@
 #!/usr/bin/perl
 # Configuration file for ikiwiki to build its documentation wiki.
 
 #!/usr/bin/perl
 # Configuration file for ikiwiki to build its documentation wiki.
 
+# Use git during the build, if it's available and if we're building
+# from a git checkout. This ensures ikiwiki gets the right mtimes and
+# ctimes for files in the doc wiki.
+our $rcs="norcs";
+BEGIN {
+       my $git=`which git 2>&1`;
+       chomp $git;
+       if (-x $git && -d ".git") {
+               $rcs="git";
+       }
+}
+
 use IkiWiki::Setup::Standard {
        wikiname => "ikiwiki",
        srcdir => "doc",
 use IkiWiki::Setup::Standard {
        wikiname => "ikiwiki",
        srcdir => "doc",
@@ -9,7 +21,7 @@ use IkiWiki::Setup::Standard {
        underlaydirbase => "underlays",
        underlaydir => "underlays/basewiki",
        discussion => 0,
        underlaydirbase => "underlays",
        underlaydir => "underlays/basewiki",
        discussion => 0,
-       exclude => qr/\/discussion|bugs\/*|todo\/*|forum\/*/,
+       exclude => qr/\/discussion|bugs\/*|todo\/*|forum\/*/, # save space
        locale => '',
        verbose => 1,
        syslog => 0,
        locale => '',
        verbose => 1,
        syslog => 0,
@@ -17,4 +29,7 @@ use IkiWiki::Setup::Standard {
        usedirs => 0,
        prefix_directives => 1,
        add_plugins => [qw{goodstuff version haiku polygen fortune table}],
        usedirs => 0,
        prefix_directives => 1,
        add_plugins => [qw{goodstuff version haiku polygen fortune table}],
+       disable_plugins => [qw{recentchanges}], # not appropriate for doc dir
+       rcs => $rcs,
+       gitorigin_branch => '', # don't pull during build
 }
 }
index 801ff9a0bf0ad2ea5fcc79c019dd41955e366e5e..acd37f8026c1a2a9ab076a877358617e9e20435e 100755 (executable)
@@ -45,7 +45,7 @@ sub getconfig () {
                        "usedirs!" => \$config{usedirs},
                        "prefix-directives!" => \$config{prefix_directives},
                        "getctime" => \$config{gettime},
                        "usedirs!" => \$config{usedirs},
                        "prefix-directives!" => \$config{prefix_directives},
                        "getctime" => \$config{gettime},
-                       "gettime" => \$config{gettime},
+                       "gettime!" => \$config{gettime},
                        "numbacklinks=i" => \$config{numbacklinks},
                        "rcs=s" => \$config{rcs},
                        "no-rcs" => sub { $config{rcs}="" },
                        "numbacklinks=i" => \$config{numbacklinks},
                        "rcs=s" => \$config{rcs},
                        "no-rcs" => sub { $config{rcs}="" },