Mercurial > hg
diff rust/hg-core/src/dirstate_tree/on_disk.rs @ 50221:1891086f6c7f stable
dirstate: use more than a bool to control append behavior
When writing dirstate-v2, we might either append to the existing file, or
create a new file.
We are about to introduce some configuration to control this behavior.
As a prelude, we change the current way the behavior was automatically
controlled to make the change smaller/clearer.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 24 Feb 2023 18:21:54 +0100 |
parents | f2e13d8d30e0 |
children | ecd28d89c29e |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs Fri Feb 24 01:15:45 2023 +0100 +++ b/rust/hg-core/src/dirstate_tree/on_disk.rs Fri Feb 24 18:21:54 2023 +0100 @@ -4,7 +4,9 @@ use crate::dirstate::{DirstateV2Data, TruncatedTimestamp}; use crate::dirstate_tree::dirstate_map::DirstateVersion; -use crate::dirstate_tree::dirstate_map::{self, DirstateMap, NodeRef}; +use crate::dirstate_tree::dirstate_map::{ + self, DirstateMap, DirstateMapWriteMode, NodeRef, +}; use crate::dirstate_tree::path_with_basename::WithBasename; use crate::errors::HgError; use crate::utils::hg_path::HgPath; @@ -634,9 +636,12 @@ /// (false), and the previous size of data on disk. pub(super) fn write( dirstate_map: &DirstateMap, - can_append: bool, + write_mode: DirstateMapWriteMode, ) -> Result<(Vec<u8>, TreeMetadata, bool, usize), DirstateError> { - let append = can_append && dirstate_map.write_should_append(); + let append = match write_mode { + DirstateMapWriteMode::Auto => dirstate_map.write_should_append(), + DirstateMapWriteMode::ForceNewDataFile => false, + }; if append { log::trace!("appending to the dirstate data file"); } else {