diff options
author | Axel Richard | 2015-10-22 09:45:55 +0000 |
---|---|---|
committer | Axel Richard | 2015-10-22 15:57:30 +0000 |
commit | 4e97142e33b17c1644621333c5c83310e8f0e1a9 (patch) | |
tree | a3ffa55547d382a3b9a40db6abc7880c77a43784 | |
parent | 858064cd462d944fb227ebc8e58b83ab6171485a (diff) | |
download | org.eclipse.emf.compare-4e97142e33b17c1644621333c5c83310e8f0e1a9.tar.gz org.eclipse.emf.compare-4e97142e33b17c1644621333c5c83310e8f0e1a9.tar.xz org.eclipse.emf.compare-4e97142e33b17c1644621333c5c83310e8f0e1a9.zip |
[475586] Reject sub-diffs of rejected diffs when cascading filter is on
The copyLeftToRight and copyRightToLeft methods will now merge only
direct sub-diffs (not all sub-diffs) and these direct sub-diffs will be
merged after the merge of the current diff.
Bug: 475586
Change-Id: Ic7fdf1bac1847df504f3aa9304552bef008983c2
Signed-off-by: Axel Richard <axel.richard@obeo.fr>
7 files changed, 358 insertions, 29 deletions
diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/merge/MergeDiffInvolvingRefineDiffTest.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/merge/MergeDiffInvolvingRefineDiffTest.java new file mode 100644 index 000000000..5ff372d71 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/merge/MergeDiffInvolvingRefineDiffTest.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * Copyright (c) 2015 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.tests.merge; + +import static org.eclipse.emf.compare.utils.EMFComparePredicates.removedFromReference; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.common.base.Predicate; +import com.google.common.collect.Iterators; + +import java.io.IOException; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.compare.Comparison; +import org.eclipse.emf.compare.Diff; +import org.eclipse.emf.compare.merge.AbstractMerger; +import org.eclipse.emf.compare.merge.IMergeOptionAware; +import org.eclipse.emf.compare.merge.IMerger; +import org.eclipse.emf.compare.scope.DefaultComparisonScope; +import org.eclipse.emf.compare.scope.IComparisonScope; +import org.eclipse.emf.compare.uml2.internal.merge.UMLMerger; +import org.eclipse.emf.compare.uml2.tests.AbstractUMLInputData; +import org.eclipse.emf.compare.uml2.tests.AbstractUMLTest; +import org.eclipse.emf.compare.uml2.tests.merge.data.DiffInvolvingRefineDiffInputData; +import org.eclipse.emf.ecore.resource.Resource; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +@SuppressWarnings("nls") +public class MergeDiffInvolvingRefineDiffTest extends AbstractUMLTest { + + private DiffInvolvingRefineDiffInputData input = new DiffInvolvingRefineDiffInputData(); + + @BeforeClass + public static void setupClass() { + fillRegistries(); + } + + @AfterClass + public static void teardownClass() { + resetRegistries(); + } + + @Override + protected AbstractUMLInputData getInput() { + return input; + } + + @Test + public void testMergeRightToLeftWithSubDiffsAwareOption() throws IOException { + final Resource left = input.getLeft(); + final Resource right = input.getRight(); + final IComparisonScope scope = new DefaultComparisonScope(left, right, null); + final Comparison comparisonBefore = getCompare().compare(scope); + EList<Diff> differences = comparisonBefore.getDifferences(); + final IMerger.Registry registry = IMerger.RegistryImpl.createStandaloneInstance(); + final IMerger umlMerger = new UMLMerger(); + umlMerger.setRanking(11); + registry.add(umlMerger); + + assertEquals(6, differences.size()); + + Predicate<? super Diff> removedFromReference = removedFromReference( + "SysMLmodel.InternalBlock.Block1", "ownedConnector", + "SysMLmodel.InternalBlock.Block1.Connector2"); + final Diff diff = Iterators.find(differences.iterator(), removedFromReference); + + IMerger merger = registry.getHighestRankingMerger(diff); + if (merger instanceof IMergeOptionAware) { + ((IMergeOptionAware)merger).getMergeOptions().put(AbstractMerger.SUB_DIFF_AWARE_OPTION, + Boolean.TRUE); + } + merger.copyRightToLeft(diff, null); + + final Comparison comparisonAfter = getCompare().compare(scope); + // The subdiffs are merged with the selected diff (and the dependencies of these subdiffs) + assertTrue("Comparison#getDifferences() must be empty after copyRightToLeft", comparisonAfter + .getDifferences().isEmpty()); + } + + @Test + public void testMergeRightToLeftWithoutSubDiffsAwareOption() throws IOException { + final Resource left = input.getLeft(); + final Resource right = input.getRight(); + final IComparisonScope scope = new DefaultComparisonScope(left, right, null); + final Comparison comparisonBefore = getCompare().compare(scope); + EList<Diff> differences = comparisonBefore.getDifferences(); + final IMerger.Registry registry = IMerger.RegistryImpl.createStandaloneInstance(); + final IMerger umlMerger = new UMLMerger(); + umlMerger.setRanking(11); + registry.add(umlMerger); + + assertEquals(6, differences.size()); + + Predicate<? super Diff> removedFromReference = removedFromReference( + "SysMLmodel.InternalBlock.Block1", "ownedConnector", + "SysMLmodel.InternalBlock.Block1.Connector2"); + final Diff diff = Iterators.find(differences.iterator(), removedFromReference); + + IMerger merger = registry.getHighestRankingMerger(diff); + if (merger instanceof IMergeOptionAware) { + ((IMergeOptionAware)merger).getMergeOptions().put(AbstractMerger.SUB_DIFF_AWARE_OPTION, + Boolean.FALSE); + } + merger.copyRightToLeft(diff, null); + + final Comparison comparisonAfter = getCompare().compare(scope); + // The subdiffs are not merge, only the selected diff + assertEquals(5, comparisonAfter.getDifferences().size()); + } +} diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/merge/data/DiffInvolvingRefineDiffInputData.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/merge/data/DiffInvolvingRefineDiffInputData.java new file mode 100644 index 000000000..d0c60414e --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/merge/data/DiffInvolvingRefineDiffInputData.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2015 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.uml2.tests.merge.data; + +import java.io.IOException; + +import org.eclipse.emf.compare.uml2.tests.AbstractUMLInputData; +import org.eclipse.emf.ecore.resource.Resource; + +public class DiffInvolvingRefineDiffInputData extends AbstractUMLInputData { + + public Resource getLeft() throws IOException { + return loadFromClassLoader("left.uml"); //$NON-NLS-1$ + } + + public Resource getRight() throws IOException { + return loadFromClassLoader("right.uml"); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/merge/data/left.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/merge/data/left.uml new file mode 100644 index 000000000..4dc2db493 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/merge/data/left.uml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8"?> +<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_CXIG4FK6EeSTF-cqE3nRDQ" name="SysMLmodel"> + <packagedElement xmi:type="uml:Package" xmi:id="_YELzwFK7EeSTF-cqE3nRDQ" name="InternalBlock"> + <packagedElement xmi:type="uml:Class" xmi:id="_jaI_YFK7EeSTF-cqE3nRDQ" name="Block1"> + <ownedAttribute xmi:id="_nUAM4FK7EeSTF-cqE3nRDQ" name="part1" aggregation="composite"/> + </packagedElement> + </packagedElement> + <profileApplication xmi:id="_DBboIFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DBkyEFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#/"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_TZ_nULU5EduiKqCzJMWbGw"/> + </profileApplication> + <profileApplication xmi:id="_DB1QwFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DB130FK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//modelelements"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_Gx8MgLX7EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCBeAFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCCsIFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//blocks"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_fSw28LX7EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCEhUFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCFIYFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//portandflows"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_rpx28LX7EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCG9kFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCHkoFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//constraints"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_5WYJ0LX7EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCJZ0FK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCKA4FK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//activities"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_C2zXMLX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCL2EFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCNEMFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//allocations"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_NxdG4LX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCOSUFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCPgcFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//requirements"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_OOJC4LX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCQukFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCR8sFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//interactions"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_meOioLX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCTK0FK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCUY8FK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//statemachines"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_nAF5kLX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCVnEFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCW1MFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//usecases"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_neZmMLX8EduFmqQsrNB9lw"/> + </profileApplication> +</uml:Model> diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/merge/data/right.uml b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/merge/data/right.uml new file mode 100644 index 000000000..95c24d60b --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/merge/data/right.uml @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Blocks="http://www.eclipse.org/papyrus/0.7.0/SysML/Blocks" xmlns:Constraints="http://www.eclipse.org/papyrus/0.7.0/SysML/Constraints" xmlns:ModelElements="http://www.eclipse.org/papyrus/0.7.0/SysML/ModelElements" xmlns:PortAndFlows="http://www.eclipse.org/papyrus/0.7.0/SysML/PortAndFlows" xmlns:Requirements="http://www.eclipse.org/papyrus/0.7.0/SysML/Requirements" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/0.7.0/SysML/Blocks http://www.eclipse.org/papyrus/0.7.0/SysML#//blocks http://www.eclipse.org/papyrus/0.7.0/SysML/Constraints http://www.eclipse.org/papyrus/0.7.0/SysML#//constraints http://www.eclipse.org/papyrus/0.7.0/SysML/ModelElements http://www.eclipse.org/papyrus/0.7.0/SysML#//modelelements http://www.eclipse.org/papyrus/0.7.0/SysML/PortAndFlows http://www.eclipse.org/papyrus/0.7.0/SysML#//portandflows http://www.eclipse.org/papyrus/0.7.0/SysML/Requirements http://www.eclipse.org/papyrus/0.7.0/SysML#//requirements"> + <uml:Model xmi:id="_CXIG4FK6EeSTF-cqE3nRDQ" name="SysMLmodel"> + <packagedElement xmi:type="uml:Package" xmi:id="_YELzwFK7EeSTF-cqE3nRDQ" name="InternalBlock"> + <packagedElement xmi:type="uml:Class" xmi:id="_jaI_YFK7EeSTF-cqE3nRDQ" name="Block1"> + <ownedAttribute xmi:type="uml:Port" xmi:id="_mEWi4FK7EeSTF-cqE3nRDQ" name="flowport2" aggregation="composite"/> + <ownedAttribute xmi:id="_nUAM4FK7EeSTF-cqE3nRDQ" name="part1" aggregation="composite"/> + <ownedConnector xmi:id="_qWtI4FK7EeSTF-cqE3nRDQ" name="Connector2"> + <end xmi:id="_qWtv8FK7EeSTF-cqE3nRDQ" partWithPort="_nUAM4FK7EeSTF-cqE3nRDQ"/> + <end xmi:id="_qWuXAFK7EeSTF-cqE3nRDQ" role="_mEWi4FK7EeSTF-cqE3nRDQ"/> + </ownedConnector> + </packagedElement> + </packagedElement> + <profileApplication xmi:id="_DBboIFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DBkyEFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#/"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_TZ_nULU5EduiKqCzJMWbGw"/> + </profileApplication> + <profileApplication xmi:id="_DB1QwFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DB130FK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//modelelements"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_Gx8MgLX7EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCBeAFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCCsIFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//blocks"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_fSw28LX7EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCEhUFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCFIYFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//portandflows"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_rpx28LX7EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCG9kFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCHkoFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//constraints"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_5WYJ0LX7EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCJZ0FK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCKA4FK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//activities"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_C2zXMLX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCL2EFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCNEMFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//allocations"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_NxdG4LX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCOSUFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCPgcFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//requirements"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_OOJC4LX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCQukFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCR8sFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//interactions"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_meOioLX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCTK0FK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCUY8FK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//statemachines"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_nAF5kLX8EduFmqQsrNB9lw"/> + </profileApplication> + <profileApplication xmi:id="_DCVnEFK6EeSTF-cqE3nRDQ"> + <eAnnotations xmi:id="_DCW1MFK6EeSTF-cqE3nRDQ" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//usecases"/> + </eAnnotations> + <appliedProfile href="pathmap://SysML_PROFILES/SysML.profile.uml#_neZmMLX8EduFmqQsrNB9lw"/> + </profileApplication> + </uml:Model> +</xmi:XMI> diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/suite/AllTests.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/suite/AllTests.java index 1d9a194ab..1fe3e2719 100644 --- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/suite/AllTests.java +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/suite/AllTests.java @@ -40,6 +40,7 @@ import org.eclipse.emf.compare.uml2.tests.implications.ImplicationsInterfaceReal import org.eclipse.emf.compare.uml2.tests.implications.ImplicationsTransitionTest; import org.eclipse.emf.compare.uml2.tests.include.AddIncludeTest; import org.eclipse.emf.compare.uml2.tests.merge.ExtensionMergeTest; +import org.eclipse.emf.compare.uml2.tests.merge.MergeDiffInvolvingRefineDiffTest; import org.eclipse.emf.compare.uml2.tests.message.AddMessageTest; import org.eclipse.emf.compare.uml2.tests.opaque.OpaqueElementBodyChangeDiffTest; import org.eclipse.emf.compare.uml2.tests.opaque.OpaqueElementBodyChangeMergeTest; @@ -74,7 +75,7 @@ import org.junit.runners.Suite.SuiteClasses; ImplicationsTransitionTest.class, ImplicationsInterfaceRealizationTest.class, StaticStereotypedElementItemProviderTest.class, DynamicStereotypedElementItemProviderTest.class, OpaqueElementBodyChangeDiffTest.class, OpaqueElementBodyChangeMergeTest.class, - DanglingStereotypeApplicationTest.class }) + DanglingStereotypeApplicationTest.class, MergeDiffInvolvingRefineDiffTest.class }) public class AllTests { /** 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 87eaa03f7..ef9ab32c8 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 @@ -94,7 +94,31 @@ public final class ComparisonUtil { * @since 3.0 */ public static Function<Diff, Iterable<Diff>> getSubDiffs(final boolean leftToRight) { - return getSubDiffs(leftToRight, new LinkedHashSet<Diff>()); + return getSubDiffs(leftToRight, false, new LinkedHashSet<Diff>()); + } + + /** + * When merging a {@link Diff}, returns the first level of sub diffs 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 + * {@link org.eclipse.emf.compare.ResourceAttachmentChange} , this method will return an empty iterable. + * </p> + * <p> + * If the diff is a {@link ReferenceChange} this method will return the first level differences contained + * in the match that contains the value of the reference change, and all associated diffs of these + * differences. + * </p> + * + * @param leftToRight + * the direction of merge. + * @return an iterable containing the first level of sub diffs of this given diff, and all associated + * diffs of these sub diffs. + * @since 3.3 + */ + public static Function<Diff, Iterable<Diff>> getDirectSubDiffs(final boolean leftToRight) { + return getSubDiffs(leftToRight, true, new LinkedHashSet<Diff>()); } /** @@ -327,6 +351,8 @@ public final class ComparisonUtil { * * @param leftToRight * the direction of merge. + * @param firstLevelOnly + * to get only the first level of subDiffs. * @param processedDiffs * a set of diffs which have been already processed. * @return an iterable containing the sub diffs of this given diff, and all associated diffs of these sub @@ -334,7 +360,7 @@ public final class ComparisonUtil { * @since 3.0 */ private static Function<Diff, Iterable<Diff>> getSubDiffs(final boolean leftToRight, - final LinkedHashSet<Diff> processedDiffs) { + final boolean firstLevelOnly, final LinkedHashSet<Diff> processedDiffs) { return new Function<Diff, Iterable<Diff>>() { public Iterable<Diff> apply(Diff diff) { if (diff instanceof ReferenceChange) { @@ -345,14 +371,16 @@ public final class ComparisonUtil { // if the diff is a Move diff, we don't want its children. if (ofKind(DifferenceKind.MOVE).apply(diff)) { subDiffs = ImmutableList.of(); - } else if (matchOfValue != null) { + } else if (matchOfValue != null && !firstLevelOnly) { subDiffs = filter(matchOfValue.getAllDifferences(), CASCADING_DIFF); + } else if (matchOfValue != null && firstLevelOnly) { + subDiffs = filter(matchOfValue.getDifferences(), CASCADING_DIFF); } else { subDiffs = ImmutableList.of(); } addAll(processedDiffs, subDiffs); final Iterable<Diff> associatedDiffs = getAssociatedDiffs(diff, subDiffs, - processedDiffs, leftToRight); + processedDiffs, leftToRight, firstLevelOnly); return ImmutableSet.copyOf(concat(subDiffs, associatedDiffs)); } } @@ -392,12 +420,14 @@ public final class ComparisonUtil { * a set of diffs which have been already processed. * @param leftToRight * the direction of merge. + * @param firstLevelOnly + * to get only the first level of subDiffs. * @return an iterable containing the associated diffs of these given sub diffs, and all sub diffs of * these associated diffs. * @since 3.0 */ private static Iterable<Diff> getAssociatedDiffs(final Diff diffRoot, Iterable<Diff> subDiffs, - LinkedHashSet<Diff> processedDiffs, boolean leftToRight) { + LinkedHashSet<Diff> processedDiffs, boolean leftToRight, boolean firstLevelOnly) { Collection<Diff> associatedDiffs = new HashSet<Diff>(); for (Diff diff : subDiffs) { final Collection<Diff> reqs = new LinkedHashSet<Diff>(); @@ -416,10 +446,12 @@ public final class ComparisonUtil { } reqs.remove(diffRoot); associatedDiffs.addAll(reqs); + associatedDiffs.addAll(diff.getRefines()); for (Diff req : reqs) { if (!Iterables.contains(subDiffs, req) && !processedDiffs.contains(req)) { processedDiffs.add(req); - addAll(associatedDiffs, getSubDiffs(leftToRight, processedDiffs).apply(req)); + addAll(associatedDiffs, getSubDiffs(leftToRight, firstLevelOnly, processedDiffs).apply( + req)); } } } 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 436c00fce..56999f22e 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 @@ -192,12 +192,6 @@ public abstract class AbstractMerger implements IMerger2, IMergeOptionAware { } } - if (isHandleSubDiffs()) { - final Set<Diff> dependenciesToMerge = Sets.newHashSet(dependencies); - Iterable<Diff> subDiffs = concat(transform(dependenciesToMerge, ComparisonUtil - .getSubDiffs(!mergeRightToLeft))); - addAll(dependencies, subDiffs); - } return dependencies; } @@ -254,7 +248,7 @@ public abstract class AbstractMerger implements IMerger2, IMergeOptionAware { } if (isHandleSubDiffs()) { - final Set<Diff> resultingToMerge = Sets.newHashSet(resulting); + final Set<Diff> resultingToMerge = Sets.newLinkedHashSet(resulting); Iterable<Diff> subDiffs = concat(transform(resultingToMerge, ComparisonUtil .getSubDiffs(!mergeRightToLeft))); addAll(resulting, subDiffs); @@ -375,13 +369,6 @@ public abstract class AbstractMerger implements IMerger2, IMergeOptionAware { } } - if (isHandleSubDiffs()) { - final Set<Diff> directlyImpliedToReject = Sets.newHashSet(directlyImpliedRejections); - Iterable<Diff> subDiffs = concat(transform(directlyImpliedToReject, ComparisonUtil - .getSubDiffs(!mergeRightToLeft))); - addAll(directlyImpliedRejections, subDiffs); - } - return directlyImpliedRejections; } @@ -694,10 +681,6 @@ public abstract class AbstractMerger implements IMerger2, IMergeOptionAware { final Set<Diff> dependencies = getDirectMergeDependencies(target, false); - if (isHandleSubDiffs()) { - addAll(dependencies, ComparisonUtil.getSubDiffs(true).apply(target)); - } - // We'll redo some of the work from getDirectMergeDependencies here in order to ensure we haven't been // merged by another diff (equivalence or implication). // requiresMerging must be executed before actually merging the dependencies because @@ -719,6 +702,13 @@ public abstract class AbstractMerger implements IMerger2, IMergeOptionAware { reject(target, false); } } + + if (isHandleSubDiffs()) { + Set<Diff> subDiffs = Sets.newLinkedHashSet(ComparisonUtil.getDirectSubDiffs(true).apply(target)); + for (Diff subDiff : subDiffs) { + mergeDiff(subDiff, false, monitor); + } + } } /** @@ -739,10 +729,6 @@ public abstract class AbstractMerger implements IMerger2, IMergeOptionAware { final Set<Diff> dependencies = getDirectMergeDependencies(target, true); - if (isHandleSubDiffs()) { - addAll(dependencies, ComparisonUtil.getSubDiffs(false).apply(target)); - } - // We'll redo some of the work from getDirectMergeDependencies here in order to ensure we haven't been // merged by another diff (equivalence or implication). // requiresMerging must be executed before actually merging the dependencies because @@ -764,6 +750,13 @@ public abstract class AbstractMerger implements IMerger2, IMergeOptionAware { accept(target, true); } } + + if (isHandleSubDiffs()) { + Set<Diff> subDiffs = Sets.newLinkedHashSet(ComparisonUtil.getDirectSubDiffs(false).apply(target)); + for (Diff subDiff : subDiffs) { + mergeDiff(subDiff, true, monitor); + } + } } /** |