comparison mercurial/posix.py @ 30444:b1ce25a40826

posix: move checkexec 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.
author Mads Kiilerich <madski@unity3d.com>
date Thu, 17 Nov 2016 12:59:36 +0100
parents 4b1af1c867fa
children 1ce4c2062ab0
comparison
equal deleted inserted replaced
30443:4e1eab73c53d 30444:b1ce25a40826
158 # a FS remount. Frequently we can detect it if files are created 158 # a FS remount. Frequently we can detect it if files are created
159 # with exec bit on. 159 # with exec bit on.
160 160
161 try: 161 try:
162 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH 162 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
163 fh, fn = tempfile.mkstemp(dir=path, prefix='hg-checkexec-') 163 cachedir = os.path.join(path, '.hg', 'cache')
164 if not os.path.isdir(cachedir):
165 cachedir = path
166 fh, fn = tempfile.mkstemp(dir=cachedir, prefix='hg-checkexec-')
164 try: 167 try:
165 os.close(fh) 168 os.close(fh)
166 m = os.stat(fn).st_mode & 0o777 169 m = os.stat(fn).st_mode & 0o777
167 new_file_has_exec = m & EXECFLAGS 170 new_file_has_exec = m & EXECFLAGS
168 os.chmod(fn, m ^ EXECFLAGS) 171 os.chmod(fn, m ^ EXECFLAGS)