]> sipb.mit.edu Git - ikiwiki.git/commitdiff
make revert hooks optional
authorJoey Hess <joey@kitenet.net>
Fri, 8 Oct 2010 21:54:12 +0000 (17:54 -0400)
committerJoey Hess <joey@kitenet.net>
Fri, 8 Oct 2010 21:54:12 +0000 (17:54 -0400)
I removed the IkiWiki::rcs_ stubs for the revert hooks. Instead
recentchanges tests to see if the hooks are available and calls
them directly.

IkiWiki.pm
IkiWiki/Plugin/recentchanges.pm
doc/plugins/write.mdwn
templates/change.tmpl

index faf4af5c7080fc783ebf8f1fd7b07881a9964d3e..1f6d70ba3ccb9311c6333f40c55d64dfa589405a 100644 (file)
@@ -1941,14 +1941,6 @@ sub rcs_receive () {
        $hooks{rcs}{rcs_receive}{call}->();
 }
 
-sub rcs_preprevert ($) {
-       $hooks{rcs}{rcs_preprevert}{call}->(@_);
-}
-
-sub rcs_revert ($) {
-       $hooks{rcs}{rcs_revert}{call}->(@_);
-}
-
 sub add_depends ($$;$) {
        my $page=shift;
        my $pagespec=shift;
index 44c981548a6913a0c6bc9e860743ec5a84eae9e1..a6d7f9fcefd98b4392cd4dcbd955c7225cde0e87 100644 (file)
@@ -93,7 +93,8 @@ sub sessioncgi ($$) {
 
        return unless $do eq 'revert' && $rev;
 
-       IkiWiki::rcs_preprevert(cgi => $q, session => $session, rev => $rev);
+       $IkiWiki::hooks{rcs}{rcs_preprevert}{call}->(
+               cgi => $q, session => $session, rev => $rev);
 
        my ($form, $buttons) = confirmation_form($q, $session);
        IkiWiki::decode_form_utf8($form);
@@ -101,7 +102,7 @@ sub sessioncgi ($$) {
        if ($form->submitted eq 'Revert' && $form->validate) {
                IkiWiki::checksessionexpiry($q, $session, $q->param('sid'));
                IkiWiki::disable_commit_hook();
-               my $r = IkiWiki::rcs_revert($rev);
+               my $r = $IkiWiki::hooks{rcs}{rcs_revert}{call}->($rev);
                if (! defined $r) { # success
                        rcs_commit_staged(
                                message => sprintf(gettext("This reverts commit %s"), $rev),
@@ -186,7 +187,9 @@ sub store ($$$) {
        ];
        push @{$change->{pages}}, { link => '...' } if $is_excess;
        
-       if (length $config{cgiurl}) {
+       if (length $config{cgiurl} &&
+           exists $IkiWiki::hooks{rcs}{rcs_preprevert} &&
+           exists $IkiWiki::hooks{rcs}{rcs_revert}) {
                $change->{reverturl} = IkiWiki::cgiurl(
                        do => "revert",
                        rev => $change->{rev}
index dbbe83851c0c5efbb2022d50b7b70e6d9798151a..6b751f0cd639bf042c7fba2c4813cc918f914e31 100644 (file)
@@ -1154,8 +1154,6 @@ context, and the whole diff in scalar context.
 This is used to get the page creation time for a file from the RCS, by looking
 it up in the history.
 
-It's ok if this is not implemented, and throws an error.
-
 If the RCS cannot determine a ctime for the file, return 0.
 
 #### `rcs_getmtime($)`
@@ -1210,6 +1208,9 @@ It should try to revert the specified rev, and leave the reversion staged
 so `rcs_commit_staged` will complete it. It should return undef on _success_
 and an error message on failure.
 
+This hook and `rcs_preprevert` are optional, if not implemented, no revert
+web interface will be available.
+
 ### PageSpec plugins
 
 It's also possible to write plugins that add new functions to
index 4525402a7fa34d479e6ce37652d9ed792e622594..60a9d94b540e6e71f5261f9c2476ebf6fbaa0efd 100644 (file)
 <span class="changedate"><TMPL_VAR COMMITDATE></span>
 <span class="desc"><br /></span>
 </div>
+<TMPL_IF REVERTURL>
 <span class="revert">
 <a href="<TMPL_VAR REVERTURL>" title="revert" rel="nofollow">[[revert|wikiicons/revert.png]]</a>
 </span>
+</TMPL_IF>
 <div class="changelog">
 <TMPL_LOOP MESSAGE>
 <TMPL_IF LINE>