Mercurial > hg
annotate tests/test-filelog.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 | efc739551c17 |
children | a0939666b836 |
rev | line source |
---|---|
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
2 """ |
26098 | 3 Tests the behavior of filelog w.r.t. data starting with '\1\n' |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
4 """ |
28744
6537e14301ef
py3: use print_function in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28743
diff
changeset
|
5 from __future__ import absolute_import, print_function |
28743
83373fc2b287
py3: use absolute_import in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
26098
diff
changeset
|
6 from mercurial import ( |
83373fc2b287
py3: use absolute_import in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
26098
diff
changeset
|
7 hg, |
28805
efc739551c17
test-filelog: alias ui as uimod
Yuya Nishihara <yuya@tcha.org>
parents:
28744
diff
changeset
|
8 ui as uimod, |
28743
83373fc2b287
py3: use absolute_import in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
26098
diff
changeset
|
9 ) |
83373fc2b287
py3: use absolute_import in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
26098
diff
changeset
|
10 from mercurial.node import ( |
83373fc2b287
py3: use absolute_import in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
26098
diff
changeset
|
11 hex, |
83373fc2b287
py3: use absolute_import in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
26098
diff
changeset
|
12 nullid, |
83373fc2b287
py3: use absolute_import in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
26098
diff
changeset
|
13 ) |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
14 |
28805
efc739551c17
test-filelog: alias ui as uimod
Yuya Nishihara <yuya@tcha.org>
parents:
28744
diff
changeset
|
15 myui = uimod.ui() |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
16 repo = hg.repository(myui, path='.', create=True) |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
17 |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
18 fl = repo.file('foobar') |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
19 |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
20 def addrev(text, renamed=False): |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
21 if renamed: |
17486 | 22 # data doesn't matter. Just make sure filelog.renamed() returns True |
20684
2761a791b113
test-filelog: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents:
17486
diff
changeset
|
23 meta = {'copyrev': hex(nullid), 'copy': 'bar'} |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
24 else: |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
25 meta = {} |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
26 |
15876
2de1244361aa
tests: lock before creating transaction in test-filelog
Mads Kiilerich <mads@kiilerich.com>
parents:
11540
diff
changeset
|
27 lock = t = None |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
28 try: |
15876
2de1244361aa
tests: lock before creating transaction in test-filelog
Mads Kiilerich <mads@kiilerich.com>
parents:
11540
diff
changeset
|
29 lock = repo.lock() |
2de1244361aa
tests: lock before creating transaction in test-filelog
Mads Kiilerich <mads@kiilerich.com>
parents:
11540
diff
changeset
|
30 t = repo.transaction('commit') |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
31 node = fl.add(text, meta, t, 0, nullid, nullid) |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
32 return node |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
33 finally: |
15876
2de1244361aa
tests: lock before creating transaction in test-filelog
Mads Kiilerich <mads@kiilerich.com>
parents:
11540
diff
changeset
|
34 if t: |
2de1244361aa
tests: lock before creating transaction in test-filelog
Mads Kiilerich <mads@kiilerich.com>
parents:
11540
diff
changeset
|
35 t.close() |
2de1244361aa
tests: lock before creating transaction in test-filelog
Mads Kiilerich <mads@kiilerich.com>
parents:
11540
diff
changeset
|
36 if lock: |
2de1244361aa
tests: lock before creating transaction in test-filelog
Mads Kiilerich <mads@kiilerich.com>
parents:
11540
diff
changeset
|
37 lock.release() |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
38 |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
39 def error(text): |
28744
6537e14301ef
py3: use print_function in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28743
diff
changeset
|
40 print('ERROR: ' + text) |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
41 |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
42 textwith = '\1\nfoo' |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
43 without = 'foo' |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
44 |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
45 node = addrev(textwith) |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
46 if not textwith == fl.read(node): |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
47 error('filelog.read for data starting with \\1\\n') |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
48 if fl.cmp(node, textwith) or not fl.cmp(node, without): |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
49 error('filelog.cmp for data starting with \\1\\n') |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
50 if fl.size(0) != len(textwith): |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
51 error('FIXME: This is a known failure of filelog.size for data starting ' |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
52 'with \\1\\n') |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
53 |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
54 node = addrev(textwith, renamed=True) |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
55 if not textwith == fl.read(node): |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
56 error('filelog.read for a renaming + data starting with \\1\\n') |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
57 if fl.cmp(node, textwith) or not fl.cmp(node, without): |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
58 error('filelog.cmp for a renaming + data starting with \\1\\n') |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
59 if fl.size(1) != len(textwith): |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
60 error('filelog.size for a renaming + data starting with \\1\\n') |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
61 |
28744
6537e14301ef
py3: use print_function in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28743
diff
changeset
|
62 print('OK.') |