Show More
@@ -17,7 +17,6 import re | |||
|
17 | 17 | import signal |
|
18 | 18 | import struct |
|
19 | 19 | import sys |
|
20 | import tempfile | |
|
21 | 20 | |
|
22 | 21 | from .i18n import _ |
|
23 | 22 | from . import ( |
@@ -1498,36 +1497,25 are you sure you want to review/edit and | |||
|
1498 | 1497 | all lines of the hunk are removed, then the edit is aborted and |
|
1499 | 1498 | the hunk is left unchanged. |
|
1500 | 1499 | """) |
|
1501 | (patchfd, patchfn) = tempfile.mkstemp(prefix="hg-editor-", | |
|
1502 | suffix=".diff", text=True) | |
|
1503 | ncpatchfp = None | |
|
1504 | try: | |
|
1505 | 1500 |
|
|
1506 | f = os.fdopen(patchfd, "w") | |
|
1507 | chunk.header.write(f) | |
|
1508 |
|
|
|
1509 | f.write('\n'.join(['# ' + i for i in phelp.splitlines()])) | |
|
1510 | f.close() | |
|
1501 | patch = cStringIO.StringIO() | |
|
1502 | patch.write(''.join(['# %s\n' % i for i in phelp.splitlines()])) | |
|
1503 | chunk.header.write(patch) | |
|
1504 | chunk.write(patch) | |
|
1505 | ||
|
1511 | 1506 |
|
|
1512 | editor = self.ui.geteditor() | |
|
1513 |
|
|
|
1514 | environ={'hguser': self.ui.username()}) | |
|
1515 | if ret != 0: | |
|
1516 |
|
|
|
1507 | try: | |
|
1508 | patch = self.ui.edit(patch.getvalue(), "", | |
|
1509 | extra={"suffix": ".diff"}) | |
|
1510 | except error.Abort as exc: | |
|
1511 | self.errorstr = str(exc) | |
|
1517 | 1512 |
|
|
1513 | ||
|
1518 | 1514 |
|
|
1519 | patchfp = open(patchfn) | |
|
1520 | ncpatchfp = cStringIO.StringIO() | |
|
1521 | for line in patchfp: | |
|
1522 | if not line.startswith('#'): | |
|
1523 | ncpatchfp.write(line) | |
|
1524 | patchfp.close() | |
|
1525 | ncpatchfp.seek(0) | |
|
1526 | newpatches = patchmod.parsepatch(ncpatchfp) | |
|
1527 | finally: | |
|
1528 | os.unlink(patchfn) | |
|
1529 | del ncpatchfp | |
|
1530 | return newpatches | |
|
1515 | patch = [line + '\n' for line in patch.splitlines() | |
|
1516 | if not line.startswith('#')] | |
|
1517 | return patchmod.parsepatch(patch) | |
|
1518 | ||
|
1531 | 1519 | if item is None: |
|
1532 | 1520 | item = self.currentselecteditem |
|
1533 | 1521 | if isinstance(item, uiheader): |
General Comments 0
You need to be logged in to leave comments.
Login now