Mercurial > hg
annotate tests/fakedirstatewritetime.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 | b38adef652fe |
children | df448de7cf3b |
rev | line source |
---|---|
25752
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
1 # extension to emulate invoking 'dirstate.write()' at the time |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
2 # specified by '[fakedirstatewritetime] fakenow', only when |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
3 # 'dirstate.write()' is invoked via functions below: |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
4 # |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
5 # - 'workingctx._checklookup()' (= 'repo.status()') |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
6 # - 'committablectx.markcommitted()' |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
7 |
27283
b38adef652fe
tests/fakedirstatewritetime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26634
diff
changeset
|
8 from __future__ import absolute_import |
b38adef652fe
tests/fakedirstatewritetime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26634
diff
changeset
|
9 |
b38adef652fe
tests/fakedirstatewritetime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26634
diff
changeset
|
10 from mercurial import ( |
b38adef652fe
tests/fakedirstatewritetime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26634
diff
changeset
|
11 context, |
b38adef652fe
tests/fakedirstatewritetime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26634
diff
changeset
|
12 dirstate, |
b38adef652fe
tests/fakedirstatewritetime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26634
diff
changeset
|
13 extensions, |
b38adef652fe
tests/fakedirstatewritetime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26634
diff
changeset
|
14 parsers, |
b38adef652fe
tests/fakedirstatewritetime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26634
diff
changeset
|
15 util, |
b38adef652fe
tests/fakedirstatewritetime.py: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26634
diff
changeset
|
16 ) |
25752
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
17 |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
18 def pack_dirstate(fakenow, orig, dmap, copymap, pl, now): |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
19 # execute what original parsers.pack_dirstate should do actually |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
20 # for consistency |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
21 actualnow = int(now) |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
22 for f, e in dmap.iteritems(): |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
23 if e[0] == 'n' and e[3] == actualnow: |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
24 e = parsers.dirstatetuple(e[0], e[1], e[2], -1) |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
25 dmap[f] = e |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
26 |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
27 return orig(dmap, copymap, pl, fakenow) |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
28 |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
29 def fakewrite(ui, func): |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
30 # fake "now" of 'pack_dirstate' only if it is invoked while 'func' |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
31 |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
32 fakenow = ui.config('fakedirstatewritetime', 'fakenow') |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
33 if not fakenow: |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
34 # Execute original one, if fakenow isn't configured. This is |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
35 # useful to prevent subrepos from executing replaced one, |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
36 # because replacing 'parsers.pack_dirstate' is also effective |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
37 # in subrepos. |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
38 return func() |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
39 |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
40 # parsing 'fakenow' in YYYYmmddHHMM format makes comparison between |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
41 # 'fakenow' value and 'touch -t YYYYmmddHHMM' argument easy |
26630
3111b45a2bbf
parsers: make pack_dirstate take now in integer for consistency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25752
diff
changeset
|
42 fakenow = util.parsedate(fakenow, ['%Y%m%d%H%M'])[0] |
25752
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
43 |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
44 orig_pack_dirstate = parsers.pack_dirstate |
26634
09bb1ee7e73e
dirstate: make writing in-memory changes aware of transaction activity
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26630
diff
changeset
|
45 orig_dirstate_getfsnow = dirstate._getfsnow |
25752
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
46 wrapper = lambda *args: pack_dirstate(fakenow, orig_pack_dirstate, *args) |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
47 |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
48 parsers.pack_dirstate = wrapper |
26634
09bb1ee7e73e
dirstate: make writing in-memory changes aware of transaction activity
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26630
diff
changeset
|
49 dirstate._getfsnow = lambda *args: fakenow |
25752
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
50 try: |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
51 return func() |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
52 finally: |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
53 parsers.pack_dirstate = orig_pack_dirstate |
26634
09bb1ee7e73e
dirstate: make writing in-memory changes aware of transaction activity
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26630
diff
changeset
|
54 dirstate._getfsnow = orig_dirstate_getfsnow |
25752
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
55 |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
56 def _checklookup(orig, workingctx, files): |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
57 ui = workingctx.repo().ui |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
58 return fakewrite(ui, lambda : orig(workingctx, files)) |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
59 |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
60 def markcommitted(orig, committablectx, node): |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
61 ui = committablectx.repo().ui |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
62 return fakewrite(ui, lambda : orig(committablectx, node)) |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
63 |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
64 def extsetup(ui): |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
65 extensions.wrapfunction(context.workingctx, '_checklookup', |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
66 _checklookup) |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
67 extensions.wrapfunction(context.committablectx, 'markcommitted', |
815df73abf12
tests: add extension to emulate invoking dirstate.write at the specific time
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
68 markcommitted) |