automatically run --gettime, and optimise it for git
* 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.master
parent
0bd6c32766
commit
dee2940c0b
|
@ -442,7 +442,6 @@ sub getsetup () {
|
||||||
},
|
},
|
||||||
gettime => {
|
gettime => {
|
||||||
type => "internal",
|
type => "internal",
|
||||||
default => 0,
|
|
||||||
description => "running in gettime mode",
|
description => "running in gettime mode",
|
||||||
safe => 0,
|
safe => 0,
|
||||||
rebuild => 0,
|
rebuild => 0,
|
||||||
|
@ -1512,6 +1511,7 @@ sub loadindex () {
|
||||||
open ($in, "<", "$config{wikistatedir}/indexdb") || return;
|
open ($in, "<", "$config{wikistatedir}/indexdb") || return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
$config{gettime}=1; # first build
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
# Remove srcdir prefix
|
||||||
$file =~ s/^\Q$config{srcdir}\E\/?//;
|
$file =~ s/^\Q$config{srcdir}\E\/?//;
|
||||||
|
|
||||||
my @raw_lines = run_or_die('git', 'log',
|
if (! keys %time_cache) {
|
||||||
'--follow', '--no-merges',
|
my $date;
|
||||||
'--pretty=raw', '--raw', '--abbrev=40', '--always', '-c',
|
foreach my $line (run_or_die('git', 'log',
|
||||||
'-r', '--', $file);
|
'--pretty=format:%ct',
|
||||||
my @ci;
|
'--name-only', '--relative')) {
|
||||||
while (my $parsed = parse_diff_tree("", \@raw_lines)) {
|
if (! defined $date && $line =~ /^(\d+)$/) {
|
||||||
push @ci, $parsed;
|
$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 () {
|
||||||
|
|
|
@ -352,6 +352,8 @@ sub find_new_files ($) {
|
||||||
my @new;
|
my @new;
|
||||||
my @internal_new;
|
my @internal_new;
|
||||||
|
|
||||||
|
my $times_noted;
|
||||||
|
|
||||||
foreach my $file (@$files) {
|
foreach my $file (@$files) {
|
||||||
my $page=pagename($file);
|
my $page=pagename($file);
|
||||||
if (exists $pagesources{$page} && $pagesources{$page} ne $file) {
|
if (exists $pagesources{$page} && $pagesources{$page} ne $file) {
|
||||||
|
@ -363,7 +365,12 @@ sub find_new_files ($) {
|
||||||
if (isinternal($page)) {
|
if (isinternal($page)) {
|
||||||
push @internal_new, $file;
|
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;
|
push @new, $file;
|
||||||
if ($config{gettime} && -e "$config{srcdir}/$file") {
|
if ($config{gettime} && -e "$config{srcdir}/$file") {
|
||||||
eval {
|
eval {
|
||||||
|
@ -377,7 +384,7 @@ sub find_new_files ($) {
|
||||||
}
|
}
|
||||||
my $mtime;
|
my $mtime;
|
||||||
eval {
|
eval {
|
||||||
my $mtime=rcs_getmtime("$config{srcdir}/$file");
|
$mtime=rcs_getmtime("$config{srcdir}/$file");
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
print STDERR $@;
|
print STDERR $@;
|
||||||
|
|
|
@ -47,8 +47,15 @@ ikiwiki (3.20100415) UNRELEASED; urgency=low
|
||||||
* Rename --getctime to --gettime. (The old name still works for
|
* Rename --getctime to --gettime. (The old name still works for
|
||||||
backwards compatability.)
|
backwards compatability.)
|
||||||
* --gettime now also looks up last modification time.
|
* --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
|
* Add rcs_getmtime to plugin API; currently only implemented
|
||||||
for git.
|
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
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ Build-Depends-Indep: dpkg-dev (>= 1.9.0), libxml-simple-perl,
|
||||||
libtimedate-perl, libhtml-template-perl,
|
libtimedate-perl, libhtml-template-perl,
|
||||||
libhtml-scrubber-perl, wdg-html-validator,
|
libhtml-scrubber-perl, wdg-html-validator,
|
||||||
libhtml-parser-perl, liburi-perl, perlmagick, po4a (>= 0.34),
|
libhtml-parser-perl, liburi-perl, perlmagick, po4a (>= 0.34),
|
||||||
libfile-chdir-perl
|
libfile-chdir-perl,
|
||||||
Maintainer: Joey Hess <joeyh@debian.org>
|
Maintainer: Joey Hess <joeyh@debian.org>
|
||||||
Uploaders: Josh Triplett <josh@freedesktop.org>
|
Uploaders: Josh Triplett <josh@freedesktop.org>
|
||||||
Standards-Version: 3.8.4
|
Standards-Version: 3.8.4
|
||||||
|
|
|
@ -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($)`
|
#### `rcs_getmtime($)`
|
||||||
|
|
||||||
This is used to get the page modification time for a file from the RCS, by
|
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()`
|
#### `rcs_receive()`
|
||||||
|
|
||||||
This is called when ikiwiki is running as a pre-receive hook (or
|
This is called when ikiwiki is running as a pre-receive hook (or
|
||||||
|
|
|
@ -320,7 +320,7 @@ also be configured using a setup file.
|
||||||
intercepted. If you enable this option then you must run at least the
|
intercepted. If you enable this option then you must run at least the
|
||||||
CGI portion of ikiwiki over SSL.
|
CGI portion of ikiwiki over SSL.
|
||||||
|
|
||||||
* --gettime
|
* --gettime, --no-gettime
|
||||||
|
|
||||||
Extract creation and modification times for each new page from the
|
Extract creation and modification times for each new page from the
|
||||||
the revision control's log. This is done automatically when building a
|
the revision control's log. This is done automatically when building a
|
||||||
|
|
|
@ -1,6 +1,18 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
# Configuration file for ikiwiki to build its documentation wiki.
|
# 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 {
|
use IkiWiki::Setup::Standard {
|
||||||
wikiname => "ikiwiki",
|
wikiname => "ikiwiki",
|
||||||
srcdir => "doc",
|
srcdir => "doc",
|
||||||
|
@ -9,7 +21,7 @@ use IkiWiki::Setup::Standard {
|
||||||
underlaydirbase => "underlays",
|
underlaydirbase => "underlays",
|
||||||
underlaydir => "underlays/basewiki",
|
underlaydir => "underlays/basewiki",
|
||||||
discussion => 0,
|
discussion => 0,
|
||||||
exclude => qr/\/discussion|bugs\/*|todo\/*|forum\/*/,
|
exclude => qr/\/discussion|bugs\/*|todo\/*|forum\/*/, # save space
|
||||||
locale => '',
|
locale => '',
|
||||||
verbose => 1,
|
verbose => 1,
|
||||||
syslog => 0,
|
syslog => 0,
|
||||||
|
@ -17,4 +29,7 @@ use IkiWiki::Setup::Standard {
|
||||||
usedirs => 0,
|
usedirs => 0,
|
||||||
prefix_directives => 1,
|
prefix_directives => 1,
|
||||||
add_plugins => [qw{goodstuff version haiku polygen fortune table}],
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ sub getconfig () {
|
||||||
"usedirs!" => \$config{usedirs},
|
"usedirs!" => \$config{usedirs},
|
||||||
"prefix-directives!" => \$config{prefix_directives},
|
"prefix-directives!" => \$config{prefix_directives},
|
||||||
"getctime" => \$config{gettime},
|
"getctime" => \$config{gettime},
|
||||||
"gettime" => \$config{gettime},
|
"gettime!" => \$config{gettime},
|
||||||
"numbacklinks=i" => \$config{numbacklinks},
|
"numbacklinks=i" => \$config{numbacklinks},
|
||||||
"rcs=s" => \$config{rcs},
|
"rcs=s" => \$config{rcs},
|
||||||
"no-rcs" => sub { $config{rcs}="" },
|
"no-rcs" => sub { $config{rcs}="" },
|
||||||
|
|
Loading…
Reference in New Issue