From patchwork Fri Jul 16 15:19:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D11101: dirstate-v2: Reserve a few bytes of space for future extensions From: phabricator X-Patchwork-Id: 49415 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Fri, 16 Jul 2021 15:19:14 +0000 SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY See doc-comment REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11101 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 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 @@ -49,13 +49,13 @@ /// Must match the constant of the same name in /// `mercurial/dirstateutils/docket.py` -const TREE_METADATA_SIZE: usize = 40; +const TREE_METADATA_SIZE: usize = 44; /// Make sure that size-affecting changes are made knowingly #[allow(unused)] fn static_assert_size_of() { - let _ = std::mem::transmute::; let _ = std::mem::transmute::; + let _ = std::mem::transmute::; let _ = std::mem::transmute::; } @@ -90,6 +90,12 @@ /// How many bytes of this data file are not used anymore unreachable_bytes: Size, + /// Current version always sets these bytes to zero when creating or + /// updating a dirstate. Future versions could assign some bits to signal + /// for example "the version that last wrote/updated this dirstate did so + /// in such and such way that can be relied on by versions that know to." + unused: [u8; 4], + /// If non-zero, a hash of ignore files that were used for some previous /// run of the `status` algorithm. /// @@ -579,6 +585,7 @@ .nodes_with_copy_source_count .into(), unreachable_bytes: dirstate_map.unreachable_bytes.into(), + unused: [0; 4], ignore_patterns_hash: dirstate_map.ignore_patterns_hash, }; Ok((writer.out, meta.as_bytes().to_vec(), append)) diff --git a/mercurial/dirstateutils/docket.py b/mercurial/dirstateutils/docket.py --- a/mercurial/dirstateutils/docket.py +++ b/mercurial/dirstateutils/docket.py @@ -16,7 +16,7 @@ # Must match the constant of the same name in # `rust/hg-core/src/dirstate_tree/on_disk.rs` -TREE_METADATA_SIZE = 40 +TREE_METADATA_SIZE = 44 # * 12 bytes: format marker # * 32 bytes: node ID of the working directory's first parent