Mercurial > python-hglib
comparison tests/test-grep.py @ 213:388820908580 2.6.2
hglib: update grep to cope with behavior change in hg 5.2.
Since version 5.2, revision filed not printed without all argument.
Fixed inaccurate pasring result with lastest hg and changed test case.
author | Daehyeok Mun <daehyeok@gmail.com> |
---|---|
date | Sat, 21 Mar 2020 19:59:50 -0700 |
parents | 1a318162f06f |
children |
comparison
equal
deleted
inserted
replaced
212:868a903689fd | 213:388820908580 |
---|---|
1 from tests import common | 1 from tests import common |
2 from hglib.util import b | 2 from hglib.util import b |
3 | 3 |
4 class test_grep(common.basetest): | 4 class test_grep(common.basetest): |
5 def test_basic(self): | 5 def test_basic(self): |
6 self.append('a', 'a\n') | 6 self.append('a', 'x\n') |
7 self.append('b', 'ab\n') | 7 self.append('b', 'xy\n') |
8 self.client.commit(b('first'), addremove=True) | 8 self.client.commit(b('first'), addremove=True) |
9 | 9 |
10 # no match | 10 # no match |
11 self.assertEquals(list(self.client.grep(b('c'))), []) | 11 self.assertEquals(list(self.client.grep(b('c'))), []) |
12 | 12 |
13 if self.client.version >= (5, 2): | 13 if self.client.version >= (5, 2): |
14 self.assertEquals(list(self.client.grep(b('a'))), | 14 self.assertEquals(list(self.client.grep(b('x'))), |
15 [(b('a'), b('a'), b('b'))]) | 15 [(b('a'), b('x')), (b('b'), b('xy'))]) |
16 self.assertEquals(list(self.client.grep(b('a'), b('a'))), | 16 self.assertEquals(list(self.client.grep(b('x'), b('a'))), |
17 [(b('a'), b('a'), b(''))]) | 17 [(b('a'), b('x'))]) |
18 | 18 |
19 self.assertEquals(list(self.client.grep(b('b'))), | 19 self.assertEquals(list(self.client.grep(b('y'))), |
20 [(b('b'), b('ab'), b(''))]) | 20 [(b('b'), b('xy'))]) |
21 else: | 21 else: |
22 self.assertEquals(list(self.client.grep(b('a'))), | 22 self.assertEquals(list(self.client.grep(b('x'))), |
23 [(b('a'), b('0'), b('a')), (b('b'), b('0'), b('ab'))]) | 23 [(b('a'), b('0'), b('x')), (b('b'), b('0'), b('xy'))]) |
24 self.assertEquals(list(self.client.grep(b('a'), b('a'))), | 24 self.assertEquals(list(self.client.grep(b('x'), b('a'))), |
25 [(b('a'), b('0'), b('a'))]) | 25 [(b('a'), b('0'), b('x'))]) |
26 | 26 self.assertEquals(list(self.client.grep(b('y'))), |
27 self.assertEquals(list(self.client.grep(b('b'))), | 27 [(b('b'), b('0'), b('xy'))]) |
28 [(b('b'), b('0'), b('ab'))]) | |
29 | 28 |
30 def test_options(self): | 29 def test_options(self): |
31 self.append('a', 'a\n') | 30 self.append('a', 'x\n') |
32 self.append('b', 'ab\n') | 31 self.append('b', 'xy\n') |
33 rev, node = self.client.commit(b('first'), addremove=True) | 32 rev, node = self.client.commit(b('first'), addremove=True) |
34 | 33 |
35 self.assertEquals([(b('a'), b('0'), b('+'), b('a')), | 34 self.assertEquals([(b('a'), b('0'), b('+'), b('x')), |
36 (b('b'), b('0'), b('+'), b('ab'))], | 35 (b('b'), b('0'), b('+'), b('xy'))], |
37 list(self.client.grep(b('a'), all=True))) | 36 list(self.client.grep(b('x'), all=True))) |
38 | 37 |
39 if self.client.version >= (5, 2): | 38 if self.client.version >= (5, 2): |
40 self.assertEquals([(b('a'), b('b'))], | 39 self.assertEquals([(b('a'),), (b('b'),)], |
41 list(self.client.grep(b('a'), fileswithmatches=True))) | 40 list(self.client.grep(b('x'), fileswithmatches=True))) |
42 | 41 |
43 self.assertEquals([(b('a'), b('1'), b('a'), b('b'))], | 42 self.assertEquals([(b('a'), b('1'), b('x')), (b('b'), b('1'), b('xy'))], |
44 list(self.client.grep(b('a'), line=True))) | 43 list(self.client.grep(b('x'), line=True))) |
45 | 44 |
46 self.assertEquals([(b('a'), b('test'), b('a'), b('b'))], | 45 self.assertEquals([(b('a'), b('test'), b('x')), |
47 list(self.client.grep(b('a'), user=True))) | 46 (b('b'), b('test'), b('xy'))], |
47 list(self.client.grep(b('x'), user=True))) | |
48 else: | 48 else: |
49 self.assertEquals([(b('a'), b('0')), (b('b'), b('0'))], | 49 self.assertEquals([(b('a'), b('0')), (b('b'), b('0'))], |
50 list(self.client.grep(b('a'), fileswithmatches=True))) | 50 list(self.client.grep(b('x'), fileswithmatches=True))) |
51 | 51 |
52 self.assertEquals([(b('a'), b('0'), b('1'), b('a')), | 52 self.assertEquals([(b('a'), b('0'), b('1'), b('x')), |
53 (b('b'), b('0'), b('1'), b('ab'))], | 53 (b('b'), b('0'), b('1'), b('xy'))], |
54 list(self.client.grep(b('a'), line=True))) | 54 list(self.client.grep(b('x'), line=True))) |
55 | 55 |
56 self.assertEquals([(b('a'), b('0'), b('test'), b('a')), | 56 self.assertEquals([(b('a'), b('0'), b('test'), b('x')), |
57 (b('b'), b('0'), b('test'), b('ab'))], | 57 (b('b'), b('0'), b('test'), b('xy'))], |
58 list(self.client.grep(b('a'), user=True))) | 58 list(self.client.grep(b('x'), user=True))) |
59 | 59 |
60 self.assertEquals([(b('a'), b('0'), b('1'), b('+'), b('test')), | 60 self.assertEquals([(b('a'), b('0'), b('1'), b('+'), b('test')), |
61 (b('b'), b('0'), b('1'), b('+'), b('test'))], | 61 (b('b'), b('0'), b('1'), b('+'), b('test'))], |
62 list(self.client.grep(b('a'), all=True, user=True, | 62 list(self.client.grep(b('x'), all=True, user=True, |
63 line=True, | 63 line=True, |
64 fileswithmatches=True))) | 64 fileswithmatches=True))) |