Patchwork [7,of,8,RFC] merge: allow passing in a memctx with the rctx argument

login
register
mail settings
Submitter Sean Farley
Date Aug. 7, 2014, 7:52 p.m.
Message ID <fd349f8559b631416eec.1407441134@laptop.att.net>
Download mbox | patch
Permalink /patch/5323/
State Accepted
Headers show

Comments

Sean Farley - Aug. 7, 2014, 7:52 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1407357667 18000
#      Wed Aug 06 15:41:07 2014 -0500
# Node ID fd349f8559b631416eecd1c7f3a320fe075a3d76
# Parent  3bfc7e57998670bac7c9bc0f822d8b581e61cd01
merge: allow passing in a memctx with the rctx argument

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -945,11 +945,11 @@  def recordupdates(repo, actions, branchm
             repo.dirstate.copy(f0, f)
         else:
             repo.dirstate.normal(f)
 
 def update(repo, node, branchmerge, force, partial, ancestor=None,
-           mergeancestor=False, labels=None):
+           mergeancestor=False, labels=None, rctx=None):
     """
     Perform a merge between the working directory and the given node
 
     node = the node to update to, or None if unspecified
     branchmerge = whether to merge between branches
@@ -992,17 +992,22 @@  def update(repo, node, branchmerge, forc
     """
 
     onode = node
     wlock = repo.wlock()
     try:
-        wc = repo[None]
+        wc = rctx
+        if wc is None:
+            wc = repo[None]
         pl = wc.parents()
         p1 = pl[0]
         pas = [None]
         if ancestor:
             pas = [repo[ancestor]]
 
+        if rctx is not None:
+            node = pl[1]
+
         if node is None:
             # Here is where we should consider bookmarks, divergent bookmarks,
             # foreground changesets (successors), and tip of current branch;
             # but currently we are only checking the branch tips.
             try:
@@ -1051,11 +1056,11 @@  def update(repo, node, branchmerge, forc
                 pas = [p1.ancestor(p2, warn=True)]
 
         fp1, fp2, xp1, xp2 = p1.node(), p2.node(), str(p1), str(p2)
 
         ### check phase
-        if not overwrite and len(pl) > 1:
+        if not overwrite and len(pl) > 1 and rctx is None:
             raise util.Abort(_("outstanding uncommitted merges"))
         if branchmerge:
             if pas == [p2]:
                 raise util.Abort(_("merging with a working directory ancestor"
                                    " has no effect"))