Patchwork D2238: narrowmerge: iterate over a copy of dict items so we can mutate the dict

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

Comments

phabricator - Feb. 13, 2018, 11:13 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/D2238

AFFECTED FILES
  hgext/narrow/narrowmerge.py

CHANGE DETAILS




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

Patch

diff --git a/hgext/narrow/narrowmerge.py b/hgext/narrow/narrowmerge.py
--- a/hgext/narrow/narrowmerge.py
+++ b/hgext/narrow/narrowmerge.py
@@ -28,7 +28,9 @@ 
         nooptypes = set(['k']) # TODO: handle with nonconflicttypes
         nonconflicttypes = set('a am c cm f g r e'.split())
         narrowmatch = repo.narrowmatch()
-        for f, action in actions.items():
+        # We mutate the items in the dict during iteration, so iterate
+        # over a copy.
+        for f, action in list(actions.items()):
             if narrowmatch(f):
                 pass
             elif not branchmerge: