# HG changeset patch # User Pierre-Yves David # Date 2020-01-15 14:48:28 # Node ID 7762a295fd4ded00e7f2c20c29a56bfef63c18c5 # Parent 7f4f7ef3133e994be4cf1b4329185998be3d5ec1 nodemap: use an explicit "Block" object in the reference implementation This will help us to introduce some test around the data currently written on disk. Differential Revision: https://phab.mercurial-scm.org/D7842 diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py --- a/mercurial/revlogutils/nodemap.py +++ b/mercurial/revlogutils/nodemap.py @@ -216,6 +216,12 @@ def _to_int(hex_digit): return int(hex_digit, 16) +class Block(dict): + """represent a block of the Trie + + contains up to 16 entry indexed from 0 to 15""" + + def _build_trie(index): """build a nodemap trie @@ -224,7 +230,7 @@ def _build_trie(index): Each block is a dictionary with keys in `[0, 15]`. Values are either another block or a revision number. """ - root = {} + root = Block() for rev in range(len(index)): hex = nodemod.hex(index[rev][7]) _insert_into_block(index, 0, root, rev, hex) @@ -253,7 +259,7 @@ def _insert_into_block(index, level, blo # vertices to fit both entry. other_hex = nodemod.hex(index[entry][7]) other_rev = entry - new = {} + new = Block() block[hex_digit] = new _insert_into_block(index, level + 1, new, other_rev, other_hex) _insert_into_block(index, level + 1, new, current_rev, current_hex)