comparison tests/test-convert-filemap.t @ 17103:5146de7bce96

convert: keep branch switching merges with ancestors (issue3340) When running convert with a filemap, merge parents which are ancestors of other parents are ignored. This is hardly a problem when parents belong to the same branch, but the result could be confusing when named branches are involved. With: -o-a1-a2-a3... <- A \ \ b1-b2-b3...-m- <- B If all b* revisions are discarded, it is useful to preserve 'm' even if it is empty after filtering to record the branch switch. This patch makes filemap preserve "ancestor parents" if there is no "non-ancestor parent" on the same branch than the merge revision. Remarks: - I am not completely convinced by the reasons given above and those detailed by Matt in this thread: http://selenic.com/pipermail/mercurial-devel/2012-May/040627.html The properties we try to preserve are not clearly defined. That said, I know this patch already helped someone on IRC and the tests output look reasonable. - This is a new version of the original "convert: filemap must preserve fast-forward merges" patch. It has exactly the same output for 2 parents merges, the additional complexity is here to handle more than two parents.
author Patrick Mezard <patrick@mezard.eu>
date Mon, 18 Jun 2012 18:19:28 +0200
parents 41885892796e
children bddf1220d7a2
comparison
equal deleted inserted replaced
17102:d9a046ae4d8e 17103:5146de7bce96
373 $ glog -R branchpruning-hg2 373 $ glog -R branchpruning-hg2
374 o 1 "closedefault" files: 374 o 1 "closedefault" files:
375 | 375 |
376 o 0 "addb" files: b 376 o 0 "addb" files: b
377 377
378
379 test merge parents/empty merges pruning
380
381 $ glog()
382 > {
383 > hg glog --template '{rev}:{node|short}@{branch} "{desc}" files: {files}\n' "$@"
384 > }
385
386 test anonymous branch pruning
387
388 $ hg init anonymousbranch
389 $ cd anonymousbranch
390 $ echo a > a
391 $ echo b > b
392 $ hg ci -Am add
393 adding a
394 adding b
395 $ echo a >> a
396 $ hg ci -m changea
397 $ hg up 0
398 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
399 $ echo b >> b
400 $ hg ci -m changeb
401 created new head
402 $ hg up 1
403 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
404 $ hg merge
405 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
406 (branch merge, don't forget to commit)
407 $ hg ci -m merge
408 $ cd ..
409
410 $ cat > filemap <<EOF
411 > include a
412 > EOF
413 $ hg convert --filemap filemap anonymousbranch anonymousbranch-hg
414 initializing destination anonymousbranch-hg repository
415 scanning source...
416 sorting...
417 converting...
418 3 add
419 2 changea
420 1 changeb
421 0 merge
422 $ glog -R anonymousbranch
423 @ 3:c71d5201a498@default "merge" files:
424 |\
425 | o 2:607eb44b17f9@default "changeb" files: b
426 | |
427 o | 1:1f60ea617824@default "changea" files: a
428 |/
429 o 0:0146e6129113@default "add" files: a b
430
431 $ glog -R anonymousbranch-hg
432 o 1:cda818e7219b@default "changea" files: a
433 |
434 o 0:c334dc3be0da@default "add" files: a
435
436 $ cat anonymousbranch-hg/.hg/shamap
437 0146e6129113dba9ac90207cfdf2d7ed35257ae5 c334dc3be0daa2a4e9ce4d2e2bdcba40c09d4916
438 1f60ea61782421edf8d051ff4fcb61b330f26a4a cda818e7219b5f7f3fb9f49780054ed6a1905ec3
439 607eb44b17f9348cd5cbd26e16af87ba77b0b037 c334dc3be0daa2a4e9ce4d2e2bdcba40c09d4916
440 c71d5201a498b2658d105a6bf69d7a0df2649aea cda818e7219b5f7f3fb9f49780054ed6a1905ec3
441
442 $ cat > filemap <<EOF
443 > include b
444 > EOF
445 $ hg convert --filemap filemap anonymousbranch anonymousbranch-hg2
446 initializing destination anonymousbranch-hg2 repository
447 scanning source...
448 sorting...
449 converting...
450 3 add
451 2 changea
452 1 changeb
453 0 merge
454 $ glog -R anonymousbranch
455 @ 3:c71d5201a498@default "merge" files:
456 |\
457 | o 2:607eb44b17f9@default "changeb" files: b
458 | |
459 o | 1:1f60ea617824@default "changea" files: a
460 |/
461 o 0:0146e6129113@default "add" files: a b
462
463 $ glog -R anonymousbranch-hg2
464 o 1:62dd350b0df6@default "changeb" files: b
465 |
466 o 0:4b9ced861657@default "add" files: b
467
468 $ cat anonymousbranch-hg2/.hg/shamap
469 0146e6129113dba9ac90207cfdf2d7ed35257ae5 4b9ced86165703791653059a1db6ed864630a523
470 1f60ea61782421edf8d051ff4fcb61b330f26a4a 4b9ced86165703791653059a1db6ed864630a523
471 607eb44b17f9348cd5cbd26e16af87ba77b0b037 62dd350b0df695f7d2c82a02e0499b16fd790f22
472 c71d5201a498b2658d105a6bf69d7a0df2649aea 62dd350b0df695f7d2c82a02e0499b16fd790f22
473
474 test named branch pruning
475
476 $ hg init namedbranch
477 $ cd namedbranch
478 $ echo a > a
479 $ echo b > b
480 $ hg ci -Am add
481 adding a
482 adding b
483 $ echo a >> a
484 $ hg ci -m changea
485 $ hg up 0
486 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
487 $ hg branch foo
488 marked working directory as branch foo
489 (branches are permanent and global, did you want a bookmark?)
490 $ echo b >> b
491 $ hg ci -m changeb
492 $ hg up default
493 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
494 $ hg merge foo
495 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
496 (branch merge, don't forget to commit)
497 $ hg ci -m merge
498 $ cd ..
499
500 $ cat > filemap <<EOF
501 > include a
502 > EOF
503 $ hg convert --filemap filemap namedbranch namedbranch-hg
504 initializing destination namedbranch-hg repository
505 scanning source...
506 sorting...
507 converting...
508 3 add
509 2 changea
510 1 changeb
511 0 merge
512 $ glog -R namedbranch
513 @ 3:73899bcbe45c@default "merge" files:
514 |\
515 | o 2:8097982d19fc@foo "changeb" files: b
516 | |
517 o | 1:1f60ea617824@default "changea" files: a
518 |/
519 o 0:0146e6129113@default "add" files: a b
520
521 $ glog -R namedbranch-hg
522 o 1:cda818e7219b@default "changea" files: a
523 |
524 o 0:c334dc3be0da@default "add" files: a
525
526
527 $ cd namedbranch
528 $ hg --config extensions.mq= strip tip
529 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
530 saved backup bundle to $TESTTMP/namedbranch/.hg/strip-backup/73899bcbe45c-backup.hg
531 $ hg up foo
532 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
533 $ hg merge default
534 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
535 (branch merge, don't forget to commit)
536 $ hg ci -m merge
537 $ cd ..
538
539 $ hg convert --filemap filemap namedbranch namedbranch-hg2
540 initializing destination namedbranch-hg2 repository
541 scanning source...
542 sorting...
543 converting...
544 3 add
545 2 changea
546 1 changeb
547 0 merge
548 $ glog -R namedbranch
549 @ 3:e1959de76e1b@foo "merge" files:
550 |\
551 | o 2:8097982d19fc@foo "changeb" files: b
552 | |
553 o | 1:1f60ea617824@default "changea" files: a
554 |/
555 o 0:0146e6129113@default "add" files: a b
556
557 $ glog -R namedbranch-hg2
558 o 2:dcf314454667@foo "merge" files:
559 |\
560 | o 1:cda818e7219b@default "changea" files: a
561 |/
562 o 0:c334dc3be0da@default "add" files: a
563