changeset 46127:c58c8f1d63b1

copies-rust: hide most of the comparison details inside a closure The function that compares values needs various supporting elements that are the same for each call. We are about to both make change to these element and change to call sites in our upcoming work. So abstracting most of the details will help to avoid conflict while these works happen in parallel. Differential Revision: https://phab.mercurial-scm.org/D9426
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 21 Nov 2020 10:50:14 +0100
parents 94300498491e
children c94d013e2299
files rust/hg-core/src/copy_tracing.rs
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/copy_tracing.rs	Sat Nov 21 09:31:34 2020 +0100
+++ b/rust/hg-core/src/copy_tracing.rs	Sat Nov 21 10:50:14 2020 +0100
@@ -463,6 +463,15 @@
     changes: &ChangedFiles,
     oracle: &mut AncestorOracle<A>,
 ) -> TimeStampedPathCopies {
+    // This closure exist as temporary help while multiple developper are
+    // actively working on this code. Feel free to re-inline it once this
+    // code is more settled.
+    let mut cmp_value =
+        |dest: &HgPathBuf,
+         src_minor: &TimeStampedPathCopy,
+         src_major: &TimeStampedPathCopy| {
+            compare_value(changes, oracle, dest, src_minor, src_major)
+        };
     if minor.is_empty() {
         major
     } else if major.is_empty() {
@@ -499,9 +508,7 @@
                 DiffItem::Update { old, new } => {
                     let (dest, src_major) = new;
                     let (_, src_minor) = old;
-                    match compare_value(
-                        changes, oracle, dest, src_minor, src_major,
-                    ) {
+                    match cmp_value(dest, src_minor, src_major) {
                         MergePick::Major => to_minor(dest, src_major),
                         MergePick::Minor => to_major(dest, src_minor),
                         // If the two entry are identical, no need to do