[PATCH 3 of 3] crecord: re-enable reviewing a patch before comitting it

Jordi GutiƩrrez Hermoso jordigh at octave.org
Fri Mar 18 16:45:38 EDT 2016

# HG changeset patch
# User Jordi GutiƩrrez Hermoso <jordigh at octave.org>
# Date 1458332747 14400
#      Fri Mar 18 16:25:47 2016 -0400
# Node ID 2a9dcd516bf0d7a28972682a9d9b3fc1b6e87ed3
# Parent  9c3a76f1439bf0e701d00343115db01949aedf18
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, but I don't know how to write one yet.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -207,6 +207,15 @@ def dorecord(ui, repo, commitfunc, cmdsu
             dopatch = fp.tell()
+            # 2.5 optionally review / modify patch in text editor
+            if opts.get('review', False):
+                patchtext = fp.read()
+                reviewedpatch = ui.edit(patchtext, "",
+                                        extra={"suffix": ".diff"})
+                fp.truncate(0)
+                fp.write(reviewedpatch)
+                fp.seek(0)
             [os.unlink(repo.wjoin(c)) for c in newlyaddedandmodifiedfiles]
             # 3a. apply filtered patch to clean repo  (clean)
             if backups:
diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -1620,6 +1620,7 @@ are you sure you want to review/edit and
                 return True
         elif keypressed in ["r"]:
             if self.confirmcommit(review=True):
+                self.opts['review'] = True
                 return True
         elif test and keypressed in ['X']:
             return True

More information about the Mercurial-devel mailing list