Mercurial > hg
comparison tests/test-absorb-filefixupstate.py @ 45942:89a2afe31e82
formating: upgrade to black 20.8b1
This required a couple of small tweaks to un-confuse black, but now it
works. Big formatting changes come from:
* Dramatically improved collection-splitting logic upstream
* Black having a strong (correct IMO) opinion that """ is better than '''
Differential Revision: https://phab.mercurial-scm.org/D9430
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 27 Nov 2020 17:03:29 -0500 |
parents | 2372284d9457 |
children | 6000f5b25c9b |
comparison
equal
deleted
inserted
replaced
45941:346af7687c6f | 45942:89a2afe31e82 |
---|---|
76 testfilefixup(case0, b'2', [b'', b'2']) | 76 testfilefixup(case0, b'2', [b'', b'2']) |
77 testfilefixup(case0, b'22', [b'', b'22']) | 77 testfilefixup(case0, b'22', [b'', b'22']) |
78 testfilefixup(case0, b'222', [b'', b'222']) | 78 testfilefixup(case0, b'222', [b'', b'222']) |
79 | 79 |
80 # input case 1: 3 lines, each commit adds one line | 80 # input case 1: 3 lines, each commit adds one line |
81 case1 = buildcontents([(b'1', [1, 2, 3]), (b'2', [2, 3]), (b'3', [3]),]) | 81 case1 = buildcontents( |
82 [ | |
83 (b'1', [1, 2, 3]), | |
84 (b'2', [2, 3]), | |
85 (b'3', [3]), | |
86 ] | |
87 ) | |
82 | 88 |
83 # 1:1 line mapping | 89 # 1:1 line mapping |
84 testfilefixup(case1, b'123', case1) | 90 testfilefixup(case1, b'123', case1) |
85 testfilefixup(case1, b'12c', [b'', b'1', b'12', b'12c']) | 91 testfilefixup(case1, b'12c', [b'', b'1', b'12', b'12c']) |
86 testfilefixup(case1, b'1b3', [b'', b'1', b'1b', b'1b3']) | 92 testfilefixup(case1, b'1b3', [b'', b'1', b'1b', b'1b3']) |
119 # (confusing) insertions | 125 # (confusing) insertions |
120 testfilefixup(case1, b'1a23', case1) | 126 testfilefixup(case1, b'1a23', case1) |
121 testfilefixup(case1, b'12b3', case1) | 127 testfilefixup(case1, b'12b3', case1) |
122 | 128 |
123 # input case 2: delete in the middle | 129 # input case 2: delete in the middle |
124 case2 = buildcontents([(b'11', [1, 2]), (b'22', [1]), (b'33', [1, 2]),]) | 130 case2 = buildcontents( |
131 [ | |
132 (b'11', [1, 2]), | |
133 (b'22', [1]), | |
134 (b'33', [1, 2]), | |
135 ] | |
136 ) | |
125 | 137 |
126 # deletion (optimize code should make it 2 chunks) | 138 # deletion (optimize code should make it 2 chunks) |
127 testfilefixup( | 139 testfilefixup( |
128 case2, b'', [b'', b'22', b''], fixups=[(4, 0, 2, 0, 0), (4, 2, 4, 0, 0)] | 140 case2, b'', [b'', b'22', b''], fixups=[(4, 0, 2, 0, 0), (4, 2, 4, 0, 0)] |
129 ) | 141 ) |
134 # non 1:1 edits | 146 # non 1:1 edits |
135 # note: unlike case0, the chunk is not "continuous" and no edit allowed | 147 # note: unlike case0, the chunk is not "continuous" and no edit allowed |
136 testfilefixup(case2, b'aaa', case2) | 148 testfilefixup(case2, b'aaa', case2) |
137 | 149 |
138 # input case 3: rev 3 reverts rev 2 | 150 # input case 3: rev 3 reverts rev 2 |
139 case3 = buildcontents([(b'1', [1, 2, 3]), (b'2', [2]), (b'3', [1, 2, 3]),]) | 151 case3 = buildcontents( |
152 [ | |
153 (b'1', [1, 2, 3]), | |
154 (b'2', [2]), | |
155 (b'3', [1, 2, 3]), | |
156 ] | |
157 ) | |
140 | 158 |
141 # 1:1 line mapping | 159 # 1:1 line mapping |
142 testfilefixup(case3, b'13', case3) | 160 testfilefixup(case3, b'13', case3) |
143 testfilefixup(case3, b'1b', [b'', b'1b', b'12b', b'1b']) | 161 testfilefixup(case3, b'1b', [b'', b'1b', b'12b', b'1b']) |
144 testfilefixup(case3, b'a3', [b'', b'a3', b'a23', b'a3']) | 162 testfilefixup(case3, b'a3', [b'', b'a3', b'a23', b'a3']) |
157 # input case 4: a slightly complex case | 175 # input case 4: a slightly complex case |
158 case4 = buildcontents( | 176 case4 = buildcontents( |
159 [ | 177 [ |
160 (b'1', [1, 2, 3]), | 178 (b'1', [1, 2, 3]), |
161 (b'2', [2, 3]), | 179 (b'2', [2, 3]), |
162 (b'3', [1, 2,]), | 180 ( |
181 b'3', | |
182 [ | |
183 1, | |
184 2, | |
185 ], | |
186 ), | |
163 (b'4', [1, 3]), | 187 (b'4', [1, 3]), |
164 (b'5', [3]), | 188 (b'5', [3]), |
165 (b'6', [2, 3]), | 189 (b'6', [2, 3]), |
166 (b'7', [2]), | 190 (b'7', [2]), |
167 (b'8', [2, 3]), | 191 (b'8', [2, 3]), |
181 testfilefixup(case4, b'27', [b'', b'34', b'23678', b'245689']) | 205 testfilefixup(case4, b'27', [b'', b'34', b'23678', b'245689']) |
182 testfilefixup(case4, b'28', [b'', b'34', b'2378', b'28']) | 206 testfilefixup(case4, b'28', [b'', b'34', b'2378', b'28']) |
183 testfilefixup(case4, b'', [b'', b'34', b'37', b'']) | 207 testfilefixup(case4, b'', [b'', b'34', b'37', b'']) |
184 | 208 |
185 # input case 5: replace a small chunk which is near a deleted line | 209 # input case 5: replace a small chunk which is near a deleted line |
186 case5 = buildcontents([(b'12', [1, 2]), (b'3', [1]), (b'4', [1, 2]),]) | 210 case5 = buildcontents( |
211 [ | |
212 (b'12', [1, 2]), | |
213 (b'3', [1]), | |
214 (b'4', [1, 2]), | |
215 ] | |
216 ) | |
187 | 217 |
188 testfilefixup(case5, b'1cd4', [b'', b'1cd34', b'1cd4']) | 218 testfilefixup(case5, b'1cd4', [b'', b'1cd34', b'1cd4']) |
189 | 219 |
190 # input case 6: base "changeset" is immutable | 220 # input case 6: base "changeset" is immutable |
191 case6 = [b'1357', b'0125678'] | 221 case6 = [b'1357', b'0125678'] |