Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2015-03-05 13:40:09 +0000
committerLaurent Delaigue2015-03-13 13:19:29 +0000
commitdde75fc4abef6086691713c7871786326f6f6417 (patch)
tree98756b74a47426d201d32ee3f7975407faefd671
parent1767592c59cd27c2610c3c81a0d0262a6633f751 (diff)
downloadorg.eclipse.emf.compare-dde75fc4abef6086691713c7871786326f6f6417.tar.gz
org.eclipse.emf.compare-dde75fc4abef6086691713c7871786326f6f6417.tar.xz
org.eclipse.emf.compare-dde75fc4abef6086691713c7871786326f6f6417.zip
[442227] Compare an untracked file with HEAD.3.1.0M6
Fix IllegalArgumentException trying to compare an untracked file with HEAD. Just like the origin side, the right/remote side of the comparison can be null, e.g compare an untracked file with HEAD. Bug: 442227 Change-Id: I8454e7cccb3e75181d2cab60e438d588566c9326 Signed-off-by: Axel Richard <axel.richard@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ComparisonScopeBuilder.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ComparisonScopeBuilder.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ComparisonScopeBuilder.java
index 9ae56d070..5b027e6e0 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ComparisonScopeBuilder.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/ComparisonScopeBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2014 Obeo.
+ * Copyright (c) 2013, 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
@@ -25,9 +25,11 @@ import java.util.LinkedHashSet;
import java.util.Set;
import org.eclipse.compare.ICompareContainer;
+import org.eclipse.compare.IStreamContentAccessor;
import org.eclipse.compare.ITypedElement;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubMonitor;
@@ -373,7 +375,13 @@ public final class ComparisonScopeBuilder {
// This is not a local comparison, and we've got no info on how to load remote revisions.
final IStorage leftStorage = StreamAccessorStorage.fromTypedElement(left);
- final IStorage rightStorage = StreamAccessorStorage.fromTypedElement(right);
+ Assert.isNotNull(leftStorage);
+ final IStorage rightStorage;
+ if (right instanceof IStreamContentAccessor) {
+ rightStorage = StreamAccessorStorage.fromTypedElement(right);
+ } else {
+ rightStorage = null;
+ }
final IStorage originStorage;
if (origin != null) {
originStorage = StreamAccessorStorage.fromTypedElement(origin);
@@ -398,8 +406,12 @@ public final class ComparisonScopeBuilder {
private SynchronizationModel loadSingleResource(IStorage left, IStorage right, IStorage origin) {
final StorageTraversal leftTraversal = new StorageTraversal(new LinkedHashSet<IStorage>(Arrays
.asList(left)));
- final StorageTraversal rightTraversal = new StorageTraversal(new LinkedHashSet<IStorage>(Arrays
- .asList(right)));
+ final StorageTraversal rightTraversal;
+ if (right != null) {
+ rightTraversal = new StorageTraversal(new LinkedHashSet<IStorage>(Arrays.asList(right)));
+ } else {
+ rightTraversal = new StorageTraversal(Sets.<IStorage> newLinkedHashSet());
+ }
final StorageTraversal originTraversal;
if (origin != null) {
originTraversal = new StorageTraversal(new LinkedHashSet<IStorage>(Arrays.asList(origin)));

Back to the top