Patchwork [1,of,2] merge: rename p1 to wctx in manifestmerge

login
register
mail settings
Submitter Bryan O'Sullivan
Date Feb. 9, 2013, 9:23 p.m.
Message ID <68226cb20b4ad583c3bd.1360444985@australite.local>
Download mbox | patch
Permalink /patch/907/
State Superseded
Commit d9ff580fcaa26199ab8d76f35f81169431ce84b3
Headers show

Comments

Bryan O'Sullivan - Feb. 9, 2013, 9:23 p.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano@fb.com>
# Date 1360444976 0
# Node ID 68226cb20b4ad583c3bdf54044c59ea979ec6e7f
# Parent  712d538d7512cbfd079c54f460243611a0593612
merge: rename p1 to wctx in manifestmerge

This is always a workingctx, and this name is more in line with other
functions in this module.
Mads Kiilerich - Feb. 9, 2013, 9:28 p.m.
On 02/09/2013 10:23 PM, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bryano@fb.com>
> # Date 1360444976 0
> # Node ID 68226cb20b4ad583c3bdf54044c59ea979ec6e7f
> # Parent  712d538d7512cbfd079c54f460243611a0593612
> merge: rename p1 to wctx in manifestmerge
>
> This is always a workingctx, and this name is more in line with other
> functions in this module.

I would like to go in the opposite direction and make manifestmerge more 
symmetric and independent of wctx and strategy for applying changes to a 
working directory. That would bring it closer to being usable for in 
memory merge.

/Mads

> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -185,7 +185,7 @@ def _forgetremoved(wctx, mctx, branchmer
>   
>       return actions
>   
> -def manifestmerge(repo, p1, p2, pa, branchmerge, force, partial):
> +def manifestmerge(repo, wctx, p2, pa, branchmerge, force, partial):
>       """
>       Merge p1 and p2 with ancestor pa and generate merge action list
>   
> @@ -197,11 +197,11 @@ def manifestmerge(repo, p1, p2, pa, bran
>       actions, copy, movewithdir = [], {}, {}
>   
>       if overwrite:
> -        pa = p1
> +        pa = wctx
>       elif pa == p2: # backwards
> -        pa = p1.p1()
> +        pa = wctx.p1()
>       elif pa and repo.ui.configbool("merge", "followcopies", True):
> -        ret = copies.mergecopies(repo, p1, p2, pa)
> +        ret = copies.mergecopies(repo, wctx, p2, pa)
>           copy, movewithdir, diverge, renamedelete = ret
>           for of, fl in diverge.iteritems():
>               actions.append((of, "dr", (fl,), "divergent renames"))
> @@ -211,16 +211,16 @@ def manifestmerge(repo, p1, p2, pa, bran
>       repo.ui.note(_("resolving manifests\n"))
>       repo.ui.debug(" branchmerge: %s, force: %s, partial: %s\n"
>                     % (bool(branchmerge), bool(force), bool(partial)))
> -    repo.ui.debug(" ancestor: %s, local: %s, remote: %s\n" % (pa, p1, p2))
> +    repo.ui.debug(" ancestor: %s, local: %s, remote: %s\n" % (pa, wctx, p2))
>   
> -    m1, m2, ma = p1.manifest(), p2.manifest(), pa.manifest()
> +    m1, m2, ma = wctx.manifest(), p2.manifest(), pa.manifest()
>       copied = set(copy.values())
>       copied.update(movewithdir.values())
>   
>       if '.hgsubstate' in m1:
>           # check whether sub state is modified
> -        for s in sorted(p1.substate):
> -            if p1.sub(s).dirty():
> +        for s in sorted(wctx.substate):
> +            if wctx.sub(s).dirty():
>                   m1['.hgsubstate'] += "+"
>                   break
>   
> @@ -300,7 +300,7 @@ def manifestmerge(repo, p1, p2, pa, bran
>               if force and not branchmerge:
>                   actions.append((f, "g", (m2.flags(f),), "remote created"))
>               else:
> -                different = _checkunknownfile(repo, p1, p2, f)
> +                different = _checkunknownfile(repo, wctx, p2, f)
>                   if force and branchmerge and different:
>                       actions.append((f, "m", (f, f, False),
>                                       "remote differs from untracked local"))
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Bryan O'Sullivan - Feb. 9, 2013, 9:30 p.m.
On Sat, Feb 9, 2013 at 1:28 PM, Mads Kiilerich <mads@kiilerich.com> wrote:

> I would like to go in the opposite direction and make manifestmerge more
> symmetric and independent of wctx and strategy for applying changes to a
> working directory. That would bring it closer to being usable for in memory
> merge.
>

That makes sense. I still applied the patch for now - when you have time to
work on improving its symmetry, please feel free to change the name back.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -185,7 +185,7 @@  def _forgetremoved(wctx, mctx, branchmer
 
     return actions
 
-def manifestmerge(repo, p1, p2, pa, branchmerge, force, partial):
+def manifestmerge(repo, wctx, p2, pa, branchmerge, force, partial):
     """
     Merge p1 and p2 with ancestor pa and generate merge action list
 
@@ -197,11 +197,11 @@  def manifestmerge(repo, p1, p2, pa, bran
     actions, copy, movewithdir = [], {}, {}
 
     if overwrite:
-        pa = p1
+        pa = wctx
     elif pa == p2: # backwards
-        pa = p1.p1()
+        pa = wctx.p1()
     elif pa and repo.ui.configbool("merge", "followcopies", True):
-        ret = copies.mergecopies(repo, p1, p2, pa)
+        ret = copies.mergecopies(repo, wctx, p2, pa)
         copy, movewithdir, diverge, renamedelete = ret
         for of, fl in diverge.iteritems():
             actions.append((of, "dr", (fl,), "divergent renames"))
@@ -211,16 +211,16 @@  def manifestmerge(repo, p1, p2, pa, bran
     repo.ui.note(_("resolving manifests\n"))
     repo.ui.debug(" branchmerge: %s, force: %s, partial: %s\n"
                   % (bool(branchmerge), bool(force), bool(partial)))
-    repo.ui.debug(" ancestor: %s, local: %s, remote: %s\n" % (pa, p1, p2))
+    repo.ui.debug(" ancestor: %s, local: %s, remote: %s\n" % (pa, wctx, p2))
 
-    m1, m2, ma = p1.manifest(), p2.manifest(), pa.manifest()
+    m1, m2, ma = wctx.manifest(), p2.manifest(), pa.manifest()
     copied = set(copy.values())
     copied.update(movewithdir.values())
 
     if '.hgsubstate' in m1:
         # check whether sub state is modified
-        for s in sorted(p1.substate):
-            if p1.sub(s).dirty():
+        for s in sorted(wctx.substate):
+            if wctx.sub(s).dirty():
                 m1['.hgsubstate'] += "+"
                 break
 
@@ -300,7 +300,7 @@  def manifestmerge(repo, p1, p2, pa, bran
             if force and not branchmerge:
                 actions.append((f, "g", (m2.flags(f),), "remote created"))
             else:
-                different = _checkunknownfile(repo, p1, p2, f)
+                different = _checkunknownfile(repo, wctx, p2, f)
                 if force and branchmerge and different:
                     actions.append((f, "m", (f, f, False),
                                     "remote differs from untracked local"))