Patchwork D11545: dirstate-v2: Move data file info in the docket closer together

login
register
mail settings
Submitter phabricator
Date Oct. 1, 2021, 1:41 p.m.
Message ID <differential-rev-PHID-DREV-3ks7are6m5vr6lwfthop-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49869/
State Superseded
Headers show

Comments

phabricator - Oct. 1, 2021, 1:41 p.m.
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Having `data_size` next to `uuid_size` (and the UUID itself) makes more sense.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11545

AFFECTED FILES
  mercurial/dirstateutils/docket.py
  rust/hg-core/src/dirstate_tree/on_disk.rs

CHANGE DETAILS




To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hg-core/src/dirstate_tree/on_disk.rs b/rust/hg-core/src/dirstate_tree/on_disk.rs
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs
@@ -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,
 }
 
diff --git a/mercurial/dirstateutils/docket.py b/mercurial/dirstateutils/docket.py
--- a/mercurial/dirstateutils/docket.py
+++ b/mercurial/dirstateutils/docket.py
@@ -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