aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2018-07-29 13:34:00 -0400
committerThomas Wolf2018-08-09 06:17:38 -0400
commit6f3d8fda4f5367a7504f37856c263231b706e3ef (patch)
treeb9f193034034348603897f16a5ca6f9c690bd2fe
parent6722dd695680ac4cd1e53007c38a788d704615d5 (diff)
downloadegit-6f3d8fda4f5367a7504f37856c263231b706e3ef.tar.gz
egit-6f3d8fda4f5367a7504f37856c263231b706e3ef.tar.xz
egit-6f3d8fda4f5367a7504f37856c263231b706e3ef.zip
Handle cancellation of rename detection
Bug: 536324 Change-Id: I54cbb02e8b0160079eb6bcce47869f090de81325 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CompareCoreUtils.java11
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java17
2 files changed, 21 insertions, 7 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CompareCoreUtils.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CompareCoreUtils.java
index d32cec0f1..8300ca4ed 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CompareCoreUtils.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CompareCoreUtils.java
@@ -15,6 +15,7 @@
package org.eclipse.egit.core.internal;
import java.io.IOException;
+import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IContainer;
@@ -29,6 +30,7 @@ import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.jgit.diff.RenameDetector;
+import org.eclipse.jgit.errors.CancelledException;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.Repository;
@@ -140,8 +142,13 @@ public class CompareCoreUtils {
RenameDetector detector = new RenameDetector(repository);
detector.addAll(entries);
- List<DiffEntry> renames = detector.compute(walk.getObjectReader(),
- NullProgressMonitor.INSTANCE);
+ List<DiffEntry> renames = Collections.emptyList();
+ try {
+ renames = detector.compute(walk.getObjectReader(),
+ NullProgressMonitor.INSTANCE);
+ } catch (CancelledException e) {
+ return null;
+ }
for (DiffEntry diff : renames) {
if (diff.getChangeType() == ChangeType.RENAME
&& newPath.equals(diff.getNewPath()))
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java
index fd8e848c3..50706cf91 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java
@@ -15,6 +15,7 @@ package org.eclipse.egit.ui.internal.history;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
@@ -39,6 +40,7 @@ import org.eclipse.jgit.diff.MyersDiff;
import org.eclipse.jgit.diff.RawText;
import org.eclipse.jgit.diff.RawTextComparator;
import org.eclipse.jgit.diff.RenameDetector;
+import org.eclipse.jgit.errors.CancelledException;
import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
@@ -170,11 +172,16 @@ public class FileDiff extends WorkbenchAdapter {
List<DiffEntry> xentries = new LinkedList<>(entries);
RenameDetector detector = new RenameDetector(repository);
detector.addAll(entries);
- EclipseGitProgressTransformer jgitProgress = new EclipseGitProgressTransformer(
- progress.newChild(1));
- List<DiffEntry> renames = detector.compute(walk.getObjectReader(),
- jgitProgress);
- if (!progress.isCanceled()) {
+ boolean cancelled = false;
+ List<DiffEntry> renames = Collections.emptyList();
+ try {
+ renames = detector.compute(walk.getObjectReader(),
+ new EclipseGitProgressTransformer(
+ progress.newChild(1)));
+ } catch (CancelledException e) {
+ cancelled = true;
+ }
+ if (!cancelled) {
progress.setWorkRemaining(renames.size());
for (DiffEntry m : renames) {
final FileDiff d = new FileDiff(repository, commit, m);