Mercurial > hg
changeset 48784:9d0d0a388c39
filemerge: remove `uselocalpath` argument from `_maketempfiles()`
The `localpath` argument is unused if `uselocalpath` is false, so we
can use `None` as a sentinel value for the variable instead and remove
extra `uselocalpath` argument. That's not much of a win, but it's a
small step towards further improvements.
Differential Revision: https://phab.mercurial-scm.org/D12189
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 14 Feb 2022 21:52:18 -0800 |
parents | 218154867575 |
children | b53f2f5a18de |
files | mercurial/filemerge.py |
diffstat | 1 files changed, 11 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/filemerge.py Fri Feb 11 22:39:53 2022 -0800 +++ b/mercurial/filemerge.py Mon Feb 14 21:52:18 2022 -0800 @@ -743,9 +743,14 @@ return False, 1, None localpath = _workingpath(repo, fcd) args = _toolstr(repo.ui, tool, b"args") + localoutputpath = None + if b"$output" in args: + localoutputpath = backup.path() with _maketempfiles( - fco, fca, backup.path(), b"$output" in args + fco, + fca, + localoutputpath, ) as temppaths: basepath, otherpath, localoutputpath = temppaths outpath = b"" @@ -908,10 +913,10 @@ @contextlib.contextmanager -def _maketempfiles(fco, fca, localpath, uselocalpath): - """Writes out `fco` and `fca` as temporary files, and (if uselocalpath) - copies `localpath` to another temporary file, so an external merge tool may - use them. +def _maketempfiles(fco, fca, localpath): + """Writes out `fco` and `fca` as temporary files, and (if localpath is not + None) copies `localpath` to another temporary file, so an external merge + tool may use them. """ tmproot = pycompat.mkdtemp(prefix=b'hgmerge-') @@ -934,7 +939,7 @@ b = tempfromcontext(b"base", fca) c = tempfromcontext(b"other", fco) d = localpath - if uselocalpath: + if localpath is not None: # We start off with this being the backup filename, so remove the .orig # to make syntax-highlighting more likely. if d.endswith(b'.orig'):