Mercurial > hg
comparison tests/test-commit-amend.t @ 23835:aa4a1672583e
bundles: do not overwrite existing backup bundles (BC)
Previously, a backup bundle could overwrite an existing bundle and cause user
data loss. For instance, if you have A<-B<-C and strip B, it produces backup
bundle B-backup.hg. If you then hg pull -r B B-backup.hg and strip it again, it
overwrites the existing B-backup.hg and C is lost.
The fix is to add a hash of all the nodes inside that bundle to the filename.
Fixed up existing tests and added a new test in test-strip.t
author | Durham Goode <durham@fb.com> |
---|---|
date | Fri, 09 Jan 2015 10:52:14 -0800 |
parents | a387b0390082 |
children | ac41aa4a66ab |
comparison
equal
deleted
inserted
replaced
23834:bf07c19b4c82 | 23835:aa4a1672583e |
---|---|
33 | 33 |
34 $ echo a >> a | 34 $ echo a >> a |
35 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1' | 35 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1' |
36 pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149 | 36 pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149 |
37 43f1ba15f28a tip | 37 43f1ba15f28a tip |
38 saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-amend-backup.hg (glob) | 38 saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-f1bf3ab8-amend-backup.hg (glob) |
39 $ echo 'pretxncommit.foo = ' >> $HGRCPATH | 39 $ echo 'pretxncommit.foo = ' >> $HGRCPATH |
40 $ hg diff -c . | 40 $ hg diff -c . |
41 diff -r ad120869acf0 -r 43f1ba15f28a a | 41 diff -r ad120869acf0 -r 43f1ba15f28a a |
42 --- a/a Thu Jan 01 00:00:00 1970 +0000 | 42 --- a/a Thu Jan 01 00:00:00 1970 +0000 |
43 +++ b/a Thu Jan 01 00:00:00 1970 +0000 | 43 +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
84 commit: 1 added, 1 unknown | 84 commit: 1 added, 1 unknown |
85 update: (current) | 85 update: (current) |
86 | 86 |
87 Add new file: | 87 Add new file: |
88 $ hg ci --amend -m 'amend base1 new file' | 88 $ hg ci --amend -m 'amend base1 new file' |
89 saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-amend-backup.hg (glob) | 89 saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-7a3b3496-amend-backup.hg (glob) |
90 | 90 |
91 Remove file that was added in amended commit: | 91 Remove file that was added in amended commit: |
92 (and test logfile option) | 92 (and test logfile option) |
93 (and test that logfile option do not trigger an editor) | 93 (and test that logfile option do not trigger an editor) |
94 | 94 |
95 $ hg rm b | 95 $ hg rm b |
96 $ echo 'amend base1 remove new file' > ../logfile | 96 $ echo 'amend base1 remove new file' > ../logfile |
97 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile | 97 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile |
98 saved backup bundle to $TESTTMP/.hg/strip-backup/b8e3cb2b3882-amend-backup.hg (glob) | 98 saved backup bundle to $TESTTMP/.hg/strip-backup/b8e3cb2b3882-0b55739a-amend-backup.hg (glob) |
99 | 99 |
100 $ hg cat b | 100 $ hg cat b |
101 b: no such file in rev 74609c7f506e | 101 b: no such file in rev 74609c7f506e |
102 [1] | 102 [1] |
103 | 103 |
114 1 changesets found | 114 1 changesets found |
115 uncompressed size of bundle content: | 115 uncompressed size of bundle content: |
116 250 (changelog) | 116 250 (changelog) |
117 143 (manifests) | 117 143 (manifests) |
118 109 a | 118 109 a |
119 saved backup bundle to $TESTTMP/.hg/strip-backup/74609c7f506e-amend-backup.hg (glob) | 119 saved backup bundle to $TESTTMP/.hg/strip-backup/74609c7f506e-1bfde511-amend-backup.hg (glob) |
120 1 changesets found | 120 1 changesets found |
121 uncompressed size of bundle content: | 121 uncompressed size of bundle content: |
122 246 (changelog) | 122 246 (changelog) |
123 143 (manifests) | 123 143 (manifests) |
124 109 a | 124 109 a |
160 > env | grep HGEDITFORM | 160 > env | grep HGEDITFORM |
161 > true | 161 > true |
162 > EOF | 162 > EOF |
163 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0' | 163 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0' |
164 HGEDITFORM=commit.amend.normal | 164 HGEDITFORM=commit.amend.normal |
165 saved backup bundle to $TESTTMP/.hg/strip-backup/1cd866679df8-amend-backup.hg (glob) | 165 saved backup bundle to $TESTTMP/.hg/strip-backup/1cd866679df8-5f5bcb85-amend-backup.hg (glob) |
166 $ echo a >> a | 166 $ echo a >> a |
167 $ hg ci --amend -u foo -d '1 0' | 167 $ hg ci --amend -u foo -d '1 0' |
168 saved backup bundle to $TESTTMP/.hg/strip-backup/780e6f23e03d-amend-backup.hg (glob) | 168 saved backup bundle to $TESTTMP/.hg/strip-backup/780e6f23e03d-83b10a27-amend-backup.hg (glob) |
169 $ hg log -r . | 169 $ hg log -r . |
170 changeset: 1:5f357c7560ab | 170 changeset: 1:5f357c7560ab |
171 tag: tip | 171 tag: tip |
172 user: foo | 172 user: foo |
173 date: Thu Jan 01 00:00:01 1970 +0000 | 173 date: Thu Jan 01 00:00:01 1970 +0000 |
258 1 changesets found | 258 1 changesets found |
259 uncompressed size of bundle content: | 259 uncompressed size of bundle content: |
260 238 (changelog) | 260 238 (changelog) |
261 143 (manifests) | 261 143 (manifests) |
262 111 a | 262 111 a |
263 saved backup bundle to $TESTTMP/.hg/strip-backup/5f357c7560ab-amend-backup.hg (glob) | 263 saved backup bundle to $TESTTMP/.hg/strip-backup/5f357c7560ab-e7c84ade-amend-backup.hg (glob) |
264 1 changesets found | 264 1 changesets found |
265 uncompressed size of bundle content: | 265 uncompressed size of bundle content: |
266 246 (changelog) | 266 246 (changelog) |
267 143 (manifests) | 267 143 (manifests) |
268 111 a | 268 111 a |
301 2 changesets found | 301 2 changesets found |
302 uncompressed size of bundle content: | 302 uncompressed size of bundle content: |
303 450 (changelog) | 303 450 (changelog) |
304 282 (manifests) | 304 282 (manifests) |
305 209 a | 305 209 a |
306 saved backup bundle to $TESTTMP/.hg/strip-backup/7ab3bf440b54-amend-backup.hg (glob) | 306 saved backup bundle to $TESTTMP/.hg/strip-backup/7ab3bf440b54-8e3b5088-amend-backup.hg (glob) |
307 1 changesets found | 307 1 changesets found |
308 uncompressed size of bundle content: | 308 uncompressed size of bundle content: |
309 246 (changelog) | 309 246 (changelog) |
310 143 (manifests) | 310 143 (manifests) |
311 113 a | 311 113 a |
328 Moving bookmarks, preserve active bookmark: | 328 Moving bookmarks, preserve active bookmark: |
329 | 329 |
330 $ hg book book1 | 330 $ hg book book1 |
331 $ hg book book2 | 331 $ hg book book2 |
332 $ hg ci --amend -m 'move bookmarks' | 332 $ hg ci --amend -m 'move bookmarks' |
333 saved backup bundle to $TESTTMP/.hg/strip-backup/ea22a388757c-amend-backup.hg (glob) | 333 saved backup bundle to $TESTTMP/.hg/strip-backup/ea22a388757c-e51094db-amend-backup.hg (glob) |
334 $ hg book | 334 $ hg book |
335 book1 1:6cec5aa930e2 | 335 book1 1:6cec5aa930e2 |
336 * book2 1:6cec5aa930e2 | 336 * book2 1:6cec5aa930e2 |
337 $ echo a >> a | 337 $ echo a >> a |
338 $ hg ci --amend -m 'move bookmarks' | 338 $ hg ci --amend -m 'move bookmarks' |
339 saved backup bundle to $TESTTMP/.hg/strip-backup/6cec5aa930e2-amend-backup.hg (glob) | 339 saved backup bundle to $TESTTMP/.hg/strip-backup/6cec5aa930e2-e9b06de4-amend-backup.hg (glob) |
340 $ hg book | 340 $ hg book |
341 book1 1:48bb6e53a15f | 341 book1 1:48bb6e53a15f |
342 * book2 1:48bb6e53a15f | 342 * book2 1:48bb6e53a15f |
343 | 343 |
344 abort does not loose bookmarks | 344 abort does not loose bookmarks |
371 $ hg ci -m 'branch foo' | 371 $ hg ci -m 'branch foo' |
372 $ hg branch default -f | 372 $ hg branch default -f |
373 marked working directory as branch default | 373 marked working directory as branch default |
374 (branches are permanent and global, did you want a bookmark?) | 374 (branches are permanent and global, did you want a bookmark?) |
375 $ hg ci --amend -m 'back to default' | 375 $ hg ci --amend -m 'back to default' |
376 saved backup bundle to $TESTTMP/.hg/strip-backup/8ac881fbf49d-amend-backup.hg (glob) | 376 saved backup bundle to $TESTTMP/.hg/strip-backup/8ac881fbf49d-fd962fef-amend-backup.hg (glob) |
377 $ hg branches | 377 $ hg branches |
378 default 2:ce12b0b57d46 | 378 default 2:ce12b0b57d46 |
379 | 379 |
380 Close branch: | 380 Close branch: |
381 | 381 |
387 $ hg ci -Am 'fork' | 387 $ hg ci -Am 'fork' |
388 adding b | 388 adding b |
389 $ echo b >> b | 389 $ echo b >> b |
390 $ hg ci -mb | 390 $ hg ci -mb |
391 $ hg ci --amend --close-branch -m 'closing branch foo' | 391 $ hg ci --amend --close-branch -m 'closing branch foo' |
392 saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-amend-backup.hg (glob) | 392 saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-6701c392-amend-backup.hg (glob) |
393 | 393 |
394 Same thing, different code path: | 394 Same thing, different code path: |
395 | 395 |
396 $ echo b >> b | 396 $ echo b >> b |
397 $ hg ci -m 'reopen branch' | 397 $ hg ci -m 'reopen branch' |
398 reopening closed branch head 4 | 398 reopening closed branch head 4 |
399 $ echo b >> b | 399 $ echo b >> b |
400 $ hg ci --amend --close-branch | 400 $ hg ci --amend --close-branch |
401 saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-amend-backup.hg (glob) | 401 saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-49c0c55d-amend-backup.hg (glob) |
402 $ hg branches | 402 $ hg branches |
403 default 2:ce12b0b57d46 | 403 default 2:ce12b0b57d46 |
404 | 404 |
405 Refuse to amend during a merge: | 405 Refuse to amend during a merge: |
406 | 406 |
417 | 417 |
418 $ hg mv b c | 418 $ hg mv b c |
419 $ hg ci -m 'b -> c' | 419 $ hg ci -m 'b -> c' |
420 $ hg mv c d | 420 $ hg mv c d |
421 $ hg ci --amend -m 'b -> d' | 421 $ hg ci --amend -m 'b -> d' |
422 saved backup bundle to $TESTTMP/.hg/strip-backup/b8c6eac7f12e-amend-backup.hg (glob) | 422 saved backup bundle to $TESTTMP/.hg/strip-backup/b8c6eac7f12e-adaaa8b1-amend-backup.hg (glob) |
423 $ hg st --rev '.^' --copies d | 423 $ hg st --rev '.^' --copies d |
424 A d | 424 A d |
425 b | 425 b |
426 $ hg cp d e | 426 $ hg cp d e |
427 $ hg ci -m 'e = d' | 427 $ hg ci -m 'e = d' |
428 $ hg cp e f | 428 $ hg cp e f |
429 $ hg ci --amend -m 'f = d' | 429 $ hg ci --amend -m 'f = d' |
430 saved backup bundle to $TESTTMP/.hg/strip-backup/7f9761d65613-amend-backup.hg (glob) | 430 saved backup bundle to $TESTTMP/.hg/strip-backup/7f9761d65613-d37aa788-amend-backup.hg (glob) |
431 $ hg st --rev '.^' --copies f | 431 $ hg st --rev '.^' --copies f |
432 A f | 432 A f |
433 d | 433 d |
434 | 434 |
435 $ mv f f.orig | 435 $ mv f f.orig |
436 $ hg rm -A f | 436 $ hg rm -A f |
437 $ hg ci -m removef | 437 $ hg ci -m removef |
438 $ hg cp a f | 438 $ hg cp a f |
439 $ mv f.orig f | 439 $ mv f.orig f |
440 $ hg ci --amend -m replacef | 440 $ hg ci --amend -m replacef |
441 saved backup bundle to $TESTTMP/.hg/strip-backup/9e8c5f7e3d95-amend-backup.hg (glob) | 441 saved backup bundle to $TESTTMP/.hg/strip-backup/9e8c5f7e3d95-90259f67-amend-backup.hg (glob) |
442 $ hg st --change . --copies | 442 $ hg st --change . --copies |
443 $ hg log -r . --template "{file_copies}\n" | 443 $ hg log -r . --template "{file_copies}\n" |
444 | 444 |
445 | 445 |
446 Move added file (issue3410): | 446 Move added file (issue3410): |
448 $ echo g >> g | 448 $ echo g >> g |
449 $ hg ci -Am g | 449 $ hg ci -Am g |
450 adding g | 450 adding g |
451 $ hg mv g h | 451 $ hg mv g h |
452 $ hg ci --amend | 452 $ hg ci --amend |
453 saved backup bundle to $TESTTMP/.hg/strip-backup/24aa8eacce2b-amend-backup.hg (glob) | 453 saved backup bundle to $TESTTMP/.hg/strip-backup/24aa8eacce2b-7059e0f1-amend-backup.hg (glob) |
454 $ hg st --change . --copies h | 454 $ hg st --change . --copies h |
455 A h | 455 A h |
456 $ hg log -r . --template "{file_copies}\n" | 456 $ hg log -r . --template "{file_copies}\n" |
457 | 457 |
458 | 458 |
468 marked working directory as branch a | 468 marked working directory as branch a |
469 (branches are permanent and global, did you want a bookmark?) | 469 (branches are permanent and global, did you want a bookmark?) |
470 $ echo a >> a | 470 $ echo a >> a |
471 $ hg ci -ma | 471 $ hg ci -ma |
472 $ hg ci --amend -m "a'" | 472 $ hg ci --amend -m "a'" |
473 saved backup bundle to $TESTTMP/.hg/strip-backup/3837aa2a2fdb-amend-backup.hg (glob) | 473 saved backup bundle to $TESTTMP/.hg/strip-backup/3837aa2a2fdb-2be01fd1-amend-backup.hg (glob) |
474 $ hg log -r . --template "{branch}\n" | 474 $ hg log -r . --template "{branch}\n" |
475 a | 475 a |
476 $ hg ci --amend -m "a''" | 476 $ hg ci --amend -m "a''" |
477 saved backup bundle to $TESTTMP/.hg/strip-backup/c05c06be7514-amend-backup.hg (glob) | 477 saved backup bundle to $TESTTMP/.hg/strip-backup/c05c06be7514-ed28c4cd-amend-backup.hg (glob) |
478 $ hg log -r . --template "{branch}\n" | 478 $ hg log -r . --template "{branch}\n" |
479 a | 479 a |
480 | 480 |
481 Also preserve other entries in the dict that are in the old commit, | 481 Also preserve other entries in the dict that are in the old commit, |
482 first graft something so there's an additional entry: | 482 first graft something so there's an additional entry: |
489 $ hg up 11 | 489 $ hg up 11 |
490 5 files updated, 0 files merged, 1 files removed, 0 files unresolved | 490 5 files updated, 0 files merged, 1 files removed, 0 files unresolved |
491 $ hg graft 12 | 491 $ hg graft 12 |
492 grafting 12:2647734878ef "fork" (tip) | 492 grafting 12:2647734878ef "fork" (tip) |
493 $ hg ci --amend -m 'graft amend' | 493 $ hg ci --amend -m 'graft amend' |
494 saved backup bundle to $TESTTMP/.hg/strip-backup/bd010aea3f39-amend-backup.hg (glob) | 494 saved backup bundle to $TESTTMP/.hg/strip-backup/bd010aea3f39-eedb103b-amend-backup.hg (glob) |
495 $ hg log -r . --debug | grep extra | 495 $ hg log -r . --debug | grep extra |
496 extra: amend_source=bd010aea3f39f3fb2a2f884b9ccb0471cd77398e | 496 extra: amend_source=bd010aea3f39f3fb2a2f884b9ccb0471cd77398e |
497 extra: branch=a | 497 extra: branch=a |
498 extra: source=2647734878ef0236dda712fae9c1651cf694ea8a | 498 extra: source=2647734878ef0236dda712fae9c1651cf694ea8a |
499 | 499 |