Mercurial > hg
annotate tests/test-ui-config @ 8137:7fd0616b3d80
ui: kill updateopts
Move setconfig into dispatch._parseconfig
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 23 Apr 2009 15:40:10 -0500 |
parents | 18a9fbb5cd78 |
children | fca54469480e |
rev | line source |
---|---|
2502
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
2 |
4069
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
3 import ConfigParser |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
4729
diff
changeset
|
4 from mercurial import ui, util, dispatch |
2502
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
5 |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
6 testui = ui.ui() |
8137 | 7 parsed = dispatch._parseconfig(testui, [ |
2502
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
8 'values.string=string value', |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
9 'values.bool1=true', |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
10 'values.bool2=false', |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
11 'lists.list1=foo', |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
12 'lists.list2=foo bar baz', |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
13 'lists.list3=alice, bob', |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
14 'lists.list4=foo bar baz alice, bob', |
3073
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
15 'interpolation.value1=hallo', |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
16 'interpolation.value2=%(value1)s world', |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
17 'interpolation.value3=%(novalue)s', |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
18 'interpolation.value4=%(bad)1', |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
19 'interpolation.value5=%bad2', |
2502
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
20 ]) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
21 |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
22 print repr(testui.configitems('values')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
23 print repr(testui.configitems('lists')) |
3073
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
24 try: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
25 print repr(testui.configitems('interpolation')) |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
26 except util.Abort, inst: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
27 print inst |
2502
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
28 print "---" |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
29 print repr(testui.config('values', 'string')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
30 print repr(testui.config('values', 'bool1')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
31 print repr(testui.config('values', 'bool2')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
32 print repr(testui.config('values', 'unknown')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
33 print "---" |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
34 try: |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
35 print repr(testui.configbool('values', 'string')) |
4729
9881abfc0e44
Catch illegal boolean values in hgrc nicely.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4549
diff
changeset
|
36 except util.Abort, inst: |
9881abfc0e44
Catch illegal boolean values in hgrc nicely.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4549
diff
changeset
|
37 print inst |
2502
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
38 print repr(testui.configbool('values', 'bool1')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
39 print repr(testui.configbool('values', 'bool2')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
40 print repr(testui.configbool('values', 'bool2', True)) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
41 print repr(testui.configbool('values', 'unknown')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
42 print repr(testui.configbool('values', 'unknown', True)) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
43 print "---" |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
44 print repr(testui.configlist('lists', 'list1')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
45 print repr(testui.configlist('lists', 'list2')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
46 print repr(testui.configlist('lists', 'list3')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
47 print repr(testui.configlist('lists', 'list4')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
48 print repr(testui.configlist('lists', 'list4', ['foo'])) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
49 print repr(testui.configlist('lists', 'unknown')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
50 print repr(testui.configlist('lists', 'unknown', '')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
51 print repr(testui.configlist('lists', 'unknown', 'foo')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
52 print repr(testui.configlist('lists', 'unknown', ['foo'])) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
53 print repr(testui.configlist('lists', 'unknown', 'foo bar')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
54 print repr(testui.configlist('lists', 'unknown', 'foo, bar')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
55 print repr(testui.configlist('lists', 'unknown', ['foo bar'])) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
56 print repr(testui.configlist('lists', 'unknown', ['foo', 'bar'])) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
57 print "---" |
3073
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
58 print repr(testui.config('interpolation', 'value1')) |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
59 print repr(testui.config('interpolation', 'value2')) |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
60 try: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
61 print repr(testui.config('interpolation', 'value3')) |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
62 except util.Abort, inst: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
63 print inst |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
64 try: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
65 print repr(testui.config('interpolation', 'value4')) |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
66 except util.Abort, inst: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
67 print inst |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
68 try: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
69 print repr(testui.config('interpolation', 'value5')) |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
70 except util.Abort, inst: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
71 print inst |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
72 print "---" |
4069
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
73 |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
74 cp = util.configparser() |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
75 cp.add_section('foo') |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
76 cp.set('foo', 'bar', 'baz') |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
77 try: |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
78 # should fail - keys are case-sensitive |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
79 cp.get('foo', 'Bar') |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
80 except ConfigParser.NoOptionError, inst: |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
81 print inst |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
82 |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
83 def function(): |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
84 pass |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
85 |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
86 cp.add_section('hook') |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
87 # values that aren't strings should work |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
88 cp.set('hook', 'commit', function) |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
89 f = cp.get('hook', 'commit') |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
90 print "f %s= function" % (f == function and '=' or '!') |