Mercurial > hg
annotate tests/test-status-inprocess.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 | 2c7e6f363138 |
children | d83ca854fa21 |
rev | line source |
---|---|
28824
9d31582dd636
tests: use /usr/bin/env python for test-status-inprocess.py
timeless <timeless@mozdev.org>
parents:
28766
diff
changeset
|
1 #!/usr/bin/env python |
28766
7f7cd44cd6d5
py3: use print_function in test-status-inprocess.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28765
diff
changeset
|
2 from __future__ import absolute_import, print_function |
28843
2c7e6f363138
tests: stop direct symbol import of mercurial modules in test-status-inprocess
Yuya Nishihara <yuya@tcha.org>
parents:
28824
diff
changeset
|
3 |
2c7e6f363138
tests: stop direct symbol import of mercurial modules in test-status-inprocess
Yuya Nishihara <yuya@tcha.org>
parents:
28824
diff
changeset
|
4 from mercurial import ( |
2c7e6f363138
tests: stop direct symbol import of mercurial modules in test-status-inprocess
Yuya Nishihara <yuya@tcha.org>
parents:
28824
diff
changeset
|
5 commands, |
2c7e6f363138
tests: stop direct symbol import of mercurial modules in test-status-inprocess
Yuya Nishihara <yuya@tcha.org>
parents:
28824
diff
changeset
|
6 localrepo, |
2c7e6f363138
tests: stop direct symbol import of mercurial modules in test-status-inprocess
Yuya Nishihara <yuya@tcha.org>
parents:
28824
diff
changeset
|
7 ui as uimod, |
28765
7779f9dfd938
py3: use absolute_import in test-status-inprocess.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
10905
diff
changeset
|
8 ) |
10838
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
9 |
28843
2c7e6f363138
tests: stop direct symbol import of mercurial modules in test-status-inprocess
Yuya Nishihara <yuya@tcha.org>
parents:
28824
diff
changeset
|
10 u = uimod.ui() |
10838
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
11 |
28766
7f7cd44cd6d5
py3: use print_function in test-status-inprocess.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28765
diff
changeset
|
12 print('% creating repo') |
28843
2c7e6f363138
tests: stop direct symbol import of mercurial modules in test-status-inprocess
Yuya Nishihara <yuya@tcha.org>
parents:
28824
diff
changeset
|
13 repo = localrepo.localrepository(u, '.', create=True) |
10838
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
14 |
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
15 f = open('test.py', 'w') |
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
16 try: |
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
17 f.write('foo\n') |
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
18 finally: |
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
19 f.close |
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
20 |
28766
7f7cd44cd6d5
py3: use print_function in test-status-inprocess.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28765
diff
changeset
|
21 print('% add and commit') |
28843
2c7e6f363138
tests: stop direct symbol import of mercurial modules in test-status-inprocess
Yuya Nishihara <yuya@tcha.org>
parents:
28824
diff
changeset
|
22 commands.add(u, repo, 'test.py') |
2c7e6f363138
tests: stop direct symbol import of mercurial modules in test-status-inprocess
Yuya Nishihara <yuya@tcha.org>
parents:
28824
diff
changeset
|
23 commands.commit(u, repo, message='*') |
2c7e6f363138
tests: stop direct symbol import of mercurial modules in test-status-inprocess
Yuya Nishihara <yuya@tcha.org>
parents:
28824
diff
changeset
|
24 commands.status(u, repo, clean=True) |
10838
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
25 |
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
26 |
28766
7f7cd44cd6d5
py3: use print_function in test-status-inprocess.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28765
diff
changeset
|
27 print('% change') |
10838
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
28 f = open('test.py', 'w') |
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
29 try: |
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
30 f.write('bar\n') |
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
31 finally: |
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
32 f.close() |
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
33 |
07dbafd3a0e2
add a test for the inprocess status dirstate race
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
diff
changeset
|
34 # this would return clean instead of changed before the fix |
28843
2c7e6f363138
tests: stop direct symbol import of mercurial modules in test-status-inprocess
Yuya Nishihara <yuya@tcha.org>
parents:
28824
diff
changeset
|
35 commands.status(u, repo, clean=True, modified=True) |