convert rcs_revert to only stage the reversion
authorJoey Hess <joey@kitenet.net>
Wed, 6 Oct 2010 19:08:12 +0000 (15:08 -0400)
committerJoey Hess <joey@kitenet.net>
Wed, 6 Oct 2010 19:08:12 +0000 (15:08 -0400)
IkiWiki.pm
IkiWiki/Plugin/git.pm
IkiWiki/Plugin/recentchanges.pm
doc/plugins/write.mdwn
doc/todo/web_reversion.mdwn

index 269647eb4cb785439dfb4c2b4baff3a2f33d737b..faf4af5c7080fc783ebf8f1fd7b07881a9964d3e 100644 (file)
@@ -1941,11 +1941,11 @@ sub rcs_receive () {
        $hooks{rcs}{rcs_receive}{call}->();
 }
 
-sub rcs_preprevert (@) {
+sub rcs_preprevert ($) {
        $hooks{rcs}{rcs_preprevert}{call}->(@_);
 }
 
-sub rcs_revert (@) {
+sub rcs_revert ($) {
        $hooks{rcs}{rcs_revert}{call}->(@_);
 }
 
index 3ccaa446a344f2dee24a4d277c2b803b8a7ff888..996ab6fba0f5e6076c3a793d4ec06ef57ec93b6f 100644 (file)
@@ -846,19 +846,14 @@ sub rcs_preprevert (@) {
                [git_parse_changes(git_commit_info($rev, 1))]);
 }
 
-sub rcs_revert (@) {
-       # Try to revert the given patch; returns undef on _success_.
-       my %params = @_;
-       my $rev = $params{rev};
+sub rcs_revert ($) {
+       # Try to revert the given rev; returns undef on _success_.
+       my $rev = $shift;
 
        if (run_or_non('git', 'revert', '--no-commit', $rev)) {
-               debug "Committing revert for patch '$rev'.";
-               rcs_commit_staged(message => 
-                       sprintf(gettext("This reverts commit %s"), $rev), @_);
+               return undef;
        }
        else {
-               # No idea what is actually getting reverted, so all we can
-               # do is say we failed.
                run_or_die('git', 'reset', '--hard');
                return sprintf(gettext("Failed to revert commit %s"), $rev);
        }
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();
-               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();
        
-               if ($r) {
+               if (defined $r) {
                        die "Revert '$rev' failed.";
                }
                else {
index 3eade34ee1e54244554d704a9b75baa4e1d07a28..dbbe83851c0c5efbb2022d50b7b70e6d9798151a 100644 (file)
@@ -1201,16 +1201,14 @@ Like `rcs_receive`, it should do whatever sanity checks are appropriate
 for the RCS to limit changes to safe changes, and die if a change would
 be unsafe to revert.
 
-#### `rcs_revert(@)`
+#### `rcs_revert($)`
 
 This is called by the revert web interface. It is passed a named
 parameter rev that is the RCS-specific change ID to revert.
 
-Addition named parameters: `message`, and `session` (optional).
-
-It should try to revert the specified rev, which includes committing
-the reversion, and returns undef on _success_ and an error message
-on failure.
+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.
 
 ### PageSpec plugins
 
index 7cb412f79be8345e4ee595b08e8dcecfaf93e1cb..784b72e0550b66378492da8923b0cee1908b2590 100644 (file)
@@ -71,10 +71,6 @@ Peter Gammie has done an initial implementation of the above.
 >>> to: --[[Joey]] 
 >>>> Please change the git pointer above, then. I will work on your branch. -- [[peteg]]
 
->>> * Would it be better for `rcs_revert` to not commit, and
->>>   `rcs_commit_staged` to then be used? This would work for git, but
->>>   maybe other RCSs would be problimatic. It would simplifiy the
->>>   interface and allow for future mulitple-revert interfaces.
 >>> * I quite don't understand why one caller of `git_parse_changes`
 >>>   needs it to chdir, and not the other one. It's running
 >>>   in the same git repo either way, and git doesn't need