Fix delete-change conflict detection (at file level)
Removing a file locally and changing it remotely should be seen as a
conflict by EMF Compare, but since we were using the local traversal
(empty since the file has been removed) as starting point, we were not
able to resolve the remote files either, ending up in an empty
comparison because of missing file variants.
Change-Id: I279ea3cd3b30fa65cc5a244917685e76d42e0f81
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFModelProvider.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFModelProvider.java
index 624a442..5dbf655 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFModelProvider.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFModelProvider.java
@@ -358,17 +358,24 @@
if (context instanceof RemoteResourceMappingContext) {
final IStorageProviderAccessor accessor = new RemoteMappingContextStorageAccessor(
(RemoteResourceMappingContext)context);
+ // An empty local traversal doesn't necessarily means empty remote and origin sides!
+ // If the local file no longer exists, remote and ancestor need to use a "dummy" containing only
+ // the local file to start their resolution.
+ StorageTraversal startingPoint = localTraversal;
+ if (startingPoint.getStorages().isEmpty()) {
+ startingPoint = new StorageTraversal(Collections.singleton(file));
+ }
ITypedElement left = null;
ITypedElement right = null;
ITypedElement origin = null;
if (((RemoteResourceMappingContext)context).isThreeWay()) {
- left = findTypedElement(localTraversal, accessor, actualMonitor, DiffSide.SOURCE);
- right = findTypedElement(localTraversal, accessor, actualMonitor, DiffSide.REMOTE);
- origin = findTypedElement(localTraversal, accessor, actualMonitor, DiffSide.ORIGIN);
+ left = findTypedElement(startingPoint, accessor, actualMonitor, DiffSide.SOURCE);
+ right = findTypedElement(startingPoint, accessor, actualMonitor, DiffSide.REMOTE);
+ origin = findTypedElement(startingPoint, accessor, actualMonitor, DiffSide.ORIGIN);
} else {
- left = findTypedElement(localTraversal, accessor, actualMonitor, DiffSide.SOURCE);
- right = findTypedElement(localTraversal, accessor, actualMonitor, DiffSide.REMOTE);
+ left = findTypedElement(startingPoint, accessor, actualMonitor, DiffSide.SOURCE);
+ right = findTypedElement(startingPoint, accessor, actualMonitor, DiffSide.REMOTE);
}
IStorage leftStorage = null;