Mercurial > hg-stable
changeset 46622:8fcf07e6bbb4
copies-rust: make more use of the new comparison property
We deal with the "both are the same" sooner and simplify the rest of the
conditional.
Differential Revision: https://phab.mercurial-scm.org/D9654
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 21 Dec 2020 11:15:45 +0100 |
parents | b0a3ca02d17a |
children | aa19d60ac974 |
files | rust/hg-core/src/copy_tracing.rs |
diffstat | 1 files changed, 12 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-core/src/copy_tracing.rs Wed Dec 16 11:11:05 2020 +0100 +++ b/rust/hg-core/src/copy_tracing.rs Mon Dec 21 11:15:45 2020 +0100 @@ -847,49 +847,31 @@ src_minor: &CopySource, src_major: &CopySource, ) -> (MergePick, bool) { - if src_major.rev == current_merge { - if src_minor.rev == current_merge { - if src_major.path.is_none() { - // We cannot get different copy information for both p1 and p2 - // from the same revision. Unless this was a - // deletion. - // - // However the deletion might come over different data on each - // branch. - let need_over = src_major.overwritten != src_minor.overwritten; - (MergePick::Any, need_over) - } else { - unreachable!(); - } - } else { - // The last value comes the current merge, this value -will- win - // eventually. - (MergePick::Major, true) - } + if src_major == src_minor { + (MergePick::Any, false) + } else if src_major.rev == current_merge { + // minor is different according to per minor == major check earlier + debug_assert!(src_minor.rev != current_merge); + + // The last value comes the current merge, this value -will- win + // eventually. + (MergePick::Major, true) } else if src_minor.rev == current_merge { // The last value comes the current merge, this value -will- win // eventually. (MergePick::Minor, true) } else if src_major.path == src_minor.path { + debug_assert!(src_major.rev != src_major.rev); // we have the same value, but from other source; - if src_major.rev == src_minor.rev { - // If the two entry are identical, they are both valid - debug_assert!(src_minor.overwritten == src_minor.overwritten); - (MergePick::Any, false) - } else if src_major.is_overwritten_by(src_minor) { + if src_major.is_overwritten_by(src_minor) { (MergePick::Minor, false) } else if src_minor.is_overwritten_by(src_major) { (MergePick::Major, false) } else { (MergePick::Any, true) } - } else if src_major.rev == src_minor.rev { - // We cannot get copy information for both p1 and p2 in the - // same rev. So this is the same value. - unreachable!( - "conflicting information from p1 and p2 in the same revision" - ); } else { + debug_assert!(src_major.rev != src_major.rev); let dest_path = path_map.untokenize(*dest); let action = changes.get_merge_case(dest_path); if src_minor.path.is_some()