Patchwork [2,of,8,"] manifestcache: stop altering the lru cache order while displaying it

login
register
mail settings
Submitter Pierre-Yves David
Date March 16, 2019, 10:36 a.m.
Message ID <a0db76493f2b874b666b.1552732583@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/39285/
State Accepted
Headers show

Comments

Pierre-Yves David - March 16, 2019, 10:36 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1552657956 0
#      Fri Mar 15 13:52:36 2019 +0000
# Node ID a0db76493f2b874b666b67ed50609b0651cedc11
# Parent  85fa9d19ba227cb04a6c4209a71b1a2f858c6ede
# EXP-Topic manifestcache
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r a0db76493f2b
manifestcache: stop altering the lru cache order while displaying it

Accessing value with `.get` alter the iteration order and make the output of
the debug command misbehave, showing multiple entry twice.

We need more than 2 entry to see the bug, so there are not test change. Later
test will introduce a third entry and would fail without this fix.

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1503,7 +1503,7 @@  def debugmanifestfulltextcache(ui, repo,
         totalsize = 0
         for nodeid in cache:
             # Use cache.get to not update the LRU order
-            data = cache.get(nodeid)
+            data = cache.peek(nodeid)
             size = len(data)
             totalsize += size + 24   # 20 bytes nodeid, 4 bytes size
             ui.write(_('id: %s, size %s\n') % (