Mercurial > hg-stable
changeset 48827:fbc02ccc207e stable
rust-dirstatemap: properly decrement counter for tracked descendants
I found this bug when writing unit tests after the fact for the `DirstateMap`.
We never decremented the tracked descendants counter since we were always
resetting the node data before reading it. This also drops the use of `state`,
in favor of the new API to get that information.
Differential Revision: https://phab.mercurial-scm.org/D12431
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Tue, 05 Apr 2022 10:55:28 +0200 |
parents | 2593873cda0f |
children | ce919b1a1063 |
files | rust/hg-core/src/dirstate_tree/dirstate_map.rs |
diffstat | 1 files changed, 4 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs Tue Apr 05 10:55:28 2022 +0200 +++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs Tue Apr 05 10:55:28 2022 +0200 @@ -858,7 +858,9 @@ return Ok(None); } } else { - let had_entry = node.data.has_entry(); + let entry = node.data.as_entry(); + let was_tracked = entry.map_or(false, |entry| entry.tracked()); + let had_entry = entry.is_some(); if had_entry { node.data = NodeData::None } @@ -867,10 +869,7 @@ node.copy_source = None } dropped = Dropped { - was_tracked: node - .data - .as_entry() - .map_or(false, |entry| entry.state().is_tracked()), + was_tracked, had_entry, had_copy_source: node.copy_source.take().is_some(), };