annotate tests/test-grep.py @ 123:cdde1656346f

client: add 'hidden' property to show hidden changesets. This enables interactions with the obsolete changesets in the repository: - add the attribute in client class - add the keyword to the relevant commands - enable log without hidden changesets even when self.hidden is True - add a few tests with the hidden keyword This changeset mirrors the behavior of the mercurial global command --hidden: an attribute is added to the client library. If set at True, adds the hidden keyword to all command which can use it to show hidden changesets. The alternative would be to add the keyword in rawcommand, but the hidden flag is not relevant for commands such as add or branch.
author Paul Tonelli <paul.tonelli@logilab.fr>
date Thu, 22 May 2014 15:23:12 +0200
parents 9bd819da245a
children 1b47146a4a2c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1 import common
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
2
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
3 class test_grep(common.basetest):
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4 def test_basic(self):
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 self.append('a', 'a\n')
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 self.append('b', 'ab\n')
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
7 self.client.commit('first', addremove=True)
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9 # no match
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10 self.assertEquals(list(self.client.grep('c')), [])
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12 self.assertEquals(list(self.client.grep('a')),
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13 [('a', '0', 'a'), ('b', '0', 'ab')])
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 self.assertEquals(list(self.client.grep('a', 'a')), [('a', '0', 'a')])
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
16 self.assertEquals(list(self.client.grep('b')), [('b', '0', 'ab')])
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18 def test_options(self):
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
19 self.append('a', 'a\n')
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
20 self.append('b', 'ab\n')
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
21 rev, node = self.client.commit('first', addremove=True)
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23 self.assertEquals([('a', '0', '+', 'a'), ('b', '0', '+', 'ab')],
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
24 list(self.client.grep('a', all=True)))
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26 self.assertEquals([('a', '0'), ('b', '0')],
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
27 list(self.client.grep('a', fileswithmatches=True)))
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
28
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29 self.assertEquals([('a', '0', '1', 'a'), ('b', '0', '1', 'ab')],
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
30 list(self.client.grep('a', line=True)))
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
31
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
32 self.assertEquals([('a', '0', 'test', 'a'), ('b', '0', 'test', 'ab')],
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
33 list(self.client.grep('a', user=True)))
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
34
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
35 self.assertEquals([('a', '0', '1', '+', 'test'),
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
36 ('b', '0', '1', '+', 'test')],
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
37 list(self.client.grep('a', all=True, user=True, line=True,
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
38 fileswithmatches=True)))