Mercurial > hg
comparison tests/hghave @ 5302:961876838de0
hghave: detect cvs and cvsps availability
"cvsps -h" was returning 1 in cygwin, probably because CVSROOT was unset, which does not prevent it to work correctly.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Fri, 14 Sep 2007 22:17:53 +0200 |
parents | 166b40c49e4a |
children | 9400d677efc7 |
comparison
equal
deleted
inserted
replaced
5301:166b40c49e4a | 5302:961876838de0 |
---|---|
9 import sys | 9 import sys |
10 import tempfile | 10 import tempfile |
11 | 11 |
12 tempprefix = 'hg-hghave-' | 12 tempprefix = 'hg-hghave-' |
13 | 13 |
14 def matchoutput(cmd, regexp): | 14 def matchoutput(cmd, regexp, ignorestatus=False): |
15 """Return True if cmd executes successfully and its output | 15 """Return True if cmd executes successfully and its output |
16 is matched by the supplied regular expression. | 16 is matched by the supplied regular expression. |
17 """ | 17 """ |
18 r = re.compile(regexp) | 18 r = re.compile(regexp) |
19 fh = os.popen(cmd) | 19 fh = os.popen(cmd) |
20 s = fh.read() | 20 s = fh.read() |
21 ret = fh.close() | 21 ret = fh.close() |
22 return ret is None and r.search(s) | 22 return (ignorestatus or ret is None) and r.search(s) |
23 | 23 |
24 def has_symlink(): | 24 def has_symlink(): |
25 return hasattr(os, "symlink") | 25 return hasattr(os, "symlink") |
26 | 26 |
27 def has_fifo(): | 27 def has_fifo(): |
28 return hasattr(os, "mkfifo") | 28 return hasattr(os, "mkfifo") |
29 | |
30 def has_cvs(): | |
31 return matchoutput('cvs --version 2>&1', r'Concurrent Versions System') | |
32 | |
33 def has_cvsps(): | |
34 return matchoutput('cvsps -h -q 2>&1', r'cvsps version', True) | |
29 | 35 |
30 def has_executablebit(): | 36 def has_executablebit(): |
31 fd, path = tempfile.mkstemp(prefix=tempprefix) | 37 fd, path = tempfile.mkstemp(prefix=tempprefix) |
32 os.close(fd) | 38 os.close(fd) |
33 try: | 39 try: |
64 | 70 |
65 def has_git(): | 71 def has_git(): |
66 return matchoutput('git --version 2>&1', r'^git version') | 72 return matchoutput('git --version 2>&1', r'^git version') |
67 | 73 |
68 checks = { | 74 checks = { |
75 "cvs": (has_cvs, "cvs client"), | |
76 "cvsps": (has_cvsps, "cvsps utility"), | |
69 "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"), | 77 "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"), |
70 "execbit": (has_executablebit, "executable bit"), | 78 "execbit": (has_executablebit, "executable bit"), |
71 "git": (has_git, "git command line client"), | 79 "git": (has_git, "git command line client"), |
72 "fifo": (has_fifo, "named pipes"), | 80 "fifo": (has_fifo, "named pipes"), |
73 "hotshot": (has_hotshot, "python hotshot module"), | 81 "hotshot": (has_hotshot, "python hotshot module"), |