Skip to content
Snippets Groups Projects
Commit e32953f39dd3 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

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
parent 1b59db21ac5a
No related branches found
No related tags found
No related merge requests found
...@@ -496,6 +496,15 @@ ...@@ -496,6 +496,15 @@
changes: &ChangedFiles, changes: &ChangedFiles,
oracle: &mut AncestorOracle<A>, oracle: &mut AncestorOracle<A>,
) -> TimeStampedPathCopies { ) -> 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() { if minor.is_empty() {
major major
} else if major.is_empty() { } else if major.is_empty() {
...@@ -532,9 +541,7 @@ ...@@ -532,9 +541,7 @@
DiffItem::Update { old, new } => { DiffItem::Update { old, new } => {
let (dest, src_major) = new; let (dest, src_major) = new;
let (_, src_minor) = old; let (_, src_minor) = old;
match compare_value( match cmp_value(dest, src_minor, src_major) {
changes, oracle, dest, src_minor, src_major,
) {
MergePick::Major => to_minor(dest, src_major), MergePick::Major => to_minor(dest, src_major),
MergePick::Minor => to_major(dest, src_minor), MergePick::Minor => to_major(dest, src_minor),
// If the two entry are identical, no need to do // If the two entry are identical, no need to do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment