D9426: copies-rust: hide most of the comparison details inside a closure
Alphare (Raphaël Gomès)
phabricator at mercurial-scm.org
Fri Nov 27 16:12:47 UTC 2020
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
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.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D9426
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
@@ -496,6 +496,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() {
@@ -532,9 +541,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
To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list