changeset 44321:f0862ee1a31e

nodemap: keep track of the ondisk id of nodemap blocks If we are to incrementally update the files, we need to keep some details about the data we read. Differential Revision: https://phab.mercurial-scm.org/D7883
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 15 Jan 2020 15:49:26 +0100
parents 671f9479af0e
children 72c15641c8b4
files mercurial/revlogutils/nodemap.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlogutils/nodemap.py	Wed Jan 15 15:49:16 2020 +0100
+++ b/mercurial/revlogutils/nodemap.py	Wed Jan 15 15:49:26 2020 +0100
@@ -221,6 +221,11 @@
 
     contains up to 16 entry indexed from 0 to 15"""
 
+    def __init__(self):
+        super(Block, self).__init__()
+        # If this block exist on disk, here is its ID
+        self.ondisk_id = None
+
     def __iter__(self):
         return iter(self.get(i) for i in range(16))
 
@@ -323,8 +328,8 @@
     new_blocks = []
     for i in range(0, len(data), S_BLOCK.size):
         block = Block()
-        ondisk_id = len(block_map)
-        block_map[ondisk_id] = block
+        block.ondisk_id = len(block_map)
+        block_map[block.ondisk_id] = block
         block_data = data[i : i + S_BLOCK.size]
         values = S_BLOCK.unpack(block_data)
         new_blocks.append((block, values))