Show More
@@ -1660,6 +1660,12 def amend(ui, repo, commitfunc, old, ext | |||
|
1660 | 1660 | # Also update it from the intermediate commit or from the wctx |
|
1661 | 1661 | extra.update(ctx.extra()) |
|
1662 | 1662 | |
|
1663 | if len(old.parents()) > 1: | |
|
1664 | # ctx.files() isn't reliable for merges, so fall back to the | |
|
1665 | # slower repo.status() method | |
|
1666 | files = set([fn for st in repo.status(base, old)[:3] | |
|
1667 | for fn in st]) | |
|
1668 | else: | |
|
1663 | 1669 | files = set(old.files()) |
|
1664 | 1670 | |
|
1665 | 1671 | # Second, we use either the commit we just did, or if there were no |
@@ -1725,7 +1731,7 def amend(ui, repo, commitfunc, old, ext | |||
|
1725 | 1731 | extra['amend_source'] = old.hex() |
|
1726 | 1732 | |
|
1727 | 1733 | new = context.memctx(repo, |
|
1728 |
parents=[base.node(), |
|
|
1734 | parents=[base.node(), old.p2().node()], | |
|
1729 | 1735 | text=message, |
|
1730 | 1736 | files=files, |
|
1731 | 1737 | filectxfn=filectxfn, |
@@ -1315,8 +1315,6 def commit(ui, repo, *pats, **opts): | |||
|
1315 | 1315 | old = repo['.'] |
|
1316 | 1316 | if old.phase() == phases.public: |
|
1317 | 1317 | raise util.Abort(_('cannot amend public changesets')) |
|
1318 | if len(old.parents()) > 1: | |
|
1319 | raise util.Abort(_('cannot amend merge changesets')) | |
|
1320 | 1318 | if len(repo[None].parents()) > 1: |
|
1321 | 1319 | raise util.Abort(_('cannot amend while merging')) |
|
1322 | 1320 | if (not obsolete._enabled) and old.children(): |
@@ -304,7 +304,7 Same thing, different code path: | |||
|
304 | 304 | $ hg branches |
|
305 | 305 | default 2:ce12b0b57d46 |
|
306 | 306 | |
|
307 |
Refuse to amend merge |
|
|
307 | Refuse to amend during a merge: | |
|
308 | 308 | |
|
309 | 309 | $ hg up -q default |
|
310 | 310 | $ hg merge foo |
@@ -314,9 +314,6 Refuse to amend merges: | |||
|
314 | 314 | abort: cannot amend while merging |
|
315 | 315 | [255] |
|
316 | 316 | $ hg ci -m 'merge' |
|
317 | $ hg ci --amend | |
|
318 | abort: cannot amend merge changesets | |
|
319 | [255] | |
|
320 | 317 | |
|
321 | 318 | Follow copies/renames: |
|
322 | 319 | |
@@ -518,3 +515,231 Test that rewriting leaving instability | |||
|
518 | 515 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
519 | 516 | summary: babar |
|
520 | 517 | |
|
518 | ||
|
519 | Amend a merge changeset (with renames and conflicts from the second parent): | |
|
520 | ||
|
521 | $ hg up -q default | |
|
522 | $ hg branch -q bar | |
|
523 | $ hg cp a aa | |
|
524 | $ hg mv z zz | |
|
525 | $ echo cc > cc | |
|
526 | $ hg add cc | |
|
527 | $ hg ci -m aazzcc | |
|
528 | $ hg up -q default | |
|
529 | $ echo a >> a | |
|
530 | $ echo dd > cc | |
|
531 | $ hg add cc | |
|
532 | $ hg ci -m aa | |
|
533 | $ hg merge -q bar | |
|
534 | warning: conflicts during merge. | |
|
535 | merging cc incomplete! (edit conflicts, then use 'hg resolve --mark') | |
|
536 | [1] | |
|
537 | $ hg resolve -m cc | |
|
538 | $ hg ci -m 'merge bar' | |
|
539 | $ hg log --config diff.git=1 -pr . | |
|
540 | changeset: 23:d51446492733 | |
|
541 | tag: tip | |
|
542 | parent: 22:30d96aeaf27b | |
|
543 | parent: 21:1aa437659d19 | |
|
544 | user: test | |
|
545 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
546 | summary: merge bar | |
|
547 | ||
|
548 | diff --git a/a b/aa | |
|
549 | copy from a | |
|
550 | copy to aa | |
|
551 | diff --git a/cc b/cc | |
|
552 | --- a/cc | |
|
553 | +++ b/cc | |
|
554 | @@ -1,1 +1,5 @@ | |
|
555 | +<<<<<<< local | |
|
556 | dd | |
|
557 | +======= | |
|
558 | +cc | |
|
559 | +>>>>>>> other | |
|
560 | diff --git a/z b/zz | |
|
561 | rename from z | |
|
562 | rename to zz | |
|
563 | ||
|
564 | $ hg debugrename aa | |
|
565 | aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e | |
|
566 | $ hg debugrename zz | |
|
567 | zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a | |
|
568 | $ hg debugrename cc | |
|
569 | cc not renamed | |
|
570 | $ hg ci --amend -m 'merge bar (amend message)' | |
|
571 | $ hg log --config diff.git=1 -pr . | |
|
572 | changeset: 24:59de3dce7a79 | |
|
573 | tag: tip | |
|
574 | parent: 22:30d96aeaf27b | |
|
575 | parent: 21:1aa437659d19 | |
|
576 | user: test | |
|
577 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
578 | summary: merge bar (amend message) | |
|
579 | ||
|
580 | diff --git a/a b/aa | |
|
581 | copy from a | |
|
582 | copy to aa | |
|
583 | diff --git a/cc b/cc | |
|
584 | --- a/cc | |
|
585 | +++ b/cc | |
|
586 | @@ -1,1 +1,5 @@ | |
|
587 | +<<<<<<< local | |
|
588 | dd | |
|
589 | +======= | |
|
590 | +cc | |
|
591 | +>>>>>>> other | |
|
592 | diff --git a/z b/zz | |
|
593 | rename from z | |
|
594 | rename to zz | |
|
595 | ||
|
596 | $ hg debugrename aa | |
|
597 | aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e | |
|
598 | $ hg debugrename zz | |
|
599 | zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a | |
|
600 | $ hg debugrename cc | |
|
601 | cc not renamed | |
|
602 | $ hg mv zz z | |
|
603 | $ hg ci --amend -m 'merge bar (undo rename)' | |
|
604 | $ hg log --config diff.git=1 -pr . | |
|
605 | changeset: 26:7fb89c461f81 | |
|
606 | tag: tip | |
|
607 | parent: 22:30d96aeaf27b | |
|
608 | parent: 21:1aa437659d19 | |
|
609 | user: test | |
|
610 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
611 | summary: merge bar (undo rename) | |
|
612 | ||
|
613 | diff --git a/a b/aa | |
|
614 | copy from a | |
|
615 | copy to aa | |
|
616 | diff --git a/cc b/cc | |
|
617 | --- a/cc | |
|
618 | +++ b/cc | |
|
619 | @@ -1,1 +1,5 @@ | |
|
620 | +<<<<<<< local | |
|
621 | dd | |
|
622 | +======= | |
|
623 | +cc | |
|
624 | +>>>>>>> other | |
|
625 | ||
|
626 | $ hg debugrename z | |
|
627 | z not renamed | |
|
628 | ||
|
629 | Amend a merge changeset (with renames during the merge): | |
|
630 | ||
|
631 | $ hg up -q bar | |
|
632 | $ echo x > x | |
|
633 | $ hg add x | |
|
634 | $ hg ci -m x | |
|
635 | $ hg up -q default | |
|
636 | $ hg merge -q bar | |
|
637 | $ hg mv aa aaa | |
|
638 | $ echo aa >> aaa | |
|
639 | $ hg ci -m 'merge bar again' | |
|
640 | $ hg log --config diff.git=1 -pr . | |
|
641 | changeset: 28:982d7a34ffee | |
|
642 | tag: tip | |
|
643 | parent: 26:7fb89c461f81 | |
|
644 | parent: 27:4c94d5bc65f5 | |
|
645 | user: test | |
|
646 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
647 | summary: merge bar again | |
|
648 | ||
|
649 | diff --git a/aa b/aa | |
|
650 | deleted file mode 100644 | |
|
651 | --- a/aa | |
|
652 | +++ /dev/null | |
|
653 | @@ -1,2 +0,0 @@ | |
|
654 | -a | |
|
655 | -a | |
|
656 | diff --git a/aaa b/aaa | |
|
657 | new file mode 100644 | |
|
658 | --- /dev/null | |
|
659 | +++ b/aaa | |
|
660 | @@ -0,0 +1,3 @@ | |
|
661 | +a | |
|
662 | +a | |
|
663 | +aa | |
|
664 | diff --git a/x b/x | |
|
665 | new file mode 100644 | |
|
666 | --- /dev/null | |
|
667 | +++ b/x | |
|
668 | @@ -0,0 +1,1 @@ | |
|
669 | +x | |
|
670 | ||
|
671 | $ hg debugrename aaa | |
|
672 | aaa renamed from aa:37d9b5d994eab34eda9c16b195ace52c7b129980 | |
|
673 | $ hg mv aaa aa | |
|
674 | $ hg ci --amend -m 'merge bar again (undo rename)' | |
|
675 | $ hg log --config diff.git=1 -pr . | |
|
676 | changeset: 30:522688c0e71b | |
|
677 | tag: tip | |
|
678 | parent: 26:7fb89c461f81 | |
|
679 | parent: 27:4c94d5bc65f5 | |
|
680 | user: test | |
|
681 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
682 | summary: merge bar again (undo rename) | |
|
683 | ||
|
684 | diff --git a/aa b/aa | |
|
685 | --- a/aa | |
|
686 | +++ b/aa | |
|
687 | @@ -1,2 +1,3 @@ | |
|
688 | a | |
|
689 | a | |
|
690 | +aa | |
|
691 | diff --git a/x b/x | |
|
692 | new file mode 100644 | |
|
693 | --- /dev/null | |
|
694 | +++ b/x | |
|
695 | @@ -0,0 +1,1 @@ | |
|
696 | +x | |
|
697 | ||
|
698 | $ hg debugrename aa | |
|
699 | aa not renamed | |
|
700 | $ hg debugrename -r .^ aa | |
|
701 | aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e | |
|
702 | ||
|
703 | Amend a merge changeset (with manifest-level conflicts): | |
|
704 | ||
|
705 | $ hg up -q bar | |
|
706 | $ hg rm aa | |
|
707 | $ hg ci -m 'rm aa' | |
|
708 | $ hg up -q default | |
|
709 | $ echo aa >> aa | |
|
710 | $ hg ci -m aa | |
|
711 | $ hg merge -q bar | |
|
712 | local changed aa which remote deleted | |
|
713 | use (c)hanged version or (d)elete? c | |
|
714 | $ hg ci -m 'merge bar (with conflicts)' | |
|
715 | $ hg log --config diff.git=1 -pr . | |
|
716 | changeset: 33:5f9904c491b8 | |
|
717 | tag: tip | |
|
718 | parent: 32:01780b896f58 | |
|
719 | parent: 31:67db8847a540 | |
|
720 | user: test | |
|
721 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
722 | summary: merge bar (with conflicts) | |
|
723 | ||
|
724 | ||
|
725 | $ hg rm aa | |
|
726 | $ hg ci --amend -m 'merge bar (with conflicts, amended)' | |
|
727 | $ hg log --config diff.git=1 -pr . | |
|
728 | changeset: 35:6ce0c89781a3 | |
|
729 | tag: tip | |
|
730 | parent: 32:01780b896f58 | |
|
731 | parent: 31:67db8847a540 | |
|
732 | user: test | |
|
733 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
734 | summary: merge bar (with conflicts, amended) | |
|
735 | ||
|
736 | diff --git a/aa b/aa | |
|
737 | deleted file mode 100644 | |
|
738 | --- a/aa | |
|
739 | +++ /dev/null | |
|
740 | @@ -1,4 +0,0 @@ | |
|
741 | -a | |
|
742 | -a | |
|
743 | -aa | |
|
744 | -aa | |
|
745 |
General Comments 0
You need to be logged in to leave comments.
Login now