]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/monotone.pm
Merge commit 'upstream/master' into pub/master
[git.ikiwiki.info.git] / IkiWiki / Plugin / monotone.pm
index d7e8f296a69f6d80c205ebbcaa4e40f3dc49e8a3..f31a8606bb4f664b6d626c345e668bf4e884dda3 100644 (file)
@@ -1,6 +1,5 @@
 #!/usr/bin/perl
-
-package IkiWiki;
+package IkiWiki::Plugin::monotone;
 
 use warnings;
 use strict;
@@ -11,7 +10,22 @@ use Date::Format qw(time2str);
 
 my $sha1_pattern = qr/[0-9a-fA-F]{40}/; # pattern to validate sha1sums
 
-hook(type => "checkconfig", id => "monotone", call => sub { #{{{
+sub import { #{{{
+       hook(type => "checkconfig", id => "monotone", call => \&checkconfig);
+       hook(type => "getsetup", id => "monotone", call => \&getsetup);
+       hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
+       hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit);
+       hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit);
+       hook(type => "rcs", id => "rcs_commit_staged", call => \&rcs_commit_staged);
+       hook(type => "rcs", id => "rcs_add", call => \&rcs_add);
+       hook(type => "rcs", id => "rcs_remove", call => \&rcs_remove);
+       hook(type => "rcs", id => "rcs_rename", call => \&rcs_rename);
+       hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges);
+       hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
+       hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
+} #}}}
+
+sub checkconfig () { #{{{
        if (!defined($config{mtnrootdir})) {
                $config{mtnrootdir} = $config{srcdir};
        }
@@ -41,20 +55,24 @@ hook(type => "checkconfig", id => "monotone", call => sub { #{{{
                error("Monotone version too old, is $version but required 0.38");
        }
 
-       if (length $config{mtn_wrapper}) {
+       if (defined $config{mtn_wrapper} && length $config{mtn_wrapper}) {
                push @{$config{wrappers}}, {
                        wrapper => $config{mtn_wrapper},
                        wrappermode => (defined $config{mtn_wrappermode} ? $config{mtn_wrappermode} : "06755"),
                };
        }
-}); #}}}
+} #}}}
 
-hook(type => "getsetup", id => "monotone", call => sub { #{{{
+sub getsetup () { #{{{
        return
+               plugin => {
+                       safe => 0, # rcs plugin
+                       rebuild => undef,
+               },
                mtn_wrapper => {
                        type => "string",
                        example => "/srv/mtn/wiki/_MTN/ikiwiki-netsync-hook",
-                       description => "monotone netsync hook executable to generate",
+                       description => "monotone netsync hook to generate",
                        safe => 0, # file
                        rebuild => 0,
                },
@@ -99,7 +117,7 @@ hook(type => "getsetup", id => "monotone", call => sub { #{{{
                        safe => 0, # path
                        rebuild => 0,
                },
-}); #}}}
+} #}}}
 
 sub get_rev () { #{{{
        my $sha1 = `mtn --root=$config{mtnrootdir} automate get_base_revision_id`;
@@ -156,7 +174,7 @@ sub mtn_merge ($$$$) { #{{{
        return $mergeRev;
 } #}}}
 
-sub commit_file_to_new_rev($$$$$$$$) { #{{{
+sub commit_file_to_new_rev ($$$$$$$$) { #{{{
        my $automator=shift;
        my $wsfilename=shift;
        my $oldFileID=shift;
@@ -398,7 +416,7 @@ sub rcs_commit ($$$;$$) { #{{{
 
        if (system("mtn", "--root=$config{mtnrootdir}", "commit", "--quiet",
                   "--author", $author, "--key", $config{mtnkey}, "-m",
-                  possibly_foolish_untaint($message), $file) != 0) {
+                  IkiWiki::possibly_foolish_untaint($message), $file) != 0) {
                debug("Traditional commit failed! Returning data as conflict.");
                my $conflict=readfile("$config{srcdir}/$file");
                if (system("mtn", "--root=$config{mtnrootdir}", "revert",
@@ -443,7 +461,7 @@ sub rcs_commit_staged ($$$) {
 
        if (system("mtn", "--root=$config{mtnrootdir}", "commit", "--quiet",
                   "--author", $author, "--key", $config{mtnkey}, "-m",
-                  possibly_foolish_untaint($message)) != 0) {
+                  IkiWiki::possibly_foolish_untaint($message)) != 0) {
                error("Monotone commit failed");
        }
 }