#!/usr/bin/perl
-
-package IkiWiki;
+package IkiWiki::Plugin::monotone;
use warnings;
use strict;
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};
}
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,
},
safe => 0, # path
rebuild => 0,
},
-}); #}}}
+} #}}}
sub get_rev () { #{{{
my $sha1 = `mtn --root=$config{mtnrootdir} automate get_base_revision_id`;
return $mergeRev;
} #}}}
-sub commit_file_to_new_rev($$$$$$$$) { #{{{
+sub commit_file_to_new_rev ($$$$$$$$) { #{{{
my $automator=shift;
my $wsfilename=shift;
my $oldFileID=shift;
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",
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");
}
}