Details
Details
- Reviewers
pulkit - Group Reviewers
hg-reviewers - Commits
- rHGe5f69e3bb3f6: ui: use a context manager to handle file streams in edit()
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
pulkit |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/ui.py (10 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
e11878dc4cf9 | 527eba3013ea | Matt Harbison | Dec 14 2019, 6:23 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | mharbison72 | ||
Closed | mharbison72 | ||
Closed | mharbison72 | ||
Closed | mharbison72 | ||
Closed | mharbison72 | ||
Closed | mharbison72 | ||
Closed | mharbison72 | ||
Closed | mharbison72 | ||
Closed | mharbison72 |
rdir = None | rdir = None | ||||
if self.configbool(b'experimental', b'editortmpinhg'): | if self.configbool(b'experimental', b'editortmpinhg'): | ||||
rdir = repopath | rdir = repopath | ||||
(fd, name) = pycompat.mkstemp( | (fd, name) = pycompat.mkstemp( | ||||
prefix=b'hg-' + extra[b'prefix'] + b'-', suffix=suffix, dir=rdir | prefix=b'hg-' + extra[b'prefix'] + b'-', suffix=suffix, dir=rdir | ||||
) | ) | ||||
try: | try: | ||||
f = os.fdopen(fd, 'wb') | with os.fdopen(fd, 'wb') as f: | ||||
f.write(util.tonativeeol(text)) | f.write(util.tonativeeol(text)) | ||||
f.close() | |||||
environ = {b'HGUSER': user} | environ = {b'HGUSER': user} | ||||
if b'transplant_source' in extra: | if b'transplant_source' in extra: | ||||
environ.update( | environ.update( | ||||
{b'HGREVISION': hex(extra[b'transplant_source'])} | {b'HGREVISION': hex(extra[b'transplant_source'])} | ||||
) | ) | ||||
for label in (b'intermediate-source', b'source', b'rebase_source'): | for label in (b'intermediate-source', b'source', b'rebase_source'): | ||||
if label in extra: | if label in extra: | ||||
self.system( | self.system( | ||||
b"%s \"%s\"" % (editor, name), | b"%s \"%s\"" % (editor, name), | ||||
environ=environ, | environ=environ, | ||||
onerr=error.Abort, | onerr=error.Abort, | ||||
errprefix=_(b"edit failed"), | errprefix=_(b"edit failed"), | ||||
blockedtag=b'editor', | blockedtag=b'editor', | ||||
) | ) | ||||
f = open(name, 'rb') | with open(name, 'rb') as f: | ||||
t = util.fromnativeeol(f.read()) | t = util.fromnativeeol(f.read()) | ||||
f.close() | |||||
finally: | finally: | ||||
os.unlink(name) | os.unlink(name) | ||||
return t | return t | ||||
def system( | def system( | ||||
self, | self, | ||||
cmd, | cmd, |