D12171: filemerge: put temporary files in single temp dir by default
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Sat Feb 12 00:55:10 UTC 2022
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
The feature introduced in D2888 <https://phab.mercurial-scm.org/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'm not sure why anyone would want to set a specific value for the
prefix, so maybe we can remove that?
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D12171
AFFECTED FILES
mercurial/configitems.py
mercurial/filemerge.py
tests/test-merge-tools.t
CHANGE DETAILS
diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
--- a/tests/test-merge-tools.t
+++ b/tests/test-merge-tools.t
@@ -1592,7 +1592,7 @@
arg: "ll:working copy"
arg: "lo:"
arg: "merge rev"
- arg: "lb:common ancestor: */f~base.*" (glob)
+ arg: "lb:common ancestor: */f~base" (glob)
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ rm -f 'printargs_merge_tool'
@@ -1608,7 +1608,7 @@
$ cat <<EOF > printargs_merge_tool
> while test \$# -gt 0; do echo arg: \""\$1"\"; shift; done
> EOF
- $ hg --config experimental.mergetempdirprefix=$TESTTMP/hgmerge. \
+ $ hg --config experimental.mergetempdirprefix=$TESTTMP/custom. \
> --config merge-tools.true.executable='sh' \
> --config merge-tools.true.args='./printargs_merge_tool ll:$labellocal lo: $labelother lb:$labelbase": "$base' \
> --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
@@ -1619,7 +1619,7 @@
arg: "ll:working copy"
arg: "lo:"
arg: "merge rev"
- arg: "lb:common ancestor: */hgmerge.*/f~base" (glob)
+ arg: "lb:common ancestor: */custom.*/f~base" (glob)
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ rm -f 'printargs_merge_tool'
@@ -1649,7 +1649,7 @@
arg: "ll:working copy: tooltmpl ef83787e2614"
arg: "lo:"
arg: "merge rev: tooltmpl 0185f4e0cf02"
- arg: "lb:common ancestor: */f~base.*" (glob)
+ arg: "lb:common ancestor: */f~base" (glob)
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ rm -f 'printargs_merge_tool'
@@ -1895,7 +1895,7 @@
$ hg update -q -C 2
$ hg merge -y -r tip --tool echo --config merge-tools.echo.args='$base $local $other $output'
merging f and f.txt to f.txt
- */f~base.* */f~local.*.txt */f~other.*.txt $TESTTMP/repo/f.txt (glob)
+ */f~base */f~local.txt */f~other.txt $TESTTMP/repo/f.txt (glob)
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
@@ -1909,9 +1909,9 @@
$ hg update -q -C 2
$ hg merge -y -r tip --tool echo \
> --config merge-tools.echo.args='$base $local $other $output' \
- > --config experimental.mergetempdirprefix=$TESTTMP/hgmerge.
+ > --config experimental.mergetempdirprefix=$TESTTMP/custom.
merging f and f.txt to f.txt
- $TESTTMP/hgmerge.*/f~base $TESTTMP/hgmerge.*/f~local.txt $TESTTMP/hgmerge.*/f~other.txt $TESTTMP/repo/f.txt (glob)
+ $TESTTMP/custom.*/f~base $TESTTMP/custom.*/f~local.txt $TESTTMP/custom.*/f~other.txt $TESTTMP/repo/f.txt (glob)
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -926,22 +926,16 @@
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=tmprootprefix)
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):
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1043,7 +1043,7 @@
coreconfigitem(
b'experimental',
b'mergetempdirprefix',
- default=None,
+ default=b'hgmerge',
)
coreconfigitem(
b'experimental',
To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list