Mercurial > hg
annotate tests/hghave @ 29196:bf7b8157c483 stable
strip: invalidate phase cache after stripping changeset (issue5235)
When we remove a changeset from the changelog, the phase cache must be
invalidated, otherwise it could refer to changesets that are no longer in the
repo.
To reproduce the failure, I created an extension querying the phase cache after
the strip transaction is over.
To do that, I stripped two commits with a bookmark on one of them to force
another transaction (we open a transaction for moving bookmarks)
after the strip transaction.
Without the fix in this patch, the test leads to a stacktrace showing the issue:
repair.strip(ui, repo, revs, backup)
File "/Users/lcharignon/facebook-hg-rpms/hg-crew/mercurial/repair.py", line 205, in strip
tr.close()
File "/Users/lcharignon/facebook-hg-rpms/hg-crew/mercurial/transaction.py", line 44, in _active
return func(self, *args, **kwds)
File "/Users/lcharignon/facebook-hg-rpms/hg-crew/mercurial/transaction.py", line 490, in close
self._postclosecallback[cat](self)
File "$TESTTMP/crashstrip2.py", line 4, in test
[repo.changelog.node(r) for r in repo.revs("not public()")]
File "/Users/lcharignon/facebook-hg-rpms/hg-crew/mercurial/changelog.py", line 337, in node
return super(changelog, self).node(rev)
File "/Users/lcharignon/facebook-hg-rpms/hg-crew/mercurial/revlog.py", line 377, in node
return self.index[rev][7]
IndexError: revlog index out of range
The situation was encountered in inhibit (evolve's repo) where we would crash
following the volatile set invalidation submitted by Augie in
e6f490e328635312ee214a12bc7fd3c7d46bf9ce. Before his patch the issue was masked
as we were not accessing the phasecache after stripping a revision.
This bug uncovered another but in histedit (see explanation in issue5235).
I changed the histedit test accordingly to avoid fixing two things at once.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Thu, 12 May 2016 06:13:59 -0700 |
parents | 544444991c83 |
children | ba8999547f81 |
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 """ |
28283
544444991c83
hghave: use print function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28047
diff
changeset
|
6 |
544444991c83
hghave: use print function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28047
diff
changeset
|
7 from __future__ import print_function |
544444991c83
hghave: use print function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28047
diff
changeset
|
8 |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
9 import optparse |
25732
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
10 import os, sys |
16966
23f621ca04b5
tests/hghave: extract hghave.py
Adrian Buehlmann <adrian@cadifra.com>
parents:
16891
diff
changeset
|
11 import hghave |
9446
57d682d7d2da
test-gendoc: test documentation generation
Martin Geisler <mg@lazybytes.net>
parents:
9395
diff
changeset
|
12 |
16966
23f621ca04b5
tests/hghave: extract hghave.py
Adrian Buehlmann <adrian@cadifra.com>
parents:
16891
diff
changeset
|
13 checks = hghave.checks |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
14 |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
15 def list_features(): |
22762
05b3238ba901
tests: make hghave list features alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
18229
diff
changeset
|
16 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
|
17 desc = feature[1] |
28283
544444991c83
hghave: use print function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28047
diff
changeset
|
18 print(name + ':', desc) |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
19 |
8059
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
20 def test_features(): |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
21 failed = 0 |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
22 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
|
23 check, _ = feature |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
24 try: |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
25 check() |
28047
863075fd4cd0
misc: use modern exception syntax
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26068
diff
changeset
|
26 except Exception as e: |
28283
544444991c83
hghave: use print function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28047
diff
changeset
|
27 print("feature %s failed: %s" % (name, e)) |
8059
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
28 failed += 1 |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
29 return failed |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
30 |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
31 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
|
32 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
|
33 help="test available features") |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
34 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
|
35 help="list available features") |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
36 |
26068
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
37 def _loadaddon(): |
25732
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
38 if 'TESTDIR' in os.environ: |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
39 # 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
|
40 # 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
|
41 path = os.environ['TESTDIR'] |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
42 else: |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
43 path = '.' |
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 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
|
46 return |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
47 |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
48 sys.path.insert(0, path) |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
49 try: |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
50 import hghaveaddon |
28047
863075fd4cd0
misc: use modern exception syntax
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26068
diff
changeset
|
51 except BaseException as inst: |
26068
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
52 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
|
53 % (path, inst)) |
25732
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
54 sys.exit(2) |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
55 sys.path.pop(0) |
b94df10cc3b5
hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22762
diff
changeset
|
56 |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
57 if __name__ == '__main__': |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
58 options, args = parser.parse_args() |
26068
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
59 _loadaddon() |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
60 if options.list_features: |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
61 list_features() |
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
62 sys.exit(0) |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5074
diff
changeset
|
63 |
8059
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
64 if options.test_features: |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
65 sys.exit(test_features()) |
41a2c5cbcb6a
hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
7823
diff
changeset
|
66 |
26068
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
67 hghave.require(args) |