equal
deleted
inserted
replaced
164 if not os.path.isdir(cachedir): |
164 if not os.path.isdir(cachedir): |
165 cachedir = path |
165 cachedir = 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""" |
182 # mktemp is not racy because symlink creation will fail if the |
182 # mktemp is not racy because symlink creation will fail if the |
183 # file already exists |
183 # file already exists |