Show More
@@ -0,0 +1,76 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | "$TESTDIR/hghave" mtn || exit 80 | |||
|
4 | ||||
|
5 | # Monotone directory is called .monotone on *nix and monotone | |||
|
6 | # on Windows. Having a variable here ease test patching. | |||
|
7 | mtndir=.monotone | |||
|
8 | echo "[extensions]" >> $HGRCPATH | |||
|
9 | echo "convert=" >> $HGRCPATH | |||
|
10 | echo 'hgext.graphlog =' >> $HGRCPATH | |||
|
11 | ||||
|
12 | HOME=`pwd`/do_not_use_HOME_mtn; export HOME | |||
|
13 | # Windows version of monotone home | |||
|
14 | APPDATA=$HOME; export APPDATA | |||
|
15 | ||||
|
16 | echo % tedious monotone keys configuration | |||
|
17 | # The /dev/null redirection is necessary under Windows, or | |||
|
18 | # it complains about home directory permissions | |||
|
19 | mtn --quiet genkey test@selenic.com 1>/dev/null 2>&1 <<EOF | |||
|
20 | passphrase | |||
|
21 | passphrase | |||
|
22 | EOF | |||
|
23 | cat >> $HOME/$mtndir/monotonerc <<EOF | |||
|
24 | function get_passphrase(keypair_id) | |||
|
25 | return "passphrase" | |||
|
26 | end | |||
|
27 | EOF | |||
|
28 | ||||
|
29 | echo % create monotone repository | |||
|
30 | mtn db init --db=repo.mtn | |||
|
31 | mtn --db=repo.mtn --branch=com.selenic.test setup workingdir | |||
|
32 | cd workingdir | |||
|
33 | echo a > a | |||
|
34 | mkdir dir | |||
|
35 | echo b > dir/b | |||
|
36 | python -c 'file("bin", "wb").write("a\\x00b")' | |||
|
37 | echo c > c | |||
|
38 | mtn add a dir/b c bin | |||
|
39 | mtn ci -m initialize | |||
|
40 | echo % update monotone working directory | |||
|
41 | mtn mv a dir/a | |||
|
42 | echo a >> dir/a | |||
|
43 | echo b >> dir/b | |||
|
44 | mtn drop c | |||
|
45 | python -c 'file("bin", "wb").write("b\\x00c")' | |||
|
46 | mtn ci -m update1 | |||
|
47 | cd .. | |||
|
48 | ||||
|
49 | echo % convert once | |||
|
50 | hg convert -s mtn repo.mtn | |||
|
51 | ||||
|
52 | cd workingdir | |||
|
53 | echo e > e | |||
|
54 | mtn add e | |||
|
55 | mtn drop dir/b | |||
|
56 | mtn mv bin bin2 | |||
|
57 | mtn ci -m update2 | |||
|
58 | cd .. | |||
|
59 | ||||
|
60 | echo % convert incrementally | |||
|
61 | hg convert -s mtn repo.mtn | |||
|
62 | ||||
|
63 | glog() | |||
|
64 | { | |||
|
65 | hg glog --template '#rev# "#desc|firstline#" files: #files#\n' "$@" | |||
|
66 | } | |||
|
67 | ||||
|
68 | cd repo.mtn-hg | |||
|
69 | hg up -C | |||
|
70 | glog | |||
|
71 | echo % manifest | |||
|
72 | # BUG: c and dir/b should not appear here | |||
|
73 | hg manifest | |||
|
74 | echo % contents | |||
|
75 | cat dir/a | |||
|
76 |
@@ -0,0 +1,50 b'' | |||||
|
1 | % tedious monotone keys configuration | |||
|
2 | % create monotone repository | |||
|
3 | mtn: adding a to workspace manifest | |||
|
4 | mtn: adding bin to workspace manifest | |||
|
5 | mtn: adding c to workspace manifest | |||
|
6 | mtn: adding dir to workspace manifest | |||
|
7 | mtn: adding dir/b to workspace manifest | |||
|
8 | mtn: beginning commit on branch 'com.selenic.test' | |||
|
9 | mtn: committed revision 803ef0bf815e35b951dbd4310acd1e45e675016e | |||
|
10 | % update monotone working directory | |||
|
11 | mtn: skipping dir, already accounted for in workspace | |||
|
12 | mtn: renaming a to dir/a in workspace manifest | |||
|
13 | mtn: dropping c from workspace manifest | |||
|
14 | mtn: beginning commit on branch 'com.selenic.test' | |||
|
15 | mtn: committed revision 4daf60753d6fe21a06ce5f716303fe55fd6d3a56 | |||
|
16 | % convert once | |||
|
17 | assuming destination repo.mtn-hg | |||
|
18 | initializing destination repo.mtn-hg repository | |||
|
19 | scanning source... | |||
|
20 | sorting... | |||
|
21 | converting... | |||
|
22 | 1 initialize | |||
|
23 | 0 update1 | |||
|
24 | mtn: adding e to workspace manifest | |||
|
25 | mtn: dropping dir/b from workspace manifest | |||
|
26 | mtn: renaming bin to bin2 in workspace manifest | |||
|
27 | mtn: beginning commit on branch 'com.selenic.test' | |||
|
28 | mtn: committed revision 6c6977a6ef609ec80e40779f89dbd2772c96de62 | |||
|
29 | % convert incrementally | |||
|
30 | assuming destination repo.mtn-hg | |||
|
31 | scanning source... | |||
|
32 | sorting... | |||
|
33 | converting... | |||
|
34 | 0 update2 | |||
|
35 | 5 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
36 | @ 2 "update2" files: bin bin2 e | |||
|
37 | | | |||
|
38 | o 1 "update1" files: a bin dir/a dir/b | |||
|
39 | | | |||
|
40 | o 0 "initialize" files: a bin c dir/b | |||
|
41 | ||||
|
42 | % manifest | |||
|
43 | bin2 | |||
|
44 | c | |||
|
45 | dir/a | |||
|
46 | dir/b | |||
|
47 | e | |||
|
48 | % contents | |||
|
49 | a | |||
|
50 | a |
@@ -1,181 +1,185 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
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 | |
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-' | |
13 |
|
13 | |||
14 | def matchoutput(cmd, regexp, ignorestatus=False): |
|
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 (ignorestatus or ret is None) and r.search(s) |
|
22 | return (ignorestatus or ret is None) and r.search(s) | |
23 |
|
23 | |||
24 | def has_baz(): |
|
24 | def has_baz(): | |
25 | return matchoutput('baz --version 2>&1', r'baz Bazaar version') |
|
25 | return matchoutput('baz --version 2>&1', r'baz Bazaar version') | |
26 |
|
26 | |||
27 | def has_cvs(): |
|
27 | def has_cvs(): | |
28 | return matchoutput('cvs --version 2>&1', r'Concurrent Versions System') |
|
28 | return matchoutput('cvs --version 2>&1', r'Concurrent Versions System') | |
29 |
|
29 | |||
30 | def has_cvsps(): |
|
30 | def has_cvsps(): | |
31 | return matchoutput('cvsps -h -q 2>&1', r'cvsps version', True) |
|
31 | return matchoutput('cvsps -h -q 2>&1', r'cvsps version', True) | |
32 |
|
32 | |||
33 | def has_darcs(): |
|
33 | def has_darcs(): | |
34 | return matchoutput('darcs', 'darcs version', True) |
|
34 | return matchoutput('darcs', 'darcs version', True) | |
35 |
|
35 | |||
|
36 | def has_mtn(): | |||
|
37 | return matchoutput('mtn --version', 'monotone', True) | |||
|
38 | ||||
36 | def has_eol_in_paths(): |
|
39 | def has_eol_in_paths(): | |
37 | try: |
|
40 | try: | |
38 | fd, path = tempfile.mkstemp(prefix=tempprefix, suffix='\n\r') |
|
41 | fd, path = tempfile.mkstemp(prefix=tempprefix, suffix='\n\r') | |
39 | os.close(fd) |
|
42 | os.close(fd) | |
40 | os.remove(path) |
|
43 | os.remove(path) | |
41 | return True |
|
44 | return True | |
42 | except: |
|
45 | except: | |
43 | return False |
|
46 | return False | |
44 |
|
47 | |||
45 | def has_executablebit(): |
|
48 | def has_executablebit(): | |
46 | fd, path = tempfile.mkstemp(prefix=tempprefix) |
|
49 | fd, path = tempfile.mkstemp(prefix=tempprefix) | |
47 | os.close(fd) |
|
50 | os.close(fd) | |
48 | try: |
|
51 | try: | |
49 | s = os.lstat(path).st_mode |
|
52 | s = os.lstat(path).st_mode | |
50 | os.chmod(path, s | 0100) |
|
53 | os.chmod(path, s | 0100) | |
51 | return (os.lstat(path).st_mode & 0100 != 0) |
|
54 | return (os.lstat(path).st_mode & 0100 != 0) | |
52 | finally: |
|
55 | finally: | |
53 | os.remove(path) |
|
56 | os.remove(path) | |
54 |
|
57 | |||
55 | def has_fifo(): |
|
58 | def has_fifo(): | |
56 | return hasattr(os, "mkfifo") |
|
59 | return hasattr(os, "mkfifo") | |
57 |
|
60 | |||
58 | def has_hotshot(): |
|
61 | def has_hotshot(): | |
59 | try: |
|
62 | try: | |
60 | # hotshot.stats tests hotshot and many problematic dependencies |
|
63 | # hotshot.stats tests hotshot and many problematic dependencies | |
61 | # like profile. |
|
64 | # like profile. | |
62 | import hotshot.stats |
|
65 | import hotshot.stats | |
63 | return True |
|
66 | return True | |
64 | except ImportError: |
|
67 | except ImportError: | |
65 | return False |
|
68 | return False | |
66 |
|
69 | |||
67 | def has_lsprof(): |
|
70 | def has_lsprof(): | |
68 | try: |
|
71 | try: | |
69 | import _lsprof |
|
72 | import _lsprof | |
70 | return True |
|
73 | return True | |
71 | except ImportError: |
|
74 | except ImportError: | |
72 | return False |
|
75 | return False | |
73 |
|
76 | |||
74 | def has_git(): |
|
77 | def has_git(): | |
75 | return matchoutput('git --version 2>&1', r'^git version') |
|
78 | return matchoutput('git --version 2>&1', r'^git version') | |
76 |
|
79 | |||
77 | def has_svn(): |
|
80 | def has_svn(): | |
78 | return matchoutput('svn --version 2>&1', r'^svn, version') and \ |
|
81 | return matchoutput('svn --version 2>&1', r'^svn, version') and \ | |
79 | matchoutput('svnadmin --version 2>&1', r'^svnadmin, version') |
|
82 | matchoutput('svnadmin --version 2>&1', r'^svnadmin, version') | |
80 |
|
83 | |||
81 | def has_svn_bindings(): |
|
84 | def has_svn_bindings(): | |
82 | try: |
|
85 | try: | |
83 | import svn.core |
|
86 | import svn.core | |
84 | return True |
|
87 | return True | |
85 | except ImportError: |
|
88 | except ImportError: | |
86 | return False |
|
89 | return False | |
87 |
|
90 | |||
88 | def has_symlink(): |
|
91 | def has_symlink(): | |
89 | return hasattr(os, "symlink") |
|
92 | return hasattr(os, "symlink") | |
90 |
|
93 | |||
91 | def has_tla(): |
|
94 | def has_tla(): | |
92 | return matchoutput('tla --version 2>&1', r'The GNU Arch Revision') |
|
95 | return matchoutput('tla --version 2>&1', r'The GNU Arch Revision') | |
93 |
|
96 | |||
94 | def has_unix_permissions(): |
|
97 | def has_unix_permissions(): | |
95 | d = tempfile.mkdtemp(prefix=tempprefix, dir=".") |
|
98 | d = tempfile.mkdtemp(prefix=tempprefix, dir=".") | |
96 | try: |
|
99 | try: | |
97 | fname = os.path.join(d, 'foo') |
|
100 | fname = os.path.join(d, 'foo') | |
98 | for umask in (077, 007, 022): |
|
101 | for umask in (077, 007, 022): | |
99 | os.umask(umask) |
|
102 | os.umask(umask) | |
100 | f = open(fname, 'w') |
|
103 | f = open(fname, 'w') | |
101 | f.close() |
|
104 | f.close() | |
102 | mode = os.stat(fname).st_mode |
|
105 | mode = os.stat(fname).st_mode | |
103 | os.unlink(fname) |
|
106 | os.unlink(fname) | |
104 | if mode & 0777 != ~umask & 0666: |
|
107 | if mode & 0777 != ~umask & 0666: | |
105 | return False |
|
108 | return False | |
106 | return True |
|
109 | return True | |
107 | finally: |
|
110 | finally: | |
108 | os.rmdir(d) |
|
111 | os.rmdir(d) | |
109 |
|
112 | |||
110 | def has_pygments(): |
|
113 | def has_pygments(): | |
111 | try: |
|
114 | try: | |
112 | import pygments |
|
115 | import pygments | |
113 | return True |
|
116 | return True | |
114 | except ImportError: |
|
117 | except ImportError: | |
115 | return False |
|
118 | return False | |
116 |
|
119 | |||
117 | checks = { |
|
120 | checks = { | |
118 | "baz": (has_baz, "GNU Arch baz client"), |
|
121 | "baz": (has_baz, "GNU Arch baz client"), | |
119 | "cvs": (has_cvs, "cvs client"), |
|
122 | "cvs": (has_cvs, "cvs client"), | |
120 | "cvsps": (has_cvsps, "cvsps utility"), |
|
123 | "cvsps": (has_cvsps, "cvsps utility"), | |
121 | "darcs": (has_darcs, "darcs client"), |
|
124 | "darcs": (has_darcs, "darcs client"), | |
122 | "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"), |
|
125 | "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"), | |
123 | "execbit": (has_executablebit, "executable bit"), |
|
126 | "execbit": (has_executablebit, "executable bit"), | |
124 | "fifo": (has_fifo, "named pipes"), |
|
127 | "fifo": (has_fifo, "named pipes"), | |
125 | "git": (has_git, "git command line client"), |
|
128 | "git": (has_git, "git command line client"), | |
126 | "hotshot": (has_hotshot, "python hotshot module"), |
|
129 | "hotshot": (has_hotshot, "python hotshot module"), | |
127 | "lsprof": (has_lsprof, "python lsprof module"), |
|
130 | "lsprof": (has_lsprof, "python lsprof module"), | |
|
131 | "mtn": (has_mtn, "monotone client"), | |||
128 | "svn": (has_svn, "subversion client and admin tools"), |
|
132 | "svn": (has_svn, "subversion client and admin tools"), | |
129 | "svn-bindings": (has_svn_bindings, "subversion python bindings"), |
|
133 | "svn-bindings": (has_svn_bindings, "subversion python bindings"), | |
130 | "symlink": (has_symlink, "symbolic links"), |
|
134 | "symlink": (has_symlink, "symbolic links"), | |
131 | "tla": (has_tla, "GNU Arch tla client"), |
|
135 | "tla": (has_tla, "GNU Arch tla client"), | |
132 | "unix-permissions": (has_unix_permissions, "unix-style permissions"), |
|
136 | "unix-permissions": (has_unix_permissions, "unix-style permissions"), | |
133 | "pygments": (has_pygments, "Pygments source highlighting library"), |
|
137 | "pygments": (has_pygments, "Pygments source highlighting library"), | |
134 | } |
|
138 | } | |
135 |
|
139 | |||
136 | def list_features(): |
|
140 | def list_features(): | |
137 | for name, feature in checks.iteritems(): |
|
141 | for name, feature in checks.iteritems(): | |
138 | desc = feature[1] |
|
142 | desc = feature[1] | |
139 | print name + ':', desc |
|
143 | print name + ':', desc | |
140 |
|
144 | |||
141 | parser = optparse.OptionParser("%prog [options] [features]") |
|
145 | parser = optparse.OptionParser("%prog [options] [features]") | |
142 | parser.add_option("--list-features", action="store_true", |
|
146 | parser.add_option("--list-features", action="store_true", | |
143 | help="list available features") |
|
147 | help="list available features") | |
144 | parser.add_option("-q", "--quiet", action="store_true", |
|
148 | parser.add_option("-q", "--quiet", action="store_true", | |
145 | help="check features silently") |
|
149 | help="check features silently") | |
146 |
|
150 | |||
147 | if __name__ == '__main__': |
|
151 | if __name__ == '__main__': | |
148 | options, args = parser.parse_args() |
|
152 | options, args = parser.parse_args() | |
149 | if options.list_features: |
|
153 | if options.list_features: | |
150 | list_features() |
|
154 | list_features() | |
151 | sys.exit(0) |
|
155 | sys.exit(0) | |
152 |
|
156 | |||
153 | quiet = options.quiet |
|
157 | quiet = options.quiet | |
154 |
|
158 | |||
155 | failures = 0 |
|
159 | failures = 0 | |
156 |
|
160 | |||
157 | def error(msg): |
|
161 | def error(msg): | |
158 | global failures |
|
162 | global failures | |
159 | if not quiet: |
|
163 | if not quiet: | |
160 | sys.stderr.write(msg + '\n') |
|
164 | sys.stderr.write(msg + '\n') | |
161 | failures += 1 |
|
165 | failures += 1 | |
162 |
|
166 | |||
163 | for feature in args: |
|
167 | for feature in args: | |
164 | negate = feature.startswith('no-') |
|
168 | negate = feature.startswith('no-') | |
165 | if negate: |
|
169 | if negate: | |
166 | feature = feature[3:] |
|
170 | feature = feature[3:] | |
167 |
|
171 | |||
168 | if feature not in checks: |
|
172 | if feature not in checks: | |
169 | error('skipped: unknown feature: ' + feature) |
|
173 | error('skipped: unknown feature: ' + feature) | |
170 | continue |
|
174 | continue | |
171 |
|
175 | |||
172 | check, desc = checks[feature] |
|
176 | check, desc = checks[feature] | |
173 | if not negate and not check(): |
|
177 | if not negate and not check(): | |
174 | error('skipped: missing feature: ' + desc) |
|
178 | error('skipped: missing feature: ' + desc) | |
175 | elif negate and check(): |
|
179 | elif negate and check(): | |
176 | error('skipped: system supports %s' % desc) |
|
180 | error('skipped: system supports %s' % desc) | |
177 |
|
181 | |||
178 | if failures != 0: |
|
182 | if failures != 0: | |
179 | sys.exit(1) |
|
183 | sys.exit(1) | |
180 |
|
184 | |||
181 |
|
185 |
General Comments 0
You need to be logged in to leave comments.
Login now