comparison mercurial/patch.py @ 25483:fb04372d7b38

record: exiting editor with non-zero status should not stop recording session Before this patch, exiting a hunk edit in record with a non-zero status lead to the end of the recording session, losing previously-selected hunks to record. This patch introduces the more desirable behavior of warning the user and continuing the recording session.
author Laurent Charignon <lcharignon@fb.com>
date Fri, 05 Jun 2015 13:31:18 -0700
parents 69609f43c752
children 2748bf78a5bf
comparison
equal deleted inserted replaced
25482:95f490136e75 25483:fb04372d7b38
1021 chunk.write(f) 1021 chunk.write(f)
1022 f.write('\n'.join(['# ' + i for i in phelp.splitlines()])) 1022 f.write('\n'.join(['# ' + i for i in phelp.splitlines()]))
1023 f.close() 1023 f.close()
1024 # Start the editor and wait for it to complete 1024 # Start the editor and wait for it to complete
1025 editor = ui.geteditor() 1025 editor = ui.geteditor()
1026 ui.system("%s \"%s\"" % (editor, patchfn), 1026 ret = ui.system("%s \"%s\"" % (editor, patchfn),
1027 environ={'HGUSER': ui.username()}, 1027 environ={'HGUSER': ui.username()})
1028 onerr=util.Abort, errprefix=_("edit failed")) 1028 if ret != 0:
1029 ui.warn(_("editor exited with exit code %d\n") % ret)
1030 continue
1029 # Remove comment lines 1031 # Remove comment lines
1030 patchfp = open(patchfn) 1032 patchfp = open(patchfn)
1031 ncpatchfp = cStringIO.StringIO() 1033 ncpatchfp = cStringIO.StringIO()
1032 for line in patchfp: 1034 for line in patchfp:
1033 if not line.startswith('#'): 1035 if not line.startswith('#'):