comparison 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
comparison
equal deleted inserted replaced
28637:4874b8efe7d2 28638:44319097e7b9
204 fname = c.filename() 204 fname = c.filename()
205 if fname in backups: 205 if fname in backups:
206 c.write(fp) 206 c.write(fp)
207 dopatch = fp.tell() 207 dopatch = fp.tell()
208 fp.seek(0) 208 fp.seek(0)
209
210 # 2.5 optionally review / modify patch in text editor
211 if opts.get('review', False):
212 patchtext = (crecordmod.diffhelptext
213 + crecordmod.patchhelptext
214 + fp.read())
215 reviewedpatch = ui.edit(patchtext, "",
216 extra={"suffix": ".diff"})
217 fp.truncate(0)
218 fp.write(reviewedpatch)
219 fp.seek(0)
209 220
210 [os.unlink(repo.wjoin(c)) for c in newlyaddedandmodifiedfiles] 221 [os.unlink(repo.wjoin(c)) for c in newlyaddedandmodifiedfiles]
211 # 3a. apply filtered patch to clean repo (clean) 222 # 3a. apply filtered patch to clean repo (clean)
212 if backups: 223 if backups:
213 # Equivalent to hg.revert 224 # Equivalent to hg.revert