Mercurial > hg
annotate tests/test-doctest.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 | 584044e5ad57 |
children | 77d25b913f80 |
rev | line source |
---|---|
7041
b856071435f7
tests: fix readline escape characters in output for test-doctest.py
Mads Kiilerich <mads@kiilerich.com>
parents:
5525
diff
changeset
|
1 # this is hack to make sure no escape characters are inserted into the output |
20047
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
2 import os, sys |
7078
967adcf5910d
test-doctest: remove TERM env variable only if it's there
Patrick Mezard <pmezard@gmail.com>
parents:
7041
diff
changeset
|
3 if 'TERM' in os.environ: |
7184
380fda3eed13
clean up trailing spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7078
diff
changeset
|
4 del os.environ['TERM'] |
3232
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
5 import doctest |
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
6 |
20047
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
7 def testmod(name, optionflags=0, testtarget=None): |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
8 __import__(name) |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
9 mod = sys.modules[name] |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
10 if testtarget is not None: |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
11 mod = getattr(mod, testtarget) |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
12 doctest.testmod(mod, optionflags=optionflags) |
14171
fa2b596db182
ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents:
13949
diff
changeset
|
13 |
20047
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
14 testmod('mercurial.changelog') |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
15 testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE) |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
16 testmod('mercurial.dispatch') |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
17 testmod('mercurial.encoding') |
20799
069bf1b821c8
clone: add doctest for default destination
Yuya Nishihara <yuya@tcha.org>
parents:
20419
diff
changeset
|
18 testmod('mercurial.hg') |
20047
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
19 testmod('mercurial.hgweb.hgwebdir_mod') |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
20 testmod('mercurial.match') |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
21 testmod('mercurial.minirst') |
24243
daee2039dd11
patch.pathtransform: add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
22546
diff
changeset
|
22 testmod('mercurial.patch') |
21568
8dd17b19e722
subrepo: normalize path in the specific way for problematic encodings
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20840
diff
changeset
|
23 testmod('mercurial.pathutil') |
25306
c87b05925054
parser: add helper to reduce nesting of chained infix operations
Yuya Nishihara <yuya@tcha.org>
parents:
24243
diff
changeset
|
24 testmod('mercurial.parser') |
20047
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
25 testmod('mercurial.revset') |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
26 testmod('mercurial.store') |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20799
diff
changeset
|
27 testmod('mercurial.subrepo') |
20047
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
28 testmod('mercurial.templatefilters') |
25783
1f6878c87c25
templater: introduce one-pass parsing of nested template strings
Yuya Nishihara <yuya@tcha.org>
parents:
25306
diff
changeset
|
29 testmod('mercurial.templater') |
20047
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
30 testmod('mercurial.ui') |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
31 testmod('mercurial.url') |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
32 testmod('mercurial.util') |
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
33 testmod('mercurial.util', testtarget='platform') |
25805
584044e5ad57
convert: use 'default' for specifying branch name in branchmap (issue4753)
Eugene Baranov <eug.baranov@gmail.com>
parents:
25788
diff
changeset
|
34 testmod('hgext.convert.convcmd') |
20047
10a7d2bcb81b
tests: make doctest test runner less verbose
Mads Kiilerich <madski@unity3d.com>
parents:
19098
diff
changeset
|
35 testmod('hgext.convert.cvsps') |
20048
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
20047
diff
changeset
|
36 testmod('hgext.convert.filemap') |
25788
a36fd0993522
convert: unescape Perforce-escaped special characters in filenames
Eugene Baranov <eug.baranov@gmail.com>
parents:
25783
diff
changeset
|
37 testmod('hgext.convert.p4') |
20419
e61a8395c3c1
convert: make subversion revsplit more stable when meeting revisions without @
Mads Kiilerich <madski@unity3d.com>
parents:
20048
diff
changeset
|
38 testmod('hgext.convert.subversion') |
22546
aac5482db318
mq: refactor patchheader header ordering to match export (BC)
Mads Kiilerich <madski@unity3d.com>
parents:
21568
diff
changeset
|
39 testmod('hgext.mq') |