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