Debian Codegraph @

tests/test-copy.t

raw
1 #testcases parent-swap meta-flag
2
3 #if meta-flag
4 $ cat << EOF >> $HGRCPATH
5 > [format]
6 > use-delta-info-flags=yes
7 > EOF
8 #else
9 $ cat << EOF >> $HGRCPATH
10 > [format]
11 > use-delta-info-flags=no
12 > EOF
13 #endif
14
15 $ mkdir part1
16 $ cd part1
17
18 $ hg init
19 $ echo a > a
20 $ hg add a
21 $ hg commit -m "1"
22 $ hg status
23 $ hg copy a b
24 $ hg --config ui.portablefilenames=abort copy a con.xml
25 abort: filename contains 'con', which is reserved on Windows: con.xml
26 [10]
27 $ hg status
28 A b
29 $ hg sum
30 parent: 0:c19d34741b0a tip
31 1
32 branch: default
33 commit: 1 copied
34 update: (current)
35 phases: 1 draft
36 $ hg --debug commit -m "2"
37 committing files:
38 b
39 b: copy a:b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
40 committing manifest
41 committing changelog
42 updating the branch cache
43 committed changeset 1:93580a2c28a50a56f63526fb305067e6fbf739c4
44
45 we should see two history entries
46
47 $ hg history -v
48 changeset: 1:93580a2c28a5
49 tag: tip
50 user: test
51 date: Thu Jan 01 00:00:00 1970 +0000
52 files: b
53 description:
54 2
55
56
57 changeset: 0:c19d34741b0a
58 user: test
59 date: Thu Jan 01 00:00:00 1970 +0000
60 files: a
61 description:
62 1
63
64
65
66 we should see one log entry for a
67
68 $ hg log a
69 changeset: 0:c19d34741b0a
70 user: test
71 date: Thu Jan 01 00:00:00 1970 +0000
72 summary: 1
73
74
75 this should show a revision linked to changeset 0
76
77 $ hg debugindex a
78 rev linkrev nodeid p1-nodeid p2-nodeid
79 0 0 b789fdd96dc2 000000000000 000000000000
80
81 we should see one log entry for b
82
83 $ hg log b
84 changeset: 1:93580a2c28a5
85 tag: tip
86 user: test
87 date: Thu Jan 01 00:00:00 1970 +0000
88 summary: 2
89
90
91 this should show a revision linked to changeset 1
92
93 $ hg debugindex b
94 rev linkrev nodeid p1-nodeid p2-nodeid
95 0 1 37d9b5d994ea 000000000000 000000000000
96
97 this should show the rename information in the metadata
98
99 $ hg debugdata b 0 | head -3 | tail -2
100 copy: a
101 copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
102
103 #if meta-flag
104 $ md5sum.py .hg/store/data/b.i
105 152daea7c98c398cf7a70300bb823e94 .hg/store/data/b.i
106 $ hg debugrevlog b | grep flags
107 flags : inline, generaldelta, hasmeta, delta-info
108 #else
109 $ md5sum.py .hg/store/data/b.i
110 44913824c8f5890ae218f9829535922e .hg/store/data/b.i
111 $ hg debugrevlog b | grep flags
112 flags : inline, generaldelta
113 #endif
114 $ hg cat b > bsum
115 $ md5sum.py bsum
116 60b725f10c9c85c70d97880dfe8191b3 bsum
117 $ hg cat a > asum
118 $ md5sum.py asum
119 60b725f10c9c85c70d97880dfe8191b3 asum
120 $ hg verify -q
121
122 $ cd ..
123
124
125 $ mkdir part2
126 $ cd part2
127
128 $ hg init
129 $ echo foo > foo
130 should fail - foo is not managed
131 $ hg mv foo bar
132 foo: not copying - file is not managed
133 abort: no files to copy
134 (maybe you meant to use --after --at-rev=.)
135 [10]
136 $ hg st -A
137 ? foo
138 respects ui.relative-paths
139 $ mkdir dir
140 $ cd dir
141 $ hg mv ../foo ../bar
142 ../foo: not copying - file is not managed
143 abort: no files to copy
144 (maybe you meant to use --after --at-rev=.)
145 [10]
146 $ hg mv ../foo ../bar --config ui.relative-paths=yes
147 ../foo: not copying - file is not managed
148 abort: no files to copy
149 (maybe you meant to use --after --at-rev=.)
150 [10]
151 $ hg mv ../foo ../bar --config ui.relative-paths=no
152 foo: not copying - file is not managed
153 abort: no files to copy
154 (maybe you meant to use --after --at-rev=.)
155 [10]
156 $ cd ..
157 $ rmdir dir
158 $ hg add foo
159 dry-run; print a warning that this is not a real copy; foo is added
160 $ hg mv --dry-run foo bar
161 foo has not been committed yet, so no copy data will be stored for bar.
162 $ hg st -A
163 A foo
164 should print a warning that this is not a real copy; bar is added
165 $ hg mv foo bar
166 foo has not been committed yet, so no copy data will be stored for bar.
167 $ hg st -A
168 A bar
169 should print a warning that this is not a real copy; foo is added
170 $ hg cp bar foo
171 bar has not been committed yet, so no copy data will be stored for foo.
172 $ hg rm -f bar
173 $ rm bar
174 $ hg st -A
175 A foo
176 $ hg commit -m1
177
178 moving a missing file
179 $ rm foo
180 $ hg mv foo foo3
181 foo: deleted in working directory
182 foo3 does not exist!
183 $ hg up -qC .
184
185 copy --after to a nonexistent target filename
186 $ hg cp -A foo dummy
187 foo: not recording copy - dummy does not exist
188 [1]
189
190 dry-run; should show that foo is clean
191 $ hg copy --dry-run foo bar
192 $ hg st -A
193 C foo
194 should show copy
195 $ hg copy foo bar
196 $ hg st -C
197 A bar
198 foo
199
200 shouldn't show copy
201 $ hg commit -m2
202 $ hg st -C
203
204 should match
205 $ hg debugindex foo
206 rev linkrev nodeid p1-nodeid p2-nodeid
207 0 0 2ed2a3912a0b 000000000000 000000000000
208 $ hg debugrename bar
209 bar renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd
210
211 $ echo bleah > foo
212 $ echo quux > bar
213 $ hg commit -m3
214
215 should not be renamed
216 $ hg debugrename bar
217 bar not renamed
218
219 $ hg copy -f foo bar
220 should show copy
221 $ hg st -C
222 M bar
223 foo
224
225 XXX: filtering lfilesrepo.status() in 3.3-rc causes the copy source to not be
226 displayed.
227 $ hg st -C --config extensions.largefiles=
228 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
229 M bar
230 foo
231
232 $ hg commit -m3
233
234 should show no parents for tip
235 $ hg debugindex bar
236 rev linkrev nodeid p1-nodeid p2-nodeid
237 0 1 7711d36246cc 000000000000 000000000000
238 1 2 bdf70a2b8d03 7711d36246cc 000000000000
239 2 3 b2558327ea8d 000000000000 000000000000
240 should match
241 $ hg debugindex foo
242 rev linkrev nodeid p1-nodeid p2-nodeid
243 0 0 2ed2a3912a0b 000000000000 000000000000
244 1 2 dd12c926cf16 2ed2a3912a0b 000000000000
245 $ hg debugrename bar
246 bar renamed from foo:dd12c926cf165e3eb4cf87b084955cb617221c17
247
248 should show no copies
249 $ hg st -C
250
251 note: since filelog based copy tracing only trace copy for new file, the copy information here is not displayed.
252
253 $ hg status --copies --change .
254 M bar
255
256 They are a devel option to walk all file and fine this information anyway.
257
258 $ hg status --copies --change . --config devel.copy-tracing.trace-all-files=yes
259 M bar
260 foo
261
262 copy --after on an added file
263 $ cp bar baz
264 $ hg add baz
265 $ hg cp -A bar baz
266 $ hg st -C
267 A baz
268 bar
269
270 foo was clean:
271 $ hg st -AC foo
272 C foo
273 Trying to copy on top of an existing file fails,
274 $ hg copy -A bar foo
275 foo: not overwriting - file already committed
276 ('hg copy --after --force' to replace the file by recording a copy)
277 [1]
278 same error without the --after, so the user doesn't have to go through
279 two hints:
280 $ hg copy bar foo
281 foo: not overwriting - file already committed
282 ('hg copy --force' to replace the file by recording a copy)
283 [1]
284 but it's considered modified after a copy --after --force
285 $ hg copy -Af bar foo
286 $ hg st -AC foo
287 M foo
288 bar
289 The hint for a file that exists but is not in file history doesn't
290 mention --force:
291 $ touch xyzzy
292 $ hg cp bar xyzzy
293 xyzzy: not overwriting - file exists
294 ('hg copy --after' to record the copy)
295 [1]
296 $ hg co -qC .
297 $ rm baz xyzzy
298
299
300 Test unmarking copy/rename of a single file
301
302 # Set up by creating a copy
303 $ hg cp bar baz
304 # Test unmarking as copy a non-existent file
305 $ hg copy --forget non-existent
306 non-existent: $ENOENT$
307 $ hg rename --forget non-existent
308 non-existent: $ENOENT$
309 # Test unmarking as copy an tracked but unrelated file
310 $ hg copy --forget foo
311 foo: not unmarking as copy - file is not marked as copied
312 $ hg rename --forget foo
313 foo: not unmarking as copy - file is not marked as copied
314 # Test unmarking as copy a copy source
315 $ hg copy --forget bar
316 bar: not unmarking as copy - file is not marked as copied
317 $ hg rename --forget bar
318 bar: not unmarking as copy - file is not marked as copied
319 # baz should still be marked as a copy
320 $ hg st -C
321 A baz
322 bar
323 # Test the normal case
324 $ hg copy --forget baz
325 $ hg st -C
326 A baz
327 $ rm bar
328 $ hg rename --after bar baz
329 $ hg st -C
330 A baz
331 bar
332 R bar
333 $ hg rename --forget baz
334 $ hg st -C
335 A baz
336 R bar
337 $ hg revert bar
338 # Test unmarking as copy with matching an non-matching patterns
339 $ hg cp bar baz --after
340 $ hg copy --forget bar baz
341 bar: not unmarking as copy - file is not marked as copied
342 $ hg cp bar baz --after
343 $ hg rename --forget bar baz
344 bar: not unmarking as copy - file is not marked as copied
345 $ hg st -C
346 A baz
347 # Test unmarking as copy with no exact matches
348 $ hg cp bar baz --after
349 $ hg copy --forget .
350 $ hg st -C
351 A baz
352 $ hg cp bar baz --after
353 $ hg st -C
354 A baz
355 bar
356 $ hg rename --forget .
357 $ hg st -C
358 A baz
359 $ hg forget baz
360 $ rm baz
361
362 Test unmarking copy of a directory
363
364 $ mkdir dir
365 $ echo foo > dir/foo
366 $ echo bar > dir/bar
367 $ hg add dir
368 adding dir/bar
369 adding dir/foo
370 $ hg ci -m 'add dir/'
371 $ hg cp dir dir2
372 copying dir/bar to dir2/bar
373 copying dir/foo to dir2/foo
374 $ touch dir2/untracked
375 $ hg copy --forget dir2
376 $ hg st -C
377 A dir2/bar
378 A dir2/foo
379 ? dir2/untracked
380 # Clean up for next test
381 $ hg forget dir2
382 removing dir2/bar
383 removing dir2/foo
384 $ rm -r dir2
385
386 Test uncopy on committed copies
387
388 # Commit some copies
389 $ hg cp bar baz
390 $ hg cp bar qux
391 $ hg ci -m copies
392 $ hg st -C --change .
393 A baz
394 bar
395 A qux
396 bar
397 $ base=$(hg log -r '.^' -T '{rev}')
398 $ hg log -G -T '{rev}:{node|short} {desc}\n' -r $base:
399 @ 5:a612dc2edfda copies
400 |
401 o 4:4800b1f1f38e add dir/
402 |
403 ~
404 # Add a dirty change on top to show that it's unaffected
405 $ echo dirty >> baz
406 $ hg st
407 M baz
408 $ cat baz
409 bleah
410 dirty
411 $ hg copy --forget --at-rev . baz
412 saved backup bundle to $TESTTMP/part2/.hg/strip-backup/a612dc2edfda-e36b4448-uncopy.hg
413 # The unwanted copy is no longer recorded, but the unrelated one is
414 $ hg st -C --change .
415 A baz
416 A qux
417 bar
418 # The old commit is gone and we have updated to the new commit
419 $ hg log -G -T '{rev}:{node|short} {desc}\n' -r $base:
420 @ 5:c45090e5effe copies
421 |
422 o 4:4800b1f1f38e add dir/
423 |
424 ~
425 # Working copy still has the uncommitted change
426 $ hg st
427 M baz
428 $ cat baz
429 bleah
430 dirty
431
432 $ hg root
433 $TESTTMP/part2
434 $ cd ..
435
436 # This should survive push and pull with both changegroup3 and changegroup 4
437
438 $ hg clone --pull part1 clone1-cg3 --quiet --config experimental.changegroup4=no
439 $ hg -R clone1-cg3 status --copies --change 0
440 A a
441 $ hg -R clone1-cg3 status --copies --change 1
442 A b
443 a
444
445 $ hg clone --pull part2 clone2-cg3 --quiet --config experimental.changegroup4=no
446 $ hg -R clone2-cg3 status --copies --change 5
447 A baz
448 A qux
449 bar
450 $ hg -R clone2-cg3 status --copies --change 4
451 A dir/bar
452 A dir/foo
453 $ hg -R clone2-cg3 status --copies --change 3
454 M bar
455 $ hg -R clone2-cg3 status --copies --change 2
456 M bar
457 M foo
458 $ hg -R clone2-cg3 status --copies --change 1
459 A bar
460 foo
461 $ hg -R clone2-cg3 status --copies --change 0
462 A foo
463
464 $ hg clone --pull part1 clone1-cg4 \
465 > --config experimental.changegroup4=yes \
466 > --quiet \
467 > --config server.validate=yes
468 $ hg -R clone1-cg4 status --copies --change 0
469 A a
470 $ hg -R clone1-cg4 status --copies --change 1
471 A b
472 a
473
474 $ hg clone --pull part2 clone2-cg4 \
475 > --config experimental.changegroup4=yes \
476 > --quiet \
477 > --config server.validate=yes
478 $ hg -R clone2-cg4 status --copies --change 5
479 A baz
480 A qux
481 bar
482 $ hg -R clone2-cg4 status --copies --change 4
483 A dir/bar
484 A dir/foo
485 $ hg -R clone2-cg4 status --copies --change 3
486 M bar
487 $ hg -R clone2-cg4 status --copies --change 2
488 M bar
489 M foo
490 $ hg -R clone2-cg4 status --copies --change 1
491 A bar
492 foo
493 $ hg -R clone2-cg4 status --copies --change 0
494 A foo
495
496 #if meta-flag
497 $ md5sum.py part1/.hg/store/data/b.i clone1*/.hg/store/data/b.i
498 152daea7c98c398cf7a70300bb823e94 part1/.hg/store/data/b.i
499 152daea7c98c398cf7a70300bb823e94 clone1-cg3/.hg/store/data/b.i
500 152daea7c98c398cf7a70300bb823e94 clone1-cg4/.hg/store/data/b.i
501 $ md5sum.py part1/.hg/store/data/a.i clone1*/.hg/store/data/a.i
502 92988ecec422f81a0282fa84f92b1e0d part1/.hg/store/data/a.i
503 92988ecec422f81a0282fa84f92b1e0d clone1-cg3/.hg/store/data/a.i
504 92988ecec422f81a0282fa84f92b1e0d clone1-cg4/.hg/store/data/a.i
505
506 $ md5sum.py part2/.hg/store/data/foo.i clone2*/.hg/store/data/foo.i
507 9feac37c4617f1fb57763b4909949835 part2/.hg/store/data/foo.i
508 9feac37c4617f1fb57763b4909949835 clone2-cg3/.hg/store/data/foo.i
509 9feac37c4617f1fb57763b4909949835 clone2-cg4/.hg/store/data/foo.i
510 $ md5sum.py part2/.hg/store/data/bar.i clone2*/.hg/store/data/bar.i
511 e830bd90a8c26363969697285899f376 part2/.hg/store/data/bar.i
512 e830bd90a8c26363969697285899f376 clone2-cg3/.hg/store/data/bar.i
513 e830bd90a8c26363969697285899f376 clone2-cg4/.hg/store/data/bar.i
514 $ md5sum.py part2/.hg/store/data/baz.i clone2*/.hg/store/data/baz.i
515 669c207ec134b978e6e04535384e0273 part2/.hg/store/data/baz.i
516 669c207ec134b978e6e04535384e0273 clone2-cg3/.hg/store/data/baz.i
517 669c207ec134b978e6e04535384e0273 clone2-cg4/.hg/store/data/baz.i
518 $ md5sum.py part2/.hg/store/data/qux.i clone2*/.hg/store/data/qux.i
519 21a3aea21d539df4c1631df4d07ad8a3 part2/.hg/store/data/qux.i
520 21a3aea21d539df4c1631df4d07ad8a3 clone2-cg3/.hg/store/data/qux.i
521 21a3aea21d539df4c1631df4d07ad8a3 clone2-cg4/.hg/store/data/qux.i
522 #else
523 $ md5sum.py part1/.hg/store/data/b.i clone1*/.hg/store/data/b.i
524 44913824c8f5890ae218f9829535922e part1/.hg/store/data/b.i
525 44913824c8f5890ae218f9829535922e clone1-cg3/.hg/store/data/b.i
526 44913824c8f5890ae218f9829535922e clone1-cg4/.hg/store/data/b.i
527 $ md5sum.py part1/.hg/store/data/a.i clone1*/.hg/store/data/a.i
528 c517d297466f14512660b97fb67ef39d part1/.hg/store/data/a.i
529 c517d297466f14512660b97fb67ef39d clone1-cg3/.hg/store/data/a.i
530 c517d297466f14512660b97fb67ef39d clone1-cg4/.hg/store/data/a.i
531
532 $ md5sum.py part2/.hg/store/data/foo.i clone2*/.hg/store/data/foo.i
533 9fccff6dee6685292e72152627c295cb part2/.hg/store/data/foo.i
534 9fccff6dee6685292e72152627c295cb clone2-cg3/.hg/store/data/foo.i
535 9fccff6dee6685292e72152627c295cb clone2-cg4/.hg/store/data/foo.i
536 $ md5sum.py part2/.hg/store/data/bar.i clone2*/.hg/store/data/bar.i
537 0eb3d23b50f1ccba7d6ec7212c4e4e64 part2/.hg/store/data/bar.i
538 0eb3d23b50f1ccba7d6ec7212c4e4e64 clone2-cg3/.hg/store/data/bar.i
539 0eb3d23b50f1ccba7d6ec7212c4e4e64 clone2-cg4/.hg/store/data/bar.i
540 $ md5sum.py part2/.hg/store/data/baz.i clone2*/.hg/store/data/baz.i
541 8a22e288ffd74c0d1fead0cb2ddd7bb0 part2/.hg/store/data/baz.i
542 8a22e288ffd74c0d1fead0cb2ddd7bb0 clone2-cg3/.hg/store/data/baz.i
543 8a22e288ffd74c0d1fead0cb2ddd7bb0 clone2-cg4/.hg/store/data/baz.i
544 $ md5sum.py part2/.hg/store/data/qux.i clone2*/.hg/store/data/qux.i
545 e106cd025269f85a938d68b6734822c2 part2/.hg/store/data/qux.i
546 e106cd025269f85a938d68b6734822c2 clone2-cg3/.hg/store/data/qux.i
547 e106cd025269f85a938d68b6734822c2 clone2-cg4/.hg/store/data/qux.i
548 #endif