diff --git a/rust/hg-core/src/dirstate.rs b/rust/hg-core/src/dirstate.rs --- a/rust/hg-core/src/dirstate.rs +++ b/rust/hg-core/src/dirstate.rs @@ -32,6 +32,11 @@ pub struct DirstateEntry { pub size: i32, } +/// A `DirstateEntry` with a size of `-2` means that it was merged from the +/// other parent. This allows revert to pick the right status back during a +/// merge. +pub const SIZE_FROM_OTHER_PARENT: i32 = -2; + pub type StateMap = HashMap; pub type StateMapIter<'a> = hash_map::Iter<'a, HgPathBuf, DirstateEntry>; pub type CopyMap = HashMap; diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs b/rust/hg-core/src/dirstate/dirstate_map.rs --- a/rust/hg-core/src/dirstate/dirstate_map.rs +++ b/rust/hg-core/src/dirstate/dirstate_map.rs @@ -5,11 +5,13 @@ // 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::utils::hg_path::{HgPath, HgPathBuf}; use crate::{ - dirstate::{parsers::PARENT_SIZE, EntryState}, + dirstate::{parsers::PARENT_SIZE, EntryState, SIZE_FROM_OTHER_PARENT}, pack_dirstate, parse_dirstate, - utils::files::normalize_case, + utils::{ + files::normalize_case, + hg_path::{HgPath, HgPathBuf}, + }, CopyMap, DirsMultiset, DirstateEntry, DirstateError, DirstateMapError, DirstateParents, DirstateParseError, StateMap, }; @@ -24,7 +26,6 @@ pub type FileFoldMap = HashMap= 0 && (size_changed || mode_changed); - let other_parent = size == -2; + let other_parent = size == SIZE_FROM_OTHER_PARENT; if metadata_changed || other_parent || copy_map.contains_key(filename.as_ref())