Mercurial > hg
annotate tests/test-bdiff.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 | 9a8363d23419 |
children | ede7bc45bf0a |
rev | line source |
---|---|
28734
4e51f9d1683e
py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28733
diff
changeset
|
1 from __future__ import absolute_import, print_function |
8656 | 2 import struct |
28733
2e54aaa65afc
py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
15530
diff
changeset
|
3 from mercurial import ( |
2e54aaa65afc
py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
15530
diff
changeset
|
4 bdiff, |
2e54aaa65afc
py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
15530
diff
changeset
|
5 mpatch, |
2e54aaa65afc
py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
15530
diff
changeset
|
6 ) |
400
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
7 |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
8 def test1(a, b): |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
9 d = bdiff.bdiff(a, b) |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
10 c = a |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
11 if d: |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
12 c = mpatch.patches(a, [d]) |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
13 if c != b: |
28734
4e51f9d1683e
py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28733
diff
changeset
|
14 print("***", repr(a), repr(b)) |
4e51f9d1683e
py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28733
diff
changeset
|
15 print("bad:") |
4e51f9d1683e
py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28733
diff
changeset
|
16 print(repr(c)[:200]) |
4e51f9d1683e
py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28733
diff
changeset
|
17 print(repr(d)) |
400
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
18 |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
19 def test(a, b): |
28734
4e51f9d1683e
py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28733
diff
changeset
|
20 print("***", repr(a), repr(b)) |
400
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
21 test1(a, b) |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
22 test1(b, a) |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
23 |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
24 test("a\nc\n\n\n\n", "a\nb\n\n\n") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
25 test("a\nb\nc\n", "a\nc\n") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
26 test("", "") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
27 test("a\nb\nc", "a\nb\nc") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
28 test("a\nb\nc\nd\n", "a\nd\n") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
29 test("a\nb\nc\nd\n", "a\nc\ne\n") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
30 test("a\nb\nc\n", "a\nc\n") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
31 test("a\n", "c\na\nb\n") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
32 test("a\n", "") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
33 test("a\n", "b\nc\n") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
34 test("a\n", "c\na\n") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
35 test("", "adjfkjdjksdhfksj") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
36 test("", "ab") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
37 test("", "abc") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
38 test("a", "a") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
39 test("ab", "ab") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
40 test("abc", "abc") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
41 test("a\n", "a\n") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
42 test("a\nb", "a\nb") |
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
43 |
7104
9514cbb6e4f6
bdiff: normalize the diff (issue1295)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
814
diff
changeset
|
44 #issue1295 |
9514cbb6e4f6
bdiff: normalize the diff (issue1295)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
814
diff
changeset
|
45 def showdiff(a, b): |
9514cbb6e4f6
bdiff: normalize the diff (issue1295)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
814
diff
changeset
|
46 bin = bdiff.bdiff(a, b) |
9514cbb6e4f6
bdiff: normalize the diff (issue1295)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
814
diff
changeset
|
47 pos = 0 |
9514cbb6e4f6
bdiff: normalize the diff (issue1295)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
814
diff
changeset
|
48 while pos < len(bin): |
9514cbb6e4f6
bdiff: normalize the diff (issue1295)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
814
diff
changeset
|
49 p1, p2, l = struct.unpack(">lll", bin[pos:pos + 12]) |
9514cbb6e4f6
bdiff: normalize the diff (issue1295)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
814
diff
changeset
|
50 pos += 12 |
28734
4e51f9d1683e
py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28733
diff
changeset
|
51 print(p1, p2, repr(bin[pos:pos + l])) |
7104
9514cbb6e4f6
bdiff: normalize the diff (issue1295)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
814
diff
changeset
|
52 pos += l |
9514cbb6e4f6
bdiff: normalize the diff (issue1295)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
814
diff
changeset
|
53 showdiff("x\n\nx\n\nx\n\nx\n\nz\n", "x\n\nx\n\ny\n\nx\n\nx\n\nz\n") |
9514cbb6e4f6
bdiff: normalize the diff (issue1295)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
814
diff
changeset
|
54 showdiff("x\n\nx\n\nx\n\nx\n\nz\n", "x\n\nx\n\ny\n\nx\n\ny\n\nx\n\nz\n") |
29013
9a8363d23419
bdiff: deal better with duplicate lines
Matt Mackall <mpm@selenic.com>
parents:
28734
diff
changeset
|
55 # we should pick up abbbc. rather than bc.de as the longest match |
9a8363d23419
bdiff: deal better with duplicate lines
Matt Mackall <mpm@selenic.com>
parents:
28734
diff
changeset
|
56 showdiff("a\nb\nb\nb\nc\n.\nd\ne\n.\nf\n", |
9a8363d23419
bdiff: deal better with duplicate lines
Matt Mackall <mpm@selenic.com>
parents:
28734
diff
changeset
|
57 "a\nb\nb\na\nb\nb\nb\nc\n.\nb\nc\n.\nd\ne\nf\n") |
7104
9514cbb6e4f6
bdiff: normalize the diff (issue1295)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
814
diff
changeset
|
58 |
28734
4e51f9d1683e
py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28733
diff
changeset
|
59 print("done") |
15530
eeac5e179243
mdiff: replace wscleanup() regexps with C loops
Patrick Mezard <pmezard@gmail.com>
parents:
12865
diff
changeset
|
60 |
eeac5e179243
mdiff: replace wscleanup() regexps with C loops
Patrick Mezard <pmezard@gmail.com>
parents:
12865
diff
changeset
|
61 def testfixws(a, b, allws): |
eeac5e179243
mdiff: replace wscleanup() regexps with C loops
Patrick Mezard <pmezard@gmail.com>
parents:
12865
diff
changeset
|
62 c = bdiff.fixws(a, allws) |
eeac5e179243
mdiff: replace wscleanup() regexps with C loops
Patrick Mezard <pmezard@gmail.com>
parents:
12865
diff
changeset
|
63 if c != b: |
28734
4e51f9d1683e
py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28733
diff
changeset
|
64 print("*** fixws", repr(a), repr(b), allws) |
4e51f9d1683e
py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28733
diff
changeset
|
65 print("got:") |
4e51f9d1683e
py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28733
diff
changeset
|
66 print(repr(c)) |
15530
eeac5e179243
mdiff: replace wscleanup() regexps with C loops
Patrick Mezard <pmezard@gmail.com>
parents:
12865
diff
changeset
|
67 |
eeac5e179243
mdiff: replace wscleanup() regexps with C loops
Patrick Mezard <pmezard@gmail.com>
parents:
12865
diff
changeset
|
68 testfixws(" \ta\r b\t\n", "ab\n", 1) |
eeac5e179243
mdiff: replace wscleanup() regexps with C loops
Patrick Mezard <pmezard@gmail.com>
parents:
12865
diff
changeset
|
69 testfixws(" \ta\r b\t\n", " a b\n", 0) |
eeac5e179243
mdiff: replace wscleanup() regexps with C loops
Patrick Mezard <pmezard@gmail.com>
parents:
12865
diff
changeset
|
70 testfixws("", "", 1) |
eeac5e179243
mdiff: replace wscleanup() regexps with C loops
Patrick Mezard <pmezard@gmail.com>
parents:
12865
diff
changeset
|
71 testfixws("", "", 0) |
eeac5e179243
mdiff: replace wscleanup() regexps with C loops
Patrick Mezard <pmezard@gmail.com>
parents:
12865
diff
changeset
|
72 |
28734
4e51f9d1683e
py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28733
diff
changeset
|
73 print("done") |