},
gettime => {
type => "internal",
- default => 0,
description => "running in gettime mode",
safe => 0,
rebuild => 0,
open ($in, "<", "$config{wikistatedir}/indexdb") || return;
}
else {
+ $config{gettime}=1; # first build
return;
}
}
}
}
-sub rcs_getctime ($) {
+{
+my %time_cache;
+
+sub findtimes ($$) {
my $file=shift;
+ my $id=shift; # 0 = mtime ; 1 = ctime
+
# 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 ($) {
- error "rcs_getmtime is not implemented for git\n"; # TODO
+ my $file=shift;
+
+ return findtimes($file, 0);
}
sub rcs_receive () {
my @new;
my @internal_new;
+ my $times_noted;
+
foreach my $file (@$files) {
my $page=pagename($file);
if (exists $pagesources{$page} && $pagesources{$page} ne $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 {
}
my $mtime;
eval {
- my $mtime=rcs_getmtime("$config{srcdir}/$file");
+ $mtime=rcs_getmtime("$config{srcdir}/$file");
};
if ($@) {
print STDERR $@;
* 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.
+ * 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
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
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
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
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
#!/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",
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,
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
}
"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}="" },