| Summary: | A move of an EObject from a containment reference to another one should NOT create two diffs | ||
|---|---|---|---|
| Product: | [Modeling] EMFCompare | Reporter: | Mikaël Barbero <mikael.barbero> |
| Component: | Core | Assignee: | EMF Compare <emf.compare-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | laurent.goubet |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
Fixed on master and backported for 1.2.1 |
Assuming this sample Ecore model: <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="p1"> <eSubpackages name="p2"> <eSubpackages name="p3"/> <eSubpackages name="p4"/> </eSubpackages> </ecore:EPackage> if I move p3 upward into p1 <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="p1"> <eSubpackages name="p2"> <eSubpackages name="p4"/> </eSubpackages> <eSubpackages name="p3"/> </ecore:EPackage> There is no reason to have the two diff that EMFCompare returns to me: - a change in p3 (p2 has been moved from p1 to p2) - a change in p2 (the order of the reference eSubpackages values has changed The issue is located into ReferencesCheck#checkContainmentReferenceOrderChange(DiffGroup, Match2Elements, EReference) When you are purging left list of all references values that have been added, you should ALSO purge elements that moved from one container to this one as they will be handled by GenericDiffEngine#checkMoves(). The patch is trivial and is about adding an or-ed condition to the purge condition: // Purge "left" list of all reference values that have been added to it for (EObject leftValue : new ArrayList<EObject>(leftElementReferences)) { if (isUnmatched(leftValue) || leftValue.eContainer() != getMatchedEObject(leftValue).eContainer()) leftElementReferences.remove(leftValue); } Regards, Mikael