Mercurial > public > mercurial-scm > hg-stable
diff mercurial/filemerge.py @ 48775:b70c9697ab41
filemerge: put temporary files in single temp dir by default
The feature introduced in D2888 seems like a pure improvement to
me. It makes the names' of temporary file easier to read. Let's have
it always enabled.
I also removed the config option for the path prefix because it
doesn't seem useful. I asked Kyle (the author of the feature) about it
and he couldn't think of a reason to keep it. I suspect it was just
that we to have a config to turn it on/off while it was experimental,
so it might as well be a configurable prefix then.
Differential Revision: https://phab.mercurial-scm.org/D12171
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 11 Feb 2022 16:52:48 -0800 |
parents | 93d6f0e7ba2f |
children | 8dd5853eaa04 |
line wrap: on
line diff
--- a/mercurial/filemerge.py Tue Feb 15 05:20:46 2022 +0100 +++ b/mercurial/filemerge.py Fri Feb 11 16:52:48 2022 -0800 @@ -926,22 +926,15 @@ copies `localpath` to another temporary file, so an external merge tool may use them. """ - tmproot = None - tmprootprefix = repo.ui.config(b'experimental', b'mergetempdirprefix') - if tmprootprefix: - tmproot = pycompat.mkdtemp(prefix=tmprootprefix) + tmproot = pycompat.mkdtemp(prefix=b'hgmerge-') def maketempfrompath(prefix, path): fullbase, ext = os.path.splitext(path) pre = b"%s~%s" % (os.path.basename(fullbase), prefix) - if tmproot: - name = os.path.join(tmproot, pre) - if ext: - name += ext - f = open(name, "wb") - else: - fd, name = pycompat.mkstemp(prefix=pre + b'.', suffix=ext) - f = os.fdopen(fd, "wb") + name = os.path.join(tmproot, pre) + if ext: + name += ext + f = open(name, "wb") return f, name def tempfromcontext(prefix, ctx): @@ -967,15 +960,7 @@ try: yield b, c, d finally: - if tmproot: - shutil.rmtree(tmproot) - else: - util.unlink(b) - util.unlink(c) - # if not uselocalpath, d is the 'orig'/backup file which we - # shouldn't delete. - if d and uselocalpath: - util.unlink(d) + shutil.rmtree(tmproot) def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):