##// END OF EJS Templates
posix: simplify checkexec check...
Mads Kiilerich -
r30445:1ce4c206 default
parent child Browse files
Show More
@@ -166,16 +166,16 b' def checkexec(path):'
166 fh, fn = tempfile.mkstemp(dir=cachedir, prefix='hg-checkexec-')
166 fh, fn = tempfile.mkstemp(dir=cachedir, prefix='hg-checkexec-')
167 try:
167 try:
168 os.close(fh)
168 os.close(fh)
169 m = os.stat(fn).st_mode & 0o777
169 m = os.stat(fn).st_mode
170 new_file_has_exec = m & EXECFLAGS
170 if m & EXECFLAGS:
171 os.chmod(fn, m ^ EXECFLAGS)
171 return False
172 exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0o777) == m)
172 os.chmod(fn, m & 0o777 | EXECFLAGS)
173 return os.stat(fn).st_mode & EXECFLAGS
173 finally:
174 finally:
174 os.unlink(fn)
175 os.unlink(fn)
175 except (IOError, OSError):
176 except (IOError, OSError):
176 # we don't care, the user probably won't be able to commit anyway
177 # we don't care, the user probably won't be able to commit anyway
177 return False
178 return False
178 return not (new_file_has_exec or exec_flags_cannot_flip)
179
179
180 def checklink(path):
180 def checklink(path):
181 """check whether the given path is on a symlink-capable filesystem"""
181 """check whether the given path is on a symlink-capable filesystem"""
General Comments 0
You need to be logged in to leave comments. Login now