Mercurial > hg
annotate tests/test-absorb-filefixupstate.py @ 46858:85e3a630cad9
revlog: move the details of revlog "v2" index inside revlog.utils.constants
the revlog module is quite large and this kind of format information would handy
for other module. So let us start to gather this information about the format in
a more appropriate place.
We update various reference to this information to use the new "source of truth"
in the process.
Differential Revision: https://phab.mercurial-scm.org/D10305
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 05 Apr 2021 12:21:12 +0200 |
parents | 89a2afe31e82 |
children | 6000f5b25c9b |
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 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
7 |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 class simplefctx(object): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 def __init__(self, content): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 self.content = content |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 def data(self): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 return self.content |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
15 |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 def insertreturns(x): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 # 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
|
18 if isinstance(x, bytes): |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
19 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
|
20 else: |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
21 return pycompat.maplist(insertreturns, x) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
23 |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 def removereturns(x): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 # the revert of "insertreturns" |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
26 if isinstance(x, bytes): |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
27 return x.replace(b'\n', b'') |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 else: |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
29 return pycompat.maplist(removereturns, x) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
31 |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 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
|
33 if lhs != rhs: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
34 raise RuntimeError( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
35 'mismatch:\n actual: %r\n expected: %r' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
36 % tuple(map(decorator, [lhs, rhs])) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
37 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
38 |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
39 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
40 def testfilefixup(oldcontents, workingcopy, expectedcontents, fixups=None): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
41 """([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
|
42 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
43 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
|
44 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
45 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
|
46 every string denots a single line. |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
47 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
48 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
|
49 """ |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
50 expectedcontents = insertreturns(expectedcontents) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
51 oldcontents = insertreturns(oldcontents) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
52 workingcopy = insertreturns(workingcopy) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
53 state = absorb.filefixupstate( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
54 pycompat.maplist(simplefctx, oldcontents), 'path' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
55 ) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
56 state.diffwith(simplefctx(workingcopy)) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
57 if fixups is not None: |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
58 assertlistequal(state.fixups, fixups) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
59 state.apply() |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
60 assertlistequal(state.finalcontents, expectedcontents, removereturns) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
61 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
62 |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
63 def buildcontents(linesrevs): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
64 # linesrevs: [(linecontent : str, revs : [int])] |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
65 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
|
66 return [b''] + [ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
67 b''.join([l for l, rs in linesrevs if r in rs]) for r in sorted(revs) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
68 ] |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
69 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
70 |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
71 # 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
|
72 case0 = [b'', b'11'] |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
73 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
74 # replace a single chunk |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
75 testfilefixup(case0, b'', [b'', b'']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
76 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
|
77 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
|
78 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
|
79 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
80 # input case 1: 3 lines, each commit adds one line |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
81 case1 = buildcontents( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
82 [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
83 (b'1', [1, 2, 3]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
84 (b'2', [2, 3]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
85 (b'3', [3]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
86 ] |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
87 ) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
88 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
89 # 1:1 line mapping |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
90 testfilefixup(case1, b'123', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
91 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 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
|
97 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
|
98 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
99 # non 1:1 edits |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
100 testfilefixup(case1, b'abcd', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
101 testfilefixup(case1, b'ab', case1) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
102 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
103 # deletion |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
104 testfilefixup(case1, b'', [b'', b'', b'', b'']) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
105 testfilefixup(case1, b'1', [b'', b'1', b'1', b'1']) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
106 testfilefixup(case1, b'2', [b'', b'', b'2', b'2']) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
107 testfilefixup(case1, b'3', [b'', b'', b'', b'3']) |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
108 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
|
109 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
110 # replaces |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
111 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
|
112 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
113 # (confusing) replaces |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
114 testfilefixup(case1, b'1bbb', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
115 testfilefixup(case1, b'bbbb', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
116 testfilefixup(case1, b'bbb3', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
117 testfilefixup(case1, b'1b', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
118 testfilefixup(case1, b'bb', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
119 testfilefixup(case1, b'b3', case1) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
120 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
121 # 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
|
122 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
|
123 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
|
124 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
125 # (confusing) insertions |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
126 testfilefixup(case1, b'1a23', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
127 testfilefixup(case1, b'12b3', case1) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
128 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
129 # input case 2: delete in the middle |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
130 case2 = buildcontents( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
131 [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
132 (b'11', [1, 2]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
133 (b'22', [1]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
134 (b'33', [1, 2]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
135 ] |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
136 ) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
137 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
138 # deletion (optimize code should make it 2 chunks) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
139 testfilefixup( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
140 case2, b'', [b'', b'22', b''], fixups=[(4, 0, 2, 0, 0), (4, 2, 4, 0, 0)] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
141 ) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
142 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
143 # 1:1 line mapping |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
144 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
|
145 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
146 # non 1:1 edits |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
147 # 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
|
148 testfilefixup(case2, b'aaa', case2) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
149 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
150 # input case 3: rev 3 reverts rev 2 |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
151 case3 = buildcontents( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
152 [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
153 (b'1', [1, 2, 3]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
154 (b'2', [2]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
155 (b'3', [1, 2, 3]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
156 ] |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
157 ) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
158 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
159 # 1:1 line mapping |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
160 testfilefixup(case3, b'13', case3) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
161 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
|
162 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
|
163 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
|
164 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
165 # non 1:1 edits |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
166 testfilefixup(case3, b'a', case3) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
167 testfilefixup(case3, b'abc', case3) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
168 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
169 # deletion |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
170 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
|
171 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
172 # insertion |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
173 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
|
174 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
175 # input case 4: a slightly complex case |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
176 case4 = buildcontents( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
177 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
178 (b'1', [1, 2, 3]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
179 (b'2', [2, 3]), |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
180 ( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
181 b'3', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
182 [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
183 1, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
184 2, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
185 ], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
186 ), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
187 (b'4', [1, 3]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
188 (b'5', [3]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
189 (b'6', [2, 3]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
190 (b'7', [2]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
191 (b'8', [2, 3]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
192 (b'9', [3]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
193 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
194 ) |
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(case4, b'1245689', case4) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
197 testfilefixup(case4, b'1a2456bbb', case4) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
198 testfilefixup(case4, b'1abc5689', case4) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
199 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
|
200 testfilefixup(case4, b'aa2bcd8ee', [b'', b'aa34', b'aa23d78', b'aa2bcd8ee']) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
201 testfilefixup(case4, b'aa2bcdd8ee', [b'', b'aa34', b'aa23678', b'aa24568ee']) |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
202 testfilefixup(case4, b'aaaaaa', case4) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
209 # input case 5: replace a small chunk which is near a deleted line |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
210 case5 = buildcontents( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
211 [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
212 (b'12', [1, 2]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
213 (b'3', [1]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
214 (b'4', [1, 2]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
215 ] |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
216 ) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
217 |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
218 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
|
219 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
220 # 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
|
221 case6 = [b'1357', b'0125678'] |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
222 |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
223 testfilefixup(case6, b'0125678', case6) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
224 testfilefixup(case6, b'0a25678', case6) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
225 testfilefixup(case6, b'0a256b8', case6) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
226 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
|
227 testfilefixup(case6, b'abcdef', case6) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
228 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
|
229 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
|
230 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
231 # 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
|
232 case7 = [b''] |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
233 |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
234 testfilefixup(case7, b'1', case7) |