# HG changeset patch # User Mads Kiilerich # Date 1479383976 -3600 # Node ID 0d87b1caed92157b8cbce246f7272ba856098af0 # Parent b324b4e431e5c03e6d3b4859985ab5d781f74007 posix: move checklink test file to .hg/cache This avoids unnecessary churn in the working directory. It is not necessarily a fully valid assumption that .hg/cache is on the same filesystem as the working directory, but I think it is an acceptable approximation. It could also be the case that different parts of the working directory is on different mount points so checking in the root folder could also be wrong. diff -r b324b4e431e5 -r 0d87b1caed92 mercurial/posix.py --- a/mercurial/posix.py Wed Jan 14 01:15:26 2015 +0100 +++ b/mercurial/posix.py Thu Nov 17 12:59:36 2016 +0100 @@ -219,9 +219,16 @@ # mktemp is not racy because symlink creation will fail if the # file already exists while True: - name = tempfile.mktemp(dir=path, prefix='hg-checklink-') + cachedir = os.path.join(path, '.hg', 'cache') + if os.path.isdir(cachedir): + checkdir = cachedir + else: + checkdir = path + cachedir = None + name = tempfile.mktemp(dir=checkdir, prefix='checklink-') try: - fd = tempfile.NamedTemporaryFile(dir=path, prefix='hg-checklink-') + fd = tempfile.NamedTemporaryFile(dir=checkdir, + prefix='hg-checklink-') try: os.symlink(os.path.basename(fd.name), name) os.unlink(name)