# HG changeset patch # User Raphaël Gomès # Date 2019-11-07 10:13:31 # Node ID 8210c3f46912d3f9c30c9ccdb38ce2a62f3da768 # Parent 51cd8673560885a62def364ca40837ba708ae8e2 rust: introduce SIZE_FROM_OTHER_PARENT constant This will clarify what `-2` meant in the codebase. This change also merged imports in affected files for cleanup. Differential Revision: https://phab.mercurial-scm.org/D7301 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())