Skip to content
Snippets Groups Projects
Commit cc2de809 authored by Sebastian Krings's avatar Sebastian Krings
Browse files

drop some problematic emf diffs, see comment

parent 11dbb6c4
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
package org.eventb.texttools; package org.eventb.texttools;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
...@@ -21,6 +22,7 @@ import org.eclipse.emf.common.util.EMap; ...@@ -21,6 +22,7 @@ import org.eclipse.emf.common.util.EMap;
import org.eclipse.emf.common.util.URI; import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.compare.Comparison; import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff; import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.DifferenceKind;
import org.eclipse.emf.compare.EMFCompare; import org.eclipse.emf.compare.EMFCompare;
import org.eclipse.emf.compare.diff.DefaultDiffEngine; import org.eclipse.emf.compare.diff.DefaultDiffEngine;
import org.eclipse.emf.compare.diff.IDiffEngine; import org.eclipse.emf.compare.diff.IDiffEngine;
...@@ -209,6 +211,8 @@ public class PersistenceHelper { ...@@ -209,6 +211,8 @@ public class PersistenceHelper {
registry.add(evbMerger); registry.add(evbMerger);
BatchMerger bm = new BatchMerger(registry); BatchMerger bm = new BatchMerger(registry);
differences = filter(differences);
bm.copyAllRightToLeft(differences, null); bm.copyAllRightToLeft(differences, null);
long time2 = System.currentTimeMillis(); long time2 = System.currentTimeMillis();
...@@ -218,6 +222,22 @@ public class PersistenceHelper { ...@@ -218,6 +222,22 @@ public class PersistenceHelper {
} }
} }
// for some reasons, there are still problematic diffs:
// usually, they can be identified as follows:
// 1. right = null, i.e. Camille does not hold this element
// 2. ADD, i.e. the "nothing" coming from Camille is added to the EMF model
// => we drop the diff before we screw up the database
// Obvoiusly it would be better not to generate the diff at all....
private static List<Diff> filter(List<Diff> differences) {
List<Diff> newList = new ArrayList<Diff>();
for (Diff d : differences) {
if (!(d.getKind() == DifferenceKind.ADD && d.getMatch().getRight() == null)) {
newList.add(d);
}
}
return newList;
}
public static void mergeRootElement(final Resource resource, public static void mergeRootElement(final Resource resource,
final EventBNamedCommentedComponentElement newVersion, final EventBNamedCommentedComponentElement newVersion,
final IProgressMonitor monitor) { final IProgressMonitor monitor) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment