Patchwork [10,of,10,py3] localrepo: forcibly copy list of filecache keys

login
register
mail settings
Submitter Augie Fackler
Date March 19, 2017, 6:26 p.m.
Message ID <3e3eff548aecf281d22c.1489947983@imladris.local>
Download mbox | patch
Permalink /patch/19458/
State Accepted
Headers show

Comments

Augie Fackler - March 19, 2017, 6:26 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1489900260 14400
#      Sun Mar 19 01:11:00 2017 -0400
# Node ID 3e3eff548aecf281d22c70ba853c0f742fd6c64b
# Parent  ce928383cf5dfb0993d27340b3fcf936a129e0fb
localrepo: forcibly copy list of filecache keys

On Python 3, keys() is more like iterkeys(), so we got in trouble for
mutating the dict while we're iterating here. Since the list of caches
should be relatively small, work around this difference by just
forcing a copy of the key list.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1318,7 +1318,7 @@  class localrepository(object):
         redundant one doesn't).
         '''
         unfiltered = self.unfiltered() # all file caches are stored unfiltered
-        for k in self._filecache.keys():
+        for k in list(self._filecache.keys()):
             # dirstate is invalidated separately in invalidatedirstate()
             if k == 'dirstate':
                 continue