From patchwork Thu Aug 7 19:52:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7,of,8,RFC] merge: allow passing in a memctx with the rctx argument From: Sean Farley X-Patchwork-Id: 5323 Message-Id: To: mercurial-devel@selenic.com Date: Thu, 07 Aug 2014 14:52:14 -0500 # HG changeset patch # User Sean Farley # 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 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"))