aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorRichard Levitte <richard@levitte.org>2011-03-30 16:56:15 +0200
committerRichard Levitte <richard@levitte.org>2011-03-30 16:56:15 +0200
commit83de1e4f1db63e13bda030916dfcba1ca8f75f0c (patch)
treeefd2895323d0fbe440439b379c061c2fad5618c6 /IkiWiki
parent0204dabccfafd89b1e98a33fc5165e8f0e4e0927 (diff)
downloadikiwiki-83de1e4f1db63e13bda030916dfcba1ca8f75f0c.tar
ikiwiki-83de1e4f1db63e13bda030916dfcba1ca8f75f0c.tar.gz
* IkiWiki/Plugin/monotone.pm: implement rcs_getmtime
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/monotone.pm50
1 files changed, 49 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/monotone.pm b/IkiWiki/Plugin/monotone.pm
index 38313a542..14c22ebca 100644
--- a/IkiWiki/Plugin/monotone.pm
+++ b/IkiWiki/Plugin/monotone.pm
@@ -703,7 +703,55 @@ sub rcs_getctime ($) {
}
sub rcs_getmtime ($) {
- error "rcs_getmtime is not implemented for monotone\n"; # TODO
+ my $file=shift;
+
+ chdir $config{srcdir}
+ or error("Cannot chdir to $config{srcdir}: $!");
+
+ my $child = open(MTNLOG, "-|");
+ if (! $child) {
+ exec("mtn", "log", "--root=$config{mtnrootdir}", "--no-graph",
+ "--brief", $file) || error("mtn log $file failed to run");
+ }
+
+ my $lastRev = "";
+ while (<MTNLOG>) {
+ if (/^($sha1_pattern)/ && $lastRev eq "") {
+ $lastRev=$1;
+ }
+ }
+ close MTNLOG || debug("mtn log $file exited $?");
+
+ if (! defined $lastRev) {
+ debug "failed to parse mtn log for $file";
+ return 0;
+ }
+
+ my $automator = Monotone->new();
+ $automator->open(undef, $config{mtnrootdir});
+
+ my $certs = [read_certs($automator, $lastRev)];
+
+ $automator->close();
+
+ my $date;
+
+ foreach my $cert (@$certs) {
+ if ($cert->{signature} eq "ok" && $cert->{trust} eq "trusted") {
+ if ($cert->{name} eq "date") {
+ $date = $cert->{value};
+ }
+ }
+ }
+
+ if (! defined $date) {
+ debug "failed to find date cert for revision $lastRev when looking for creation time of $file";
+ return 0;
+ }
+
+ $date=str2time($date, 'UTC');
+ debug("found mtime ".localtime($date)." for $file");
+ return $date;
}
1