##// END OF EJS Templates
tests: conditionalize return code on chg in test-config.t...
Pulkit Goyal -
r46604:60523483 default
parent child Browse files
Show More
@@ -1,390 +1,414 b''
1 hide outer repo
1 hide outer repo
2 $ hg init
2 $ hg init
3
3
4 Invalid syntax: no value
4 Invalid syntax: no value
5
5
6 $ cat > .hg/hgrc << EOF
6 $ cat > .hg/hgrc << EOF
7 > novaluekey
7 > novaluekey
8 > EOF
8 > EOF
9 #if chg
10 $ hg showconfig
11 config error at $TESTTMP/.hg/hgrc:1: novaluekey
12 [255]
13 #else
9 $ hg showconfig
14 $ hg showconfig
10 config error at $TESTTMP/.hg/hgrc:1: novaluekey
15 config error at $TESTTMP/.hg/hgrc:1: novaluekey
11 [30]
16 [30]
17 #endif
12
18
13 Invalid syntax: no key
19 Invalid syntax: no key
14
20
15 $ cat > .hg/hgrc << EOF
21 $ cat > .hg/hgrc << EOF
16 > =nokeyvalue
22 > =nokeyvalue
17 > EOF
23 > EOF
24 #if chg
25 $ hg showconfig
26 config error at $TESTTMP/.hg/hgrc:1: =nokeyvalue
27 [255]
28 #else
18 $ hg showconfig
29 $ hg showconfig
19 config error at $TESTTMP/.hg/hgrc:1: =nokeyvalue
30 config error at $TESTTMP/.hg/hgrc:1: =nokeyvalue
20 [30]
31 [30]
32 #endif
21
33
22 Test hint about invalid syntax from leading white space
34 Test hint about invalid syntax from leading white space
23
35
24 $ cat > .hg/hgrc << EOF
36 $ cat > .hg/hgrc << EOF
25 > key=value
37 > key=value
26 > EOF
38 > EOF
39 #if chg
40 $ hg showconfig
41 config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: key=value
42 [255]
43 #else
27 $ hg showconfig
44 $ hg showconfig
28 config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: key=value
45 config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: key=value
29 [30]
46 [30]
47 #endif
30
48
31 $ cat > .hg/hgrc << EOF
49 $ cat > .hg/hgrc << EOF
32 > [section]
50 > [section]
33 > key=value
51 > key=value
34 > EOF
52 > EOF
53 #if chg
54 $ hg showconfig
55 config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: [section]
56 [255]
57 #else
35 $ hg showconfig
58 $ hg showconfig
36 config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: [section]
59 config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: [section]
37 [30]
60 [30]
61 #endif
38
62
39 Reset hgrc
63 Reset hgrc
40
64
41 $ echo > .hg/hgrc
65 $ echo > .hg/hgrc
42
66
43 Test case sensitive configuration
67 Test case sensitive configuration
44
68
45 $ cat <<EOF >> $HGRCPATH
69 $ cat <<EOF >> $HGRCPATH
46 > [Section]
70 > [Section]
47 > KeY = Case Sensitive
71 > KeY = Case Sensitive
48 > key = lower case
72 > key = lower case
49 > EOF
73 > EOF
50
74
51 $ hg showconfig Section
75 $ hg showconfig Section
52 Section.KeY=Case Sensitive
76 Section.KeY=Case Sensitive
53 Section.key=lower case
77 Section.key=lower case
54
78
55 $ hg showconfig Section -Tjson
79 $ hg showconfig Section -Tjson
56 [
80 [
57 {
81 {
58 "defaultvalue": null,
82 "defaultvalue": null,
59 "name": "Section.KeY",
83 "name": "Section.KeY",
60 "source": "*.hgrc:*", (glob)
84 "source": "*.hgrc:*", (glob)
61 "value": "Case Sensitive"
85 "value": "Case Sensitive"
62 },
86 },
63 {
87 {
64 "defaultvalue": null,
88 "defaultvalue": null,
65 "name": "Section.key",
89 "name": "Section.key",
66 "source": "*.hgrc:*", (glob)
90 "source": "*.hgrc:*", (glob)
67 "value": "lower case"
91 "value": "lower case"
68 }
92 }
69 ]
93 ]
70 $ hg showconfig Section.KeY -Tjson
94 $ hg showconfig Section.KeY -Tjson
71 [
95 [
72 {
96 {
73 "defaultvalue": null,
97 "defaultvalue": null,
74 "name": "Section.KeY",
98 "name": "Section.KeY",
75 "source": "*.hgrc:*", (glob)
99 "source": "*.hgrc:*", (glob)
76 "value": "Case Sensitive"
100 "value": "Case Sensitive"
77 }
101 }
78 ]
102 ]
79 $ hg showconfig -Tjson | tail -7
103 $ hg showconfig -Tjson | tail -7
80 {
104 {
81 "defaultvalue": null,
105 "defaultvalue": null,
82 "name": "*", (glob)
106 "name": "*", (glob)
83 "source": "*", (glob)
107 "source": "*", (glob)
84 "value": "*" (glob)
108 "value": "*" (glob)
85 }
109 }
86 ]
110 ]
87
111
88 Test config default of various types:
112 Test config default of various types:
89
113
90 {"defaultvalue": ""} for -T'json(defaultvalue)' looks weird, but that's
114 {"defaultvalue": ""} for -T'json(defaultvalue)' looks weird, but that's
91 how the templater works. Unknown keywords are evaluated to "".
115 how the templater works. Unknown keywords are evaluated to "".
92
116
93 dynamicdefault
117 dynamicdefault
94
118
95 $ hg config --config alias.foo= alias -Tjson
119 $ hg config --config alias.foo= alias -Tjson
96 [
120 [
97 {
121 {
98 "name": "alias.foo",
122 "name": "alias.foo",
99 "source": "--config",
123 "source": "--config",
100 "value": ""
124 "value": ""
101 }
125 }
102 ]
126 ]
103 $ hg config --config alias.foo= alias -T'json(defaultvalue)'
127 $ hg config --config alias.foo= alias -T'json(defaultvalue)'
104 [
128 [
105 {"defaultvalue": ""}
129 {"defaultvalue": ""}
106 ]
130 ]
107 $ hg config --config alias.foo= alias -T'{defaultvalue}\n'
131 $ hg config --config alias.foo= alias -T'{defaultvalue}\n'
108
132
109
133
110 null
134 null
111
135
112 $ hg config --config auth.cookiefile= auth -Tjson
136 $ hg config --config auth.cookiefile= auth -Tjson
113 [
137 [
114 {
138 {
115 "defaultvalue": null,
139 "defaultvalue": null,
116 "name": "auth.cookiefile",
140 "name": "auth.cookiefile",
117 "source": "--config",
141 "source": "--config",
118 "value": ""
142 "value": ""
119 }
143 }
120 ]
144 ]
121 $ hg config --config auth.cookiefile= auth -T'json(defaultvalue)'
145 $ hg config --config auth.cookiefile= auth -T'json(defaultvalue)'
122 [
146 [
123 {"defaultvalue": null}
147 {"defaultvalue": null}
124 ]
148 ]
125 $ hg config --config auth.cookiefile= auth -T'{defaultvalue}\n'
149 $ hg config --config auth.cookiefile= auth -T'{defaultvalue}\n'
126
150
127
151
128 false
152 false
129
153
130 $ hg config --config commands.commit.post-status= commands -Tjson
154 $ hg config --config commands.commit.post-status= commands -Tjson
131 [
155 [
132 {
156 {
133 "defaultvalue": false,
157 "defaultvalue": false,
134 "name": "commands.commit.post-status",
158 "name": "commands.commit.post-status",
135 "source": "--config",
159 "source": "--config",
136 "value": ""
160 "value": ""
137 }
161 }
138 ]
162 ]
139 $ hg config --config commands.commit.post-status= commands -T'json(defaultvalue)'
163 $ hg config --config commands.commit.post-status= commands -T'json(defaultvalue)'
140 [
164 [
141 {"defaultvalue": false}
165 {"defaultvalue": false}
142 ]
166 ]
143 $ hg config --config commands.commit.post-status= commands -T'{defaultvalue}\n'
167 $ hg config --config commands.commit.post-status= commands -T'{defaultvalue}\n'
144 False
168 False
145
169
146 true
170 true
147
171
148 $ hg config --config format.dotencode= format -Tjson
172 $ hg config --config format.dotencode= format -Tjson
149 [
173 [
150 {
174 {
151 "defaultvalue": true,
175 "defaultvalue": true,
152 "name": "format.dotencode",
176 "name": "format.dotencode",
153 "source": "--config",
177 "source": "--config",
154 "value": ""
178 "value": ""
155 }
179 }
156 ]
180 ]
157 $ hg config --config format.dotencode= format -T'json(defaultvalue)'
181 $ hg config --config format.dotencode= format -T'json(defaultvalue)'
158 [
182 [
159 {"defaultvalue": true}
183 {"defaultvalue": true}
160 ]
184 ]
161 $ hg config --config format.dotencode= format -T'{defaultvalue}\n'
185 $ hg config --config format.dotencode= format -T'{defaultvalue}\n'
162 True
186 True
163
187
164 bytes
188 bytes
165
189
166 $ hg config --config commands.resolve.mark-check= commands -Tjson
190 $ hg config --config commands.resolve.mark-check= commands -Tjson
167 [
191 [
168 {
192 {
169 "defaultvalue": "none",
193 "defaultvalue": "none",
170 "name": "commands.resolve.mark-check",
194 "name": "commands.resolve.mark-check",
171 "source": "--config",
195 "source": "--config",
172 "value": ""
196 "value": ""
173 }
197 }
174 ]
198 ]
175 $ hg config --config commands.resolve.mark-check= commands -T'json(defaultvalue)'
199 $ hg config --config commands.resolve.mark-check= commands -T'json(defaultvalue)'
176 [
200 [
177 {"defaultvalue": "none"}
201 {"defaultvalue": "none"}
178 ]
202 ]
179 $ hg config --config commands.resolve.mark-check= commands -T'{defaultvalue}\n'
203 $ hg config --config commands.resolve.mark-check= commands -T'{defaultvalue}\n'
180 none
204 none
181
205
182 empty list
206 empty list
183
207
184 $ hg config --config commands.show.aliasprefix= commands -Tjson
208 $ hg config --config commands.show.aliasprefix= commands -Tjson
185 [
209 [
186 {
210 {
187 "defaultvalue": [],
211 "defaultvalue": [],
188 "name": "commands.show.aliasprefix",
212 "name": "commands.show.aliasprefix",
189 "source": "--config",
213 "source": "--config",
190 "value": ""
214 "value": ""
191 }
215 }
192 ]
216 ]
193 $ hg config --config commands.show.aliasprefix= commands -T'json(defaultvalue)'
217 $ hg config --config commands.show.aliasprefix= commands -T'json(defaultvalue)'
194 [
218 [
195 {"defaultvalue": []}
219 {"defaultvalue": []}
196 ]
220 ]
197 $ hg config --config commands.show.aliasprefix= commands -T'{defaultvalue}\n'
221 $ hg config --config commands.show.aliasprefix= commands -T'{defaultvalue}\n'
198
222
199
223
200 nonempty list
224 nonempty list
201
225
202 $ hg config --config progress.format= progress -Tjson
226 $ hg config --config progress.format= progress -Tjson
203 [
227 [
204 {
228 {
205 "defaultvalue": ["topic", "bar", "number", "estimate"],
229 "defaultvalue": ["topic", "bar", "number", "estimate"],
206 "name": "progress.format",
230 "name": "progress.format",
207 "source": "--config",
231 "source": "--config",
208 "value": ""
232 "value": ""
209 }
233 }
210 ]
234 ]
211 $ hg config --config progress.format= progress -T'json(defaultvalue)'
235 $ hg config --config progress.format= progress -T'json(defaultvalue)'
212 [
236 [
213 {"defaultvalue": ["topic", "bar", "number", "estimate"]}
237 {"defaultvalue": ["topic", "bar", "number", "estimate"]}
214 ]
238 ]
215 $ hg config --config progress.format= progress -T'{defaultvalue}\n'
239 $ hg config --config progress.format= progress -T'{defaultvalue}\n'
216 topic bar number estimate
240 topic bar number estimate
217
241
218 int
242 int
219
243
220 $ hg config --config profiling.freq= profiling -Tjson
244 $ hg config --config profiling.freq= profiling -Tjson
221 [
245 [
222 {
246 {
223 "defaultvalue": 1000,
247 "defaultvalue": 1000,
224 "name": "profiling.freq",
248 "name": "profiling.freq",
225 "source": "--config",
249 "source": "--config",
226 "value": ""
250 "value": ""
227 }
251 }
228 ]
252 ]
229 $ hg config --config profiling.freq= profiling -T'json(defaultvalue)'
253 $ hg config --config profiling.freq= profiling -T'json(defaultvalue)'
230 [
254 [
231 {"defaultvalue": 1000}
255 {"defaultvalue": 1000}
232 ]
256 ]
233 $ hg config --config profiling.freq= profiling -T'{defaultvalue}\n'
257 $ hg config --config profiling.freq= profiling -T'{defaultvalue}\n'
234 1000
258 1000
235
259
236 float
260 float
237
261
238 $ hg config --config profiling.showmax= profiling -Tjson
262 $ hg config --config profiling.showmax= profiling -Tjson
239 [
263 [
240 {
264 {
241 "defaultvalue": 0.999,
265 "defaultvalue": 0.999,
242 "name": "profiling.showmax",
266 "name": "profiling.showmax",
243 "source": "--config",
267 "source": "--config",
244 "value": ""
268 "value": ""
245 }
269 }
246 ]
270 ]
247 $ hg config --config profiling.showmax= profiling -T'json(defaultvalue)'
271 $ hg config --config profiling.showmax= profiling -T'json(defaultvalue)'
248 [
272 [
249 {"defaultvalue": 0.999}
273 {"defaultvalue": 0.999}
250 ]
274 ]
251 $ hg config --config profiling.showmax= profiling -T'{defaultvalue}\n'
275 $ hg config --config profiling.showmax= profiling -T'{defaultvalue}\n'
252 0.999
276 0.999
253
277
254 Test empty config source:
278 Test empty config source:
255
279
256 $ cat <<EOF > emptysource.py
280 $ cat <<EOF > emptysource.py
257 > def reposetup(ui, repo):
281 > def reposetup(ui, repo):
258 > ui.setconfig(b'empty', b'source', b'value')
282 > ui.setconfig(b'empty', b'source', b'value')
259 > EOF
283 > EOF
260 $ cp .hg/hgrc .hg/hgrc.orig
284 $ cp .hg/hgrc .hg/hgrc.orig
261 $ cat <<EOF >> .hg/hgrc
285 $ cat <<EOF >> .hg/hgrc
262 > [extensions]
286 > [extensions]
263 > emptysource = `pwd`/emptysource.py
287 > emptysource = `pwd`/emptysource.py
264 > EOF
288 > EOF
265
289
266 $ hg config --debug empty.source
290 $ hg config --debug empty.source
267 read config from: * (glob)
291 read config from: * (glob)
268 none: value
292 none: value
269 $ hg config empty.source -Tjson
293 $ hg config empty.source -Tjson
270 [
294 [
271 {
295 {
272 "defaultvalue": null,
296 "defaultvalue": null,
273 "name": "empty.source",
297 "name": "empty.source",
274 "source": "",
298 "source": "",
275 "value": "value"
299 "value": "value"
276 }
300 }
277 ]
301 ]
278
302
279 $ cp .hg/hgrc.orig .hg/hgrc
303 $ cp .hg/hgrc.orig .hg/hgrc
280
304
281 Test "%unset"
305 Test "%unset"
282
306
283 $ cat >> $HGRCPATH <<EOF
307 $ cat >> $HGRCPATH <<EOF
284 > [unsettest]
308 > [unsettest]
285 > local-hgrcpath = should be unset (HGRCPATH)
309 > local-hgrcpath = should be unset (HGRCPATH)
286 > %unset local-hgrcpath
310 > %unset local-hgrcpath
287 >
311 >
288 > global = should be unset (HGRCPATH)
312 > global = should be unset (HGRCPATH)
289 >
313 >
290 > both = should be unset (HGRCPATH)
314 > both = should be unset (HGRCPATH)
291 >
315 >
292 > set-after-unset = should be unset (HGRCPATH)
316 > set-after-unset = should be unset (HGRCPATH)
293 > EOF
317 > EOF
294
318
295 $ cat >> .hg/hgrc <<EOF
319 $ cat >> .hg/hgrc <<EOF
296 > [unsettest]
320 > [unsettest]
297 > local-hgrc = should be unset (.hg/hgrc)
321 > local-hgrc = should be unset (.hg/hgrc)
298 > %unset local-hgrc
322 > %unset local-hgrc
299 >
323 >
300 > %unset global
324 > %unset global
301 >
325 >
302 > both = should be unset (.hg/hgrc)
326 > both = should be unset (.hg/hgrc)
303 > %unset both
327 > %unset both
304 >
328 >
305 > set-after-unset = should be unset (.hg/hgrc)
329 > set-after-unset = should be unset (.hg/hgrc)
306 > %unset set-after-unset
330 > %unset set-after-unset
307 > set-after-unset = should be set (.hg/hgrc)
331 > set-after-unset = should be set (.hg/hgrc)
308 > EOF
332 > EOF
309
333
310 $ hg showconfig unsettest
334 $ hg showconfig unsettest
311 unsettest.set-after-unset=should be set (.hg/hgrc)
335 unsettest.set-after-unset=should be set (.hg/hgrc)
312
336
313 Test exit code when no config matches
337 Test exit code when no config matches
314
338
315 $ hg config Section.idontexist
339 $ hg config Section.idontexist
316 [1]
340 [1]
317
341
318 sub-options in [paths] aren't expanded
342 sub-options in [paths] aren't expanded
319
343
320 $ cat > .hg/hgrc << EOF
344 $ cat > .hg/hgrc << EOF
321 > [paths]
345 > [paths]
322 > foo = ~/foo
346 > foo = ~/foo
323 > foo:suboption = ~/foo
347 > foo:suboption = ~/foo
324 > EOF
348 > EOF
325
349
326 $ hg showconfig paths
350 $ hg showconfig paths
327 paths.foo:suboption=~/foo
351 paths.foo:suboption=~/foo
328 paths.foo=$TESTTMP/foo
352 paths.foo=$TESTTMP/foo
329
353
330 edit failure
354 edit failure
331
355
332 $ HGEDITOR=false hg config --edit
356 $ HGEDITOR=false hg config --edit
333 abort: edit failed: false exited with status 1
357 abort: edit failed: false exited with status 1
334 [10]
358 [10]
335
359
336 config affected by environment variables
360 config affected by environment variables
337
361
338 $ EDITOR=e1 VISUAL=e2 hg config --debug | grep 'ui\.editor'
362 $ EDITOR=e1 VISUAL=e2 hg config --debug | grep 'ui\.editor'
339 $VISUAL: ui.editor=e2
363 $VISUAL: ui.editor=e2
340
364
341 $ VISUAL=e2 hg config --debug --config ui.editor=e3 | grep 'ui\.editor'
365 $ VISUAL=e2 hg config --debug --config ui.editor=e3 | grep 'ui\.editor'
342 --config: ui.editor=e3
366 --config: ui.editor=e3
343
367
344 $ PAGER=p1 hg config --debug | grep 'pager\.pager'
368 $ PAGER=p1 hg config --debug | grep 'pager\.pager'
345 $PAGER: pager.pager=p1
369 $PAGER: pager.pager=p1
346
370
347 $ PAGER=p1 hg config --debug --config pager.pager=p2 | grep 'pager\.pager'
371 $ PAGER=p1 hg config --debug --config pager.pager=p2 | grep 'pager\.pager'
348 --config: pager.pager=p2
372 --config: pager.pager=p2
349
373
350 verify that aliases are evaluated as well
374 verify that aliases are evaluated as well
351
375
352 $ hg init aliastest
376 $ hg init aliastest
353 $ cd aliastest
377 $ cd aliastest
354 $ cat > .hg/hgrc << EOF
378 $ cat > .hg/hgrc << EOF
355 > [ui]
379 > [ui]
356 > user = repo user
380 > user = repo user
357 > EOF
381 > EOF
358 $ touch index
382 $ touch index
359 $ unset HGUSER
383 $ unset HGUSER
360 $ hg ci -Am test
384 $ hg ci -Am test
361 adding index
385 adding index
362 $ hg log --template '{author}\n'
386 $ hg log --template '{author}\n'
363 repo user
387 repo user
364 $ cd ..
388 $ cd ..
365
389
366 alias has lower priority
390 alias has lower priority
367
391
368 $ hg init aliaspriority
392 $ hg init aliaspriority
369 $ cd aliaspriority
393 $ cd aliaspriority
370 $ cat > .hg/hgrc << EOF
394 $ cat > .hg/hgrc << EOF
371 > [ui]
395 > [ui]
372 > user = alias user
396 > user = alias user
373 > username = repo user
397 > username = repo user
374 > EOF
398 > EOF
375 $ touch index
399 $ touch index
376 $ unset HGUSER
400 $ unset HGUSER
377 $ hg ci -Am test
401 $ hg ci -Am test
378 adding index
402 adding index
379 $ hg log --template '{author}\n'
403 $ hg log --template '{author}\n'
380 repo user
404 repo user
381 $ cd ..
405 $ cd ..
382
406
383 configs should be read in lexicographical order
407 configs should be read in lexicographical order
384
408
385 $ mkdir configs
409 $ mkdir configs
386 $ for i in `$TESTDIR/seq.py 10 99`; do
410 $ for i in `$TESTDIR/seq.py 10 99`; do
387 > printf "[section]\nkey=$i" > configs/$i.rc
411 > printf "[section]\nkey=$i" > configs/$i.rc
388 > done
412 > done
389 $ HGRCPATH=configs hg config section.key
413 $ HGRCPATH=configs hg config section.key
390 99
414 99
General Comments 0
You need to be logged in to leave comments. Login now