Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2018-07-08 11:07:50 -0400
committerThomas Wolf2018-07-16 12:34:15 -0400
commitd3a2f47f1aeba79b76d8929bd26c1828a9724e07 (patch)
treed8d317d926cae3e8d02aa1146d2742edb121fd44 /org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal
parent0da9aa76e5fb1f2af437d9b21f87bb66f0e15c96 (diff)
downloadegit-d3a2f47f1aeba79b76d8929bd26c1828a9724e07.tar.gz
egit-d3a2f47f1aeba79b76d8929bd26c1828a9724e07.tar.xz
egit-d3a2f47f1aeba79b76d8929bd26c1828a9724e07.zip
Fix "Compare with Previous" in history view and commit editor outline
Enable or include the command only if there _is_ a previous revision to compare to (i.e., only if the diff is not an addition). Also fix the comparison itself to work for renames, too. Bug: 536799 Change-Id: Ia2c0a706d1bac2f67fad4dbe686cd3e0d9d013d8 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorOutlinePage.java28
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffViewer.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java2
3 files changed, 18 insertions, 20 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorOutlinePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorOutlinePage.java
index 50a264f11..fa2cb6bdb 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorOutlinePage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorOutlinePage.java
@@ -224,19 +224,21 @@ public class DiffEditorOutlinePage extends NestedContentOutlinePage {
}
}
});
- }
- if (selected.size() == 1) {
- menuManager.add(new Separator());
- menuManager.add(new Action(
- UIText.CommitFileDiffViewer_CompareMenuLabel) {
-
- @Override
- public void run() {
- FileDiffRegion fileDiff = selected.iterator().next();
- DiffViewer.showTwoWayFileDiff(fileDiff.getRepository(),
- fileDiff.getDiff());
- }
- });
+ if (selected.size() == 1) {
+ menuManager.add(new Separator());
+ menuManager.add(new Action(
+ UIText.CommitFileDiffViewer_CompareMenuLabel) {
+
+ @Override
+ public void run() {
+ FileDiffRegion fileDiff = selected.iterator()
+ .next();
+ DiffViewer.showTwoWayFileDiff(
+ fileDiff.getRepository(),
+ fileDiff.getDiff());
+ }
+ });
+ }
}
});
Menu menu = contextMenu.createContextMenu(viewer.getTree());
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffViewer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffViewer.java
index 303fa411e..f758e60bd 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffViewer.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffViewer.java
@@ -39,7 +39,6 @@ import org.eclipse.compare.ITypedElement;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.egit.core.internal.util.ResourceUtil;
@@ -842,11 +841,8 @@ public class DiffViewer extends HyperlinkSourceViewer {
newCommit.getName(), oldCommit.getName(), false,
page);
} else {
- IPath location = new Path(
- repository.getWorkTree().getAbsolutePath())
- .append(np);
- CompareUtils.compare(location, repository,
- newCommit.getName(), oldCommit.getName(), false,
+ CompareUtils.compareBetween(repository, np, op,
+ newCommit.getName(), oldCommit.getName(),
page);
}
} catch (IOException e) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java
index 2b73ac854..2f4d5fa27 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java
@@ -366,7 +366,7 @@ public class CommitFileDiffViewer extends TableViewer {
boolean oneOrMoreSelected = !sel.isEmpty();
openThisVersion.setEnabled(oneOrMoreSelected && !deleteSelected);
openPreviousVersion.setEnabled(oneOrMoreSelected && !addSelected);
- compare.setEnabled(sel.size() == 1);
+ compare.setEnabled(sel.size() == 1 && !addSelected);
blame.setEnabled(oneOrMoreSelected);
if (sel.size() == 1) {
FileDiff diff = (FileDiff) sel.getFirstElement();

Back to the top