Patchwork D2344: merge: make a copy of dict.items() before mutating the dict during iteration

login
register
mail settings
Submitter phabricator
Date Feb. 18, 2018, 8:54 p.m.
Message ID <differential-rev-PHID-DREV-zvnjgfxk3zs3uf36ydzj-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28134/
State Superseded
Headers show

Comments

phabricator - Feb. 18, 2018, 8:54 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2344

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1185,8 +1185,9 @@ 
 def _resolvetrivial(repo, wctx, mctx, ancestor, actions):
     """Resolves false conflicts where the nodeid changed but the content
        remained the same."""
-
-    for f, (m, args, msg) in actions.items():
+    # We force a copy of actions.items() because we're going to mutate
+    # actions as we resolve trivial conflicts.
+    for f, (m, args, msg) in list(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[f] = 'r', None, "prompt same"