6 $dir = "/tmp/ikiwiki-test-hg.$$";
9 if (! -x $hg || ! mkdir($dir)) {
11 use Test::More skip_all => "hg not available or could not make test dir"
15 use Test::More tests => 11;
17 BEGIN { use_ok("IkiWiki"); }
19 %config=IkiWiki::defaultconfig();
20 $config{rcs} = "mercurial";
21 $config{srcdir} = "$dir/repo";
22 IkiWiki::loadplugins();
23 IkiWiki::checkconfig();
26 my $session=CGI::Session->new;
27 $session->param("name", "Joe User");
29 system "hg init $config{srcdir}";
32 my $test1 = readfile("t/test1.mdwn");
33 writefile('test1.mdwn', $config{srcdir}, $test1);
34 IkiWiki::rcs_add("test1.mdwn");
37 message => "Added the first page",
43 @changes = IkiWiki::rcs_recentchanges(3);
46 is($changes[0]{message}[0]{"line"}, "Added the first page");
47 is($changes[0]{pages}[0]{"page"}, "test1");
48 is($changes[0]{user}, "Joe User");
51 my $username = "Foo Bar";
52 my $user = "$username <foo.bar\@example.com>";
53 my $message = "Added the second page";
55 my $test2 = readfile("t/test2.mdwn");
56 writefile('test2.mdwn', $config{srcdir}, $test2);
57 system "hg add -R $config{srcdir} $config{srcdir}/test2.mdwn";
58 system "hg commit -R $config{srcdir} -u \"$user\" -m \"$message\" -d \"0 0\"";
60 @changes = IkiWiki::rcs_recentchanges(3);
63 is($changes[0]{message}[0]{"line"}, $message);
64 is($changes[0]{user}, $username);
65 is($changes[0]{pages}[0]{"page"}, "test2");
67 is($changes[1]{pages}[0]{"page"}, "test1");
69 my $ctime = IkiWiki::rcs_getctime("test2.mdwn");