mercurial/merge.py
changeset 43796 ebfd349eac46
parent 43787 be8552f25cab
child 43797 fb07126dadbe
equal deleted inserted replaced
43795:0f6782df1100 43796:ebfd349eac46
  2580         )
  2580         )
  2581     return stats
  2581     return stats
  2582 
  2582 
  2583 
  2583 
  2584 def graft(
  2584 def graft(
  2585     repo, ctx, pctx, labels=None, keepparent=False, keepconflictparent=False
  2585     repo, ctx, base, labels=None, keepparent=False, keepconflictparent=False
  2586 ):
  2586 ):
  2587     """Do a graft-like merge.
  2587     """Do a graft-like merge.
  2588 
  2588 
  2589     This is a merge where the merge ancestor is chosen such that one
  2589     This is a merge where the merge ancestor is chosen such that one
  2590     or more changesets are grafted onto the current changeset. In
  2590     or more changesets are grafted onto the current changeset. In
  2591     addition to the merge, this fixes up the dirstate to include only
  2591     addition to the merge, this fixes up the dirstate to include only
  2592     a single parent (if keepparent is False) and tries to duplicate any
  2592     a single parent (if keepparent is False) and tries to duplicate any
  2593     renames/copies appropriately.
  2593     renames/copies appropriately.
  2594 
  2594 
  2595     ctx - changeset to rebase
  2595     ctx - changeset to rebase
  2596     pctx - merge base, usually ctx.p1()
  2596     base - merge base, usually ctx.p1()
  2597     labels - merge labels eg ['local', 'graft']
  2597     labels - merge labels eg ['local', 'graft']
  2598     keepparent - keep second parent if any
  2598     keepparent - keep second parent if any
  2599     keepconflictparent - if unresolved, keep parent used for the merge
  2599     keepconflictparent - if unresolved, keep parent used for the merge
  2600 
  2600 
  2601     """
  2601     """
  2610     stats = update(
  2610     stats = update(
  2611         repo,
  2611         repo,
  2612         ctx.node(),
  2612         ctx.node(),
  2613         True,
  2613         True,
  2614         True,
  2614         True,
  2615         pctx.node(),
  2615         base.node(),
  2616         mergeancestor=mergeancestor,
  2616         mergeancestor=mergeancestor,
  2617         labels=labels,
  2617         labels=labels,
  2618     )
  2618     )
  2619 
  2619 
  2620     if keepconflictparent and stats.unresolvedcount:
  2620     if keepconflictparent and stats.unresolvedcount:
  2621         pother = ctx.node()
  2621         pother = ctx.node()
  2622     else:
  2622     else:
  2623         pother = nullid
  2623         pother = nullid
  2624         parents = ctx.parents()
  2624         parents = ctx.parents()
  2625         if keepparent and len(parents) == 2 and pctx in parents:
  2625         if keepparent and len(parents) == 2 and base in parents:
  2626             parents.remove(pctx)
  2626             parents.remove(base)
  2627             pother = parents[0].node()
  2627             pother = parents[0].node()
  2628 
  2628 
  2629     with repo.dirstate.parentchange():
  2629     with repo.dirstate.parentchange():
  2630         repo.setparents(repo[b'.'].node(), pother)
  2630         repo.setparents(repo[b'.'].node(), pother)
  2631         repo.dirstate.write(repo.currenttransaction())
  2631         repo.dirstate.write(repo.currenttransaction())
  2632         # fix up dirstate for copies and renames
  2632         # fix up dirstate for copies and renames
  2633         copies.duplicatecopies(repo, repo[None], ctx.rev(), pctx.rev())
  2633         copies.duplicatecopies(repo, repo[None], ctx.rev(), base.rev())
  2634     return stats
  2634     return stats
  2635 
  2635 
  2636 
  2636 
  2637 def purge(
  2637 def purge(
  2638     repo,
  2638     repo,