Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-08-20 08:49:40 +0000
committerEike Stepper2012-08-20 08:49:40 +0000
commit9a9447a7370e31eaa4e602a9b406581bc6959584 (patch)
treeb0dd071e53a6373ce01f50dc390dc7e6e06e087e
parent9eb96d64721b6204870b74c6a255f69d7aa5034d (diff)
downloadcdo-9a9447a7370e31eaa4e602a9b406581bc6959584.tar.gz
cdo-9a9447a7370e31eaa4e602a9b406581bc6959584.tar.xz
cdo-9a9447a7370e31eaa4e602a9b406581bc6959584.zip
Add git pull / cherry-pick
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/META-INF/MANIFEST.MF10
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/plugin.xml56
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/AbstractAction.java (renamed from plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/AbstractRepositoryAction.java)52
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/AbstractRepositoryAction.java37
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitAddAllAction.java (renamed from plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitAddAllAction.java)8
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitBashAction.java (renamed from plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitBashAction.java)8
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitCleanAction.java (renamed from plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitCleanAction.java)8
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitPullAction.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitResetHardAction.java (renamed from plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitResetHardAction.java)8
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitStatusAction.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/revision/AbstractRevisionAction.java111
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/revision/GitCherryPickAction.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/revision/GitRebaseAction.java28
13 files changed, 371 insertions, 42 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.releng.gitbash/META-INF/MANIFEST.MF
index ecf471dd76..a3c9a4d5df 100644
--- a/plugins/org.eclipse.emf.cdo.releng.gitbash/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/META-INF/MANIFEST.MF
@@ -9,10 +9,14 @@ Bundle-Activator: org.eclipse.emf.cdo.releng.gitbash.Activator
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jgit;bundle-version="[1.0.0,3.0.0)",
- org.eclipse.egit.core;bundle-version="[1.0.0,3.0.0)",
+ org.eclipse.team.ui;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.jgit;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.egit.core;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.egit.ui;bundle-version="[2.0.0,3.0.0)",
org.eclipse.mylyn.tasks.core;bundle-version="[3.3.0,4.0.0)";resolution:=optional,
org.eclipse.mylyn.tasks.ui;bundle-version="[3.3.0,4.0.0)";resolution:=optional
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.emf.cdo.releng.gitbash;version="1.0.100";x-internal:=true
+Export-Package: org.eclipse.emf.cdo.releng.gitbash;version="1.0.100";x-internal:=true,
+ org.eclipse.emf.cdo.releng.gitbash.repository;version="1.0.100";x-internal:=true,
+ org.eclipse.emf.cdo.releng.gitbash.revision;version="1.0.100";x-internal:=true
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/plugin.xml b/plugins/org.eclipse.emf.cdo.releng.gitbash/plugin.xml
index c1245cdbfd..a3f09a4654 100644
--- a/plugins/org.eclipse.emf.cdo.releng.gitbash/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/plugin.xml
@@ -20,8 +20,9 @@
id="org.eclipse.emf.cdo.releng.gitbash.contribution1"
objectClass="org.eclipse.egit.ui.internal.repository.tree.RepositoryNode">
<action
- class="org.eclipse.emf.cdo.releng.gitbash.GitCleanAction"
+ class="org.eclipse.emf.cdo.releng.gitbash.repository.GitCleanAction"
enablesFor="1"
+ icon="icons/gitbash.gif"
id="org.eclipse.emf.cdo.releng.gitbash.GitCleanAction"
label="Git Clean"
menubarPath="additions"
@@ -29,8 +30,9 @@
style="push"
tooltip="Execute git clean -f -d"/>
<action
- class="org.eclipse.emf.cdo.releng.gitbash.GitResetHardAction"
+ class="org.eclipse.emf.cdo.releng.gitbash.repository.GitResetHardAction"
enablesFor="1"
+ icon="icons/gitbash.gif"
id="org.eclipse.emf.cdo.releng.gitbash.GitResetHardAction"
label="Git Reset Hard"
menubarPath="additions"
@@ -38,8 +40,9 @@
style="push"
tooltip="Execute git reset --hard"/>
<action
- class="org.eclipse.emf.cdo.releng.gitbash.GitAddAllAction"
+ class="org.eclipse.emf.cdo.releng.gitbash.repository.GitAddAllAction"
enablesFor="1"
+ icon="icons/gitbash.gif"
id="org.eclipse.emf.cdo.releng.gitbash.GitAddAllAction"
label="Git Add All"
menubarPath="additions"
@@ -47,7 +50,27 @@
style="push"
tooltip="Execute git add --all"/>
<action
- class="org.eclipse.emf.cdo.releng.gitbash.GitBashAction"
+ class="org.eclipse.emf.cdo.releng.gitbash.repository.GitPullAction"
+ enablesFor="1"
+ icon="icons/gitbash.gif"
+ id="org.eclipse.emf.cdo.releng.gitbash.repository.GitPullAction"
+ label="Git Pull"
+ menubarPath="additions"
+ state="true"
+ style="push"
+ tooltip="Execute git pull"/>
+ <action
+ class="org.eclipse.emf.cdo.releng.gitbash.repository.GitStatusAction"
+ enablesFor="1"
+ icon="icons/gitbash.gif"
+ id="org.eclipse.emf.cdo.releng.gitbash.GitStatusAction"
+ label="Git Status"
+ menubarPath="additions"
+ state="true"
+ style="push"
+ tooltip="Execute git status"/>
+ <action
+ class="org.eclipse.emf.cdo.releng.gitbash.repository.GitBashAction"
enablesFor="1"
icon="icons/gitbash.gif"
id="org.eclipse.emf.cdo.releng.gitbash.GitAction"
@@ -60,6 +83,31 @@
<objectContribution
adaptable="false"
id="org.eclipse.emf.cdo.releng.gitbash.contribution2"
+ objectClass="org.eclipse.jgit.revwalk.RevObject">
+ <action
+ class="org.eclipse.emf.cdo.releng.gitbash.revision.GitRebaseAction"
+ enablesFor="1"
+ icon="icons/gitbash.gif"
+ id="org.eclipse.emf.cdo.releng.gitbash.GitRebaseAction"
+ label="Git Rebase"
+ menubarPath="additions"
+ state="true"
+ style="push"
+ tooltip="Execute git rebase"/>
+ <action
+ class="org.eclipse.emf.cdo.releng.gitbash.revision.GitCherryPickAction"
+ enablesFor="1"
+ icon="icons/gitbash.gif"
+ id="org.eclipse.emf.cdo.releng.gitbash.revision.GitCherryPickAction"
+ label="Git Cherry-Pick"
+ menubarPath="additions"
+ state="true"
+ style="push"
+ tooltip="Execute git cherry-pick -n"/>
+ </objectContribution>
+ <objectContribution
+ adaptable="false"
+ id="org.eclipse.emf.cdo.releng.gitbash.contribution3"
objectClass="org.eclipse.mylyn.tasks.core.ITaskAttachment">
<action
class="org.eclipse.emf.cdo.releng.gitbash.GitApplyAction"
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/AbstractRepositoryAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/AbstractAction.java
index 3e6cf322e0..369ce66ce2 100644
--- a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/AbstractRepositoryAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/AbstractAction.java
@@ -14,24 +14,29 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jgit.lib.Repository;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
-import java.io.File;
-
/**
* @author Eike Stepper
*/
-public abstract class AbstractRepositoryAction implements IObjectActionDelegate
+public abstract class AbstractAction<TARGET> implements IObjectActionDelegate
{
private IWorkbenchPart targetPart;
- private Repository repository;
+ private Class<TARGET> targetClass;
+
+ private TARGET target;
+
+ public AbstractAction(Class<TARGET> targetClass)
+ {
+ this.targetClass = targetClass;
+ }
- public AbstractRepositoryAction()
+ public IWorkbenchPart getTargetPart()
{
+ return targetPart;
}
public void setActivePart(IAction action, IWorkbenchPart targetPart)
@@ -41,26 +46,22 @@ public abstract class AbstractRepositoryAction implements IObjectActionDelegate
public void selectionChanged(IAction action, ISelection selection)
{
- repository = null;
+ target = null;
if (selection instanceof IStructuredSelection)
{
IStructuredSelection ssel = (IStructuredSelection)selection;
Object element = ssel.getFirstElement();
- if (element instanceof IAdaptable)
- {
- IAdaptable adaptable = (IAdaptable)element;
- repository = (Repository)adaptable.getAdapter(Repository.class);
- }
+ target = getAdapter(element, targetClass);
}
}
public void run(IAction action)
{
- if (repository != null)
+ if (target != null)
{
try
{
- run(targetPart.getSite().getShell(), repository.getWorkTree());
+ run(targetPart.getSite().getShell(), target);
}
catch (Exception ex)
{
@@ -69,5 +70,26 @@ public abstract class AbstractRepositoryAction implements IObjectActionDelegate
}
}
- protected abstract void run(Shell shell, File workTree) throws Exception;
+ protected abstract void run(Shell shell, TARGET target) throws Exception;
+
+ @SuppressWarnings("unchecked")
+ public static <T> T getAdapter(Object adaptable, Class<T> c)
+ {
+ if (c.isInstance(adaptable))
+ {
+ return (T)adaptable;
+ }
+
+ if (adaptable instanceof IAdaptable)
+ {
+ IAdaptable a = (IAdaptable)adaptable;
+ Object adapter = a.getAdapter(c);
+ if (c.isInstance(adapter))
+ {
+ return (T)adapter;
+ }
+ }
+
+ return null;
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/AbstractRepositoryAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/AbstractRepositoryAction.java
new file mode 100644
index 0000000000..3be657bb00
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/AbstractRepositoryAction.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.gitbash.repository;
+
+import org.eclipse.emf.cdo.releng.gitbash.AbstractAction;
+
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.swt.widgets.Shell;
+
+import java.io.File;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractRepositoryAction extends AbstractAction<Repository>
+{
+ public AbstractRepositoryAction()
+ {
+ super(Repository.class);
+ }
+
+ @Override
+ protected void run(Shell shell, Repository repository) throws Exception
+ {
+ run(shell, repository.getWorkTree());
+ }
+
+ protected abstract void run(Shell shell, File workTree) throws Exception;
+}
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitAddAllAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitAddAllAction.java
index aba2aef32e..0d1bc6157d 100644
--- a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitAddAllAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitAddAllAction.java
@@ -8,7 +8,9 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.emf.cdo.releng.gitbash;
+package org.eclipse.emf.cdo.releng.gitbash.repository;
+
+import org.eclipse.emf.cdo.releng.gitbash.GitBash;
import org.eclipse.swt.widgets.Shell;
@@ -19,10 +21,6 @@ import java.io.File;
*/
public class GitAddAllAction extends AbstractRepositoryAction
{
- public GitAddAllAction()
- {
- }
-
@Override
protected void run(Shell shell, File workTree) throws Exception
{
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitBashAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitBashAction.java
index 3f3f4f60af..238c9ed7d3 100644
--- a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitBashAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitBashAction.java
@@ -8,7 +8,9 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.emf.cdo.releng.gitbash;
+package org.eclipse.emf.cdo.releng.gitbash.repository;
+
+import org.eclipse.emf.cdo.releng.gitbash.GitBash;
import org.eclipse.swt.widgets.Shell;
@@ -19,10 +21,6 @@ import java.io.File;
*/
public class GitBashAction extends AbstractRepositoryAction
{
- public GitBashAction()
- {
- }
-
@Override
protected void run(Shell shell, File workTree) throws Exception
{
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitCleanAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitCleanAction.java
index e27411a744..e309e06eee 100644
--- a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitCleanAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitCleanAction.java
@@ -8,7 +8,9 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.emf.cdo.releng.gitbash;
+package org.eclipse.emf.cdo.releng.gitbash.repository;
+
+import org.eclipse.emf.cdo.releng.gitbash.GitBash;
import org.eclipse.swt.widgets.Shell;
@@ -19,10 +21,6 @@ import java.io.File;
*/
public class GitCleanAction extends AbstractRepositoryAction
{
- public GitCleanAction()
- {
- }
-
@Override
protected void run(Shell shell, File workTree) throws Exception
{
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitPullAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitPullAction.java
new file mode 100644
index 0000000000..d03a34ad3a
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitPullAction.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.gitbash.repository;
+
+import org.eclipse.emf.cdo.releng.gitbash.GitBash;
+
+import org.eclipse.swt.widgets.Shell;
+
+import java.io.File;
+
+/**
+ * @author Eike Stepper
+ */
+public class GitPullAction extends AbstractRepositoryAction
+{
+ @Override
+ protected void run(Shell shell, File workTree) throws Exception
+ {
+ GitBash.executeCommand(shell, workTree, "git pull");
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitResetHardAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitResetHardAction.java
index 0695333dab..7342b1b99b 100644
--- a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitResetHardAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitResetHardAction.java
@@ -8,7 +8,9 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.emf.cdo.releng.gitbash;
+package org.eclipse.emf.cdo.releng.gitbash.repository;
+
+import org.eclipse.emf.cdo.releng.gitbash.GitBash;
import org.eclipse.swt.widgets.Shell;
@@ -19,10 +21,6 @@ import java.io.File;
*/
public class GitResetHardAction extends AbstractRepositoryAction
{
- public GitResetHardAction()
- {
- }
-
@Override
protected void run(Shell shell, File workTree) throws Exception
{
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitStatusAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitStatusAction.java
new file mode 100644
index 0000000000..91057c01d2
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/GitStatusAction.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.gitbash.repository;
+
+import org.eclipse.emf.cdo.releng.gitbash.GitBash;
+
+import org.eclipse.swt.widgets.Shell;
+
+import java.io.File;
+
+/**
+ * @author Eike Stepper
+ */
+public class GitStatusAction extends AbstractRepositoryAction
+{
+ @Override
+ protected void run(Shell shell, File workTree) throws Exception
+ {
+ GitBash.executeCommand(shell, workTree, "git status");
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/revision/AbstractRevisionAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/revision/AbstractRevisionAction.java
new file mode 100644
index 0000000000..1d420accc5
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/revision/AbstractRevisionAction.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.gitbash.revision;
+
+import org.eclipse.emf.cdo.releng.gitbash.AbstractAction;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.egit.core.AdapterUtils;
+import org.eclipse.egit.core.project.RepositoryMapping;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevObject;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.ui.history.IHistoryView;
+import org.eclipse.ui.IWorkbenchPart;
+
+import java.io.File;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractRevisionAction extends AbstractAction<RevObject>
+{
+ public AbstractRevisionAction()
+ {
+ super(RevObject.class);
+ }
+
+ @Override
+ protected void run(Shell shell, RevObject revision) throws Exception
+ {
+ Repository repository = getRepository();
+ if (repository != null)
+ {
+ File workTree = repository.getWorkTree();
+ String id = revision.getId().name();
+ run(shell, workTree, id);
+ }
+ }
+
+ protected abstract void run(Shell shell, File workTree, String revision) throws Exception;
+
+ @SuppressWarnings({ "restriction", "rawtypes" })
+ private Repository getRepository()
+ {
+ Object input = getInput();
+ if (input == null)
+ {
+ return null;
+ }
+
+ if (input instanceof org.eclipse.egit.ui.internal.history.HistoryPageInput)
+ {
+ return ((org.eclipse.egit.ui.internal.history.HistoryPageInput)input).getRepository();
+ }
+
+ if (input instanceof org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)
+ {
+ return ((org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)input).getRepository();
+ }
+
+ if (input instanceof IResource)
+ {
+ RepositoryMapping mapping = RepositoryMapping.getMapping((IResource)input);
+ if (mapping != null)
+ {
+ return mapping.getRepository();
+ }
+ }
+
+ if (input instanceof IAdaptable)
+ {
+ IResource resource = (IResource)((IAdaptable)input).getAdapter(IResource.class);
+ if (resource != null)
+ {
+ RepositoryMapping mapping = RepositoryMapping.getMapping(resource);
+ if (mapping != null)
+ {
+ return mapping.getRepository();
+ }
+ }
+ }
+
+ Repository repo = AdapterUtils.adapt(input, Repository.class);
+ if (repo != null)
+ {
+ return repo;
+ }
+
+ return null;
+ }
+
+ private Object getInput()
+ {
+ IWorkbenchPart part = getTargetPart();
+ if (part instanceof IHistoryView)
+ {
+ return ((IHistoryView)part).getHistoryPage().getInput();
+ }
+
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/revision/GitCherryPickAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/revision/GitCherryPickAction.java
new file mode 100644
index 0000000000..fee0ce8aee
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/revision/GitCherryPickAction.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.gitbash.revision;
+
+import org.eclipse.emf.cdo.releng.gitbash.GitBash;
+
+import org.eclipse.swt.widgets.Shell;
+
+import java.io.File;
+
+/**
+ * @author Eike Stepper
+ */
+public class GitCherryPickAction extends AbstractRevisionAction
+{
+ @Override
+ protected void run(Shell shell, File workTree, String revision) throws Exception
+ {
+ GitBash.executeCommand(shell, workTree, "git cherry-pick -n " + revision);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/revision/GitRebaseAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/revision/GitRebaseAction.java
new file mode 100644
index 0000000000..184be7371b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/revision/GitRebaseAction.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.gitbash.revision;
+
+import org.eclipse.swt.widgets.Shell;
+
+import java.io.File;
+
+/**
+ * @author Eike Stepper
+ */
+public class GitRebaseAction extends AbstractRevisionAction
+{
+ @Override
+ protected void run(Shell shell, File workTree, String revision) throws Exception
+ {
+ System.out.println(workTree.getAbsolutePath() + " --> git rebase " + revision);
+ // GitBash.executeCommand(shell, workTree, "git rebase ");
+ }
+}

Back to the top