summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Rcs/mercurial.pm24
-rw-r--r--debian/changelog3
-rw-r--r--doc/todo/mercurial.mdwn1
-rwxr-xr-xt/mercurial.t7
4 files changed, 29 insertions, 6 deletions
diff --git a/IkiWiki/Rcs/mercurial.pm b/IkiWiki/Rcs/mercurial.pm
index da2beb7cd..67002ac57 100644
--- a/IkiWiki/Rcs/mercurial.pm
+++ b/IkiWiki/Rcs/mercurial.pm
@@ -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
diff --git a/debian/changelog b/debian/changelog
index 345878cfc..8d6c7851b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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
diff --git a/doc/todo/mercurial.mdwn b/doc/todo/mercurial.mdwn
index e25039b13..5594a093c 100644
--- a/doc/todo/mercurial.mdwn
+++ b/doc/todo/mercurial.mdwn
@@ -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.
diff --git a/t/mercurial.t b/t/mercurial.t
index c42e328c2..da4e2beaa 100755
--- a/t/mercurial.t
+++ b/t/mercurial.t
@@ -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";