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

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Wed Dec 2 16:02:51 UTC 2020


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

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;
+                });
             }
         }
     }



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


More information about the Mercurial-devel mailing list