Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Delaigue2015-09-16 11:56:57 -0400
committerLaurent Delaigue2015-09-18 02:49:19 -0400
commit92e3df0cb5f57f5c81f324ee599834cc31deb047 (patch)
tree0a18aebe46a5deea3c840733320bcd39b647f900
parentc08604342db8739550949ba51c21a46ed9445d51 (diff)
downloadorg.eclipse.emf.compare-92e3df0cb5f57f5c81f324ee599834cc31deb047.tar.gz
org.eclipse.emf.compare-92e3df0cb5f57f5c81f324ee599834cc31deb047.tar.xz
org.eclipse.emf.compare-92e3df0cb5f57f5c81f324ee599834cc31deb047.zip
[477607] Fix erroneous conflict detection on uncontrol
Bug: 477607 Change-Id: Ie27efabd1596c74df9fe2290e039284c129a363f Signed-off-by: Laurent Delaigue <laurent.delaigue@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java55
1 files changed, 43 insertions, 12 deletions
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java
index 9defe1604..2af90aca7 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/DefaultConflictDetector.java
@@ -924,18 +924,45 @@ public class DefaultConflictDetector implements IConflictDetector {
// [381143] Every Diff "under" a root deletion conflicts with it.
if (diff.getKind() == DifferenceKind.DELETE) {
- final Predicate<? super Diff> candidateFilter = new ConflictCandidateFilter(diff);
- for (Diff extendedCandidate : Iterables.filter(match.getAllDifferences(), candidateFilter)) {
- if (isDeleteOrUnsetDiff(extendedCandidate)) {
- conflictOn(comparison, diff, extendedCandidate, ConflictKind.PSEUDO);
- } else {
- conflictOn(comparison, diff, extendedCandidate, ConflictKind.REAL);
+ // [477607] DELETE does not necessarily mean that the element is removed from the model
+ EObject o = getRelatedModelElement(diff);
+ if (o != null && o.eContainer() == null) {
+ final Predicate<? super Diff> candidateFilter = new ConflictCandidateFilter(diff);
+ for (Diff extendedCandidate : Iterables.filter(match.getAllDifferences(), candidateFilter)) {
+ if (isDeleteOrUnsetDiff(extendedCandidate)) {
+ conflictOn(comparison, diff, extendedCandidate, ConflictKind.PSEUDO);
+ } else {
+ conflictOn(comparison, diff, extendedCandidate, ConflictKind.REAL);
+ }
}
}
}
}
/**
+ * Provide the model element the given diff applies to.
+ *
+ * @param diff
+ * The change
+ * @return The modele element of the given diff, or null if it cannot be found.
+ */
+ private EObject getRelatedModelElement(ResourceAttachmentChange diff) {
+ Match m = diff.getMatch();
+ EObject o;
+ switch (diff.getSource()) {
+ case LEFT:
+ o = m.getLeft();
+ break;
+ case RIGHT:
+ o = m.getRight();
+ break;
+ default:
+ o = null;
+ }
+ return o;
+ }
+
+ /**
* Returns the MatchResource corresponding to the given <code>resource</code>.
*
* @param comparison
@@ -984,12 +1011,16 @@ public class DefaultConflictDetector implements IConflictDetector {
// other
conflictOn(comparison, diff, candidate, ConflictKind.REAL);
} else if (diff.getKind() == DifferenceKind.DELETE) {
- // The root has been deleted.
- // Anything other than a delete of this value in a reference is a conflict.
- if (candidate.getKind() == DifferenceKind.DELETE) {
- // No conflict here
- } else {
- conflictOn(comparison, diff, candidate, ConflictKind.REAL);
+ // [477607] DELETE does not necessarily mean that the element is removed from the model
+ EObject o = getRelatedModelElement(diff);
+ if (o != null && o.eContainer() == null) {
+ // The root has been deleted.
+ // Anything other than a delete of this value in a reference is a conflict.
+ if (candidate.getKind() == DifferenceKind.DELETE) {
+ // No conflict here
+ } else {
+ conflictOn(comparison, diff, candidate, ConflictKind.REAL);
+ }
}
}
}

Back to the top