Show More
@@ -4,7 +4,7 b' if all features are there, non-zero othe' | |||||
4 | prefixed with "no-", the absence of feature is tested. |
|
4 | prefixed with "no-", the absence of feature is tested. | |
5 | """ |
|
5 | """ | |
6 | import optparse |
|
6 | import optparse | |
7 | import os |
|
7 | import os, stat | |
8 | import re |
|
8 | import re | |
9 | import sys |
|
9 | import sys | |
10 | import tempfile |
|
10 | import tempfile | |
@@ -64,14 +64,21 b' def has_eol_in_paths():' | |||||
64 | return False |
|
64 | return False | |
65 |
|
65 | |||
66 | def has_executablebit(): |
|
66 | def has_executablebit(): | |
67 | fd, path = tempfile.mkstemp(prefix=tempprefix) |
|
|||
68 | os.close(fd) |
|
|||
69 | try: |
|
67 | try: | |
70 | s = os.lstat(path).st_mode |
|
68 | EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH | |
71 | os.chmod(path, s | 0100) |
|
69 | fh, fn = tempfile.mkstemp(dir=".", prefix='hg-checkexec-') | |
72 | return (os.lstat(path).st_mode & 0100 != 0) |
|
70 | try: | |
73 | finally: |
|
71 | os.close(fh) | |
74 | os.remove(path) |
|
72 | m = os.stat(fn).st_mode & 0777 | |
|
73 | new_file_has_exec = m & EXECFLAGS | |||
|
74 | os.chmod(fn, m ^ EXECFLAGS) | |||
|
75 | exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0777) == m) | |||
|
76 | finally: | |||
|
77 | os.unlink(fn) | |||
|
78 | except (IOError, OSError): | |||
|
79 | # we don't care, the user probably won't be able to commit anyway | |||
|
80 | return False | |||
|
81 | return not (new_file_has_exec or exec_flags_cannot_flip) | |||
75 |
|
82 | |||
76 | def has_icasefs(): |
|
83 | def has_icasefs(): | |
77 | # Stolen from mercurial.util |
|
84 | # Stolen from mercurial.util |
General Comments 0
You need to be logged in to leave comments.
Login now