merge: let _resolvetrivial() work on the file->action dict
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 11 Dec 2014 21:06:16 -0800
changeset 23639 35c724903157
parent 23638 09be050ca98c
child 23640 b46b9865dd08
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.
mercurial/merge.py
--- a/mercurial/merge.py	Thu Dec 11 20:56:53 2014 -0800
+++ b/mercurial/merge.py	Thu Dec 11 21:06:16 2014 -0800
@@ -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)