convert rcs_revert to only stage the reversion
[ikiwiki.git] / IkiWiki / Plugin / recentchanges.pm
index 439241b936073c4ffe2580fcd2da44b07df133e7..44c981548a6913a0c6bc9e860743ec5a84eae9e1 100644 (file)
@@ -101,12 +101,17 @@ sub sessioncgi ($$) {
        if ($form->submitted eq 'Revert' && $form->validate) {
                IkiWiki::checksessionexpiry($q, $session, $q->param('sid'));
                IkiWiki::disable_commit_hook();
        if ($form->submitted eq 'Revert' && $form->validate) {
                IkiWiki::checksessionexpiry($q, $session, $q->param('sid'));
                IkiWiki::disable_commit_hook();
-               my $r = IkiWiki::rcs_revert(
-                       session => $session,
-                       rev => $rev);
+               my $r = IkiWiki::rcs_revert($rev);
+               if (! defined $r) { # success
+                       rcs_commit_staged(
+                               message => sprintf(gettext("This reverts commit %s"), $rev),
+                               session => $session,
+                               rev => $rev,
+                       );
+               }
                IkiWiki::enable_commit_hook();
        
                IkiWiki::enable_commit_hook();
        
-               if ($r) {
+               if (defined $r) {
                        die "Revert '$rev' failed.";
                }
                else {
                        die "Revert '$rev' failed.";
                }
                else {