annotate tests/test-config.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 e738d6fe5f3f
children 9ecb271600fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1 import os, common, hglib
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
2
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
3 class test_config(common.basetest):
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4 def setUp(self):
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 common.basetest.setUp(self)
118
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 21
diff changeset
6 f = open('.hg/hgrc', 'a')
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 21
diff changeset
7 f.write('[section]\nkey=value\n')
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 21
diff changeset
8 f.close()
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9 self.client = hglib.open()
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11 def test_basic(self):
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12 config = self.client.config()
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 self.assertTrue(('section', 'key', 'value') in self.client.config())
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
16 self.assertTrue([('section', 'key', 'value')],
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17 self.client.config('section'))
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18 self.assertTrue([('section', 'key', 'value')],
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
19 self.client.config(['section', 'foo']))
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
20 self.assertRaises(hglib.error.CommandError,
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
21 self.client.config, ['a.b', 'foo'])
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23 def test_show_source(self):
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
24 config = self.client.config(showsource=True)
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26 self.assertTrue((os.path.abspath('.hg/hgrc') + ':2',
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
27 'section', 'key', 'value') in config)