Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgoubet2019-09-06 08:38:58 -0400
committerlgoubet2019-09-06 11:16:03 -0400
commit1da5b3a19c2bdd646e7ab710308ab41437c56ba3 (patch)
tree8afb53ab8a0d1e9601c913dd9bc61ab6b41faf06
parente19f31d1091ef35e3e8f5bdc3ce7da239e64cd6e (diff)
downloadorg.eclipse.emf.compare-1da5b3a19c2bdd646e7ab710308ab41437c56ba3.tar.gz
org.eclipse.emf.compare-1da5b3a19c2bdd646e7ab710308ab41437c56ba3.tar.xz
org.eclipse.emf.compare-1da5b3a19c2bdd646e7ab710308ab41437c56ba3.zip
Diffs depending on pseudo-conflicts do not reject the other side
When a diff directly or indirectly requires or implies the merging of a diff that is part of a pseudo conflict, it should not require the rejection of the other side's diffs since a pseudo conflict is something that exists in both sides of the comparison. Change-Id: I97c25caf71b128a7bf302ff48c26859cea10a44b
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/ComparisonUtilTest.java4
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/utils/ComparisonUtil.java13
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/merge/AbstractMerger.java6
3 files changed, 15 insertions, 8 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/ComparisonUtilTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/ComparisonUtilTest.java
index 5929b72d3..87ef5f497 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/ComparisonUtilTest.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/ComparisonUtilTest.java
@@ -94,13 +94,13 @@ public class ComparisonUtilTest {
leftToRight = false;
subDiffs = ComparisonUtil.getSubDiffs(leftToRight).apply(leftPeriodicalDiff3Way);
- assertEquals(7, Iterables.size(subDiffs));
+ assertEquals(5, Iterables.size(subDiffs));
// Left to right on a deleted element
leftToRight = true;
subDiffs = ComparisonUtil.getSubDiffs(leftToRight).apply(leftPeriodicalDiff3Way);
- assertEquals(7, Iterables.size(subDiffs));
+ assertEquals(5, Iterables.size(subDiffs));
// Right to left on a added element
final Predicate<? super Diff> leftMagazine3Way = and(fromSide(DifferenceSource.LEFT),
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/utils/ComparisonUtil.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/utils/ComparisonUtil.java
index 76f6e0cd3..5efdc6092 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/utils/ComparisonUtil.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/utils/ComparisonUtil.java
@@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.emf.compare.internal.utils;
+import static com.google.common.base.Predicates.and;
import static com.google.common.base.Predicates.instanceOf;
import static com.google.common.base.Predicates.not;
import static com.google.common.base.Predicates.or;
@@ -24,6 +25,7 @@ import static org.eclipse.emf.compare.DifferenceKind.ADD;
import static org.eclipse.emf.compare.DifferenceKind.CHANGE;
import static org.eclipse.emf.compare.DifferenceKind.DELETE;
import static org.eclipse.emf.compare.DifferenceKind.MOVE;
+import static org.eclipse.emf.compare.utils.EMFComparePredicates.fromSide;
import static org.eclipse.emf.compare.utils.EMFComparePredicates.hasConflict;
import static org.eclipse.emf.compare.utils.EMFComparePredicates.ofKind;
@@ -342,8 +344,9 @@ public final class ComparisonUtil {
}
/**
- * When merging a {@link Diff}, returns the sub diffs of this given diff, and all associated diffs (see
- * {@link DiffUtil#getAssociatedDiffs(Iterable, boolean, Diff)}) of these sub diffs.
+ * When merging a {@link Diff}, returns the sub diffs <b>from the same side</b> of this given diff, and
+ * all associated diffs (see {@link DiffUtil#getAssociatedDiffs(Iterable, boolean, Diff)}) of these sub
+ * diffs.
* <p>
* If the diff is an {@link org.eclipse.emf.compare.AttributeChange}, a
* {@link org.eclipse.emf.compare.FeatureMapChange} or a
@@ -376,9 +379,11 @@ public final class ComparisonUtil {
if (matchOfValue != null) {
final Iterable<Diff> subDiffs;
if (!firstLevelOnly) {
- subDiffs = filter(matchOfValue.getAllDifferences(), CASCADING_DIFF);
+ subDiffs = filter(matchOfValue.getAllDifferences(),
+ and(fromSide(diff.getSource()), CASCADING_DIFF));
} else {
- subDiffs = filter(matchOfValue.getDifferences(), CASCADING_DIFF);
+ subDiffs = filter(matchOfValue.getDifferences(),
+ and(fromSide(diff.getSource()), CASCADING_DIFF));
}
addAll(processedDiffs, subDiffs);
final Iterable<Diff> associatedDiffs = getAssociatedDiffs(diff, subDiffs,
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/merge/AbstractMerger.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/merge/AbstractMerger.java
index 1202796f4..42914a8f4 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/merge/AbstractMerger.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/merge/AbstractMerger.java
@@ -710,8 +710,10 @@ public abstract class AbstractMerger implements IMerger2, IMergeOptionAware, IMe
}
if (target.getConflict() != null && target.getConflict().getKind() == PSEUDO) {
- impliedMerges.addAll(target.getConflict().getDifferences());
- impliedMerges.remove(target);
+ // Only diffs _from the same side_ are implied!
+ target.getConflict().getDifferences().stream()
+ .filter(d -> d != target && d.getSource() == target.getSource())
+ .forEach(impliedMerges::add);
}
// If a diff refines another, we have to check if the "macro" diff has to be merged with it. It is the

Back to the top