1 from __future__ import absolute_import |
1 from __future__ import absolute_import |
2 from __future__ import print_function |
2 from __future__ import print_function |
3 |
3 |
4 from mercurial import minifileset |
4 from mercurial import minifileset |
|
5 |
5 |
6 |
6 def check(text, truecases, falsecases): |
7 def check(text, truecases, falsecases): |
7 f = minifileset.compile(text) |
8 f = minifileset.compile(text) |
8 for args in truecases: |
9 for args in truecases: |
9 if not f(*args): |
10 if not f(*args): |
10 print('unexpected: %r should include %r' % (text, args)) |
11 print('unexpected: %r should include %r' % (text, args)) |
11 for args in falsecases: |
12 for args in falsecases: |
12 if f(*args): |
13 if f(*args): |
13 print('unexpected: %r should exclude %r' % (text, args)) |
14 print('unexpected: %r should exclude %r' % (text, args)) |
14 |
15 |
|
16 |
15 check(b'all()', [(b'a.php', 123), (b'b.txt', 0)], []) |
17 check(b'all()', [(b'a.php', 123), (b'b.txt', 0)], []) |
16 check(b'none()', [], [(b'a.php', 123), (b'b.txt', 0)]) |
18 check(b'none()', [], [(b'a.php', 123), (b'b.txt', 0)]) |
17 check(b'!!!!((!(!!all())))', [], [(b'a.php', 123), (b'b.txt', 0)]) |
19 check(b'!!!!((!(!!all())))', [], [(b'a.php', 123), (b'b.txt', 0)]) |
18 |
20 |
19 check(b'"path:a" & (**.b | **.c)', |
21 check( |
20 [(b'a/b.b', 0), (b'a/c.c', 0)], [(b'b/c.c', 0)]) |
22 b'"path:a" & (**.b | **.c)', [(b'a/b.b', 0), (b'a/c.c', 0)], [(b'b/c.c', 0)] |
21 check(b'(path:a & **.b) | **.c', |
23 ) |
22 [(b'a/b.b', 0), (b'a/c.c', 0), (b'b/c.c', 0)], []) |
24 check( |
|
25 b'(path:a & **.b) | **.c', [(b'a/b.b', 0), (b'a/c.c', 0), (b'b/c.c', 0)], [] |
|
26 ) |
23 |
27 |
24 check(b'**.bin - size("<20B")', |
28 check( |
25 [(b'b.bin', 21)], [(b'a.bin', 11), (b'b.txt', 21)]) |
29 b'**.bin - size("<20B")', [(b'b.bin', 21)], [(b'a.bin', 11), (b'b.txt', 21)] |
|
30 ) |
26 |
31 |
27 check(b'!!**.bin or size(">20B") + "path:bin" or !size(">10")', |
32 check( |
28 [(b'a.bin', 11), (b'b.txt', 21), (b'bin/abc', 11)], |
33 b'!!**.bin or size(">20B") + "path:bin" or !size(">10")', |
29 [(b'a.notbin', 11), (b'b.txt', 11), (b'bin2/abc', 11)]) |
34 [(b'a.bin', 11), (b'b.txt', 21), (b'bin/abc', 11)], |
|
35 [(b'a.notbin', 11), (b'b.txt', 11), (b'bin2/abc', 11)], |
|
36 ) |
30 |
37 |
31 check( |
38 check( |
32 b'(**.php and size(">10KB")) | **.zip | ("path:bin" & !"path:bin/README") ' |
39 b'(**.php and size(">10KB")) | **.zip | ("path:bin" & !"path:bin/README") ' |
33 b' | size(">1M")', |
40 b' | size(">1M")', |
34 [(b'a.php', 15000), (b'a.zip', 0), (b'bin/a', 0), (b'bin/README', 1e7)], |
41 [(b'a.php', 15000), (b'a.zip', 0), (b'bin/a', 0), (b'bin/README', 1e7)], |
35 [(b'a.php', 5000), (b'b.zip2', 0), (b't/bin/a', 0), (b'bin/README', 1)]) |
42 [(b'a.php', 5000), (b'b.zip2', 0), (b't/bin/a', 0), (b'bin/README', 1)], |
|
43 ) |