[PATCH 3 of 4] merge: allow passing in a memctx with the rctx argument (RFC DO NOT COMMIT)

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Aug 19 02:03:18 CDT 2014



On 08/18/2014 07:42 PM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley at gmail.com>
> # Date 1407357667 18000
> #      Wed Aug 06 15:41:07 2014 -0500
> # Node ID ed4082b72da600548d6c9ecec102a3639e9bf3e0
> # Parent  d1a21cc0bc4ba5764a1f8760fd041a91939b4d00
> merge: allow passing in a memctx with the rctx argument (RFC DO NOT COMMIT)
>
> This is a hack to do an in-memory merge without changing too much code. Future
> patches will instead extract the parts of merge.update so that a cleaner
> approach can be used without changing the signature of the function.

I do not see this patch are specifically dirty. You are adding a new 
optional argument to specify the "destination" of the merge. Sounds like 
reasonable. Would just needs some documentation.

> 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=branchmerge)]
>
>           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"))

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list