[Updated] D12192: filemerge: reduce some duplication in `_maketempfiles()`
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Wed Feb 16 10:31:23 UTC 2022
Closed by commit rHG69000dc0dced: filemerge: reduce some duplication in `_maketempfiles()` (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12192?vs=32230&id=32249
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D12192/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D12192
AFFECTED FILES
mercurial/filemerge.py
CHANGE DETAILS
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -19,7 +19,6 @@
)
from .pycompat import (
getattr,
- open,
)
from . import (
@@ -923,30 +922,24 @@
"""
tmproot = pycompat.mkdtemp(prefix=b'hgmerge-')
- def maketempfrompath(prefix, path):
+ def maketempfrompath(prefix, path, data):
fullbase, ext = os.path.splitext(path)
pre = b"%s~%s" % (os.path.basename(fullbase), prefix)
name = os.path.join(tmproot, pre)
if ext:
name += ext
- f = open(name, "wb")
- return f, name
+ util.writefile(name, data)
+ return name
def tempfromcontext(prefix, ctx):
- f, name = maketempfrompath(prefix, ctx.path())
- data = ctx.decodeddata()
- f.write(data)
- f.close()
- return name
+ return maketempfrompath(prefix, ctx.path(), ctx.decodeddata())
b = tempfromcontext(b"base", fca)
c = tempfromcontext(b"other", fco)
d = localpath
if localpath is not None:
- f, d = maketempfrompath(b"local", d)
data = util.readfile(localpath)
- f.write(data)
- f.close()
+ d = maketempfrompath(b"local", localpath, data)
try:
yield b, c, d
To: martinvonz, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220216/18c28976/attachment-0002.html>
More information about the Mercurial-patches
mailing list