]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Rcs/mercurial.pm
fixups
[ikiwiki.git] / IkiWiki / Rcs / mercurial.pm
index 15edb324581dc33e912dc17f214117b419fa689f..3a98e09d8721c24030e988bdf6473a661e3cc695 100644 (file)
@@ -1,14 +1,58 @@
 #!/usr/bin/perl
 
+package IkiWiki;
+
 use warnings;
 use strict;
 use IkiWiki;
 use Encode;
 use open qw{:utf8 :std};
 
-package IkiWiki;
-
-sub mercurial_log($) {
+hook(type => "checkconfig", id => "mercurial", call => sub { #{{{
+       if (! defined $config{diffurl}) {
+               $config{diffurl}="";
+       }
+       if (length $config{mercurial_wrapper}) {
+               push @{$config{wrappers}}, {
+                       wrapper => $config{mercurial_wrapper},
+                       wrappermode => (defined $config{mercurial_wrappermode} ? $config{mercurial_wrappermode} : "06755"),
+               };
+       }
+}); #}}}
+
+hook(type => "getsetup", id => "mercurial", call => sub { #{{{
+       return
+               mercurial_wrapper => {
+                       type => "string",
+                       #example => # FIXME add example
+                       description => "mercurial post-commit executable to generate",
+                       safe => 0, # file
+                       rebuild => 0,
+               },
+               mercurial_wrappermode => {
+                       type => "string",
+                       example => '06755',
+                       description => "mode for mercurial_wrapper (can safely be made suid)",
+                       safe => 0,
+                       rebuild => 0,
+               },
+               historyurl => {
+                       type => "string",
+                       example => "http://example.com:8000/log/tip/[[file]]",
+                       description => "url to hg serve'd repository, to show file history ([[file]] substituted)",
+                       safe => 1,
+                       rebuild => 1,
+               },
+               diffurl => {
+                       type => "string",
+                       example => "http://localhost:8000/?fd=[[r2]];file=[[file]]",
+                       description => "url to hg serve'd repository, to show diff ([[file]] and [[r2]] substituted)",
+                       safe => 1,
+                       rebuild => 1,
+               },
+}); #}}}
+
+sub mercurial_log ($) { #{{{
        my $out = shift;
        my @infos;
 
@@ -52,7 +96,7 @@ sub mercurial_log($) {
        close $out;
 
        return @infos;
-}
+} #}}}
 
 sub rcs_update () { #{{{
        my @cmdline = ("hg", "-q", "-R", "$config{srcdir}", "update");
@@ -92,6 +136,14 @@ sub rcs_commit ($$$;$$) { #{{{
        return undef; # success
 } #}}}
 
+sub rcs_commit_staged ($$$) {
+       # Commits all staged changes. Changes can be staged using rcs_add,
+       # rcs_remove, and rcs_rename.
+       my ($message, $user, $ipaddr)=@_;
+       
+       error("rcs_commit_staged not implemented for mercurial"); # TODO
+}
+
 sub rcs_add ($) { # {{{
        my ($file) = @_;
 
@@ -101,12 +153,21 @@ sub rcs_add ($) { # {{{
        }
 } #}}}
 
+sub rcs_remove ($) { # {{{
+       my ($file) = @_;
+
+       error("rcs_remove not implemented for mercurial"); # TODO
+} #}}}
+
+sub rcs_rename ($$) { # {{{
+       my ($src, $dest) = @_;
+
+       error("rcs_rename not implemented for mercurial"); # TODO
+} #}}}
+
 sub rcs_recentchanges ($) { #{{{
        my ($num) = @_;
 
-       eval q{use CGI 'escapeHTML'};
-       error($@) if $@;
-
        my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "-l", $num,
                "--style", "default");
        open (my $out, "@cmdline |");
@@ -142,7 +203,7 @@ sub rcs_recentchanges ($) { #{{{
                        rev        => $info->{"changeset"},
                        user       => $user,
                        committype => "mercurial",
-                       when       => time - str2time($info->{"date"}),
+                       when       => str2time($info->{"date"}),
                        message    => [@message],
                        pages      => [@pages],
                };
@@ -151,7 +212,7 @@ sub rcs_recentchanges ($) { #{{{
        return @ret;
 } #}}}
 
-sub rcs_notify () { #{{{
+sub rcs_diff ($) { #{{{
        # TODO
 } #}}}