Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgoubet2019-07-17 04:51:07 -0400
committerlgoubet2019-07-17 05:28:03 -0400
commit1998e64ba331e977271a01a57e1e12dbb5a99148 (patch)
tree05981c5d7cb1ef0b1a1d01e50d9a7ad079e78726
parentc6921d7e119909e179b5920e97739a3666110b07 (diff)
downloadorg.eclipse.emf.compare-1998e64ba331e977271a01a57e1e12dbb5a99148.tar.gz
org.eclipse.emf.compare-1998e64ba331e977271a01a57e1e12dbb5a99148.tar.xz
org.eclipse.emf.compare-1998e64ba331e977271a01a57e1e12dbb5a99148.zip
Fix detection of pseudo conflicts on single-valued attribute changes
Pseudo-conflicts on single-valued attribute changes was populated with the origin as the changed value even if the left/right side was non-null. Change-Id: Id225da76bb381a476715c9af9581cd0bc2b9e47a
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/FeatureMapMoveDiffTest.java2
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/SingleValuedAttributePseudoConflictTest.java77
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/FeatureMapMoveDiffInputData.java (renamed from plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/FeatureMapMoveDiffInputData.java)6
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/SingleValuedAttributePseudoConflictInputData.java31
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/left.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/origin.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/right.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/UMLDifferencesOrderTest.java2
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/data/a1/expectedResultWithUMLRefineElementFilter.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/diff/DefaultDiffEngine.java7
10 files changed, 131 insertions, 10 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/FeatureMapMoveDiffTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/FeatureMapMoveDiffTest.java
index 08b428a29..81a219ac6 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/FeatureMapMoveDiffTest.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/FeatureMapMoveDiffTest.java
@@ -26,7 +26,7 @@ import org.eclipse.emf.compare.FeatureMapChange;
import org.eclipse.emf.compare.ReferenceChange;
import org.eclipse.emf.compare.scope.DefaultComparisonScope;
import org.eclipse.emf.compare.scope.IComparisonScope;
-import org.eclipse.emf.compare.tests.diff.data.FeatureMapMoveDiffInputData;
+import org.eclipse.emf.compare.tests.diff.data.featuremapmove.FeatureMapMoveDiffInputData;
import org.eclipse.emf.ecore.resource.Resource;
import org.junit.Test;
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/SingleValuedAttributePseudoConflictTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/SingleValuedAttributePseudoConflictTest.java
new file mode 100644
index 000000000..20b610c8e
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/SingleValuedAttributePseudoConflictTest.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Laurent Goubet - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.tests.diff;
+
+import static org.eclipse.emf.compare.utils.ReferenceUtil.safeEGet;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.eclipse.emf.compare.AttributeChange;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Conflict;
+import org.eclipse.emf.compare.ConflictKind;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.DifferenceKind;
+import org.eclipse.emf.compare.DifferenceSource;
+import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.scope.DefaultComparisonScope;
+import org.eclipse.emf.compare.scope.IComparisonScope;
+import org.eclipse.emf.compare.tests.diff.data.pseudoconflict.SingleValuedAttributePseudoConflictInputData;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.junit.Test;
+
+public class SingleValuedAttributePseudoConflictTest {
+ private SingleValuedAttributePseudoConflictInputData input = new SingleValuedAttributePseudoConflictInputData();
+
+ @Test
+ public void testSingleValuedAttributePseudoConflict() throws IOException {
+ Resource left = input.getSingleValueAttributePseudoConflictLeft();
+ Resource right = input.getSingleValueAttributePseudoConflictRight();
+ Resource origin = input.getSingleValueAttributePseudoConflictOrigin();
+
+ IComparisonScope scope = new DefaultComparisonScope(right, left, origin);
+ Comparison comparison = EMFCompare.builder().build().compare(scope);
+
+ // There are only two differences
+ List<Diff> differences = comparison.getDifferences();
+ assertEquals(2, differences.size());
+ Diff diff1 = differences.get(0);
+ Diff diff2 = differences.get(1);
+
+ // They constitute a single pseudo conflict
+ assertNotNull(diff1.getConflict());
+ assertEquals(diff1.getConflict(), diff2.getConflict());
+ Conflict conflict = diff1.getConflict();
+ assertEquals(ConflictKind.PSEUDO, conflict.getKind());
+
+ // They are both a CHANGE AttributeChange on opposite sides
+ assertTrue(diff1 instanceof AttributeChange);
+ assertEquals(DifferenceKind.CHANGE, diff1.getKind());
+ assertEquals(DifferenceSource.LEFT, diff1.getSource());
+ assertTrue(diff2 instanceof AttributeChange);
+ assertEquals(DifferenceKind.CHANGE, diff2.getKind());
+ assertEquals(DifferenceSource.RIGHT, diff2.getSource());
+
+ // And they have their own side as the changed value (not the origin side)
+ Match container = diff1.getMatch();
+ Object leftValue = safeEGet(container.getLeft(), ((AttributeChange)diff1).getAttribute());
+ Object rightValue = safeEGet(container.getRight(), ((AttributeChange)diff2).getAttribute());
+ assertNotNull(leftValue);
+ assertEquals(leftValue, rightValue);
+ assertEquals(leftValue, ((AttributeChange)diff1).getValue());
+ assertEquals(rightValue, ((AttributeChange)diff2).getValue());
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/FeatureMapMoveDiffInputData.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/FeatureMapMoveDiffInputData.java
index 6f88c9521..d664d8d0f 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/FeatureMapMoveDiffInputData.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/featuremapmove/FeatureMapMoveDiffInputData.java
@@ -8,7 +8,7 @@
* Contributors:
* Stefan Dirix - initial API and implementation
*******************************************************************************/
-package org.eclipse.emf.compare.tests.diff.data;
+package org.eclipse.emf.compare.tests.diff.data.featuremapmove;
import java.io.IOException;
@@ -18,10 +18,10 @@ import org.eclipse.emf.ecore.resource.Resource;
@SuppressWarnings("nls")
public class FeatureMapMoveDiffInputData extends AbstractInputData {
public Resource getFeatureMapMoveLeft() throws IOException {
- return loadFromClassLoader("featuremapmove/left.nodes");
+ return loadFromClassLoader("left.nodes");
}
public Resource getFeatureMapMoveRight() throws IOException {
- return loadFromClassLoader("featuremapmove/right.nodes");
+ return loadFromClassLoader("right.nodes");
}
}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/SingleValuedAttributePseudoConflictInputData.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/SingleValuedAttributePseudoConflictInputData.java
new file mode 100644
index 000000000..4cdadcfb1
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/SingleValuedAttributePseudoConflictInputData.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Laurent Goubet - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.tests.diff.data.pseudoconflict;
+
+import java.io.IOException;
+
+import org.eclipse.emf.compare.tests.framework.AbstractInputData;
+import org.eclipse.emf.ecore.resource.Resource;
+
+@SuppressWarnings("nls")
+public class SingleValuedAttributePseudoConflictInputData extends AbstractInputData {
+ public Resource getSingleValueAttributePseudoConflictLeft() throws IOException {
+ return loadFromClassLoader("left.nodes");
+ }
+
+ public Resource getSingleValueAttributePseudoConflictRight() throws IOException {
+ return loadFromClassLoader("right.nodes");
+ }
+
+ public Resource getSingleValueAttributePseudoConflictOrigin() throws IOException {
+ return loadFromClassLoader("origin.nodes");
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/left.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/left.nodes
new file mode 100644
index 000000000..27d2691d0
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/left.nodes
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes" xmi:id="_wZM5IKhyEemotbw2fRcn-w" name="model">
+ <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_yCMQMKhyEemotbw2fRcn-w" name="conflict_container" singleValuedAttribute="changedValue"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/origin.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/origin.nodes
new file mode 100644
index 000000000..c58414932
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/origin.nodes
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes" xmi:id="_wZM5IKhyEemotbw2fRcn-w" name="model">
+ <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_yCMQMKhyEemotbw2fRcn-w" name="conflict_container" singleValuedAttribute="originValue"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/right.nodes b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/right.nodes
new file mode 100644
index 000000000..27d2691d0
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/data/pseudoconflict/right.nodes
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes" xmi:id="_wZM5IKhyEemotbw2fRcn-w" name="model">
+ <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_yCMQMKhyEemotbw2fRcn-w" name="conflict_container" singleValuedAttribute="changedValue"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/UMLDifferencesOrderTest.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/UMLDifferencesOrderTest.java
index 3b0db0519..f06d16b14 100644
--- a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/UMLDifferencesOrderTest.java
+++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/UMLDifferencesOrderTest.java
@@ -91,7 +91,7 @@ public class UMLDifferencesOrderTest extends AbstractDifferenceOrderTest {
*
* @throws IOException
*/
- @Ignore("Refining diffs are displayed insinde refined diffs in an order that's not stable.")
+ @Ignore("Refining diffs are displayed inside refined diffs in an order that's not stable.")
@Test
public void testDiffOrder() throws IOException {
UMLRefinedElementsFilter umlRefineFilter = new UMLRefinedElementsFilter();
diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/data/a1/expectedResultWithUMLRefineElementFilter.nodes b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/data/a1/expectedResultWithUMLRefineElementFilter.nodes
index 9f04cfd0a..4db034233 100644
--- a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/data/a1/expectedResultWithUMLRefineElementFilter.nodes
+++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/data/a1/expectedResultWithUMLRefineElementFilter.nodes
@@ -13,8 +13,8 @@
<containmentRef1 xmi:id="_CgR29uvwEeOe_vfK-oM2bA" name="ChangingNameNode_NewName [name changed]"/>
</containmentRef1>
<containmentRef1 xmi:id="_CgR29-vwEeOe_vfK-oM2bA" name="&lt;Class> PseudoConflictingNode_NewName">
- <containmentRef1 xmi:id="_CgR2-OvwEeOe_vfK-oM2bA" name="PseudoConflictingNode [name changed]"/>
- <containmentRef1 xmi:id="_CgR2-evwEeOe_vfK-oM2bA" name="PseudoConflictingNode [name changed]"/>
+ <containmentRef1 xmi:id="_CgR2-OvwEeOe_vfK-oM2bA" name="PseudoConflictingNode_NewName [name changed]"/>
+ <containmentRef1 xmi:id="_CgR2-evwEeOe_vfK-oM2bA" name="PseudoConflictingNode_NewName [name changed]"/>
</containmentRef1>
<containmentRef1 xmi:id="_CgR2_OvwEeOe_vfK-oM2bA" name="&lt;Class> NodeToDelete">
<containmentRef1 xmi:id="_CgR2_OvwEeOe_vfK-oM2bB" name="&lt;Class> NodeToDelete [packagedElement delete]"/>
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/diff/DefaultDiffEngine.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/diff/DefaultDiffEngine.java
index cf7aa9e10..de5c61b59 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/diff/DefaultDiffEngine.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/diff/DefaultDiffEngine.java
@@ -1242,9 +1242,10 @@ public class DefaultDiffEngine implements IDiffEngine {
final boolean matchingLO = helper.matchingValues(leftValue, originValue);
// if !matchingLO, the same change has been made on both side. This is actually a
- // pseudo-conflict. It can be either a set or unset diff according to the value of origin.
- if (!matchingLO && isNullOrEmptyString(originValue)) {
- // The same value has been SET on both sides
+ // pseudo-conflict.
+ if (!matchingLO && !isNullOrEmptyString(leftValue)) {
+ // The same value has been SET or CHANGED on both sides
+ // (depending on whether origin is null or not)
getDiffProcessor().attributeChange(match, attribute, leftValue, DifferenceKind.CHANGE,
DifferenceSource.LEFT);
getDiffProcessor().attributeChange(match, attribute, rightValue, DifferenceKind.CHANGE,

Back to the top