py3: avoid changing dictionary during iteration
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 11 Feb 2018 16:56:29 -0800
changeset 36117 c02771617a70
parent 36116 b587a889b97e
child 36118 9e47bfbeb723
py3: avoid changing dictionary during iteration dict.items() and friends are iterators/views in Python 3. You aren't allowed to mutate the underlying dictionary when iterating on these views. So iterate over a copy of things. Differential Revision: https://phab.mercurial-scm.org/D2164
mercurial/copies.py
--- a/mercurial/copies.py	Sun Feb 11 16:54:56 2018 -0800
+++ b/mercurial/copies.py	Sun Feb 11 16:56:29 2018 -0800
@@ -123,7 +123,7 @@
             t[k] = v
 
     # remove criss-crossed copies
-    for k, v in t.items():
+    for k, v in list(t.items()):
         if k in src and v in dst:
             del t[k]