[PATCH 3 of 6 V2] merge: let _resolvetrivial() work on the file->action dict

Martin von Zweigbergk martinvonz at google.com
Mon Dec 22 15:36:19 CST 2014


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1418360776 28800
#      Thu Dec 11 21:06:16 2014 -0800
# Node ID 8ade20976e1484ad0edffe4e13949f442dce3a5d
# Parent  28e63496413bfb7e6e97f4347c224e28fd4c4b73
merge: let _resolvetrivial() work on the file->action dict

By moving the conversion from the file->action dict after
_resolvetrivial(), we greatly simplify and clarify that method.

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -531,25 +531,13 @@
     """Resolves false conflicts where the nodeid changed but the content
        remained the same."""
 
-    cdactions = []
-    for action in actions['cd']:
-        f = action[0]
-        if f in ancestor and not wctx[f].cmp(ancestor[f]):
+    for f, (m, args, msg) in actions.items():
+        if m == 'cd' and f in ancestor and not wctx[f].cmp(ancestor[f]):
             # local did change but ended up with same content
-            actions['r'].append((f, None, "prompt same"))
-        else:
-            cdactions.append(action)
-    actions['cd'] = cdactions
-
-    dcactions = []
-    for action in actions['dc']:
-        f = action[0]
-        if f in ancestor and not mctx[f].cmp(ancestor[f]):
+            actions[f] = 'r', None, "prompt same"
+        elif m == 'dc' and f in ancestor and not mctx[f].cmp(ancestor[f]):
             # remote did change but ended up with same content
-            pass # don't get = keep local deleted
-        else:
-            dcactions.append(action)
-    actions['dc'] = dcactions
+            del actions[f] # don't get = keep local deleted
 
 def calculateupdates(repo, wctx, mctx, ancestors, branchmerge, force, partial,
                      acceptremote, followcopies):
@@ -627,14 +615,14 @@
             continue
         repo.ui.note(_('end of auction\n\n'))
 
+    _resolvetrivial(repo, wctx, mctx, ancestors[0], actions)
+
     # Convert to dictionary-of-lists format
     actionbyfile = actions
     actions = dict((m, []) for m in 'a f g cd dc r dm dg m e k'.split())
     for f, (m, args, msg) in actionbyfile.iteritems():
         actions[m].append((f, args, msg))
 
-    _resolvetrivial(repo, wctx, mctx, ancestors[0], actions)
-
     if wctx.rev() is None:
         ractions, factions = _forgetremoved(wctx, mctx, branchmerge)
         actions['r'].extend(ractions)


More information about the Mercurial-devel mailing list