* Mercurial backend improvements, including --get-ctime support.
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sun, 26 Nov 2006 20:01:43 +0000 (20:01 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sun, 26 Nov 2006 20:01:43 +0000 (20:01 +0000)
IkiWiki/Rcs/mercurial.pm
debian/changelog
doc/todo/mercurial.mdwn
t/mercurial.t

index da2beb7cdd0e30f0df9f902a62d651c36dfcdd69..67002ac57148bbf7fd1edda1b644d1bccba36949 100644 (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
index 345878cfcb98e75d5e09692e74990c77bf54d897..8d6c7851b2c59f26cbbd58e1ca5f3160f4d65b14 100644 (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
 
index e25039b13239ef87dd85dbd91d143d1ef937a6ec..5594a093c416a64248d0e4d4bf5fb59d83306c3a 100644 (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.
index c42e328c283bf10936766b9762d958ec6c3023e7..da4e2beaa78fc3e46284f8e8b309cbf1d74b9de4 100755 (executable)
@@ -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";