rust/hg-core/src/dirstate_tree/dirstate_map.rs
changeset 49147 10b9f11daf15
parent 49143 e55ce61891e3
parent 49145 dd2503a63d33
child 49365 79b2c98ab7b4
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Tue Apr 19 12:17:23 2022 -0700
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Mon Apr 25 11:09:33 2022 +0200
@@ -50,6 +50,10 @@
 
     /// How many bytes of `on_disk` are not used anymore
     pub(super) unreachable_bytes: u32,
+
+    /// Size of the data used to first load this `DirstateMap`. Used in case
+    /// we need to write some new metadata, but no new data on disk.
+    pub(super) old_data_size: usize,
 }
 
 /// Using a plain `HgPathBuf` of the full path from the repository root as a
@@ -436,6 +440,7 @@
             nodes_with_copy_source_count: 0,
             ignore_patterns_hash: [0; on_disk::IGNORE_PATTERNS_HASH_LEN],
             unreachable_bytes: 0,
+            old_data_size: 0,
         }
     }
 
@@ -1232,12 +1237,13 @@
     /// Returns new data and metadata together with whether that data should be
     /// appended to the existing data file whose content is at
     /// `map.on_disk` (true), instead of written to a new data file
-    /// (false).
+    /// (false), and the previous size of data on disk.
     #[timed]
     pub fn pack_v2(
         &self,
         can_append: bool,
-    ) -> Result<(Vec<u8>, on_disk::TreeMetadata, bool), DirstateError> {
+    ) -> Result<(Vec<u8>, on_disk::TreeMetadata, bool, usize), DirstateError>
+    {
         let map = self.get_map();
         on_disk::write(map, can_append)
     }
@@ -1795,7 +1801,8 @@
             None,
         )?;
 
-        let (packed, metadata, _should_append) = map.pack_v2(false)?;
+        let (packed, metadata, _should_append, _old_data_size) =
+            map.pack_v2(false)?;
         let packed_len = packed.len();
         assert!(packed_len > 0);