copies-rust: rename Oracle.is_ancestor to Oracle.is_overwrite
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 02 Dec 2020 16:11:35 +0100
changeset 46154 ecbb2fc9418c
parent 46153 0a721fc457bf
child 46155 fce2f20a54ce
copies-rust: rename Oracle.is_ancestor to Oracle.is_overwrite The core information that we want here is about "does information from revision X overwrite information in Y". To do so, we check is X is an ancestors of Y, but this is an implementation details, they could be other ways. We update the naming to clarify this (and align more with wording used in upcoming changesets. For people curious about other ways: for example we could record the overwrite graph as it happens and reuse that to check if X overwrite Y, without having to do potential expensive `is_ancestor` call on the revision graph. Differential Revision: https://phab.mercurial-scm.org/D9496
rust/hg-core/src/copy_tracing.rs
--- a/rust/hg-core/src/copy_tracing.rs	Wed Dec 02 11:04:11 2020 +0100
+++ b/rust/hg-core/src/copy_tracing.rs	Wed Dec 02 16:11:35 2020 +0100
@@ -244,7 +244,7 @@
     }
 
     /// returns `true` if `anc` is an ancestors of `desc`, `false` otherwise
-    fn is_ancestor(&mut self, anc: Revision, desc: Revision) -> bool {
+    fn is_overwrite(&mut self, anc: Revision, desc: Revision) -> bool {
         if anc > desc {
             false
         } else if anc == desc {
@@ -705,7 +705,7 @@
         if src_major.rev == src_minor.rev {
             // If the two entry are identical, they are both valid
             MergePick::Any
-        } else if oracle.is_ancestor(src_major.rev, src_minor.rev) {
+        } else if oracle.is_overwrite(src_major.rev, src_minor.rev) {
             MergePick::Minor
         } else {
             MergePick::Major
@@ -733,7 +733,7 @@
             // from each side might conflict.  The major side will
             // win such conflict.
             MergePick::Major
-        } else if oracle.is_ancestor(src_major.rev, src_minor.rev) {
+        } else if oracle.is_overwrite(src_major.rev, src_minor.rev) {
             // If the minor side is strictly newer than the major
             // side, it should be kept.
             MergePick::Minor
@@ -741,7 +741,7 @@
             // without any special case, the "major" value win
             // other the "minor" one.
             MergePick::Major
-        } else if oracle.is_ancestor(src_minor.rev, src_major.rev) {
+        } else if oracle.is_overwrite(src_minor.rev, src_major.rev) {
             // the "major" rev is a direct ancestors of "minor",
             // any different value should
             // overwrite