equal
deleted
inserted
replaced
2 """Test the running system for features availability. Exit with zero |
2 """Test the running system for features availability. Exit with zero |
3 if all features are there, non-zero otherwise. If a feature name is |
3 if all features are there, non-zero otherwise. If a feature name is |
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 |
11 |
11 |
12 tempprefix = 'hg-hghave-' |
12 tempprefix = 'hg-hghave-' |
62 return True |
62 return True |
63 except: |
63 except: |
64 return False |
64 return False |
65 |
65 |
66 def has_executablebit(): |
66 def has_executablebit(): |
67 fd, path = tempfile.mkstemp(prefix=tempprefix) |
67 try: |
68 os.close(fd) |
68 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH |
69 try: |
69 fh, fn = tempfile.mkstemp(dir=".", prefix='hg-checkexec-') |
70 s = os.lstat(path).st_mode |
70 try: |
71 os.chmod(path, s | 0100) |
71 os.close(fh) |
72 return (os.lstat(path).st_mode & 0100 != 0) |
72 m = os.stat(fn).st_mode & 0777 |
73 finally: |
73 new_file_has_exec = m & EXECFLAGS |
74 os.remove(path) |
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 |
78 fd, path = tempfile.mkstemp(prefix=tempprefix, dir='.') |
85 fd, path = tempfile.mkstemp(prefix=tempprefix, dir='.') |
79 os.close(fd) |
86 os.close(fd) |
159 |
166 |
160 def has_p4(): |
167 def has_p4(): |
161 return matchoutput('p4 -V', r'Rev\. P4/') and matchoutput('p4d -V', r'Rev\. P4D/') |
168 return matchoutput('p4 -V', r'Rev\. P4/') and matchoutput('p4d -V', r'Rev\. P4D/') |
162 |
169 |
163 def has_symlink(): |
170 def has_symlink(): |
|
171 if not hasattr(os, "symlink"): |
|
172 return False |
|
173 name = tempfile.mktemp(dir=".", prefix='hg-checklink-') |
|
174 try: |
|
175 os.symlink(".", name) |
|
176 os.unlink(name) |
|
177 return True |
|
178 except (OSError, AttributeError): |
|
179 return False |
164 return hasattr(os, "symlink") # FIXME: should also check file system and os |
180 return hasattr(os, "symlink") # FIXME: should also check file system and os |
165 |
181 |
166 def has_tla(): |
182 def has_tla(): |
167 return matchoutput('tla --version 2>&1', r'The GNU Arch Revision') |
183 return matchoutput('tla --version 2>&1', r'The GNU Arch Revision') |
168 |
184 |