changeset 46581:d6d57bfc1a1b

copies-rust: record "overwritten" information from both side on delete With this change, we can ensure every (`dest`, `rev`) points to the same value, making a lots of comparison simpler. Differential Revision: https://phab.mercurial-scm.org/D9652
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 16 Dec 2020 11:06:58 +0100
parents 2076df13d00f
children b0a3ca02d17a
files rust/hg-core/src/copy_tracing.rs
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/copy_tracing.rs	Wed Dec 16 10:59:00 2020 +0100
+++ b/rust/hg-core/src/copy_tracing.rs	Wed Dec 16 11:06:58 2020 +0100
@@ -75,6 +75,19 @@
         self.path = None;
     }
 
+    /// Mark pre-existing copy information as "dropped" by a file deletion
+    ///
+    /// Use this when recording copy information from  parent → child edges
+    fn mark_delete_with_pair(&mut self, rev: Revision, other: &Self) {
+        self.overwritten.insert(self.rev);
+        if other.rev != rev {
+            self.overwritten.insert(other.rev);
+        }
+        self.overwritten.extend(other.overwritten.iter().copied());
+        self.rev = rev;
+        self.path = None;
+    }
+
     fn is_overwritten_by(&self, other: &Self) -> bool {
         other.overwritten.contains(&self.rev)
     }
@@ -535,8 +548,10 @@
                         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);
+                        let cs1 = e1.get_mut();
+                        let cs2 = e2.get();
+                        cs1.mark_delete_with_pair(current_rev, &cs2);
+                        e2.insert(cs1.clone());
                     }
                 }
             }