comparison mercurial/debugcommands.py @ 47682:78f7f0d490ee

dirstate-v2: Move fixed-size tree metadata into the docket file Before this changeset, the dirstate-v2 data file contained not only nodes and paths that may be reused when appending to an existing file, but also some fixed-size metadata that applies to the entire tree and was added at the end of the data file for every append. This moves that metadata into the docket file, so that repeated "append" operations without meaningful changes don?t actually need to grow any file. Differential Revision: https://phab.mercurial-scm.org/D11098
author Simon Sapin <simon.sapin@octobus.net>
date Thu, 15 Jul 2021 23:02:17 +0200
parents 096ee2e260a3
children 284a20269a97
comparison
equal deleted inserted replaced
47681:d94118365ec5 47682:78f7f0d490ee
997 or nothing for dirstate-v2 997 or nothing for dirstate-v2
998 """ 998 """
999 if repo.dirstate._use_dirstate_v2: 999 if repo.dirstate._use_dirstate_v2:
1000 docket = repo.dirstate._map.docket 1000 docket = repo.dirstate._map.docket
1001 hash_len = 20 # 160 bits for SHA-1 1001 hash_len = 20 # 160 bits for SHA-1
1002 hash_offset = docket.data_size - hash_len # hash is at the end 1002 hash_bytes = docket.tree_metadata[-hash_len:]
1003 data_filename = docket.data_filename()
1004 with repo.vfs(data_filename) as f:
1005 f.seek(hash_offset)
1006 hash_bytes = f.read(hash_len)
1007 ui.write(binascii.hexlify(hash_bytes) + b'\n') 1003 ui.write(binascii.hexlify(hash_bytes) + b'\n')
1008 1004
1009 1005
1010 @command( 1006 @command(
1011 b'debugdiscovery', 1007 b'debugdiscovery',