comparison rust/hg-core/src/dirstate_tree/dispatch.rs @ 47678:065e61628980

dirstate-v2: Support appending to the same data file For now we?re still writing the entire data every time, so appending is not useful yet. Later we?ll have new nodes pointing to some existing data for nodes and paths that haven?t changed. The decision whether to append is pseudo-random in order to make tests exercise both code paths. This will be replaced by a heuristic based on the amount of unused existing data. Differential Revision: https://phab.mercurial-scm.org/D11094
author Simon Sapin <simon.sapin@octobus.net>
date Tue, 13 Jul 2021 17:18:23 +0200
parents ff97e793ed36
children 78f7f0d490ee
comparison
equal deleted inserted replaced
47677:da1c0cd68d53 47678:065e61628980
177 now: Timestamp, 177 now: Timestamp,
178 ) -> Result<Vec<u8>, DirstateError>; 178 ) -> Result<Vec<u8>, DirstateError>;
179 179
180 /// Clear mtimes that are ambigous with `now` (similar to 180 /// Clear mtimes that are ambigous with `now` (similar to
181 /// `clear_ambiguous_times` but for all files in the dirstate map), and 181 /// `clear_ambiguous_times` but for all files in the dirstate map), and
182 /// serialize bytes to write the `.hg/dirstate` file to disk in dirstate-v2 182 /// serialize bytes to write a dirstate data file to disk in dirstate-v2
183 /// format. 183 /// format.
184 /// 184 ///
185 /// Returns new data together with whether that data should be appended to
186 /// the existing data file whose content is at `self.on_disk` (true),
187 /// instead of written to a new data file (false).
188 ///
185 /// Note: this is only supported by the tree dirstate map. 189 /// Note: this is only supported by the tree dirstate map.
186 fn pack_v2(&mut self, now: Timestamp) -> Result<Vec<u8>, DirstateError>; 190 fn pack_v2(
191 &mut self,
192 now: Timestamp,
193 can_append: bool,
194 ) -> Result<(Vec<u8>, bool), DirstateError>;
187 195
188 /// Run the status algorithm. 196 /// Run the status algorithm.
189 /// 197 ///
190 /// This is not sematically a method of the dirstate map, but a different 198 /// This is not sematically a method of the dirstate map, but a different
191 /// algorithm is used for the flat v.s. tree dirstate map so having it in 199 /// algorithm is used for the flat v.s. tree dirstate map so having it in
381 now: Timestamp, 389 now: Timestamp,
382 ) -> Result<Vec<u8>, DirstateError> { 390 ) -> Result<Vec<u8>, DirstateError> {
383 self.pack(parents, now) 391 self.pack(parents, now)
384 } 392 }
385 393
386 fn pack_v2(&mut self, _now: Timestamp) -> Result<Vec<u8>, DirstateError> { 394 fn pack_v2(
395 &mut self,
396 _now: Timestamp,
397 _can_append: bool,
398 ) -> Result<(Vec<u8>, bool), DirstateError> {
387 panic!( 399 panic!(
388 "should have used dirstate_tree::DirstateMap to use the v2 format" 400 "should have used dirstate_tree::DirstateMap to use the v2 format"
389 ) 401 )
390 } 402 }
391 403