48 return matchoutput('mtn --version', r'monotone', True) and not matchoutput( |
48 return matchoutput('mtn --version', r'monotone', True) and not matchoutput( |
49 'mtn --version', r'monotone 0\.', True) |
49 'mtn --version', r'monotone 0\.', True) |
50 |
50 |
51 def has_eol_in_paths(): |
51 def has_eol_in_paths(): |
52 try: |
52 try: |
53 fd, path = tempfile.mkstemp(prefix=tempprefix, suffix='\n\r') |
53 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix, suffix='\n\r') |
54 os.close(fd) |
54 os.close(fd) |
55 os.remove(path) |
55 os.remove(path) |
56 return True |
56 return True |
57 except (IOError, OSError): |
57 except (IOError, OSError): |
58 return False |
58 return False |
59 |
59 |
60 def has_executablebit(): |
60 def has_executablebit(): |
61 try: |
61 try: |
62 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH |
62 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH |
63 fh, fn = tempfile.mkstemp(dir=".", prefix='hg-checkexec-') |
63 fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix) |
64 try: |
64 try: |
65 os.close(fh) |
65 os.close(fh) |
66 m = os.stat(fn).st_mode & 0777 |
66 m = os.stat(fn).st_mode & 0777 |
67 new_file_has_exec = m & EXECFLAGS |
67 new_file_has_exec = m & EXECFLAGS |
68 os.chmod(fn, m ^ EXECFLAGS) |
68 os.chmod(fn, m ^ EXECFLAGS) |
74 return False |
74 return False |
75 return not (new_file_has_exec or exec_flags_cannot_flip) |
75 return not (new_file_has_exec or exec_flags_cannot_flip) |
76 |
76 |
77 def has_icasefs(): |
77 def has_icasefs(): |
78 # Stolen from mercurial.util |
78 # Stolen from mercurial.util |
79 fd, path = tempfile.mkstemp(prefix=tempprefix, dir='.') |
79 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix) |
80 os.close(fd) |
80 os.close(fd) |
81 try: |
81 try: |
82 s1 = os.stat(path) |
82 s1 = os.stat(path) |
83 d, b = os.path.split(path) |
83 d, b = os.path.split(path) |
84 p2 = os.path.join(d, b.upper()) |
84 p2 = os.path.join(d, b.upper()) |
103 return getattr(os, "mkfifo", None) is not None |
103 return getattr(os, "mkfifo", None) is not None |
104 |
104 |
105 def has_cacheable_fs(): |
105 def has_cacheable_fs(): |
106 from mercurial import util |
106 from mercurial import util |
107 |
107 |
108 fd, path = tempfile.mkstemp(prefix=tempprefix) |
108 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix) |
109 os.close(fd) |
109 os.close(fd) |
110 try: |
110 try: |
111 return util.cachestat(path).cacheable() |
111 return util.cachestat(path).cacheable() |
112 finally: |
112 finally: |
113 os.remove(path) |
113 os.remove(path) |
163 matchoutput('p4d -V', r'Rev\. P4D/')) |
163 matchoutput('p4d -V', r'Rev\. P4D/')) |
164 |
164 |
165 def has_symlink(): |
165 def has_symlink(): |
166 if getattr(os, "symlink", None) is None: |
166 if getattr(os, "symlink", None) is None: |
167 return False |
167 return False |
168 name = tempfile.mktemp(dir=".", prefix='hg-checklink-') |
168 name = tempfile.mktemp(dir='.', prefix=tempprefix) |
169 try: |
169 try: |
170 os.symlink(".", name) |
170 os.symlink(".", name) |
171 os.unlink(name) |
171 os.unlink(name) |
172 return True |
172 return True |
173 except (OSError, AttributeError): |
173 except (OSError, AttributeError): |
178 |
178 |
179 def has_gpg(): |
179 def has_gpg(): |
180 return matchoutput('gpg --version 2>&1', r'GnuPG') |
180 return matchoutput('gpg --version 2>&1', r'GnuPG') |
181 |
181 |
182 def has_unix_permissions(): |
182 def has_unix_permissions(): |
183 d = tempfile.mkdtemp(prefix=tempprefix, dir=".") |
183 d = tempfile.mkdtemp(dir='.', prefix=tempprefix) |
184 try: |
184 try: |
185 fname = os.path.join(d, 'foo') |
185 fname = os.path.join(d, 'foo') |
186 for umask in (077, 007, 022): |
186 for umask in (077, 007, 022): |
187 os.umask(umask) |
187 os.umask(umask) |
188 f = open(fname, 'w') |
188 f = open(fname, 'w') |