##// END OF EJS Templates
filemerge: put temporary files in single temp dir by default...
Martin von Zweigbergk -
r49624:b70c9697 default
parent child Browse files
Show More
@@ -1042,11 +1042,6 b' coreconfigitem('
1042 )
1042 )
1043 coreconfigitem(
1043 coreconfigitem(
1044 b'experimental',
1044 b'experimental',
1045 b'mergetempdirprefix',
1046 default=None,
1047 )
1048 coreconfigitem(
1049 b'experimental',
1050 b'mmapindexthreshold',
1045 b'mmapindexthreshold',
1051 default=None,
1046 default=None,
1052 )
1047 )
@@ -926,22 +926,15 b' def _maketempfiles(repo, fco, fca, local'
926 copies `localpath` to another temporary file, so an external merge tool may
926 copies `localpath` to another temporary file, so an external merge tool may
927 use them.
927 use them.
928 """
928 """
929 tmproot = None
929 tmproot = pycompat.mkdtemp(prefix=b'hgmerge-')
930 tmprootprefix = repo.ui.config(b'experimental', b'mergetempdirprefix')
931 if tmprootprefix:
932 tmproot = pycompat.mkdtemp(prefix=tmprootprefix)
933
930
934 def maketempfrompath(prefix, path):
931 def maketempfrompath(prefix, path):
935 fullbase, ext = os.path.splitext(path)
932 fullbase, ext = os.path.splitext(path)
936 pre = b"%s~%s" % (os.path.basename(fullbase), prefix)
933 pre = b"%s~%s" % (os.path.basename(fullbase), prefix)
937 if tmproot:
934 name = os.path.join(tmproot, pre)
938 name = os.path.join(tmproot, pre)
935 if ext:
939 if ext:
936 name += ext
940 name += ext
937 f = open(name, "wb")
941 f = open(name, "wb")
942 else:
943 fd, name = pycompat.mkstemp(prefix=pre + b'.', suffix=ext)
944 f = os.fdopen(fd, "wb")
945 return f, name
938 return f, name
946
939
947 def tempfromcontext(prefix, ctx):
940 def tempfromcontext(prefix, ctx):
@@ -967,15 +960,7 b' def _maketempfiles(repo, fco, fca, local'
967 try:
960 try:
968 yield b, c, d
961 yield b, c, d
969 finally:
962 finally:
970 if tmproot:
963 shutil.rmtree(tmproot)
971 shutil.rmtree(tmproot)
972 else:
973 util.unlink(b)
974 util.unlink(c)
975 # if not uselocalpath, d is the 'orig'/backup file which we
976 # shouldn't delete.
977 if d and uselocalpath:
978 util.unlink(d)
979
964
980
965
981 def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
966 def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
@@ -1592,34 +1592,7 b' mergemarkertemplate settings:'
1592 arg: "ll:working copy"
1592 arg: "ll:working copy"
1593 arg: "lo:"
1593 arg: "lo:"
1594 arg: "merge rev"
1594 arg: "merge rev"
1595 arg: "lb:common ancestor: */f~base.*" (glob)
1595 arg: "lb:common ancestor: */f~base" (glob)
1596 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1597 (branch merge, don't forget to commit)
1598 $ rm -f 'printargs_merge_tool'
1599
1600 Same test with experimental.mergetempdirprefix set:
1601
1602 $ beforemerge
1603 [merge-tools]
1604 false.whatever=
1605 true.priority=1
1606 true.executable=cat
1607 # hg update -C 1
1608 $ cat <<EOF > printargs_merge_tool
1609 > while test \$# -gt 0; do echo arg: \""\$1"\"; shift; done
1610 > EOF
1611 $ hg --config experimental.mergetempdirprefix=$TESTTMP/hgmerge. \
1612 > --config merge-tools.true.executable='sh' \
1613 > --config merge-tools.true.args='./printargs_merge_tool ll:$labellocal lo: $labelother lb:$labelbase": "$base' \
1614 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1615 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1616 > --config ui.mergemarkers=detailed \
1617 > merge -r 2
1618 merging f
1619 arg: "ll:working copy"
1620 arg: "lo:"
1621 arg: "merge rev"
1622 arg: "lb:common ancestor: */hgmerge.*/f~base" (glob)
1623 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1596 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1624 (branch merge, don't forget to commit)
1597 (branch merge, don't forget to commit)
1625 $ rm -f 'printargs_merge_tool'
1598 $ rm -f 'printargs_merge_tool'
@@ -1649,7 +1622,7 b' mergemarkertemplate:'
1649 arg: "ll:working copy: tooltmpl ef83787e2614"
1622 arg: "ll:working copy: tooltmpl ef83787e2614"
1650 arg: "lo:"
1623 arg: "lo:"
1651 arg: "merge rev: tooltmpl 0185f4e0cf02"
1624 arg: "merge rev: tooltmpl 0185f4e0cf02"
1652 arg: "lb:common ancestor: */f~base.*" (glob)
1625 arg: "lb:common ancestor: */f~base" (glob)
1653 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1626 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1654 (branch merge, don't forget to commit)
1627 (branch merge, don't forget to commit)
1655 $ rm -f 'printargs_merge_tool'
1628 $ rm -f 'printargs_merge_tool'
@@ -1895,23 +1868,7 b' Verify naming of temporary files and tha'
1895 $ hg update -q -C 2
1868 $ hg update -q -C 2
1896 $ hg merge -y -r tip --tool echo --config merge-tools.echo.args='$base $local $other $output'
1869 $ hg merge -y -r tip --tool echo --config merge-tools.echo.args='$base $local $other $output'
1897 merging f and f.txt to f.txt
1870 merging f and f.txt to f.txt
1898 */f~base.* */f~local.*.txt */f~other.*.txt $TESTTMP/repo/f.txt (glob)
1871 */hgmerge-*/f~base */hgmerge-*/f~local.txt */hgmerge-*/f~other.txt */repo/f.txt (glob)
1899 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1900 (branch merge, don't forget to commit)
1901
1902 Verify naming of temporary files and that extension is preserved
1903 (experimental.mergetempdirprefix version):
1904
1905 $ hg update -q -C 1
1906 $ hg mv f f.txt
1907 $ hg ci -qm "f.txt"
1908 warning: commit already existed in the repository!
1909 $ hg update -q -C 2
1910 $ hg merge -y -r tip --tool echo \
1911 > --config merge-tools.echo.args='$base $local $other $output' \
1912 > --config experimental.mergetempdirprefix=$TESTTMP/hgmerge.
1913 merging f and f.txt to f.txt
1914 $TESTTMP/hgmerge.*/f~base $TESTTMP/hgmerge.*/f~local.txt $TESTTMP/hgmerge.*/f~other.txt $TESTTMP/repo/f.txt (glob)
1915 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1872 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1916 (branch merge, don't forget to commit)
1873 (branch merge, don't forget to commit)
1917
1874
General Comments 0
You need to be logged in to leave comments. Login now