Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cmdutil.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 | bf35644b9f3a |
children | 44611ad4fbd9 |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Sun Mar 20 18:24:59 2016 -0400 +++ b/mercurial/cmdutil.py Sun Mar 20 21:08:17 2016 -0400 @@ -207,6 +207,17 @@ dopatch = fp.tell() fp.seek(0) + # 2.5 optionally review / modify patch in text editor + if opts.get('review', False): + patchtext = (crecordmod.diffhelptext + + crecordmod.patchhelptext + + 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: