Show More
@@ -0,0 +1,47 b'' | |||||
|
1 | #!/usr/bin/env python | |||
|
2 | ||||
|
3 | from mercurial import ui | |||
|
4 | ||||
|
5 | testui = ui.ui() | |||
|
6 | testui.updateopts(config=[ | |||
|
7 | 'values.string=string value', | |||
|
8 | 'values.bool1=true', | |||
|
9 | 'values.bool2=false', | |||
|
10 | 'lists.list1=foo', | |||
|
11 | 'lists.list2=foo bar baz', | |||
|
12 | 'lists.list3=alice, bob', | |||
|
13 | 'lists.list4=foo bar baz alice, bob', | |||
|
14 | ]) | |||
|
15 | ||||
|
16 | print repr(testui.configitems('values')) | |||
|
17 | print repr(testui.configitems('lists')) | |||
|
18 | print "---" | |||
|
19 | print repr(testui.config('values', 'string')) | |||
|
20 | print repr(testui.config('values', 'bool1')) | |||
|
21 | print repr(testui.config('values', 'bool2')) | |||
|
22 | print repr(testui.config('values', 'unknown')) | |||
|
23 | print "---" | |||
|
24 | try: | |||
|
25 | print repr(testui.configbool('values', 'string')) | |||
|
26 | except ValueError, why: | |||
|
27 | print why | |||
|
28 | print repr(testui.configbool('values', 'bool1')) | |||
|
29 | print repr(testui.configbool('values', 'bool2')) | |||
|
30 | print repr(testui.configbool('values', 'bool2', True)) | |||
|
31 | print repr(testui.configbool('values', 'unknown')) | |||
|
32 | print repr(testui.configbool('values', 'unknown', True)) | |||
|
33 | print "---" | |||
|
34 | print repr(testui.configlist('lists', 'list1')) | |||
|
35 | print repr(testui.configlist('lists', 'list2')) | |||
|
36 | print repr(testui.configlist('lists', 'list3')) | |||
|
37 | print repr(testui.configlist('lists', 'list4')) | |||
|
38 | print repr(testui.configlist('lists', 'list4', ['foo'])) | |||
|
39 | print repr(testui.configlist('lists', 'unknown')) | |||
|
40 | print repr(testui.configlist('lists', 'unknown', '')) | |||
|
41 | print repr(testui.configlist('lists', 'unknown', 'foo')) | |||
|
42 | print repr(testui.configlist('lists', 'unknown', ['foo'])) | |||
|
43 | print repr(testui.configlist('lists', 'unknown', 'foo bar')) | |||
|
44 | print repr(testui.configlist('lists', 'unknown', 'foo, bar')) | |||
|
45 | print repr(testui.configlist('lists', 'unknown', ['foo bar'])) | |||
|
46 | print repr(testui.configlist('lists', 'unknown', ['foo', 'bar'])) | |||
|
47 | print "---" |
@@ -0,0 +1,29 b'' | |||||
|
1 | [('bool1', 'true'), ('bool2', 'false'), ('string', 'string value')] | |||
|
2 | [('list1', 'foo'), ('list2', 'foo bar baz'), ('list3', 'alice, bob'), ('list4', 'foo bar baz alice, bob')] | |||
|
3 | --- | |||
|
4 | 'string value' | |||
|
5 | 'true' | |||
|
6 | 'false' | |||
|
7 | None | |||
|
8 | --- | |||
|
9 | Not a boolean: string value | |||
|
10 | True | |||
|
11 | False | |||
|
12 | False | |||
|
13 | False | |||
|
14 | True | |||
|
15 | --- | |||
|
16 | ['foo'] | |||
|
17 | ['foo', 'bar', 'baz'] | |||
|
18 | ['alice', 'bob'] | |||
|
19 | ['foo', 'bar', 'baz', 'alice', 'bob'] | |||
|
20 | ['foo', 'bar', 'baz', 'alice', 'bob'] | |||
|
21 | [] | |||
|
22 | [] | |||
|
23 | ['foo'] | |||
|
24 | ['foo'] | |||
|
25 | ['foo', 'bar'] | |||
|
26 | ['foo', 'bar'] | |||
|
27 | ['foo bar'] | |||
|
28 | ['foo', 'bar'] | |||
|
29 | --- |
@@ -99,10 +99,10 b' class ui(object):' | |||||
99 | """Return a list of comma/space separated strings""" |
|
99 | """Return a list of comma/space separated strings""" | |
100 | result = self.config(section, name) |
|
100 | result = self.config(section, name) | |
101 | if result is None: |
|
101 | if result is None: | |
102 |
retur |
|
102 | result = default or [] | |
103 | else: |
|
103 | if isinstance(result, basestring): | |
104 |
re |
|
104 | result = result.replace(",", " ").split() | |
105 |
|
105 | return result | ||
106 |
|
106 | |||
107 | def configbool(self, section, name, default=False): |
|
107 | def configbool(self, section, name, default=False): | |
108 | if self.overlay.has_key((section, name)): |
|
108 | if self.overlay.has_key((section, name)): |
General Comments 0
You need to be logged in to leave comments.
Login now