changeset 48165:d467e44f71d7

dirstate-v2: Move data file info in the docket closer together Having `data_size` next to `uuid_size` (and the UUID itself) makes more sense. Differential Revision: https://phab.mercurial-scm.org/D11545
author Simon Sapin <simon.sapin@octobus.net>
date Fri, 01 Oct 2021 12:27:17 +0200
parents 1ab4523afe12
children e8a576de703f
files mercurial/dirstateutils/docket.py rust/hg-core/src/dirstate_tree/on_disk.rs
diffstat 2 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstateutils/docket.py	Fri Oct 01 09:29:50 2021 +0200
+++ b/mercurial/dirstateutils/docket.py	Fri Oct 01 12:27:17 2021 +0200
@@ -21,15 +21,15 @@
 # * 12 bytes: format marker
 # * 32 bytes: node ID of the working directory's first parent
 # * 32 bytes: node ID of the working directory's second parent
+# * {TREE_METADATA_SIZE} bytes: tree metadata, parsed separately
 # * 4 bytes: big-endian used size of the data file
-# * {TREE_METADATA_SIZE} bytes: tree metadata, parsed separately
 # * 1 byte: length of the data file's UUID
 # * variable: data file's UUID
 #
 # Node IDs are null-padded if shorter than 32 bytes.
 # A data file shorter than the specified used size is corrupted (truncated)
 HEADER = struct.Struct(
-    ">{}s32s32sL{}sB".format(len(V2_FORMAT_MARKER), TREE_METADATA_SIZE)
+    ">{}s32s32s{}sLB".format(len(V2_FORMAT_MARKER), TREE_METADATA_SIZE)
 )
 
 
@@ -51,7 +51,7 @@
         if not data:
             parents = (nodeconstants.nullid, nodeconstants.nullid)
             return cls(parents, 0, b'', None)
-        marker, p1, p2, data_size, meta, uuid_size = HEADER.unpack_from(data)
+        marker, p1, p2, meta, data_size, uuid_size = HEADER.unpack_from(data)
         if marker != V2_FORMAT_MARKER:
             raise ValueError("expected dirstate-v2 marker")
         uuid = data[HEADER.size : HEADER.size + uuid_size]
@@ -65,8 +65,8 @@
             V2_FORMAT_MARKER,
             p1,
             p2,
+            self.tree_metadata,
             self.data_size,
-            self.tree_metadata,
             len(self.uuid),
         )
         return header + self.uuid
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs	Fri Oct 01 09:29:50 2021 +0200
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs	Fri Oct 01 12:27:17 2021 +0200
@@ -67,11 +67,11 @@
     parent_1: [u8; STORED_NODE_ID_BYTES],
     parent_2: [u8; STORED_NODE_ID_BYTES],
 
+    metadata: TreeMetadata,
+
     /// Counted in bytes
     data_size: Size,
 
-    metadata: TreeMetadata,
-
     uuid_size: u8,
 }