[PATCH 1 of 5 v3] merge: refactor action calculation into function

David Schleimer dschleimer at fb.com
Tue Dec 4 20:58:36 UTC 2012


# HG changeset patch
# User David Schleimer <dschleimer at fb.com>
# Date 1354654458 28800
# Node ID 5b661fc9662414d64156489e6503aca683f38cbe
# Parent  0a5ae98da1ec3efacd371fe3cfca6f9584f94df3
merge: refactor action calculation into function

This pulls the code used to calculate the changes that need to happen
during merge.update() into a separate function.  This is not useful on
its own, but is instead preparatory to performing grafts in memory
when there are no potential conflicts.

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -448,6 +448,26 @@
 
     return updated, merged, removed, unresolved
 
+def calculateupdates(repo, tctx, mctx, ancestor, branchmerge, force, partial):
+    "Calculate the actions needed to merge mctx into tctx"
+    action = []
+    folding = not util.checkcase(repo.path)
+    if folding:
+        # collision check is not needed for clean update
+        if (not branchmerge and
+            (force or not tctx.dirty(missing=True, branch=False))):
+            _checkcollision(mctx, None)
+        else:
+            _checkcollision(mctx, tctx)
+    if not force:
+        _checkunknown(repo, tctx, mctx)
+    action += _forgetremoved(tctx, mctx, branchmerge)
+    action += manifestmerge(repo, tctx, mctx,
+                            ancestor,
+                            force and not branchmerge,
+                            partial)
+    return action
+
 def recordupdates(repo, action, branchmerge):
     "record merge actions to the dirstate"
 
@@ -609,19 +629,7 @@
                 pa = p1
 
         ### calculate phase
-        action = []
-        folding = not util.checkcase(repo.path)
-        if folding:
-            # collision check is not needed for clean update
-            if (not branchmerge and
-                (force or not wc.dirty(missing=True, branch=False))):
-                _checkcollision(p2, None)
-            else:
-                _checkcollision(p2, (wc, pa))
-        if not force:
-            _checkunknown(repo, wc, p2)
-        action += _forgetremoved(wc, p2, branchmerge)
-        action += manifestmerge(repo, wc, p2, pa, overwrite, partial)
+        action = calculateupdates(repo, wc, p2, pa, branchmerge, force, partial)
 
         ### apply phase
         if not branchmerge: # just jump to the new rev


More information about the Mercurial-devel mailing list