* Mercurial backend improvements, including --get-ctime support.

master
joey 2006-11-26 20:01:43 +00:00
parent 06137b95d4
commit b20d4f6681
4 changed files with 29 additions and 6 deletions

View File

@ -107,6 +107,9 @@ sub rcs_recentchanges ($) { #{{{
my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "-l", $num);
open (my $out, "@cmdline |");
eval q{use Date::Parse};
error($@) if $@;
my @ret;
foreach my $info (mercurial_log($out)) {
my @pages = ();
@ -135,7 +138,7 @@ sub rcs_recentchanges ($) { #{{{
rev => $info->{"changeset"},
user => $user,
committype => "mercurial",
when => $info->{"date"},
when => str2time($info->{"date"}),
message => [@message],
pages => [@pages],
};
@ -149,7 +152,24 @@ sub rcs_notify () { #{{{
} #}}}
sub rcs_getctime ($) { #{{{
error "getctime not implemented";
my ($file) = @_;
# XXX filename passes through the shell here, should try to avoid
# that just in case
my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "-l", '1', $file);
open (my $out, "@cmdline |");
my @log = mercurial_log($out);
if (length @log < 1) {
return 0;
}
eval q{use Date::Parse};
error($@) if $@;
my $ctime = str2time($log[0]->{"date"});
return $ctime;
} #}}}
1

3
debian/changelog vendored
View File

@ -46,8 +46,9 @@ ikiwiki (1.34) UNRELEASED; urgency=low
* Add softwaresite example.
* Add a poll plugin.
* Add quick mode for archive page generation.
* Mercurial backend improvements, including --get-ctime support.
-- Joey Hess <joeyh@debian.org> Thu, 23 Nov 2006 17:13:32 -0500
-- Joey Hess <joeyh@debian.org> Sun, 26 Nov 2006 15:01:14 -0500
ikiwiki (1.33) unstable; urgency=low

View File

@ -1,4 +1,3 @@
* Need to get post commit hook working (or an example of how to use it.)
* Need --ctime support.
* rcs_notify is not implemented
* Is the code sufficiently robust? It just warns when mercurial fails.

View File

@ -12,7 +12,7 @@ BEGIN {
}
}
}
use Test::More tests => 10;
use Test::More tests => 11;
BEGIN { use_ok("IkiWiki"); }
@ -45,7 +45,7 @@ my $message = "Added the second page";
my $test2 = readfile("t/test2.mdwn");
writefile('test2.mdwn', $config{srcdir}, $test2);
system "hg add -R $config{srcdir} $config{srcdir}/test2.mdwn";
system "hg commit -R $config{srcdir} -u \"$user\" -m \"$message\"";
system "hg commit -R $config{srcdir} -u \"$user\" -m \"$message\" -d \"0 0\"";
@changes = IkiWiki::rcs_recentchanges(3);
@ -56,4 +56,7 @@ is($changes[0]{pages}[0]{"page"}, "test2.mdwn");
is($changes[1]{pages}[0]{"page"}, "test1.mdwn");
my $ctime = IkiWiki::rcs_getctime("test2.mdwn");
is($ctime, 0);
system "rm -rf $dir";