Mercurial > hg
annotate tests/hghave @ 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 | 05e7f57c74ac |
children | 863075fd4cd0 |
rev | line source |
---|---|
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
2 """Test the running system for features availability. Exit with zero |
5084
80309fa23cdb
hghave: feature absence can be checked by prefixing with 'no-'
Patrick Mezard <pmezard@gmail.com>
parents:
5081
diff
changeset
|
3 if all features are there, non-zero otherwise. If a feature name is |
80309fa23cdb
hghave: feature absence can be checked by prefixing with 'no-'
Patrick Mezard <pmezard@gmail.com>
parents:
5081
diff
changeset
|
4 prefixed with "no-", the absence of feature is tested. |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
5 """ |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
6 import optparse |
25732
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
7 import os, sys |
16966
23f621ca04b5
tests/hghave: extract hghave.py
Adrian Buehlmann <adrian@cadifra.com>
parents:
16891
diff
changeset
|
8 import hghave |
9446
57d682d7d2da
test-gendoc: test documentation generation
Martin Geisler <mg@lazybytes.net>
parents:
9395
diff
changeset
|
9 |
16966
23f621ca04b5
tests/hghave: extract hghave.py
Adrian Buehlmann <adrian@cadifra.com>
parents:
16891
diff
changeset
|
10 checks = hghave.checks |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
11 |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
12 def list_features(): |
22762
05b3238ba901
tests: make hghave list features alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
18229
diff
changeset
|
13 for name, feature in sorted(checks.iteritems()): |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
14 desc = feature[1] |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
15 print name + ':', desc |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
16 |
8059
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
17 def test_features(): |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
18 failed = 0 |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
19 for name, feature in checks.iteritems(): |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
20 check, _ = feature |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
21 try: |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
22 check() |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
23 except Exception, e: |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
24 print "feature %s failed: %s" % (name, e) |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
25 failed += 1 |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
26 return failed |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
27 |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
28 parser = optparse.OptionParser("%prog [options] [features]") |
8059
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
29 parser.add_option("--test-features", action="store_true", |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
30 help="test available features") |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
31 parser.add_option("--list-features", action="store_true", |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
32 help="list available features") |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
33 |
26068
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
34 def _loadaddon(): |
25732
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
35 if 'TESTDIR' in os.environ: |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
36 # loading from '.' isn't needed, because `hghave` should be |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
37 # running at TESTTMP in this case |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
38 path = os.environ['TESTDIR'] |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
39 else: |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
40 path = '.' |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
41 |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
42 if not os.path.exists(os.path.join(path, 'hghaveaddon.py')): |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
43 return |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
44 |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
45 sys.path.insert(0, path) |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
46 try: |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
47 import hghaveaddon |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
48 except BaseException, inst: |
26068
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
49 sys.stderr.write('failed to import hghaveaddon.py from %r: %s\n' |
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
50 % (path, inst)) |
25732
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
51 sys.exit(2) |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
52 sys.path.pop(0) |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
53 |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
54 if __name__ == '__main__': |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
55 options, args = parser.parse_args() |
26068
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
56 _loadaddon() |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
57 if options.list_features: |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
58 list_features() |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
59 sys.exit(0) |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5074
diff
changeset
|
60 |
8059
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
61 if options.test_features: |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
62 sys.exit(test_features()) |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
63 |
26068
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
64 hghave.require(args) |