changeset 49156:09984dc70352 stable

rust-dirstate-v2: fix the unused bytes counter when rewriting the dirstate As per the previous patch, the counter was incorrectly carried over from the old docket when it should be reset for a complete rewrite. Differential Revision: https://phab.mercurial-scm.org/D12594
author Raphaël Gomès <rgomes@octobus.net>
date Thu, 28 Apr 2022 17:15:35 +0200
parents c69adc82e7f7
children 5d610521a285
files rust/hg-core/src/dirstate_tree/on_disk.rs tests/test-dirstate.t
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs	Thu Apr 28 17:11:51 2022 +0200
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs	Thu Apr 28 17:15:35 2022 +0200
@@ -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,
     };
--- a/tests/test-dirstate.t	Thu Apr 28 17:11:51 2022 +0200
+++ b/tests/test-dirstate.t	Thu Apr 28 17:15:35 2022 +0200
@@ -195,8 +195,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