diff 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
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Thu Jul 08 19:23:44 2021 +0200
+++ b/mercurial/debugcommands.py	Thu Jul 15 23:02:17 2021 +0200
@@ -999,11 +999,7 @@
     if repo.dirstate._use_dirstate_v2:
         docket = repo.dirstate._map.docket
         hash_len = 20  # 160 bits for SHA-1
-        hash_offset = docket.data_size - hash_len  # hash is at the end
-        data_filename = docket.data_filename()
-        with repo.vfs(data_filename) as f:
-            f.seek(hash_offset)
-            hash_bytes = f.read(hash_len)
+        hash_bytes = docket.tree_metadata[-hash_len:]
         ui.write(binascii.hexlify(hash_bytes) + b'\n')