Patchwork D9494: copies-rust: use the entry API to overwrite deleted entry

login
register
mail settings
Submitter phabricator
Date Dec. 2, 2020, 4:02 p.m.
Message ID <differential-rev-PHID-DREV-ms2l64hmrlqnxdd37qnb-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47776/
State Superseded
Headers show

Comments

phabricator - Dec. 2, 2020, 4:02 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is more efficient, more idiomatic and more compact.
  
  The main motivation for this change is to cleanup that area before start to do
  "overwrite" tracking. Such tracking will ultimately help to avoid costly
  is_ancestors call when merging changeset.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/copy_tracing.rs

CHANGE DETAILS




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

Patch

diff --git a/rust/hg-core/src/copy_tracing.rs b/rust/hg-core/src/copy_tracing.rs
--- a/rust/hg-core/src/copy_tracing.rs
+++ b/rust/hg-core/src/copy_tracing.rs
@@ -514,13 +514,10 @@ 
                 // propagate this information when merging two
                 // TimeStampedPathCopies object.
                 let deleted = path_map.tokenize(deleted_path);
-                if copies.contains_key(&deleted) {
-                    let ttpc = TimeStampedPathCopy {
-                        rev: current_rev,
-                        path: None,
-                    };
-                    copies.insert(deleted, ttpc);
-                }
+                copies.entry(deleted).and_modify(|old| {
+                    old.rev = current_rev;
+                    old.path = None;
+                });
             }
         }
     }