Mercurial > hg
view rust/hg-core/src/dirstate.rs @ 48042:008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
This propagate to this Rust struct the similar change that was made recently
to the Python classe and C struct. Namely, instead of storing a four-valued
`state` field we now store seven (bit-packed) booleans that give lower-level
information.
Additionally, the marker values -1 and -2 for mtime and size should not
be used internally anymore. They are replaced by some combinations of booleans
For now, all uses of of `DirstateEntry` still use the compatibility APIs
with `state` and marker values. Later the Rust API for DirstateMap
will be increasingly updated to the new style.
Also change the expected result of the test_non_normal_other_parent_entries
unit test. Only a `DirstateEntry` with `size == -2 && mtime != -1` is
affected, but this case never occurs outside of unit tests.
`size == -2` was the marker value for "from other parent" entries,
where no meaningful mtime is stored.
Differential Revision: https://phab.mercurial-scm.org/D11484
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 20 Sep 2021 19:18:21 +0200 |
parents | 08efe5945d2b |
children | bf8837e3d7ce |
line wrap: on
line source
// dirstate module // // Copyright 2019 Raphaël Gomès <rgomes@octobus.net> // // This software may be used and distributed according to the terms of the // GNU General Public License version 2 or any later version. use crate::dirstate_tree::on_disk::DirstateV2ParseError; use crate::revlog::node::NULL_NODE; use crate::revlog::Node; use crate::utils::hg_path::{HgPath, HgPathBuf}; use crate::FastHashMap; use bytes_cast::BytesCast; pub mod dirs_multiset; pub mod dirstate_map; pub mod entry; pub mod parsers; pub mod status; pub use self::entry::*; #[derive(Debug, PartialEq, Copy, Clone, BytesCast)] #[repr(C)] pub struct DirstateParents { pub p1: Node, pub p2: Node, } impl DirstateParents { pub const NULL: Self = Self { p1: NULL_NODE, p2: NULL_NODE, }; } pub type StateMap = FastHashMap<HgPathBuf, DirstateEntry>; pub type StateMapIter<'a> = Box< dyn Iterator< Item = Result<(&'a HgPath, DirstateEntry), DirstateV2ParseError>, > + Send + 'a, >; pub type CopyMap = FastHashMap<HgPathBuf, HgPathBuf>; pub type CopyMapIter<'a> = Box< dyn Iterator<Item = Result<(&'a HgPath, &'a HgPath), DirstateV2ParseError>> + Send + 'a, >;