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

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date March 18, 2016, 8:45 p.m.
Message ID <2a9dcd516bf0d7a28972.1458333938@Iris>
Download mbox | patch
Permalink /patch/13940/
State Superseded
Commit 44319097e7b975bb87a28c5d0f4362571e72492d
Headers show

Comments

Jordi Gutiérrez Hermoso - March 18, 2016, 8:45 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@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.

Patch

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()
             fp.seek(0)
 
+            # 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