Mercurial > hg
annotate tests/test-demandimport.py @ 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 | 16390f4cccf0 |
children | 4b50e1f922a0 |
rev | line source |
---|---|
28948
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
1 from __future__ import print_function |
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
2 |
4631
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 from mercurial import demandimport |
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 demandimport.enable() |
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
5 |
23643
2205d00b6d2b
demandimport: blacklist distutils.msvc9compiler (issue4475)
Augie Fackler <raf@durin42.com>
parents:
21025
diff
changeset
|
6 import os |
2205d00b6d2b
demandimport: blacklist distutils.msvc9compiler (issue4475)
Augie Fackler <raf@durin42.com>
parents:
21025
diff
changeset
|
7 if os.name != 'nt': |
2205d00b6d2b
demandimport: blacklist distutils.msvc9compiler (issue4475)
Augie Fackler <raf@durin42.com>
parents:
21025
diff
changeset
|
8 try: |
2205d00b6d2b
demandimport: blacklist distutils.msvc9compiler (issue4475)
Augie Fackler <raf@durin42.com>
parents:
21025
diff
changeset
|
9 import distutils.msvc9compiler |
28948
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
10 print('distutils.msvc9compiler needs to be an immediate ' |
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
11 'importerror on non-windows platforms') |
23643
2205d00b6d2b
demandimport: blacklist distutils.msvc9compiler (issue4475)
Augie Fackler <raf@durin42.com>
parents:
21025
diff
changeset
|
12 distutils.msvc9compiler |
2205d00b6d2b
demandimport: blacklist distutils.msvc9compiler (issue4475)
Augie Fackler <raf@durin42.com>
parents:
21025
diff
changeset
|
13 except ImportError: |
2205d00b6d2b
demandimport: blacklist distutils.msvc9compiler (issue4475)
Augie Fackler <raf@durin42.com>
parents:
21025
diff
changeset
|
14 pass |
2205d00b6d2b
demandimport: blacklist distutils.msvc9compiler (issue4475)
Augie Fackler <raf@durin42.com>
parents:
21025
diff
changeset
|
15 |
4631
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
16 import re |
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
17 |
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
18 rsub = re.sub |
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
19 def f(obj): |
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
20 l = repr(obj) |
4802
3a4310e8fe72
test-demandimport: match upper-case hexadecimal
Patrick Mezard <pmezard@gmail.com>
parents:
4631
diff
changeset
|
21 l = rsub("0x[0-9a-fA-F]+", "0x?", l) |
4631
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
22 l = rsub("from '.*'", "from '?'", l) |
13083
c0290fc6b486
test-demandimport.py: PyPy support
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
12865
diff
changeset
|
23 l = rsub("'<[a-z]*>'", "'<whatever>'", l) |
4631
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
24 return l |
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
25 |
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
26 import os |
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
27 |
28948
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
28 print("os =", f(os)) |
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
29 print("os.system =", f(os.system)) |
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
30 print("os =", f(os)) |
4631
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
31 |
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
32 from mercurial import util |
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
33 |
28948
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
34 print("util =", f(util)) |
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
35 print("util.system =", f(util.system)) |
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
36 print("util =", f(util)) |
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
37 print("util.system =", f(util.system)) |
4631
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
38 |
27535
0d0f4070f6d7
test-demandimport: ensure that relative imports are deferred
Bryan O'Sullivan <bos@serpentine.com>
parents:
23643
diff
changeset
|
39 from mercurial import hgweb |
28948
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
40 print("hgweb =", f(hgweb)) |
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
41 print("hgweb_mod =", f(hgweb.hgweb_mod)) |
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
42 print("hgweb =", f(hgweb)) |
27535
0d0f4070f6d7
test-demandimport: ensure that relative imports are deferred
Bryan O'Sullivan <bos@serpentine.com>
parents:
23643
diff
changeset
|
43 |
4631
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
44 import re as fred |
28948
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
45 print("fred =", f(fred)) |
4631
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
46 |
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
47 import sys as re |
28948
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
48 print("re =", f(re)) |
4631
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
49 |
28948
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
50 print("fred =", f(fred)) |
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
51 print("fred.sub =", f(fred.sub)) |
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
52 print("fred =", f(fred)) |
4631
e3afa670e484
demandimport: fix issue579 and add a test
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
53 |
28948
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
54 print("re =", f(re)) |
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
55 print("re.stderr =", f(re.stderr)) |
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
56 print("re =", f(re)) |
21025
54af51c18c4c
demandimport: make it possible to disable by setting HGDEMANDIMPORT=disable
Mads Kiilerich <madski@unity3d.com>
parents:
13083
diff
changeset
|
57 |
54af51c18c4c
demandimport: make it possible to disable by setting HGDEMANDIMPORT=disable
Mads Kiilerich <madski@unity3d.com>
parents:
13083
diff
changeset
|
58 demandimport.disable() |
54af51c18c4c
demandimport: make it possible to disable by setting HGDEMANDIMPORT=disable
Mads Kiilerich <madski@unity3d.com>
parents:
13083
diff
changeset
|
59 os.environ['HGDEMANDIMPORT'] = 'disable' |
54af51c18c4c
demandimport: make it possible to disable by setting HGDEMANDIMPORT=disable
Mads Kiilerich <madski@unity3d.com>
parents:
13083
diff
changeset
|
60 demandimport.enable() |
54af51c18c4c
demandimport: make it possible to disable by setting HGDEMANDIMPORT=disable
Mads Kiilerich <madski@unity3d.com>
parents:
13083
diff
changeset
|
61 from mercurial import node |
28948
16390f4cccf0
py3: make test-demandimport use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27535
diff
changeset
|
62 print("node =", f(node)) |