Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2018-07-17 05:34:51 -0400
committerThomas Wolf2018-07-17 05:34:51 -0400
commit9cf5c4a0fa4718d2070b1dac3b7bc7eb17784de2 (patch)
treee945cc4914dbb3179a4a21cb5b3ad253aaab02b3 /org.eclipse.egit.ui/src/org/eclipse/egit/ui
parentd3a2f47f1aeba79b76d8929bd26c1828a9724e07 (diff)
downloadegit-9cf5c4a0fa4718d2070b1dac3b7bc7eb17784de2.tar.gz
egit-9cf5c4a0fa4718d2070b1dac3b7bc7eb17784de2.tar.xz
egit-9cf5c4a0fa4718d2070b1dac3b7bc7eb17784de2.zip
Disable "Compare with previous" for deletions
"Compare with Previous" in the history view and in the commit viewer outline makes no sense for deletions. The operation makes only sense if both a new and an old version exist. Bug: 536799 Change-Id: Id08200fe9900942cd83a9da0e1badfd075a5590b Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/DiffEditorOutlinePage.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitFileDiffViewer.java12
2 files changed, 10 insertions, 6 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 fa2cb6bdb..b89ca7008 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,7 +224,9 @@ public class DiffEditorOutlinePage extends NestedContentOutlinePage {
}
}
});
- if (selected.size() == 1) {
+ if (selected.size() == 1 && !haveNew.isEmpty()) {
+ // "Compare with previous" makes only sense if there are
+ // both a new and a previous version.
menuManager.add(new Separator());
menuManager.add(new Action(
UIText.CommitFileDiffViewer_CompareMenuLabel) {
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 2f4d5fa27..0a97359f4 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
@@ -107,7 +107,7 @@ public class CommitFileDiffViewer extends TableViewer {
private IAction openWorkingTreeVersion;
- private IAction compare;
+ private IAction compareWithPrevious;
private IAction compareWorkingTreeVersion;
@@ -264,7 +264,8 @@ public class CommitFileDiffViewer extends TableViewer {
}
};
- compare = new Action(UIText.CommitFileDiffViewer_CompareMenuLabel) {
+ compareWithPrevious = new Action(
+ UIText.CommitFileDiffViewer_CompareMenuLabel) {
@Override
public void run() {
ISelection s = getSelection();
@@ -313,7 +314,7 @@ public class CommitFileDiffViewer extends TableViewer {
mgr.add(openThisVersion);
mgr.add(openPreviousVersion);
mgr.add(new Separator());
- mgr.add(compare);
+ mgr.add(compareWithPrevious);
mgr.add(compareWorkingTreeVersion);
mgr.add(blame);
@@ -366,7 +367,8 @@ public class CommitFileDiffViewer extends TableViewer {
boolean oneOrMoreSelected = !sel.isEmpty();
openThisVersion.setEnabled(oneOrMoreSelected && !deleteSelected);
openPreviousVersion.setEnabled(oneOrMoreSelected && !addSelected);
- compare.setEnabled(sel.size() == 1 && !addSelected);
+ compareWithPrevious.setEnabled(
+ sel.size() == 1 && !addSelected && !deleteSelected);
blame.setEnabled(oneOrMoreSelected);
if (sel.size() == 1) {
FileDiff diff = (FileDiff) sel.getFirstElement();
@@ -387,7 +389,7 @@ public class CommitFileDiffViewer extends TableViewer {
openThisVersion.setEnabled(false);
openPreviousVersion.setEnabled(false);
openWorkingTreeVersion.setEnabled(false);
- compare.setEnabled(false);
+ compareWithPrevious.setEnabled(false);
blame.setEnabled(false);
compareWorkingTreeVersion.setEnabled(false);
}

Back to the top