Debian Codegraph @

tests/test-status-ambiguous-length.t

raw
1 ============================================================
2 Test how `hg status` behavior for file with ambiguous length
3 ============================================================
4
5 #testcases dirstate-v1 dirstate-v2
6 #testcases parents-swap delta-info
7
8 Some file have an actual file size that differs from the "uncompressed size"
9 stored in the revlog index. This happens mostly because of metadata.
10
11 As the `hg status` logic uses the stored file size to fast path modification
12 checks, this can create issues.
13
14 The logic for this fast path mostly happens when the on-disk mtime is different
15 from the one in the dirstate but the size is the same as the one expected in
16 the dirstate.
17
18 Here we will be testing two ways of having different sizes:
19
20 A: the file has rename information
21 B: the initial bytes of the file are the same as a metadata header, so empty metadata are stored
22
23 Before the "delta-info" format, a revision's parentage was used to detect
24 metadata in some cases. So we will be testing multiple parentage cases:
25
26 1: the file revision has no parent
27 2: the file revision has a single parent
28 3: the file revision has two parents
29
30 The combinations of the two dimensions will be denoted A1, A2, …, B3
31
32 ┌──────────────┬────┬────┬────┐
33 │ ╲ parents │ 0 │ 1 │ 2 │
34 │ metadata ╲ │ │ │ │
35 ├──────────────┼────┼────┼────┤
36 │ │ │ │ │
37 │ rename │ A1 │ A2 │ ø │
38 │ │ │ │ │
39 ├──────────────┼────┼────┼────┤
40 │ │ │ │ │
41 │ "\1\n" start │ B1 │ B2 │ B3 │
42 │ │ │ │ │
43 └──────────────┴────┴────┴────┘
44
45 (Case A3 can't happen, see A2 documentation for details)
46
47 We test with both dirstate-v1 and dirstate-v2 as they store slightly different
48 information and use different logic.
49
50 We also test with and without delta-info as this uses different logic to detect
51 metadata presence.
52
53 Variant setup
54 =============
55
56 #if dirstate-v2
57 $ cat >> $HGRCPATH << EOF
58 > [format]
59 > use-dirstate-v2=yes
60 > [storage]
61 > dirstate-v2.slow-path=allow
62 > EOF
63 #else
64 $ cat >> $HGRCPATH << EOF
65 > [format]
66 > use-dirstate-v2=no
67 > EOF
68 #endif
69
70
71 #if delta-info
72 $ cat << EOF >> $HGRCPATH
73 > [format]
74 > use-delta-info-flags=yes
75 > EOF
76 #else
77 $ cat << EOF >> $HGRCPATH
78 > [format]
79 > use-delta-info-flags=no
80 > EOF
81 #endif
82
83 Case-A1
84 =======
85
86 file-revision with rename metadata but no parents
87
88 "A1" requires a rename, so we create "old_A1" to be renamed to "A1" in the next
89 changeset
90
91 $ hg init repo-A1
92 $ cd repo-A1
93
94 $ echo foo >> old_A1
95 $ hg add old_A1
96 $ hg commit -m 'c01c'
97 $ hg mv old_A1 A1
98 $ hg commit -m 'c02c'
99 $ hg debugindex A1
100 rev linkrev nodeid p1-nodeid p2-nodeid
101 0 1 2e5eab2edf5c 000000000000 000000000000
102
103 Make sure we a nice and new clean dirstate
104
105 $ hg up -C null
106 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
107 $ hg up tip
108 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
109
110 Test that status report the file as clean when the mtime is ambiguous
111
112 $ touch -t 200001010000 A1
113 $ env RHG_ON_UNSUPPORTED=abort hg status --all A1
114 C A1
115
116 $ cd ..
117
118 Case-A1 second
119 ==============
120
121 This case highlights that the rename always replaces one parent.
122
123 (we don't really care that the rename replaces the parent, but we want to test
124 the behavior of status in that case)
125
126 File revision with a rename and 1 parent. This can be achieved by renaming a
127 file over another one.
128
129 $ hg init repo-A1s
130 $ cd repo-A1s
131
132 $ echo bar >> A1s
133 $ echo baz >> old_A1s
134 $ hg add old_A1s A1s
135 $ hg commit -m 'c01c'
136 $ hg mv old_A1s A1s --force
137 $ hg commit -m 'c02c'
138 $ hg debugindex A1s
139 rev linkrev nodeid p1-nodeid p2-nodeid
140 0 0 b004912a8510 000000000000 000000000000
141 1 1 6b58d91010da 000000000000 000000000000
142
143 Make sure we have a nice and new clean dirstate
144
145 $ hg up -C null
146 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
147 $ hg up tip
148 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
149
150 Test that status reports the file as clean when the mtime is ambiguous
151
152 $ touch -t 200001010000 A1s
153 $ env RHG_ON_UNSUPPORTED=abort hg status --all A1s
154 C A1s
155
156 $ cd ..
157
158 Case-A2
159 =======
160
161 Even in case of a merge, the rename will only preserve one of the two parents.
162
163 So case A3 isn't possible and this creates A2 (with the infamous parent swap
164 that created issue6528).
165
166 (we don't really care than the rename replaces the parent, but we want to test
167 the behavior of status in that case)
168
169 $ hg init repo-A2
170 $ cd repo-A2
171 $ cat << EOF > A2
172 > initial
173 > content
174 > EOF
175 $ echo foo >> old_A2
176 $ hg add A2 old_A2
177 $ hg commit -m 'c01c'
178 $ cat << EOF > A2
179 > left
180 > initial
181 > content
182 > EOF
183 $ hg commit -m 'c02c'
184 $ hg up '.~1'
185 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
186 $ cat << EOF > A2
187 > initial
188 > content
189 > right
190 > EOF
191 $ hg commit -m 'c03c'
192 created new head
193 $ hg merge
194 merging A2
195 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
196 (branch merge, don't forget to commit)
197 $ hg mv old_A2 A2 --force
198 $ hg commit -m 'c04c'
199 $ hg debugindex A2
200 rev linkrev nodeid p1-nodeid p2-nodeid
201 0 0 52535790e5a4 000000000000 000000000000
202 1 1 a75f9ba0708f 52535790e5a4 000000000000
203 2 2 ea304aefd227 52535790e5a4 000000000000
204 3 3 1acf5a646c20 000000000000 a75f9ba0708f (parents-swap !)
205 3 3 1acf5a646c20 a75f9ba0708f 000000000000 (delta-info !)
206
207 Make sure we have a nice and new clean dirstate
208
209 $ hg up -C null
210 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
211 $ hg up tip
212 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
213
214 Test that status reports the file as clean when the mtime is ambiguous
215
216 $ touch -t 200001010000 A2
217 $ env RHG_ON_UNSUPPORTED=abort hg status --all A2
218 C A2
219
220 $ cd ..
221
222 Case-B1
223 =======
224
225 "B1" is simple, we just commit a new file whose content starts with a "metadata
226 header"
227
228 $ hg init repo-B1
229 $ cd repo-B1
230
231
232 >>> with open('B1', 'wb') as f:
233 ... f.write(b"\x01\nfooB1")
234 7
235 $ hg add B1
236 $ hg commit -m 'c01c'
237 $ hg debugindex B1
238 rev linkrev nodeid p1-nodeid p2-nodeid
239 0 0 18007faa00ac 000000000000 000000000000
240
241 Make sure we have a nice and new clean dirstate
242
243 $ hg up -C null
244 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
245 $ hg up tip
246 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
247
248 Test that status reports the file as clean when the mtime is ambiguous
249
250 $ touch -t 200001010000 B1
251 $ env RHG_ON_UNSUPPORTED=abort hg status --all B1
252 C B1
253
254 $ cd ..
255
256 Case-B2
257 =======
258 $ hg init repo-B2
259 $ cd repo-B2
260
261 "B2" wants a parent, so we need a first version to iterate over
262
263 $ echo fooB2 >> B2
264 $ hg add B2
265 $ hg commit -m 'c01c'
266 >>> with open('B2', 'wb') as f:
267 ... f.write(b"\x01\nfooB2")
268 7
269 $ hg commit -m 'c02c'
270 $ hg debugindex B2
271 rev linkrev nodeid p1-nodeid p2-nodeid
272 0 0 288ace91caa7 000000000000 000000000000
273 1 1 99f93d9af14a 000000000000 288ace91caa7 (parents-swap !)
274 1 1 99f93d9af14a 288ace91caa7 000000000000 (delta-info !)
275
276 Make sure we have a nice and new clean dirstate
277
278 $ hg up -C null
279 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
280 $ hg up tip
281 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
282
283 Test that status reports the file as clean when the mtime is ambiguous
284
285 $ touch -t 200001010000 B2
286 $ env RHG_ON_UNSUPPORTED=abort hg status --all B2
287 C B2
288
289 $ cd ..
290
291 Case-B3
292 =======
293
294 A case with two parents, so we need a merge, with the content starting with a
295 metadata header.
296
297 $ hg init repo-B3
298 $ cd repo-B3
299 $ cat << EOF > B3
300 > initial
301 > content
302 > EOF
303 $ echo foo >> old_B3
304 $ hg add B3 old_B3
305 $ hg commit -m 'c01c'
306 $ cat << EOF > B3
307 > left
308 > initial
309 > content
310 > EOF
311 $ hg commit -m 'c02c'
312 $ hg up '.~1'
313 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
314 $ cat << EOF > B3
315 > initial
316 > content
317 > right
318 > EOF
319 $ hg commit -m 'c03c'
320 created new head
321 $ hg merge
322 merging B3
323 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
324 (branch merge, don't forget to commit)
325 >>> with open('B3', 'wb') as f:
326 ... f.write(b"\x01\nfooB2")
327 7
328 $ hg commit -m 'c04c'
329 $ hg debugindex B3
330 rev linkrev nodeid p1-nodeid p2-nodeid
331 0 0 52535790e5a4 000000000000 000000000000
332 1 1 a75f9ba0708f 52535790e5a4 000000000000
333 2 2 ea304aefd227 52535790e5a4 000000000000
334 3 3 9ff56e8cfdcb ea304aefd227 a75f9ba0708f
335
336 Make sure we have a nice and new clean dirstate
337
338 $ hg up -C null
339 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
340 $ hg up tip
341 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
342
343 Test that status reports the file as clean when the mtime is ambiguous
344
345 $ touch -t 200001010000 B3
346 $ env RHG_ON_UNSUPPORTED=abort hg status --all B3
347 C B3
348
349 $ cd ..