[Commented On] D9651: copies-rust: refactor the "deletion" case

baymax (Baymax, Your Personal Patch-care Companion) phabricator at mercurial-scm.org
Tue Jan 5 09:08:06 UTC 2021


baymax added a comment.
baymax updated this revision to Diff 24585.


  ✅ refresh by Heptapod after a successful CI run (🐙 💚)

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D9651?vs=24501&id=24585

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D9651/new/

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

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
@@ -517,22 +517,35 @@
                 // propagate this information when merging two
                 // InternalPathCopies object.
                 let deleted = path_map.tokenize(deleted_path);
-                match &mut p1_copies {
-                    None => (),
-                    Some(copies) => {
-                        copies.entry(deleted).and_modify(|old| {
-                            old.mark_delete(current_rev);
-                        });
-                    }
+
+                let p1_entry = match &mut p1_copies {
+                    None => None,
+                    Some(copies) => match copies.entry(deleted) {
+                        Entry::Occupied(e) => Some(e),
+                        Entry::Vacant(_) => None,
+                    },
+                };
+                let p2_entry = match &mut p2_copies {
+                    None => None,
+                    Some(copies) => match copies.entry(deleted) {
+                        Entry::Occupied(e) => Some(e),
+                        Entry::Vacant(_) => None,
+                    },
                 };
-                match &mut p2_copies {
-                    None => (),
-                    Some(copies) => {
-                        copies.entry(deleted).and_modify(|old| {
-                            old.mark_delete(current_rev);
-                        });
+
+                match (p1_entry, p2_entry) {
+                    (None, None) => (),
+                    (Some(mut e), None) => {
+                        e.get_mut().mark_delete(current_rev)
                     }
-                };
+                    (None, Some(mut e)) => {
+                        e.get_mut().mark_delete(current_rev)
+                    }
+                    (Some(mut e1), Some(mut e2)) => {
+                        e1.get_mut().mark_delete(current_rev);
+                        e2.get_mut().mark_delete(current_rev);
+                    }
+                }
             }
         }
     }



To: marmoute, #hg-reviewers
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210105/bd01629e/attachment-0001.html>


More information about the Mercurial-patches mailing list