diff mercurial/crecord.py @ 28638:44319097e7b9

crecord: re-enable reviewing a patch before comitting it The "r" option for this feature was copied into Mercurial from crecord, but the actual implementation never made it into hg until now. It's a moderately useful feature that allows the user to edit the patch in a text editor before comitting it for good. This requires a test, so we must also enable a corresponding testing 'R' option that skips the confirmation dialogue. In addition, we also need a help text for the editor when reviewing the final patch. As for why this is a useful feature if we can already edit hunks in an editor, I would like to offer the following points: * editing hunks does not show the entire patch all at once ** furthermore, the hunk "tree" in the TUI has no root that could be selected for edition * it is helpful to be able to see the entire final patch for confirmation ** within this view, the unselected hunks are hidden, which is visusally cleaner ** this works as a final review of the complete result, which is a bit more difficult to do conceptually via hunk editing * this feature was already in crecord, so it was an oversight to not bring it to core * it works and is consistent with editing hunks
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Sun, 20 Mar 2016 21:08:17 -0400
parents 4874b8efe7d2
children 86db5cb55d46
line wrap: on
line diff
--- a/mercurial/crecord.py	Sun Mar 20 18:24:59 2016 -0400
+++ b/mercurial/crecord.py	Sun Mar 20 21:08:17 2016 -0400
@@ -43,6 +43,13 @@
 # of the hunk are removed, then the edit is aborted and the hunk is left
 # unchanged.
 """)
+
+patchhelptext = _("""#
+# If the patch applies cleanly, the edited patch will immediately
+# be finalised. If it does not apply cleanly, rejects files will be
+# generated. You can use those when you try again.
+""")
+
 try:
     import curses
     import fcntl
@@ -1595,10 +1602,14 @@
         elif keypressed in ["c"]:
             if self.confirmcommit():
                 return True
+        elif test and keypressed in ['X']:
+            return True
         elif keypressed in ["r"]:
             if self.confirmcommit(review=True):
+                self.opts['review'] = True
                 return True
-        elif test and keypressed in ['X']:
+        elif test and keypressed in ['R']:
+            self.opts['review'] = True
             return True
         elif keypressed in [' '] or (test and keypressed in ["TOGGLE"]):
             self.toggleapply()