author | Mads Kiilerich <mads@kiilerich.com> |
Mon, 07 Nov 2011 02:44:04 +0100 | |
branch | stable |
changeset 1009 | 0c737b00568d |
parent 1007 | 4fad25af75dd |
child 1010 | 13862cca5537 |
permissions | -rw-r--r-- |
1007
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
2 |
"""Test the running system for features availability. Exit with zero |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
3 |
if all features are there, non-zero otherwise. If a feature name is |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
4 |
prefixed with "no-", the absence of feature is tested. |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
5 |
""" |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
6 |
import optparse |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
7 |
import os |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
8 |
import re |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
9 |
import sys |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
10 |
import tempfile |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
11 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
12 |
tempprefix = 'hg-hghave-' |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
13 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
14 |
def matchoutput(cmd, regexp, ignorestatus=False): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
15 |
"""Return True if cmd executes successfully and its output |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
16 |
is matched by the supplied regular expression. |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
17 |
""" |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
18 |
r = re.compile(regexp) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
19 |
fh = os.popen(cmd) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
20 |
s = fh.read() |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
21 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
22 |
ret = fh.close() |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
23 |
except IOError: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
24 |
# Happen in Windows test environment |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
25 |
ret = 1 |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
26 |
return (ignorestatus or ret is None) and r.search(s) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
27 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
28 |
def has_baz(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
29 |
return matchoutput('baz --version 2>&1', r'baz Bazaar version') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
30 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
31 |
def has_bzr(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
32 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
33 |
import bzrlib |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
34 |
return bzrlib.__doc__ != None |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
35 |
except ImportError: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
36 |
return False |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
37 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
38 |
def has_bzr114(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
39 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
40 |
import bzrlib |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
41 |
return (bzrlib.__doc__ != None |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
42 |
and bzrlib.version_info[:2] >= (1, 14)) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
43 |
except ImportError: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
44 |
return False |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
45 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
46 |
def has_cvs(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
47 |
re = r'Concurrent Versions System.*?server' |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
48 |
return matchoutput('cvs --version 2>&1', re) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
49 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
50 |
def has_darcs(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
51 |
return matchoutput('darcs --version', r'2\.[2-9]', True) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
52 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
53 |
def has_mtn(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
54 |
return matchoutput('mtn --version', r'monotone', True) and not matchoutput( |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
55 |
'mtn --version', r'monotone 0\.', True) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
56 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
57 |
def has_eol_in_paths(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
58 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
59 |
fd, path = tempfile.mkstemp(prefix=tempprefix, suffix='\n\r') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
60 |
os.close(fd) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
61 |
os.remove(path) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
62 |
return True |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
63 |
except: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
64 |
return False |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
65 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
66 |
def has_executablebit(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
67 |
fd, path = tempfile.mkstemp(prefix=tempprefix) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
68 |
os.close(fd) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
69 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
70 |
s = os.lstat(path).st_mode |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
71 |
os.chmod(path, s | 0100) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
72 |
return (os.lstat(path).st_mode & 0100 != 0) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
73 |
finally: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
74 |
os.remove(path) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
75 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
76 |
def has_icasefs(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
77 |
# Stolen from mercurial.util |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
78 |
fd, path = tempfile.mkstemp(prefix=tempprefix, dir='.') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
79 |
os.close(fd) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
80 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
81 |
s1 = os.stat(path) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
82 |
d, b = os.path.split(path) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
83 |
p2 = os.path.join(d, b.upper()) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
84 |
if path == p2: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
85 |
p2 = os.path.join(d, b.lower()) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
86 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
87 |
s2 = os.stat(p2) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
88 |
return s2 == s1 |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
89 |
except: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
90 |
return False |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
91 |
finally: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
92 |
os.remove(path) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
93 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
94 |
def has_inotify(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
95 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
96 |
import hgext.inotify.linux.watcher |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
97 |
return True |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
98 |
except ImportError: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
99 |
return False |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
100 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
101 |
def has_fifo(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
102 |
return hasattr(os, "mkfifo") |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
103 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
104 |
def has_cacheable_fs(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
105 |
from mercurial import util |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
106 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
107 |
fd, path = tempfile.mkstemp(prefix=tempprefix) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
108 |
os.close(fd) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
109 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
110 |
return util.cachestat(path).cacheable() |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
111 |
finally: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
112 |
os.remove(path) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
113 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
114 |
def has_lsprof(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
115 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
116 |
import _lsprof |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
117 |
return True |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
118 |
except ImportError: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
119 |
return False |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
120 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
121 |
def has_gettext(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
122 |
return matchoutput('msgfmt --version', 'GNU gettext-tools') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
123 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
124 |
def has_git(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
125 |
return matchoutput('git --version 2>&1', r'^git version') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
126 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
127 |
def has_docutils(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
128 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
129 |
from docutils.core import publish_cmdline |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
130 |
return True |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
131 |
except ImportError: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
132 |
return False |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
133 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
134 |
def getsvnversion(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
135 |
m = matchoutput('svn --version 2>&1', r'^svn,\s+version\s+(\d+)\.(\d+)') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
136 |
if not m: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
137 |
return (0, 0) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
138 |
return (int(m.group(1)), int(m.group(2))) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
139 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
140 |
def has_svn15(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
141 |
return getsvnversion() >= (1, 5) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
142 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
143 |
def has_svn13(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
144 |
return getsvnversion() >= (1, 3) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
145 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
146 |
def has_svn(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
147 |
return matchoutput('svn --version 2>&1', r'^svn, version') and \ |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
148 |
matchoutput('svnadmin --version 2>&1', r'^svnadmin, version') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
149 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
150 |
def has_svn_bindings(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
151 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
152 |
import svn.core |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
153 |
version = svn.core.SVN_VER_MAJOR, svn.core.SVN_VER_MINOR |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
154 |
if version < (1, 4): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
155 |
return False |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
156 |
return True |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
157 |
except ImportError: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
158 |
return False |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
159 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
160 |
def has_p4(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
161 |
return matchoutput('p4 -V', r'Rev\. P4/') and matchoutput('p4d -V', r'Rev\. P4D/') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
162 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
163 |
def has_symlink(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
164 |
return hasattr(os, "symlink") |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
165 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
166 |
def has_tla(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
167 |
return matchoutput('tla --version 2>&1', r'The GNU Arch Revision') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
168 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
169 |
def has_gpg(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
170 |
return matchoutput('gpg --version 2>&1', r'GnuPG') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
171 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
172 |
def has_unix_permissions(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
173 |
d = tempfile.mkdtemp(prefix=tempprefix, dir=".") |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
174 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
175 |
fname = os.path.join(d, 'foo') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
176 |
for umask in (077, 007, 022): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
177 |
os.umask(umask) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
178 |
f = open(fname, 'w') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
179 |
f.close() |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
180 |
mode = os.stat(fname).st_mode |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
181 |
os.unlink(fname) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
182 |
if mode & 0777 != ~umask & 0666: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
183 |
return False |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
184 |
return True |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
185 |
finally: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
186 |
os.rmdir(d) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
187 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
188 |
def has_pyflakes(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
189 |
return matchoutput('echo "import re" 2>&1 | pyflakes', |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
190 |
r"<stdin>:1: 're' imported but unused", |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
191 |
True) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
192 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
193 |
def has_pygments(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
194 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
195 |
import pygments |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
196 |
return True |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
197 |
except ImportError: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
198 |
return False |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
199 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
200 |
def has_outer_repo(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
201 |
return matchoutput('hg root 2>&1', r'') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
202 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
203 |
def has_ssl(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
204 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
205 |
import ssl |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
206 |
import OpenSSL |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
207 |
OpenSSL.SSL.Context |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
208 |
return True |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
209 |
except ImportError: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
210 |
return False |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
211 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
212 |
checks = { |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
213 |
"baz": (has_baz, "GNU Arch baz client"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
214 |
"bzr": (has_bzr, "Canonical's Bazaar client"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
215 |
"bzr114": (has_bzr114, "Canonical's Bazaar client >= 1.14"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
216 |
"cacheable": (has_cacheable_fs, "cacheable filesystem"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
217 |
"cvs": (has_cvs, "cvs client/server"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
218 |
"darcs": (has_darcs, "darcs client"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
219 |
"docutils": (has_docutils, "Docutils text processing library"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
220 |
"eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
221 |
"execbit": (has_executablebit, "executable bit"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
222 |
"fifo": (has_fifo, "named pipes"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
223 |
"gettext": (has_gettext, "GNU Gettext (msgfmt)"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
224 |
"git": (has_git, "git command line client"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
225 |
"gpg": (has_gpg, "gpg client"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
226 |
"icasefs": (has_icasefs, "case insensitive file system"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
227 |
"inotify": (has_inotify, "inotify extension support"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
228 |
"lsprof": (has_lsprof, "python lsprof module"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
229 |
"mtn": (has_mtn, "monotone client (>= 1.0)"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
230 |
"outer-repo": (has_outer_repo, "outer repo"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
231 |
"p4": (has_p4, "Perforce server and client"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
232 |
"pyflakes": (has_pyflakes, "Pyflakes python linter"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
233 |
"pygments": (has_pygments, "Pygments source highlighting library"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
234 |
"ssl": (has_ssl, "python >= 2.6 ssl module and python OpenSSL"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
235 |
"svn": (has_svn, "subversion client and admin tools"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
236 |
"svn13": (has_svn13, "subversion client and admin tools >= 1.3"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
237 |
"svn15": (has_svn15, "subversion client and admin tools >= 1.5"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
238 |
"svn-bindings": (has_svn_bindings, "subversion python bindings"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
239 |
"symlink": (has_symlink, "symbolic links"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
240 |
"tla": (has_tla, "GNU Arch tla client"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
241 |
"unix-permissions": (has_unix_permissions, "unix-style permissions"), |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
242 |
} |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
243 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
244 |
def list_features(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
245 |
for name, feature in checks.iteritems(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
246 |
desc = feature[1] |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
247 |
print name + ':', desc |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
248 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
249 |
def test_features(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
250 |
failed = 0 |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
251 |
for name, feature in checks.iteritems(): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
252 |
check, _ = feature |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
253 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
254 |
check() |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
255 |
except Exception, e: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
256 |
print "feature %s failed: %s" % (name, e) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
257 |
failed += 1 |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
258 |
return failed |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
259 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
260 |
parser = optparse.OptionParser("%prog [options] [features]") |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
261 |
parser.add_option("--test-features", action="store_true", |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
262 |
help="test available features") |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
263 |
parser.add_option("--list-features", action="store_true", |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
264 |
help="list available features") |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
265 |
parser.add_option("-q", "--quiet", action="store_true", |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
266 |
help="check features silently") |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
267 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
268 |
if __name__ == '__main__': |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
269 |
options, args = parser.parse_args() |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
270 |
if options.list_features: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
271 |
list_features() |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
272 |
sys.exit(0) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
273 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
274 |
if options.test_features: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
275 |
sys.exit(test_features()) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
276 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
277 |
quiet = options.quiet |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
278 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
279 |
failures = 0 |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
280 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
281 |
def error(msg): |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
282 |
global failures |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
283 |
if not quiet: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
284 |
sys.stderr.write(msg + '\n') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
285 |
failures += 1 |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
286 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
287 |
for feature in args: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
288 |
negate = feature.startswith('no-') |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
289 |
if negate: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
290 |
feature = feature[3:] |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
291 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
292 |
if feature not in checks: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
293 |
error('skipped: unknown feature: ' + feature) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
294 |
continue |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
295 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
296 |
check, desc = checks[feature] |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
297 |
try: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
298 |
available = check() |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
299 |
except Exception, e: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
300 |
error('hghave check failed: ' + feature) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
301 |
continue |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
302 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
303 |
if not negate and not available: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
304 |
error('skipped: missing feature: ' + desc) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
305 |
elif negate and available: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
306 |
error('skipped: system supports %s' % desc) |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
307 |
|
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
308 |
if failures != 0: |
4fad25af75dd
Add hghave test as of 5635a4017061
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
309 |
sys.exit(1) |