Patchwork D12594: rust-dirstate-v2: fix the unused bytes counter when rewriting the dirstate

login
register
mail settings
Submitter phabricator
Date April 28, 2022, 3:16 p.m.
Message ID <differential-rev-PHID-DREV-ohqyatohw6oqpm4sosy7-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50941/
State New
Headers show

Comments

phabricator - April 28, 2022, 3:16 p.m.
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  As per the previous patch, the counter was incorrectly carried over from the
  old docket when it should be reset for a complete rewrite.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/on_disk.rs
  tests/test-dirstate.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-dirstate.t b/tests/test-dirstate.t
--- a/tests/test-dirstate.t
+++ b/tests/test-dirstate.t
@@ -193,8 +193,7 @@ 
 Check that unused bytes counter is reset when creating a new docket
 
   $ hg debugstate --docket | grep unused
-  number of unused bytes: 0 (no-rust !)
-  number of unused bytes: [1-9]\d* (re) (rust known-bad-output !)
+  number of unused bytes: 0
 
 #endif
 
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
@@ -622,13 +622,18 @@ 
 
     let root_nodes = writer.write_nodes(dirstate_map.root.as_ref())?;
 
+    let unreachable_bytes = if append {
+        dirstate_map.unreachable_bytes
+    } else {
+        0
+    };
     let meta = TreeMetadata {
         root_nodes,
         nodes_with_entry_count: dirstate_map.nodes_with_entry_count.into(),
         nodes_with_copy_source_count: dirstate_map
             .nodes_with_copy_source_count
             .into(),
-        unreachable_bytes: dirstate_map.unreachable_bytes.into(),
+        unreachable_bytes: unreachable_bytes.into(),
         unused: [0; 4],
         ignore_patterns_hash: dirstate_map.ignore_patterns_hash,
     };