1511 # Merge phase |
1511 # Merge phase |
1512 # Update to destination and merge it with local |
1512 # Update to destination and merge it with local |
1513 p1ctx = repo[p1] |
1513 p1ctx = repo[p1] |
1514 if wctx.isinmemory(): |
1514 if wctx.isinmemory(): |
1515 wctx.setbase(p1ctx) |
1515 wctx.setbase(p1ctx) |
|
1516 scope = util.nullcontextmanager |
1516 else: |
1517 else: |
1517 if repo[b'.'].rev() != p1: |
1518 if repo[b'.'].rev() != p1: |
1518 repo.ui.debug(b" update to %d:%s\n" % (p1, p1ctx)) |
1519 repo.ui.debug(b" update to %d:%s\n" % (p1, p1ctx)) |
1519 mergemod.clean_update(p1ctx) |
1520 mergemod.clean_update(p1ctx) |
1520 else: |
1521 else: |
1521 repo.ui.debug(b" already in destination\n") |
1522 repo.ui.debug(b" already in destination\n") |
|
1523 scope = lambda: repo.dirstate.changing_parents(repo) |
1522 # This is, alas, necessary to invalidate workingctx's manifest cache, |
1524 # This is, alas, necessary to invalidate workingctx's manifest cache, |
1523 # as well as other data we litter on it in other places. |
1525 # as well as other data we litter on it in other places. |
1524 wctx = repo[None] |
1526 wctx = repo[None] |
1525 repo.dirstate.write(repo.currenttransaction()) |
1527 repo.dirstate.write(repo.currenttransaction()) |
1526 ctx = repo[rev] |
1528 ctx = repo[rev] |
1527 repo.ui.debug(b" merge against %d:%s\n" % (rev, ctx)) |
1529 repo.ui.debug(b" merge against %d:%s\n" % (rev, ctx)) |
1528 if base is not None: |
1530 if base is not None: |
1529 repo.ui.debug(b" detach base %d:%s\n" % (base, repo[base])) |
1531 repo.ui.debug(b" detach base %d:%s\n" % (base, repo[base])) |
1530 |
1532 |
1531 # See explanation in merge.graft() |
1533 with scope(): |
1532 mergeancestor = repo.changelog.isancestor(p1ctx.node(), ctx.node()) |
1534 # See explanation in merge.graft() |
1533 stats = mergemod._update( |
1535 mergeancestor = repo.changelog.isancestor(p1ctx.node(), ctx.node()) |
1534 repo, |
1536 stats = mergemod._update( |
1535 rev, |
1537 repo, |
1536 branchmerge=True, |
1538 rev, |
1537 force=True, |
1539 branchmerge=True, |
1538 ancestor=base, |
1540 force=True, |
1539 mergeancestor=mergeancestor, |
1541 ancestor=base, |
1540 labels=[b'dest', b'source', b'parent of source'], |
1542 mergeancestor=mergeancestor, |
1541 wc=wctx, |
1543 labels=[b'dest', b'source', b'parent of source'], |
1542 ) |
1544 wc=wctx, |
1543 wctx.setparents(p1ctx.node(), repo[p2].node()) |
1545 ) |
1544 if collapse: |
1546 wctx.setparents(p1ctx.node(), repo[p2].node()) |
1545 copies.graftcopies(wctx, ctx, p1ctx) |
1547 if collapse: |
1546 else: |
1548 copies.graftcopies(wctx, ctx, p1ctx) |
1547 # If we're not using --collapse, we need to |
1549 else: |
1548 # duplicate copies between the revision we're |
1550 # If we're not using --collapse, we need to |
1549 # rebasing and its first parent. |
1551 # duplicate copies between the revision we're |
1550 copies.graftcopies(wctx, ctx, ctx.p1()) |
1552 # rebasing and its first parent. |
|
1553 copies.graftcopies(wctx, ctx, ctx.p1()) |
1551 |
1554 |
1552 if stats.unresolvedcount > 0: |
1555 if stats.unresolvedcount > 0: |
1553 if wctx.isinmemory(): |
1556 if wctx.isinmemory(): |
1554 raise error.InMemoryMergeConflictsError() |
1557 raise error.InMemoryMergeConflictsError() |
1555 else: |
1558 else: |