diff options
author | Mathias Kinzler | 2010-12-09 15:10:41 +0000 |
---|---|---|
committer | Mathias Kinzler | 2010-12-09 15:10:41 +0000 |
commit | 2605c9317831bfae62141bdca162be05c4f983f0 (patch) | |
tree | 3c1d016a2d872d02487f92304db14ab68513923a | |
parent | 3730da0da2c2761e79ec43dd29f9c9f2a9249e46 (diff) | |
download | egit-2605c9317831bfae62141bdca162be05c4f983f0.tar.gz egit-2605c9317831bfae62141bdca162be05c4f983f0.tar.xz egit-2605c9317831bfae62141bdca162be05c4f983f0.zip |
Add Skip and Continue to Rebase menu
This depends on JGit change
http://egit.eclipse.org/r/#change,2081
which implements --skip and --continue in the corresponding JGit
command.
Skip is also added to the RebaseResultDialog.
Change-Id: I4db94bc6306e28d1f0c43eb9840d38cc036c56da
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
11 files changed, 306 insertions, 76 deletions
diff --git a/org.eclipse.egit.ui/icons/elcl16/continue.gif b/org.eclipse.egit.ui/icons/elcl16/continue.gif Binary files differnew file mode 100644 index 0000000000..16f4e25175 --- /dev/null +++ b/org.eclipse.egit.ui/icons/elcl16/continue.gif diff --git a/org.eclipse.egit.ui/icons/elcl16/skip.gif b/org.eclipse.egit.ui/icons/elcl16/skip.gif Binary files differnew file mode 100644 index 0000000000..1ec36ae2f1 --- /dev/null +++ b/org.eclipse.egit.ui/icons/elcl16/skip.gif diff --git a/org.eclipse.egit.ui/plugin.xml b/org.eclipse.egit.ui/plugin.xml index a96daba71c..172542e547 100644 --- a/org.eclipse.egit.ui/plugin.xml +++ b/org.eclipse.egit.ui/plugin.xml @@ -1375,6 +1375,55 @@ </count> <iterate> <and> + <instanceof + value="org.eclipse.egit.ui.internal.repository.tree.RepositoryNode"> + </instanceof> + <test + property="GitRepository.canAbortRebase"> + </test> + </and> + </iterate> + </and> + </visibleWhen> + </command> + <command + commandId="org.eclipse.egit.ui.RepositoriesViewContinueRebase" + label="&Continue" + style="push"> + <visibleWhen + checkEnabled="false"> + <and> + <count + value="1"> + </count> + <iterate> + <and> + <instanceof + value="org.eclipse.egit.ui.internal.repository.tree.RepositoryNode"> + </instanceof> + <test + property="GitRepository.canAbortRebase"> + </test> + </and> + </iterate> + </and> + </visibleWhen> + </command> + <command + commandId="org.eclipse.egit.ui.RepositoriesViewSkipRebase" + label="&Skip" + style="push"> + <visibleWhen + checkEnabled="false"> + <and> + <count + value="1"> + </count> + <iterate> + <and> + <instanceof + value="org.eclipse.egit.ui.internal.repository.tree.RepositoryNode"> + </instanceof> <test property="GitRepository.canAbortRebase"> </test> @@ -1956,6 +2005,18 @@ id="org.eclipse.egit.ui.RepositoriesViewAbortRebase" name="Abort Rebase"> </command> + <command + categoryId="org.eclipse.egit.ui.commandCategory" + defaultHandler="org.eclipse.egit.ui.internal.repository.tree.command.SkipRebaseCommand" + id="org.eclipse.egit.ui.RepositoriesViewSkipRebase" + name="Skip Rebase"> + </command> + <command + categoryId="org.eclipse.egit.ui.commandCategory" + defaultHandler="org.eclipse.egit.ui.internal.repository.tree.command.ContinueRebaseCommand" + id="org.eclipse.egit.ui.RepositoriesViewContinueRebase" + name="Continue Rebase"> + </command> </extension> <extension point="org.eclipse.ui.commandImages"> @@ -2095,6 +2156,14 @@ commandId="org.eclipse.egit.ui.RepositoriesViewAbortRebase" icon="icons/elcl16/progress_stop.gif"> </image> + <image + commandId="org.eclipse.egit.ui.RepositoriesViewContinueRebase" + icon="icons/elcl16/continue.gif"> + </image> + <image + commandId="org.eclipse.egit.ui.RepositoriesViewSkipRebase" + icon="icons/elcl16/skip.gif"> + </image> </extension> <extension point="org.eclipse.core.expressions.propertyTesters"> diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java index 59b7efe15a..b45afe847f 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java @@ -38,6 +38,9 @@ public class UIText extends NLS { public static String AbstractHistoryCommanndHandler_NoUniqueRepository; /** */ + public static String AbstractRebaseCommand_DialogTitle; + + /** */ public static String Activator_refreshFailed; /** */ @@ -524,6 +527,9 @@ public class UIText extends NLS { public static String RebaseResultDialog_MergeButton; /** */ + public static String RebaseResultDialog_SkipCommitButton; + + /** */ public static String RebaseResultDialog_StartMergeRadioText; /** */ @@ -1610,6 +1616,15 @@ public class UIText extends NLS { public static String ConfirmationPage_title; /** */ + public static String ContinueRebaseCommand_CancelDialogMessage; + + /** */ + public static String ContinueRebaseCommand_CancelDialogTitle; + + /** */ + public static String ContinueRebaseCommand_JobName; + + /** */ public static String CreateBranchPage_BranchNameLabel; /** */ @@ -2655,6 +2670,15 @@ public class UIText extends NLS { public static String SelectUriWiazrd_Title; /** */ + public static String SkipRebaseCommand_CancelDialogMessage; + + /** */ + public static String SkipRebaseCommand_CancelDialogTitle; + + /** */ + public static String SkipRebaseCommand_JobName; + + /** */ public static String SynchronizeWithAction_localRepoName; /** */ diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/merge/GitMergeEditorInput.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/merge/GitMergeEditorInput.java index 19a2e38dac..80d5ab9f02 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/merge/GitMergeEditorInput.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/merge/GitMergeEditorInput.java @@ -9,6 +9,7 @@ package org.eclipse.egit.ui.internal.merge; import java.io.ByteArrayInputStream; +import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; @@ -40,6 +41,7 @@ import org.eclipse.egit.ui.internal.EditableRevision; import org.eclipse.egit.ui.internal.LocalFileRevision; import org.eclipse.egit.ui.internal.GitCompareFileRevisionEditorInput.EmptyTypedElement; import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jgit.api.RebaseCommand; import org.eclipse.jgit.dircache.DirCacheEntry; import org.eclipse.jgit.dircache.DirCacheIterator; import org.eclipse.jgit.lib.Constants; @@ -53,6 +55,8 @@ import org.eclipse.jgit.treewalk.AbstractTreeIterator; import org.eclipse.jgit.treewalk.FileTreeIterator; import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.treewalk.filter.PathFilterGroup; +import org.eclipse.jgit.util.IO; +import org.eclipse.jgit.util.RawParseUtils; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.graphics.Image; import org.eclipse.team.core.Team; @@ -170,6 +174,11 @@ public class GitMergeEditorInput extends CompareEditorInput { String target; if (repo.getRepositoryState().equals(RepositoryState.MERGING)) target = Constants.MERGE_HEAD; + else if (repo.getRepositoryState().equals( + RepositoryState.REBASING_INTERACTIVE)) + target = readFile(repo.getDirectory(), + RebaseCommand.REBASE_MERGE + File.separatorChar + + RebaseCommand.STOPPED_SHA); else target = Constants.ORIG_HEAD; ObjectId mergeHead = repo.resolve(target); @@ -426,4 +435,13 @@ public class GitMergeEditorInput extends CompareEditorInput { }; return child; } + + private String readFile(File directory, String fileName) throws IOException { + byte[] content = IO.readFully(new File(directory, fileName)); + // strip off the last LF + int end = content.length; + while (0 < end && content[end - 1] == '\n') + end--; + return RawParseUtils.decode(content, 0, end); + } } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseResultDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseResultDialog.java index 14b1b3f55c..3c2a406589 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseResultDialog.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseResultDialog.java @@ -77,6 +77,8 @@ public class RebaseResultDialog extends MessageDialog { private Button startMergeButton; + private Button skipCommitButton; + private Button abortRebaseButton; private Button doNothingButton; @@ -200,6 +202,10 @@ public class RebaseResultDialog extends MessageDialog { startMergeButton = new Button(actionGroup, SWT.RADIO); startMergeButton.setText(UIText.RebaseResultDialog_StartMergeRadioText); + + skipCommitButton = new Button(actionGroup, SWT.RADIO); + skipCommitButton.setText(UIText.RebaseResultDialog_SkipCommitButton); + abortRebaseButton = new Button(actionGroup, SWT.RADIO); abortRebaseButton .setText(UIText.RebaseResultDialog_AbortRebaseRadioText); @@ -277,18 +283,27 @@ public class RebaseResultDialog extends MessageDialog { } CompareUI.openCompareEditor(input); return; + } else if (skipCommitButton.getSelection()) { + // skip the rebase + try { + final RebaseOperation op = new RebaseOperation(repo, + Operation.SKIP); + op.execute(null); + + show(op.getResult(), repo); + } catch (CoreException e) { + Activator.handleError(e.getMessage(), e, true); + } } else if (abortRebaseButton.getSelection()) { // abort the rebase - if (result.getStatus() == Status.STOPPED) { - try { - final RebaseOperation op = new RebaseOperation(repo, - Operation.ABORT); - op.execute(null); + try { + final RebaseOperation op = new RebaseOperation(repo, + Operation.ABORT); + op.execute(null); - show(op.getResult(), repo); - } catch (CoreException e) { - Activator.handleError(e.getMessage(), e, true); - } + show(op.getResult(), repo); + } catch (CoreException e) { + Activator.handleError(e.getMessage(), e, true); } } else if (doNothingButton.getSelection()) { // nothing diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AbortRebaseCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AbortRebaseCommand.java index 6d1d42849a..dbab3da0df 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AbortRebaseCommand.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AbortRebaseCommand.java @@ -10,78 +10,18 @@ *******************************************************************************/ package org.eclipse.egit.ui.internal.repository.tree.command; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.jobs.JobChangeAdapter; -import org.eclipse.egit.core.op.RebaseOperation; import org.eclipse.egit.ui.UIText; -import org.eclipse.egit.ui.internal.rebase.RebaseResultDialog; -import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jgit.api.RebaseCommand.Operation; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; /** * Implements "Abort Rebase" */ -public class AbortRebaseCommand extends - RepositoriesViewCommandHandler<RepositoryTreeNode> { - public Object execute(ExecutionEvent event) throws ExecutionException { - - RepositoryTreeNode node = getSelectedNodes(event).get(0); - - final Repository repository = node.getRepository(); - - String jobname = UIText.AbortRebaseCommand_JobName; - final RebaseOperation rebase = new RebaseOperation(repository, - Operation.ABORT); - Job job = new Job(jobname) { - @Override - protected IStatus run(IProgressMonitor monitor) { - try { - rebase.execute(monitor); - } catch (final CoreException e) { - return e.getStatus(); - } - return Status.OK_STATUS; - } - }; - job.setUser(true); - job.setRule(rebase.getSchedulingRule()); - job.addJobChangeListener(new JobChangeAdapter() { - @Override - public void done(IJobChangeEvent cevent) { - IStatus result = cevent.getJob().getResult(); - if (result.getSeverity() == IStatus.CANCEL) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - // don't use getShell(event) here since - // the active shell has changed since the - // execution has been triggered. - Shell shell = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(); - MessageDialog - .openInformation( - shell, - UIText.AbortRebaseCommand_CancelDialogTitle, - UIText.AbortRebaseCommand_CancelDialogMessage); - } - }); - } else if (result.isOK()) { - RebaseResultDialog.show(rebase.getResult(), repository); - } - } - }); - job.schedule(); - return null; +public class AbortRebaseCommand extends AbstractRebaseCommand { + /** + * Default constructor + */ + public AbortRebaseCommand() { + super(Operation.ABORT, UIText.AbortRebaseCommand_JobName, + UIText.AbortRebaseCommand_CancelDialogMessage); } } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AbstractRebaseCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AbstractRebaseCommand.java new file mode 100644 index 0000000000..206e7bc93e --- /dev/null +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AbstractRebaseCommand.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2010 SAP AG. + * 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: + * Mathias Kinzler (SAP AG) - initial implementation + *******************************************************************************/ +package org.eclipse.egit.ui.internal.repository.tree.command; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.egit.core.op.RebaseOperation; +import org.eclipse.egit.ui.UIText; +import org.eclipse.egit.ui.internal.rebase.RebaseResultDialog; +import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jgit.api.RebaseCommand.Operation; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; + +/** + * Rebase command base class + */ +public abstract class AbstractRebaseCommand extends + RepositoriesViewCommandHandler<RepositoryTreeNode> { + private final Operation operation; + + private final String jobname; + + private final String dialogMessage; + + /** + * @param operation + * @param jobname + * @param dialogMessage + */ + protected AbstractRebaseCommand(Operation operation, String jobname, + String dialogMessage) { + this.operation = operation; + this.jobname = jobname; + this.dialogMessage = dialogMessage; + } + + public Object execute(ExecutionEvent event) throws ExecutionException { + + RepositoryTreeNode node = getSelectedNodes(event).get(0); + + final Repository repository = node.getRepository(); + + final RebaseOperation rebase = new RebaseOperation(repository, + this.operation); + Job job = new Job(jobname) { + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + rebase.execute(monitor); + } catch (final CoreException e) { + return e.getStatus(); + } + return Status.OK_STATUS; + } + }; + job.setUser(true); + job.setRule(rebase.getSchedulingRule()); + job.addJobChangeListener(new JobChangeAdapter() { + @Override + public void done(IJobChangeEvent cevent) { + IStatus result = cevent.getJob().getResult(); + if (result.getSeverity() == IStatus.CANCEL) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + // don't use getShell(event) here since + // the active shell has changed since the + // execution has been triggered. + Shell shell = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getShell(); + MessageDialog.openInformation(shell, + UIText.AbstractRebaseCommand_DialogTitle, + dialogMessage); + } + }); + } else if (result.isOK()) { + RebaseResultDialog.show(rebase.getResult(), repository); + } + } + }); + job.schedule(); + return null; + } +} diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ContinueRebaseCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ContinueRebaseCommand.java new file mode 100644 index 0000000000..a9506f39bf --- /dev/null +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/ContinueRebaseCommand.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2010 SAP AG. + * 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: + * Mathias Kinzler (SAP AG) - initial implementation + *******************************************************************************/ +package org.eclipse.egit.ui.internal.repository.tree.command; + +import org.eclipse.egit.ui.UIText; +import org.eclipse.jgit.api.RebaseCommand.Operation; + +/** + * Implements "Continue Rebase" + */ +public class ContinueRebaseCommand extends AbstractRebaseCommand { + /** + * Default constructor + */ + public ContinueRebaseCommand() { + super(Operation.CONTINUE, UIText.ContinueRebaseCommand_JobName, + UIText.ContinueRebaseCommand_CancelDialogMessage); + } +} diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/SkipRebaseCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/SkipRebaseCommand.java new file mode 100644 index 0000000000..6992e0654b --- /dev/null +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/SkipRebaseCommand.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2010 SAP AG. + * 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: + * Mathias Kinzler (SAP AG) - initial implementation + *******************************************************************************/ +package org.eclipse.egit.ui.internal.repository.tree.command; + +import org.eclipse.egit.ui.UIText; +import org.eclipse.jgit.api.RebaseCommand.Operation; + +/** + * Implements "Skip Rebase" + */ +public class SkipRebaseCommand extends AbstractRebaseCommand { + /** + * Default constructor + */ + public SkipRebaseCommand() { + super(Operation.SKIP, UIText.SkipRebaseCommand_JobName, + UIText.SkipRebaseCommand_CancelDialogMessage); + } +} diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties index 8ecc1e2843..ae6fdccf40 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties @@ -11,6 +11,7 @@ AbortRebaseCommand_CancelDialogTitle=Abort of Rebase was canceled AbortRebaseCommand_JobName=Aborting Rebase AbstractHistoryCommanndHandler_NoInputMessage=Could not get the current input from the history view AbstractHistoryCommanndHandler_NoUniqueRepository=Resources belong to different Repositories +AbstractRebaseCommand_DialogTitle=Action was canceled Activator_refreshingProjects=Refreshing git managed projects Activator_refreshJobName=Git repository refresh Job Activator_repoScanJobName=Repository Change Scanner @@ -185,6 +186,7 @@ RebaseResultDialog_DiffCalculationErrorMessage=Could not calculate Diff of curre RebaseResultDialog_DiffDetailsLabel=&Files with rebase conflicts: RebaseResultDialog_DoNothingRadioText=Do nothing (return to the &workbench) RebaseResultDialog_MergeButton=Merge +RebaseResultDialog_SkipCommitButton=&Skip this commit and continue with the Rebase RebaseResultDialog_StartMergeRadioText=Start Merge &Tool to resolve conflicts RebaseResultDialog_StatusLabel=Result status: {0} RebaseResultDialog_ToggleShowButton=Don't show this confirmation dialog again @@ -831,6 +833,9 @@ ConfigurationEditorComponent_RemoveSubsectionTitle=Remove Subsection ConfigurationEditorComponent_ValueColumnHeader=Value ConfigurationEditorComponent_ValueLabel=&Value: ConfigurationEditorComponent_WrongNumberOfTokensMessage=Wrong number of tokens +ContinueRebaseCommand_CancelDialogMessage=The Abort operation was canceled +ContinueRebaseCommand_CancelDialogTitle=Abort of Rebase was canceled +ContinueRebaseCommand_JobName=Continuing Rebase MixedResetToRevisionAction_mixedReset=Mixed Reset UIIcons_errorDeterminingIconBase=Can't determine icon base. @@ -933,6 +938,9 @@ SelectSynchronizeResourceDialog_srcRef=Select which branch or tag should be trea SelectSynchronizeResourceDialog_dstRef=Select which branch or tag should be treated as destination: SelectSynchronizeResourceDialog_includeUncommitedChanges=Include local &uncommited changes in comparison SelectUriWiazrd_Title=Select a URI +SkipRebaseCommand_CancelDialogMessage=The Skip operation was canceled +SkipRebaseCommand_CancelDialogTitle=Skip of Rebase was canceled +SkipRebaseCommand_JobName=Skipping Rebase SynchronizeWithAction_localRepoName=<local .git> ValidationUtils_CanNotResolveRefMessage=Can not resolve {0} |