Patchwork D3692: merge: add a 'keepconflictparent' argument to graft

login
register
mail settings
Submitter phabricator
Date June 29, 2018, 7:29 p.m.
Message ID <417ffb33726696f92fc84b40412c7258@localhost.localdomain>
Download mbox | patch
Permalink /patch/32510/
State Not Applicable
Headers show

Comments

phabricator - June 29, 2018, 7:29 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd4be8ea8f22d: merge: add a &#039;keepconflictparent&#039; argument to graft (authored by lothiraldan, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3692?vs=8981&id=9361

REVISION DETAIL
  https://phab.mercurial-scm.org/D3692

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS




To: lothiraldan, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -2194,7 +2194,8 @@ 
                   error=stats.unresolvedcount)
     return stats
 
-def graft(repo, ctx, pctx, labels, keepparent=False):
+def graft(repo, ctx, pctx, labels, keepparent=False,
+          keepconflictparent=False):
     """Do a graft-like merge.
 
     This is a merge where the merge ancestor is chosen such that one
@@ -2207,6 +2208,7 @@ 
     pctx - merge base, usually ctx.p1()
     labels - merge labels eg ['local', 'graft']
     keepparent - keep second parent if any
+    keepparent - if unresolved, keep parent used for the merge
 
     """
     # If we're grafting a descendant onto an ancestor, be sure to pass
@@ -2220,11 +2222,15 @@ 
     stats = update(repo, ctx.node(), True, True, pctx.node(),
                    mergeancestor=mergeancestor, labels=labels)
 
-    pother = nullid
-    parents = ctx.parents()
-    if keepparent and len(parents) == 2 and pctx in parents:
-        parents.remove(pctx)
-        pother = parents[0].node()
+
+    if keepconflictparent and stats.unresolvedcount:
+        pother = ctx.node()
+    else:
+        pother = nullid
+        parents = ctx.parents()
+        if keepparent and len(parents) == 2 and pctx in parents:
+            parents.remove(pctx)
+            pother = parents[0].node()
 
     with repo.dirstate.parentchange():
         repo.setparents(repo['.'].node(), pother)