Mercurial > hg
changeset 44211:fc7175df6359
graft: let caller pass in overlayworkingctx to merge.graft()
Passing in a different `wctx` than `repo[None]` is useful because it
allows the caller to decide to not touch the working directory.
Differential Revision: https://phab.mercurial-scm.org/D8026
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 10 Jan 2020 13:12:24 -0800 |
parents | d0c3eead515a |
children | cb8b67016110 |
files | mercurial/merge.py |
diffstat | 1 files changed, 17 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Wed Jan 29 23:14:31 2020 -0800 +++ b/mercurial/merge.py Fri Jan 10 13:12:24 2020 -0800 @@ -2590,7 +2590,13 @@ def graft( - repo, ctx, base, labels=None, keepparent=False, keepconflictparent=False + repo, + ctx, + base, + labels=None, + keepparent=False, + keepconflictparent=False, + wctx=None, ): """Do a graft-like merge. @@ -2613,7 +2619,7 @@ # to copy commits), and 2) informs update that the incoming changes are # newer than the destination so it doesn't prompt about "remote changed foo # which local deleted". - wctx = repo[None] + wctx = wctx or repo[None] pctx = wctx.p1() mergeancestor = repo.changelog.isancestor(pctx.node(), ctx.node()) @@ -2625,6 +2631,7 @@ base.node(), mergeancestor=mergeancestor, labels=labels, + wc=wctx, ) if keepconflictparent and stats.unresolvedcount: @@ -2639,11 +2646,16 @@ if pother == pctx.node(): pother = nullid - with repo.dirstate.parentchange(): - repo.setparents(pctx.node(), pother) - repo.dirstate.write(repo.currenttransaction()) + if wctx.isinmemory(): + wctx.setparents(pctx.node(), pother) # fix up dirstate for copies and renames copies.graftcopies(wctx, ctx, base) + else: + with repo.dirstate.parentchange(): + repo.setparents(pctx.node(), pother) + repo.dirstate.write(repo.currenttransaction()) + # fix up dirstate for copies and renames + copies.graftcopies(wctx, ctx, base) return stats