]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Fix get_ctime implementation in Bazaar plugin, add get_mtime implementation.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 17 Apr 2010 16:45:23 +0000 (18:45 +0200)
committerJoey Hess <joey@kitenet.net>
Sat, 17 Apr 2010 17:52:16 +0000 (13:52 -0400)
IkiWiki/Plugin/bzr.pm
t/bazaar.t

index f79ca7c8f52e53831414d7f327d44664a4bf67b2..3712302cea5d7fdbdfe1738073940b4b2476d50b 100644 (file)
@@ -286,14 +286,8 @@ sub rcs_diff ($) {
        }
 }
 
-sub rcs_getctime ($) {
-       my ($file) = @_;
-
-       # XXX filename passes through the shell here, should try to avoid
-       # that just in case
-       my @cmdline = ("bzr", "log", "--limit", '1', "$config{srcdir}/$file");
-       open (my $out, "@cmdline |");
-
+sub extract_timestamp ($) {
+       my ($out) = @_;
        my @log = bzr_log($out);
 
        if (length @log < 1) {
@@ -307,8 +301,24 @@ sub rcs_getctime ($) {
        return $ctime;
 }
 
+sub rcs_getctime ($) {
+       my ($file) = @_;
+
+       # XXX filename passes through the shell here, should try to avoid
+       # that just in case
+       my @cmdline = ("bzr", "log", "--forward", "--limit", '1', "$config{srcdir}/$file");
+       open (my $out, "@cmdline |");
+       return extract_timestamp($out);
+}
+
 sub rcs_getmtime ($) {
-       error "rcs_getmtime is not implemented for bzr\n"; # TODO
+       my ($file) = @_;
+
+       # XXX filename passes through the shell here, should try to avoid
+       # that just in case
+       my @cmdline = ("bzr", "log", "--limit", '1', "$config{srcdir}/$file");
+       open (my $out, "@cmdline |");
+       return extract_timestamp($out);
 }
 
 1
index 2ca44a65e084ce1395855ae177f4fa8632ba3e5c..0bdd883d51e754d587d4a92e37d34c67b97621bf 100755 (executable)
@@ -12,7 +12,7 @@ BEGIN {
                }
        }
 }
-use Test::More tests => 16;
+use Test::More tests => 17;
 
 BEGIN { use_ok("IkiWiki"); }
 
@@ -60,6 +60,9 @@ is($changes[1]{pages}[0]{"page"}, "test1");
 my $ctime = IkiWiki::rcs_getctime("test2.mdwn");
 ok($ctime >= time() - 20);
 
+my $mtime = IkiWiki::rcs_getmtime("test2.mdwn");
+ok($mtime >= time() - 20);
+
 writefile('test3.mdwn', $config{srcdir}, $test1);
 IkiWiki::rcs_add("test3.mdwn");
 IkiWiki::rcs_rename("test3.mdwn", "test4.mdwn");