Mercurial > hg
annotate tests/test-absorb-filefixupstate.py @ 39872:733db72f0f54
revlog: move revision verification out of verify
File revision verification is performing low-level checks of file
storage, namely that flags are appropriate and revision data can
be resolved.
Since these checks are somewhat revlog-specific and may not
be appropriate for alternate storage backends, this commit moves
those checks from verify.py to revlog.py.
Because we're now emitting warnings/errors that apply to specific
revisions, we taught the iverifyproblem interface to expose the
problematic node and to report this node in verify output. This
was necessary to prevent unwanted test changes.
After this change, revlog.verifyintegrity() and file verify code
in verify.py both iterate over revisions and resolve their fulltext.
But they do so in separate loops. (verify.py needs to resolve
fulltexts as part of calling renamed() - at least when using revlogs.)
This should add overhead.
But on the mozilla-unified repo:
$ hg verify
before: time: real 700.640 secs (user 585.520+0.000 sys 23.480+0.000)
after: time: real 682.380 secs (user 570.370+0.000 sys 22.240+0.000)
I'm not sure what's going on. Maybe avoiding the filelog attribute
proxies shaved off enough time to offset the losses? Maybe fulltext
resolution has less overhead than I thought?
I've left a comment indicating the potential for optimization. But
because it doesn't produce a performance regression on a large
repository, I'm not going to worry about it.
Differential Revision: https://phab.mercurial-scm.org/D4745
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 24 Sep 2018 11:27:47 -0700 |
parents | 1aab0007a7c0 |
children | dcda50856843 |
rev | line source |
---|---|
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 from __future__ import absolute_import, print_function |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 import itertools |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
4 from mercurial import pycompat |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 from hgext import absorb |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 class simplefctx(object): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 def __init__(self, content): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 self.content = content |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 def data(self): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 return self.content |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 def insertreturns(x): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
15 # insert "\n"s after each single char |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
16 if isinstance(x, bytes): |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
17 return b''.join(ch + b'\n' for ch in pycompat.bytestr(x)) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 else: |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
19 return pycompat.maplist(insertreturns, x) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 def removereturns(x): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 # the revert of "insertreturns" |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
23 if isinstance(x, bytes): |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
24 return x.replace(b'\n', b'') |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 else: |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
26 return pycompat.maplist(removereturns, x) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
27 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 def assertlistequal(lhs, rhs, decorator=lambda x: x): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
29 if lhs != rhs: |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 raise RuntimeError('mismatch:\n actual: %r\n expected: %r' |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
31 % tuple(map(decorator, [lhs, rhs]))) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 def testfilefixup(oldcontents, workingcopy, expectedcontents, fixups=None): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
34 """([str], str, [str], [(rev, a1, a2, b1, b2)]?) -> None |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
35 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
36 workingcopy is a string, of which every character denotes a single line. |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
37 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
38 oldcontents, expectedcontents are lists of strings, every character of |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
39 every string denots a single line. |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
40 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
41 if fixups is not None, it's the expected fixups list and will be checked. |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
42 """ |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
43 expectedcontents = insertreturns(expectedcontents) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
44 oldcontents = insertreturns(oldcontents) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
45 workingcopy = insertreturns(workingcopy) |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
46 state = absorb.filefixupstate(pycompat.maplist(simplefctx, oldcontents)) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
47 state.diffwith(simplefctx(workingcopy)) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
48 if fixups is not None: |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
49 assertlistequal(state.fixups, fixups) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
50 state.apply() |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
51 assertlistequal(state.finalcontents, expectedcontents, removereturns) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
52 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
53 def buildcontents(linesrevs): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
54 # linesrevs: [(linecontent : str, revs : [int])] |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
55 revs = set(itertools.chain(*[revs for line, revs in linesrevs])) |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
56 return [b''] + [ |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
57 b''.join([l for l, rs in linesrevs if r in rs]) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
58 for r in sorted(revs) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
59 ] |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
60 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
61 # input case 0: one single commit |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
62 case0 = [b'', b'11'] |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
63 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
64 # replace a single chunk |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
65 testfilefixup(case0, b'', [b'', b'']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
66 testfilefixup(case0, b'2', [b'', b'2']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
67 testfilefixup(case0, b'22', [b'', b'22']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
68 testfilefixup(case0, b'222', [b'', b'222']) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
69 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
70 # input case 1: 3 lines, each commit adds one line |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
71 case1 = buildcontents([ |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
72 (b'1', [1, 2, 3]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
73 (b'2', [ 2, 3]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
74 (b'3', [ 3]), |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
75 ]) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
76 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
77 # 1:1 line mapping |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
78 testfilefixup(case1, b'123', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
79 testfilefixup(case1, b'12c', [b'', b'1', b'12', b'12c']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
80 testfilefixup(case1, b'1b3', [b'', b'1', b'1b', b'1b3']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
81 testfilefixup(case1, b'1bc', [b'', b'1', b'1b', b'1bc']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
82 testfilefixup(case1, b'a23', [b'', b'a', b'a2', b'a23']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
83 testfilefixup(case1, b'a2c', [b'', b'a', b'a2', b'a2c']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
84 testfilefixup(case1, b'ab3', [b'', b'a', b'ab', b'ab3']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
85 testfilefixup(case1, b'abc', [b'', b'a', b'ab', b'abc']) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
86 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
87 # non 1:1 edits |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
88 testfilefixup(case1, b'abcd', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
89 testfilefixup(case1, b'ab', case1) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
90 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
91 # deletion |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
92 testfilefixup(case1, b'', [b'', b'', b'', b'']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
93 testfilefixup(case1, b'1', [b'', b'1', b'1', b'1']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
94 testfilefixup(case1, b'2', [b'', b'', b'2', b'2']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
95 testfilefixup(case1, b'3', [b'', b'', b'', b'3']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
96 testfilefixup(case1, b'13', [b'', b'1', b'1', b'13']) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
97 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
98 # replaces |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
99 testfilefixup(case1, b'1bb3', [b'', b'1', b'1bb', b'1bb3']) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
100 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
101 # (confusing) replaces |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
102 testfilefixup(case1, b'1bbb', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
103 testfilefixup(case1, b'bbbb', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
104 testfilefixup(case1, b'bbb3', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
105 testfilefixup(case1, b'1b', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
106 testfilefixup(case1, b'bb', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
107 testfilefixup(case1, b'b3', case1) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
108 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
109 # insertions at the beginning and the end |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
110 testfilefixup(case1, b'123c', [b'', b'1', b'12', b'123c']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
111 testfilefixup(case1, b'a123', [b'', b'a1', b'a12', b'a123']) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
112 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
113 # (confusing) insertions |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
114 testfilefixup(case1, b'1a23', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
115 testfilefixup(case1, b'12b3', case1) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
116 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
117 # input case 2: delete in the middle |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
118 case2 = buildcontents([ |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
119 (b'11', [1, 2]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
120 (b'22', [1 ]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
121 (b'33', [1, 2]), |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
122 ]) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
123 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
124 # deletion (optimize code should make it 2 chunks) |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
125 testfilefixup(case2, b'', [b'', b'22', b''], |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
126 fixups=[(4, 0, 2, 0, 0), (4, 2, 4, 0, 0)]) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
127 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
128 # 1:1 line mapping |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
129 testfilefixup(case2, b'aaaa', [b'', b'aa22aa', b'aaaa']) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
130 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
131 # non 1:1 edits |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
132 # note: unlike case0, the chunk is not "continuous" and no edit allowed |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
133 testfilefixup(case2, b'aaa', case2) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
134 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
135 # input case 3: rev 3 reverts rev 2 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
136 case3 = buildcontents([ |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
137 (b'1', [1, 2, 3]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
138 (b'2', [ 2 ]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
139 (b'3', [1, 2, 3]), |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
140 ]) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
141 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
142 # 1:1 line mapping |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
143 testfilefixup(case3, b'13', case3) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
144 testfilefixup(case3, b'1b', [b'', b'1b', b'12b', b'1b']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
145 testfilefixup(case3, b'a3', [b'', b'a3', b'a23', b'a3']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
146 testfilefixup(case3, b'ab', [b'', b'ab', b'a2b', b'ab']) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
147 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
148 # non 1:1 edits |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
149 testfilefixup(case3, b'a', case3) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
150 testfilefixup(case3, b'abc', case3) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
151 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
152 # deletion |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
153 testfilefixup(case3, b'', [b'', b'', b'2', b'']) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
154 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
155 # insertion |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
156 testfilefixup(case3, b'a13c', [b'', b'a13c', b'a123c', b'a13c']) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
157 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
158 # input case 4: a slightly complex case |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
159 case4 = buildcontents([ |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
160 (b'1', [1, 2, 3]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
161 (b'2', [ 2, 3]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
162 (b'3', [1, 2, ]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
163 (b'4', [1, 3]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
164 (b'5', [ 3]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
165 (b'6', [ 2, 3]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
166 (b'7', [ 2 ]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
167 (b'8', [ 2, 3]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
168 (b'9', [ 3]), |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
169 ]) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
170 |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
171 testfilefixup(case4, b'1245689', case4) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
172 testfilefixup(case4, b'1a2456bbb', case4) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
173 testfilefixup(case4, b'1abc5689', case4) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
174 testfilefixup(case4, b'1ab5689', [b'', b'134', b'1a3678', b'1ab5689']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
175 testfilefixup(case4, b'aa2bcd8ee', [b'', b'aa34', b'aa23d78', b'aa2bcd8ee']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
176 testfilefixup(case4, b'aa2bcdd8ee',[b'', b'aa34', b'aa23678', b'aa24568ee']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
177 testfilefixup(case4, b'aaaaaa', case4) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
178 testfilefixup(case4, b'aa258b', [b'', b'aa34', b'aa2378', b'aa258b']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
179 testfilefixup(case4, b'25bb', [b'', b'34', b'23678', b'25689']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
180 testfilefixup(case4, b'27', [b'', b'34', b'23678', b'245689']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
181 testfilefixup(case4, b'28', [b'', b'34', b'2378', b'28']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
182 testfilefixup(case4, b'', [b'', b'34', b'37', b'']) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
183 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
184 # input case 5: replace a small chunk which is near a deleted line |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
185 case5 = buildcontents([ |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
186 (b'12', [1, 2]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
187 (b'3', [1]), |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
188 (b'4', [1, 2]), |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
189 ]) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
190 |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
191 testfilefixup(case5, b'1cd4', [b'', b'1cd34', b'1cd4']) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
192 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
193 # input case 6: base "changeset" is immutable |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
194 case6 = [b'1357', b'0125678'] |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
195 |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
196 testfilefixup(case6, b'0125678', case6) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
197 testfilefixup(case6, b'0a25678', case6) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
198 testfilefixup(case6, b'0a256b8', case6) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
199 testfilefixup(case6, b'abcdefg', [b'1357', b'a1c5e7g']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
200 testfilefixup(case6, b'abcdef', case6) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
201 testfilefixup(case6, b'', [b'1357', b'157']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
202 testfilefixup(case6, b'0123456789', [b'1357', b'0123456789']) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
203 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
204 # input case 7: change an empty file |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
205 case7 = [b''] |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
206 |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
207 testfilefixup(case7, b'1', case7) |