Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2013-08-29 23:23:55 +0000
committerMatthias Sohn2013-09-04 16:17:51 +0000
commit522ea8bd0f4910e1b6e7d890c54c7341e3ac8323 (patch)
tree63cdf115b57701040aae499666e68348f77e9f06
parente61a3ecc3ecd8aa090813e79ce2ce5a5dd22bb2b (diff)
downloadegit-522ea8bd0f4910e1b6e7d890c54c7341e3ac8323.tar.gz
egit-522ea8bd0f4910e1b6e7d890c54c7341e3ac8323.tar.xz
egit-522ea8bd0f4910e1b6e7d890c54c7341e3ac8323.zip
[historyView] Prevent nested merge and cherry-pick
When a merge, cherry-pick or rebase is already in progress the commands merge and cherry-pick need to be disabled since we can't nest these operations. Change-Id: I358e9ef787de93c92ce12d3c9a320ec5dc928e66 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CherryPickHandler.java9
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/MergeHandler.java9
2 files changed, 18 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CherryPickHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CherryPickHandler.java
index 7b9e06c91d..5e96498dfd 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CherryPickHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CherryPickHandler.java
@@ -19,6 +19,7 @@ import org.eclipse.egit.ui.internal.commit.RepositoryCommit;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.RepositoryState;
import org.eclipse.jgit.revwalk.RevCommit;
/**
@@ -26,6 +27,14 @@ import org.eclipse.jgit.revwalk.RevCommit;
*/
public class CherryPickHandler extends AbstractHistoryCommandHandler {
+ @Override
+ public boolean isEnabled() {
+ final Repository repository = getRepository(getPage());
+ if (repository == null)
+ return false;
+ return repository.getRepositoryState().equals(RepositoryState.SAFE);
+ }
+
public Object execute(ExecutionEvent event) throws ExecutionException {
RevCommit commit = (RevCommit) getSelection(getPage())
.getFirstElement();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/MergeHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/MergeHandler.java
index 3c81d65275..d3564a35e2 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/MergeHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/MergeHandler.java
@@ -49,6 +49,15 @@ import org.eclipse.ui.handlers.HandlerUtil;
* Executes the Merge
*/
public class MergeHandler extends AbstractHistoryCommandHandler {
+
+ @Override
+ public boolean isEnabled() {
+ final Repository repository = getRepository(getPage());
+ if (repository == null)
+ return false;
+ return repository.getRepositoryState().equals(RepositoryState.SAFE);
+ }
+
public Object execute(ExecutionEvent event) throws ExecutionException {
RevCommit commit = (RevCommit) getSelection(getPage()).getFirstElement();
final Repository repository = getRepository(event);

Back to the top