Mercurial > python-hglib
comparison tests/test-grep.py @ 56:9bd819da245a
client: add grep command
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Fri, 19 Aug 2011 20:08:13 +0300 |
parents | |
children | 1b47146a4a2c |
comparison
equal
deleted
inserted
replaced
55:5833f6ac0929 | 56:9bd819da245a |
---|---|
1 import common | |
2 | |
3 class test_grep(common.basetest): | |
4 def test_basic(self): | |
5 self.append('a', 'a\n') | |
6 self.append('b', 'ab\n') | |
7 self.client.commit('first', addremove=True) | |
8 | |
9 # no match | |
10 self.assertEquals(list(self.client.grep('c')), []) | |
11 | |
12 self.assertEquals(list(self.client.grep('a')), | |
13 [('a', '0', 'a'), ('b', '0', 'ab')]) | |
14 self.assertEquals(list(self.client.grep('a', 'a')), [('a', '0', 'a')]) | |
15 | |
16 self.assertEquals(list(self.client.grep('b')), [('b', '0', 'ab')]) | |
17 | |
18 def test_options(self): | |
19 self.append('a', 'a\n') | |
20 self.append('b', 'ab\n') | |
21 rev, node = self.client.commit('first', addremove=True) | |
22 | |
23 self.assertEquals([('a', '0', '+', 'a'), ('b', '0', '+', 'ab')], | |
24 list(self.client.grep('a', all=True))) | |
25 | |
26 self.assertEquals([('a', '0'), ('b', '0')], | |
27 list(self.client.grep('a', fileswithmatches=True))) | |
28 | |
29 self.assertEquals([('a', '0', '1', 'a'), ('b', '0', '1', 'ab')], | |
30 list(self.client.grep('a', line=True))) | |
31 | |
32 self.assertEquals([('a', '0', 'test', 'a'), ('b', '0', 'test', 'ab')], | |
33 list(self.client.grep('a', user=True))) | |
34 | |
35 self.assertEquals([('a', '0', '1', '+', 'test'), | |
36 ('b', '0', '1', '+', 'test')], | |
37 list(self.client.grep('a', all=True, user=True, line=True, | |
38 fileswithmatches=True))) |