Patchwork D12432: rust-dirstatemap: correctly decrement the copies counter

login
register
mail settings
Submitter phabricator
Date April 4, 2022, 3:30 p.m.
Message ID <differential-rev-PHID-DREV-7nmnbvaqoerybvreonv7-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50777/
State New
Headers show

Comments

phabricator - April 4, 2022, 3:30 p.m.
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This was caught when writing unit tests for the `DirstateMap`. We were always
  setting `had_copy_source` to `false` since we erased the value just before.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D12432

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.rs

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -864,14 +864,16 @@ 
                 if had_entry {
                     node.data = NodeData::None
                 }
+                let mut had_copy_source = false;
                 if let Some(source) = &node.copy_source {
                     DirstateMap::count_dropped_path(unreachable_bytes, source);
+                    had_copy_source = true;
                     node.copy_source = None
                 }
                 dropped = Dropped {
                     was_tracked,
                     had_entry,
-                    had_copy_source: node.copy_source.take().is_some(),
+                    had_copy_source,
                 };
             }
             // After recursion, for both leaf (rest_of_path is None) nodes and