Mercurial > hg
annotate tests/test-ui-config.py @ 26750:9f9ec4abe700
cmdutil: make in-memory changes visible to external editor (issue4378)
Before this patch, external editor process for the commit log can't
view some in-memory changes (especially, of dirstate), because they
aren't written out until the end of transaction (or wlock).
This causes unexpected output of Mercurial commands spawned from that
editor process.
To make in-memory changes visible to external editor process, this
patch does:
- write (or schedule to write) in-memory dirstate changes, and
- set HG_PENDING environment variable, if:
- a transaction is running, and
- there are in-memory changes to be visible
"hg diff" spawned from external editor process for "hg qrefresh"
shows:
- "changes newly imported into the topmost" before 49148d7868df(*)
- "all changes recorded in the topmost by refreshing" after this patch
(*) 49148d7868df changed steps invoking editor process
Even though backward compatibility may be broken, the latter behavior
looks reasonable, because "hg diff" spawned from the editor process
consistently shows "what changes new revision records" regardless of
invocation context.
In fact, issue4378 itself should be resolved by 800e090e9c64, which
made 'repo.transaction()' write in-memory dirstate changes out
explicitly before starting transaction. It also made "hg qrefresh"
imply 'dirstate.write()' before external editor invocation in call
chain below.
- mq.queue.refresh
- strip.strip
- repair.strip
- localrepository.transaction
- dirstate.write
- localrepository.commit
- invoke external editor
Though, this patch has '(issue4378)' in own summary line to indicate
that issues like issue4378 should be fixed by this.
BTW, this patch adds '-m' option to a 'hg ci --amend' execution in
'test-commit-amend.t', to avoid invoking external editor process.
In this case, "unsure" states may be changed to "clean" according to
timestamp or so on. These changes should be written into pending file,
if external editor invocation is required,
Then, writing dirstate changes out breaks stability of test, because
it shows "transaction abort!/rollback completed" occasionally.
Aborting after editor process invocation while commands below may
cause similar instability of tests, too (AFAIK, there is no more such
one, at this revision)
- commit --amend
- without --message/--logfile
- import
- without --message/--logfile,
- without --no-commit,
- without --bypass,
- one of below, and
- patch has no description text, or
- with --edit
- aborting at the 1st patch, which adds or removes file(s)
- if it only changes existing files, status is checked only for
changed files by 'scmutil.matchfiles()', and transition from
"unsure" to "normal" in dirstate doesn't occur (= dirstate
isn't changed, and written out)
- aborting at the 2nd or later patch implies other pending
changes (e.g. changelog), and always causes showing
"transaction abort!/rollback completed"
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 17 Oct 2015 01:15:34 +0900 |
parents | 328739ea70c3 |
children | ae606bdedc3e |
rev | line source |
---|---|
8656 | 1 from mercurial import ui, dispatch, error |
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
|
2 |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
3 testui = ui.ui() |
8137 | 4 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
|
5 '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
|
6 '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
|
7 'values.bool2=false', |
14171
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
8 'values.boolinvalid=foo', |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
9 'values.int1=42', |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
10 'values.int2=-42', |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
11 'values.intinvalid=foo', |
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
|
12 '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
|
13 '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
|
14 '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
|
15 'lists.list4=foo bar baz alice, bob', |
10982
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
16 'lists.list5=abc d"ef"g "hij def"', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
17 'lists.list6="hello world", "how are you?"', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
18 'lists.list7=Do"Not"Separate', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
19 'lists.list8="Do"Separate', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
20 'lists.list9="Do\\"NotSeparate"', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
21 'lists.list10=string "with extraneous" quotation mark"', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
22 'lists.list11=x, y', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
23 'lists.list12="x", "y"', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
24 'lists.list13=""" key = "x", "y" """', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
25 'lists.list14=,,,, ', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
26 'lists.list15=" just with starting quotation', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
27 'lists.list16="longer quotation" with "no ending quotation', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
28 'lists.list17=this is \\" "not a quotation mark"', |
11309
ef7636efeb01
ui: handle leading newlines/spaces/commas in configlist
Thomas Arendsen Hein <thomas@intevation.de>
parents:
10982
diff
changeset
|
29 'lists.list18=\n \n\nding\ndong', |
14171
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
30 ]) |
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
|
31 |
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.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
|
33 print repr(testui.configitems('lists')) |
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 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
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 print repr(testui.configbool('values', 'string')) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14171
diff
changeset
|
42 except error.ConfigError as inst: |
4729
9881abfc0e44
Catch illegal boolean values in hgrc nicely.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4549
diff
changeset
|
43 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
|
44 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
|
45 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
|
46 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
|
47 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
|
48 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
|
49 print "---" |
14171
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
50 print repr(testui.configint('values', 'int1')) |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
51 print repr(testui.configint('values', 'int2')) |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
52 print "---" |
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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 print repr(testui.configlist('lists', 'list4', ['foo'])) |
10982
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
58 print repr(testui.configlist('lists', 'list5')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
59 print repr(testui.configlist('lists', 'list6')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
60 print repr(testui.configlist('lists', 'list7')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
61 print repr(testui.configlist('lists', 'list8')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
62 print repr(testui.configlist('lists', 'list9')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
63 print repr(testui.configlist('lists', 'list10')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
64 print repr(testui.configlist('lists', 'list11')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
65 print repr(testui.configlist('lists', 'list12')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
66 print repr(testui.configlist('lists', 'list13')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
67 print repr(testui.configlist('lists', 'list14')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
68 print repr(testui.configlist('lists', 'list15')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
69 print repr(testui.configlist('lists', 'list16')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
70 print repr(testui.configlist('lists', 'list17')) |
11309
ef7636efeb01
ui: handle leading newlines/spaces/commas in configlist
Thomas Arendsen Hein <thomas@intevation.de>
parents:
10982
diff
changeset
|
71 print repr(testui.configlist('lists', 'list18')) |
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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 print repr(testui.configlist('lists', 'unknown', ['foo', 'bar'])) |
4069
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
80 |
8144
fca54469480e
ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents:
8137
diff
changeset
|
81 print repr(testui.config('values', 'String')) |
4069
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 # values that aren't strings should work |
8144
fca54469480e
ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents:
8137
diff
changeset
|
87 testui.setconfig('hook', 'commit', function) |
fca54469480e
ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents:
8137
diff
changeset
|
88 print function == testui.config('hook', 'commit') |
14171
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
89 |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
90 # invalid values |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
91 try: |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
92 testui.configbool('values', 'boolinvalid') |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
93 except error.ConfigError: |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
94 print 'boolinvalid' |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
95 try: |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
96 testui.configint('values', 'intinvalid') |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
97 except error.ConfigError: |
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
12865
diff
changeset
|
98 print 'intinvalid' |