Mercurial > hg
diff rust/hg-cpython/src/dirstate/dirstate_map.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 | 10b9f11daf15 |
children | ecd28d89c29e |
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs Fri Feb 24 01:15:45 2023 +0100 +++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs Fri Feb 24 18:21:54 2023 +0100 @@ -23,7 +23,8 @@ pybytes_deref::PyBytesDeref, }; use hg::{ - dirstate::StateMapIter, dirstate_tree::on_disk::DirstateV2ParseError, + dirstate::StateMapIter, dirstate_tree::dirstate_map::DirstateMapWriteMode, + dirstate_tree::on_disk::DirstateV2ParseError, dirstate_tree::owning::OwningDirstateMap, revlog::Node, utils::files::normalize_case, utils::hg_path::HgPath, DirstateEntry, DirstateError, DirstateParents, @@ -247,10 +248,15 @@ /// instead of written to a new data file (False). def write_v2( &self, - can_append: bool, + write_mode: usize, ) -> PyResult<PyObject> { let inner = self.inner(py).borrow(); - let result = inner.pack_v2(can_append); + let rust_write_mode = match write_mode { + 0 => DirstateMapWriteMode::Auto, + 1 => DirstateMapWriteMode::ForceNewDataFile, + _ => DirstateMapWriteMode::Auto, // XXX should we error out? + }; + let result = inner.pack_v2(rust_write_mode); match result { Ok((packed, tree_metadata, append, _old_data_size)) => { let packed = PyBytes::new(py, &packed);