Mercurial > hg
annotate tests/test-absorb-filefixupstate.py @ 50517:cd2a2963b982
stream-clone: upgrade the error message for bad stream request
The new version if more compact and more consistent with the general Mercurial
usage.
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Sun, 21 May 2023 00:00:29 +0200 |
parents | 642e31cb55f0 |
children |
rev | line source |
---|---|
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 import itertools |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
2 from mercurial import pycompat |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 from hgext import absorb |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
5 |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
6 class simplefctx: |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 def __init__(self, content): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 self.content = content |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 def data(self): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 return self.content |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
13 |
38917
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 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
21 |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 def removereturns(x): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 # the revert of "insertreturns" |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
24 if isinstance(x, bytes): |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
25 return x.replace(b'\n', b'') |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 else: |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
27 return pycompat.maplist(removereturns, x) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
29 |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 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
|
31 if lhs != rhs: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
32 raise RuntimeError( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
33 'mismatch:\n actual: %r\n expected: %r' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
34 % tuple(map(decorator, [lhs, rhs])) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
35 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
36 |
38917
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 def testfilefixup(oldcontents, workingcopy, expectedcontents, fixups=None): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
39 """([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
|
40 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
41 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
|
42 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
43 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
|
44 every string denots a single line. |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
45 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
46 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
|
47 """ |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
48 expectedcontents = insertreturns(expectedcontents) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
49 oldcontents = insertreturns(oldcontents) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
50 workingcopy = insertreturns(workingcopy) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
51 state = absorb.filefixupstate( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
52 pycompat.maplist(simplefctx, oldcontents), 'path' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
53 ) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
54 state.diffwith(simplefctx(workingcopy)) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
55 if fixups is not None: |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
56 assertlistequal(state.fixups, fixups) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
57 state.apply() |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
58 assertlistequal(state.finalcontents, expectedcontents, removereturns) |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
59 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
60 |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
61 def buildcontents(linesrevs): |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
62 # linesrevs: [(linecontent : str, revs : [int])] |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
63 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
|
64 return [b''] + [ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
65 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
|
66 ] |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
67 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
68 |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
69 # 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
|
70 case0 = [b'', b'11'] |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
71 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
72 # replace a single chunk |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
73 testfilefixup(case0, b'', [b'', b'']) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
74 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
|
75 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
|
76 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
|
77 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
78 # 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
|
79 case1 = buildcontents( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
80 [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
81 (b'1', [1, 2, 3]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
82 (b'2', [2, 3]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
83 (b'3', [3]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
84 ] |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
85 ) |
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 # 1:1 line mapping |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
88 testfilefixup(case1, b'123', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
97 # non 1:1 edits |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
98 testfilefixup(case1, b'abcd', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
99 testfilefixup(case1, b'ab', case1) |
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 # deletion |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
102 testfilefixup(case1, b'', [b'', b'', b'', b'']) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
103 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
|
104 testfilefixup(case1, b'2', [b'', b'', b'2', b'2']) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
105 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
|
106 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
|
107 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
108 # replaces |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
109 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
|
110 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
111 # (confusing) replaces |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
112 testfilefixup(case1, b'1bbb', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
113 testfilefixup(case1, b'bbbb', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
114 testfilefixup(case1, b'bbb3', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
115 testfilefixup(case1, b'1b', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
116 testfilefixup(case1, b'bb', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
117 testfilefixup(case1, b'b3', case1) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
118 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
119 # 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
|
120 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
|
121 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
|
122 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
123 # (confusing) insertions |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
124 testfilefixup(case1, b'1a23', case1) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
125 testfilefixup(case1, b'12b3', case1) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
126 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
127 # input case 2: delete in the middle |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
128 case2 = buildcontents( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
129 [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
130 (b'11', [1, 2]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
131 (b'22', [1]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
132 (b'33', [1, 2]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
133 ] |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
134 ) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
135 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
136 # deletion (optimize code should make it 2 chunks) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
137 testfilefixup( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
138 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
|
139 ) |
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 # 1:1 line mapping |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
142 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
|
143 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
144 # non 1:1 edits |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
145 # 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
|
146 testfilefixup(case2, b'aaa', case2) |
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 # 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
|
149 case3 = buildcontents( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
150 [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
151 (b'1', [1, 2, 3]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
152 (b'2', [2]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
153 (b'3', [1, 2, 3]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
154 ] |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
155 ) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
156 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
157 # 1:1 line mapping |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
158 testfilefixup(case3, b'13', case3) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
159 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
|
160 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
|
161 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
|
162 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
163 # non 1:1 edits |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
164 testfilefixup(case3, b'a', case3) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
165 testfilefixup(case3, b'abc', case3) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
166 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
167 # deletion |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
168 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
|
169 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
170 # insertion |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
171 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
|
172 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
173 # input case 4: a slightly complex case |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
174 case4 = buildcontents( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
175 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
176 (b'1', [1, 2, 3]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
177 (b'2', [2, 3]), |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
178 ( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
179 b'3', |
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 1, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
182 2, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
183 ], |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
184 ), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
185 (b'4', [1, 3]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
186 (b'5', [3]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
187 (b'6', [2, 3]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
188 (b'7', [2]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
189 (b'8', [2, 3]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
190 (b'9', [3]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
191 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40187
diff
changeset
|
192 ) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
193 |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
194 testfilefixup(case4, b'1245689', case4) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
195 testfilefixup(case4, b'1a2456bbb', case4) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
196 testfilefixup(case4, b'1abc5689', case4) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
197 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
|
198 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
|
199 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
|
200 testfilefixup(case4, b'aaaaaa', case4) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
207 # 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
|
208 case5 = buildcontents( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
209 [ |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
210 (b'12', [1, 2]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
211 (b'3', [1]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
212 (b'4', [1, 2]), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
213 ] |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43076
diff
changeset
|
214 ) |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
215 |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
216 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
|
217 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
218 # 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
|
219 case6 = [b'1357', b'0125678'] |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
220 |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
221 testfilefixup(case6, b'0125678', case6) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
222 testfilefixup(case6, b'0a25678', case6) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
223 testfilefixup(case6, b'0a256b8', case6) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
224 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
|
225 testfilefixup(case6, b'abcdef', case6) |
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
226 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
|
227 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
|
228 |
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
229 # 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
|
230 case7 = [b''] |
38917
5111d11b8719
absorb: import extension from Facebook's hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
231 |
38988
1aab0007a7c0
tests: port test-absorb-filefixupstate to Python 3
Augie Fackler <augie@google.com>
parents:
38917
diff
changeset
|
232 testfilefixup(case7, b'1', case7) |