##// END OF EJS Templates
fix: fix handling of merge commits by using overlayworkingctx...
Kyle Lippincott -
r44414:eebdd670 default
parent child Browse files
Show More
@@ -730,36 +730,40 b' def replacerev(ui, repo, ctx, filedata, '
730 730 ):
731 731 return
732 732
733 def filectxfn(repo, memctx, path):
734 if path not in ctx:
735 return None
736 fctx = ctx[path]
737 copysource = fctx.copysource()
738 return context.memfilectx(
739 repo,
740 memctx,
741 path=fctx.path(),
742 data=filedata.get(path, fctx.data()),
743 islink=fctx.islink(),
744 isexec=fctx.isexec(),
745 copysource=copysource,
746 )
747
748 733 extra = ctx.extra().copy()
749 734 extra[b'fix_source'] = ctx.hex()
750 735
751 memctx = context.memctx(
736 wctx = context.overlayworkingctx(repo)
737 wctx.setbase(repo[newp1node])
738 merge.update(
752 739 repo,
753 parents=(newp1node, newp2node),
740 ctx.rev(),
741 branchmerge=False,
742 force=True,
743 ancestor=p1rev,
744 mergeancestor=False,
745 wc=wctx,
746 )
747 copies.duplicatecopies(
748 repo, wctx, ctx.rev(), ctx.p1().rev(), skiprev=newp1node
749 )
750
751 for path in filedata.keys():
752 fctx = ctx[path]
753 copysource = fctx.copysource()
754 wctx.write(path, filedata[path], flags=fctx.flags())
755 if copysource:
756 wctx.markcopied(path, copysource)
757
758 memctx = wctx.tomemctx(
754 759 text=ctx.description(),
755 files=set(ctx.files()) | set(filedata.keys()),
756 filectxfn=filectxfn,
757 user=ctx.user(),
760 branch=ctx.branch(),
761 extra=extra,
758 762 date=ctx.date(),
759 extra=extra,
760 branch=ctx.branch(),
761 editor=None,
763 parents=(newp1node, newp2node),
764 user=ctx.user(),
762 765 )
766
763 767 sucnode = memctx.commit()
764 768 prenode = ctx.node()
765 769 if prenode == sucnode:
@@ -1456,3 +1456,242 b' changes.'
1456 1456 2 through 2
1457 1457
1458 1458 $ cd ..
1459
1460 Test various cases around merges. We were previously dropping files if they were
1461 created on only the p2 side of the merge, so let's test permutations of:
1462 * added, was fixed
1463 * added, considered for fixing but was already good
1464 * added, not considered for fixing
1465 * modified, was fixed
1466 * modified, considered for fixing but was already good
1467 * modified, not considered for fixing
1468
1469 Before the bug was fixed where we would drop files, this test demonstrated the
1470 following issues:
1471 * new_in_r1.ignored, new_in_r1_already_good.changed, and
1472 > mod_in_r1_already_good.changed were NOT in the manifest for the merge commit
1473 * mod_in_r1.ignored had its contents from r0, NOT r1.
1474
1475 We're also setting a named branch for every commit to demonstrate that the
1476 branch is kept intact and there aren't issues updating to another branch in the
1477 middle of fix.
1478
1479 $ hg init merge_keeps_files
1480 $ cd merge_keeps_files
1481 $ for f in r0 mod_in_r1 mod_in_r2 mod_in_merge mod_in_child; do
1482 > for c in changed whole ignored; do
1483 > printf "hello\n" > $f.$c
1484 > done
1485 > printf "HELLO\n" > "mod_in_${f}_already_good.changed"
1486 > done
1487 $ hg branch -q r0
1488 $ hg ci -Aqm 'r0'
1489 $ hg phase -p
1490 $ make_test_files() {
1491 > printf "world\n" >> "mod_in_$1.changed"
1492 > printf "world\n" >> "mod_in_$1.whole"
1493 > printf "world\n" >> "mod_in_$1.ignored"
1494 > printf "WORLD\n" >> "mod_in_$1_already_good.changed"
1495 > printf "new in $1\n" > "new_in_$1.changed"
1496 > printf "new in $1\n" > "new_in_$1.whole"
1497 > printf "new in $1\n" > "new_in_$1.ignored"
1498 > printf "ALREADY GOOD, NEW IN THIS REV\n" > "new_in_$1_already_good.changed"
1499 > }
1500 $ make_test_commit() {
1501 > make_test_files "$1"
1502 > hg branch -q "$1"
1503 > hg ci -Aqm "$2"
1504 > }
1505 $ make_test_commit r1 "merge me, pt1"
1506 $ hg co -q ".^"
1507 $ make_test_commit r2 "merge me, pt2"
1508 $ hg merge -qr 1
1509 $ make_test_commit merge "evil merge"
1510 $ make_test_commit child "child of merge"
1511 $ make_test_files wdir
1512 $ hg fix -r 'not public()' -w
1513 $ hg log -G -T'{rev}:{shortest(node,8)}: branch:{branch} desc:{desc}'
1514 @ 8:c22ce900: branch:child desc:child of merge
1515 |
1516 o 7:5a30615a: branch:merge desc:evil merge
1517 |\
1518 | o 6:4e5acdc4: branch:r2 desc:merge me, pt2
1519 | |
1520 o | 5:eea01878: branch:r1 desc:merge me, pt1
1521 |/
1522 o 0:0c548d87: branch:r0 desc:r0
1523
1524 $ hg files -r tip
1525 mod_in_child.changed
1526 mod_in_child.ignored
1527 mod_in_child.whole
1528 mod_in_child_already_good.changed
1529 mod_in_merge.changed
1530 mod_in_merge.ignored
1531 mod_in_merge.whole
1532 mod_in_merge_already_good.changed
1533 mod_in_mod_in_child_already_good.changed
1534 mod_in_mod_in_merge_already_good.changed
1535 mod_in_mod_in_r1_already_good.changed
1536 mod_in_mod_in_r2_already_good.changed
1537 mod_in_r0_already_good.changed
1538 mod_in_r1.changed
1539 mod_in_r1.ignored
1540 mod_in_r1.whole
1541 mod_in_r1_already_good.changed
1542 mod_in_r2.changed
1543 mod_in_r2.ignored
1544 mod_in_r2.whole
1545 mod_in_r2_already_good.changed
1546 new_in_child.changed
1547 new_in_child.ignored
1548 new_in_child.whole
1549 new_in_child_already_good.changed
1550 new_in_merge.changed
1551 new_in_merge.ignored
1552 new_in_merge.whole
1553 new_in_merge_already_good.changed
1554 new_in_r1.changed
1555 new_in_r1.ignored
1556 new_in_r1.whole
1557 new_in_r1_already_good.changed
1558 new_in_r2.changed
1559 new_in_r2.ignored
1560 new_in_r2.whole
1561 new_in_r2_already_good.changed
1562 r0.changed
1563 r0.ignored
1564 r0.whole
1565 $ for f in "$(hg files -r tip)"; do hg cat -r tip $f -T'{path}:\n{data}\n'; done
1566 mod_in_child.changed:
1567 hello
1568 WORLD
1569
1570 mod_in_child.ignored:
1571 hello
1572 world
1573
1574 mod_in_child.whole:
1575 HELLO
1576 WORLD
1577
1578 mod_in_child_already_good.changed:
1579 WORLD
1580
1581 mod_in_merge.changed:
1582 hello
1583 WORLD
1584
1585 mod_in_merge.ignored:
1586 hello
1587 world
1588
1589 mod_in_merge.whole:
1590 HELLO
1591 WORLD
1592
1593 mod_in_merge_already_good.changed:
1594 WORLD
1595
1596 mod_in_mod_in_child_already_good.changed:
1597 HELLO
1598
1599 mod_in_mod_in_merge_already_good.changed:
1600 HELLO
1601
1602 mod_in_mod_in_r1_already_good.changed:
1603 HELLO
1604
1605 mod_in_mod_in_r2_already_good.changed:
1606 HELLO
1607
1608 mod_in_r0_already_good.changed:
1609 HELLO
1610
1611 mod_in_r1.changed:
1612 hello
1613 WORLD
1614
1615 mod_in_r1.ignored:
1616 hello
1617 world
1618
1619 mod_in_r1.whole:
1620 HELLO
1621 WORLD
1622
1623 mod_in_r1_already_good.changed:
1624 WORLD
1625
1626 mod_in_r2.changed:
1627 hello
1628 WORLD
1629
1630 mod_in_r2.ignored:
1631 hello
1632 world
1633
1634 mod_in_r2.whole:
1635 HELLO
1636 WORLD
1637
1638 mod_in_r2_already_good.changed:
1639 WORLD
1640
1641 new_in_child.changed:
1642 NEW IN CHILD
1643
1644 new_in_child.ignored:
1645 new in child
1646
1647 new_in_child.whole:
1648 NEW IN CHILD
1649
1650 new_in_child_already_good.changed:
1651 ALREADY GOOD, NEW IN THIS REV
1652
1653 new_in_merge.changed:
1654 NEW IN MERGE
1655
1656 new_in_merge.ignored:
1657 new in merge
1658
1659 new_in_merge.whole:
1660 NEW IN MERGE
1661
1662 new_in_merge_already_good.changed:
1663 ALREADY GOOD, NEW IN THIS REV
1664
1665 new_in_r1.changed:
1666 NEW IN R1
1667
1668 new_in_r1.ignored:
1669 new in r1
1670
1671 new_in_r1.whole:
1672 NEW IN R1
1673
1674 new_in_r1_already_good.changed:
1675 ALREADY GOOD, NEW IN THIS REV
1676
1677 new_in_r2.changed:
1678 NEW IN R2
1679
1680 new_in_r2.ignored:
1681 new in r2
1682
1683 new_in_r2.whole:
1684 NEW IN R2
1685
1686 new_in_r2_already_good.changed:
1687 ALREADY GOOD, NEW IN THIS REV
1688
1689 r0.changed:
1690 hello
1691
1692 r0.ignored:
1693 hello
1694
1695 r0.whole:
1696 hello
1697
General Comments 0
You need to be logged in to leave comments. Login now