Show More
@@ -122,7 +122,9 b' class ui(object):' | |||||
122 | try: |
|
122 | try: | |
123 | return self.cdata.get(section, name) |
|
123 | return self.cdata.get(section, name) | |
124 | except ConfigParser.InterpolationError, inst: |
|
124 | except ConfigParser.InterpolationError, inst: | |
125 |
raise util.Abort(_("Error in configuration |
|
125 | raise util.Abort(_("Error in configuration section [%s] " | |
|
126 | "parameter '%s':\n%s") | |||
|
127 | % (section, name, inst)) | |||
126 | if self.parentui is None: |
|
128 | if self.parentui is None: | |
127 | return default |
|
129 | return default | |
128 | else: |
|
130 | else: | |
@@ -144,7 +146,9 b' class ui(object):' | |||||
144 | try: |
|
146 | try: | |
145 | return self.cdata.getboolean(section, name) |
|
147 | return self.cdata.getboolean(section, name) | |
146 | except ConfigParser.InterpolationError, inst: |
|
148 | except ConfigParser.InterpolationError, inst: | |
147 |
raise util.Abort(_("Error in configuration |
|
149 | raise util.Abort(_("Error in configuration section [%s] " | |
|
150 | "parameter '%s':\n%s") | |||
|
151 | % (section, name, inst)) | |||
148 | if self.parentui is None: |
|
152 | if self.parentui is None: | |
149 | return default |
|
153 | return default | |
150 | else: |
|
154 | else: | |
@@ -162,7 +166,8 b' class ui(object):' | |||||
162 | try: |
|
166 | try: | |
163 | items.update(dict(self.cdata.items(section))) |
|
167 | items.update(dict(self.cdata.items(section))) | |
164 | except ConfigParser.InterpolationError, inst: |
|
168 | except ConfigParser.InterpolationError, inst: | |
165 |
raise util.Abort(_("Error in configuration:\n%s") |
|
169 | raise util.Abort(_("Error in configuration section [%s]:\n%s") | |
|
170 | % (section, inst)) | |||
166 | x = items.items() |
|
171 | x = items.items() | |
167 | x.sort() |
|
172 | x.sort() | |
168 | return x |
|
173 | return x | |
@@ -174,10 +179,14 b' class ui(object):' | |||||
174 | yield section, name, value |
|
179 | yield section, name, value | |
175 | seen[section, name] = 1 |
|
180 | seen[section, name] = 1 | |
176 | for section in self.cdata.sections(): |
|
181 | for section in self.cdata.sections(): | |
177 | for name, value in self.cdata.items(section): |
|
182 | try: | |
178 | if (section, name) in seen: continue |
|
183 | for name, value in self.cdata.items(section): | |
179 | yield section, name, value.replace('\n', '\\n') |
|
184 | if (section, name) in seen: continue | |
180 |
|
|
185 | yield section, name, value.replace('\n', '\\n') | |
|
186 | seen[section, name] = 1 | |||
|
187 | except ConfigParser.InterpolationError, inst: | |||
|
188 | raise util.Abort(_("Error in configuration section [%s]:\n%s") | |||
|
189 | % (section, inst)) | |||
181 | if self.parentui is not None: |
|
190 | if self.parentui is not None: | |
182 | for parent in self.parentui.walkconfig(seen): |
|
191 | for parent in self.parentui.walkconfig(seen): | |
183 | yield parent |
|
192 | yield parent |
@@ -1,6 +1,6 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 |
|
2 | |||
3 | from mercurial import ui |
|
3 | from mercurial import ui, util | |
4 |
|
4 | |||
5 | testui = ui.ui() |
|
5 | testui = ui.ui() | |
6 | testui.updateopts(config=[ |
|
6 | testui.updateopts(config=[ | |
@@ -11,10 +11,19 b' testui.updateopts(config=[' | |||||
11 | 'lists.list2=foo bar baz', |
|
11 | 'lists.list2=foo bar baz', | |
12 | 'lists.list3=alice, bob', |
|
12 | 'lists.list3=alice, bob', | |
13 | 'lists.list4=foo bar baz alice, bob', |
|
13 | 'lists.list4=foo bar baz alice, bob', | |
|
14 | 'interpolation.value1=hallo', | |||
|
15 | 'interpolation.value2=%(value1)s world', | |||
|
16 | 'interpolation.value3=%(novalue)s', | |||
|
17 | 'interpolation.value4=%(bad)1', | |||
|
18 | 'interpolation.value5=%bad2', | |||
14 | ]) |
|
19 | ]) | |
15 |
|
20 | |||
16 | print repr(testui.configitems('values')) |
|
21 | print repr(testui.configitems('values')) | |
17 | print repr(testui.configitems('lists')) |
|
22 | print repr(testui.configitems('lists')) | |
|
23 | try: | |||
|
24 | print repr(testui.configitems('interpolation')) | |||
|
25 | except util.Abort, inst: | |||
|
26 | print inst | |||
18 | print "---" |
|
27 | print "---" | |
19 | print repr(testui.config('values', 'string')) |
|
28 | print repr(testui.config('values', 'string')) | |
20 | print repr(testui.config('values', 'bool1')) |
|
29 | print repr(testui.config('values', 'bool1')) | |
@@ -45,3 +54,18 b" print repr(testui.configlist('lists', 'u" | |||||
45 | print repr(testui.configlist('lists', 'unknown', ['foo bar'])) |
|
54 | print repr(testui.configlist('lists', 'unknown', ['foo bar'])) | |
46 | print repr(testui.configlist('lists', 'unknown', ['foo', 'bar'])) |
|
55 | print repr(testui.configlist('lists', 'unknown', ['foo', 'bar'])) | |
47 | print "---" |
|
56 | print "---" | |
|
57 | print repr(testui.config('interpolation', 'value1')) | |||
|
58 | print repr(testui.config('interpolation', 'value2')) | |||
|
59 | try: | |||
|
60 | print repr(testui.config('interpolation', 'value3')) | |||
|
61 | except util.Abort, inst: | |||
|
62 | print inst | |||
|
63 | try: | |||
|
64 | print repr(testui.config('interpolation', 'value4')) | |||
|
65 | except util.Abort, inst: | |||
|
66 | print inst | |||
|
67 | try: | |||
|
68 | print repr(testui.config('interpolation', 'value5')) | |||
|
69 | except util.Abort, inst: | |||
|
70 | print inst | |||
|
71 | print "---" |
@@ -1,5 +1,7 b'' | |||||
1 | [('bool1', 'true'), ('bool2', 'false'), ('string', 'string value')] |
|
1 | [('bool1', 'true'), ('bool2', 'false'), ('string', 'string value')] | |
2 | [('list1', 'foo'), ('list2', 'foo bar baz'), ('list3', 'alice, bob'), ('list4', 'foo bar baz alice, bob')] |
|
2 | [('list1', 'foo'), ('list2', 'foo bar baz'), ('list3', 'alice, bob'), ('list4', 'foo bar baz alice, bob')] | |
|
3 | Error in configuration section [interpolation]: | |||
|
4 | '%' must be followed by '%' or '(', found: '%bad2' | |||
3 | --- |
|
5 | --- | |
4 | 'string value' |
|
6 | 'string value' | |
5 | 'true' |
|
7 | 'true' | |
@@ -27,3 +29,17 b' True' | |||||
27 | ['foo bar'] |
|
29 | ['foo bar'] | |
28 | ['foo', 'bar'] |
|
30 | ['foo', 'bar'] | |
29 | --- |
|
31 | --- | |
|
32 | 'hallo' | |||
|
33 | 'hallo world' | |||
|
34 | Error in configuration section [interpolation] parameter 'value3': | |||
|
35 | Bad value substitution: | |||
|
36 | section: [interpolation] | |||
|
37 | option : value3 | |||
|
38 | key : novalue | |||
|
39 | rawval : | |||
|
40 | ||||
|
41 | Error in configuration section [interpolation] parameter 'value4': | |||
|
42 | bad interpolation variable reference '%(bad)1' | |||
|
43 | Error in configuration section [interpolation] parameter 'value5': | |||
|
44 | '%' must be followed by '%' or '(', found: '%bad2' | |||
|
45 | --- |
General Comments 0
You need to be logged in to leave comments.
Login now