Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java')
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java47
1 files changed, 29 insertions, 18 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java
index ec9f8fa1b9..06fbbabb2e 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java
@@ -13,6 +13,7 @@ package org.eclipse.egit.core.op;
import java.io.IOException;
import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
@@ -33,7 +34,7 @@ import org.eclipse.team.core.TeamException;
* This class implements checkouts of a specific revision. A check
* is made that this can be done without data loss.
*/
-public class BranchOperation implements IWorkspaceRunnable {
+public class BranchOperation implements IEGitOperation {
private final Repository repository;
@@ -61,34 +62,44 @@ public class BranchOperation implements IWorkspaceRunnable {
- public void run(IProgressMonitor monitor) throws CoreException {
+ /* (non-Javadoc)
+ * @see org.eclipse.egit.core.op.IEGitOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void execute(IProgressMonitor monitor) throws CoreException {
if (!refName.startsWith(Constants.R_REFS))
throw new TeamException(NLS.bind(
CoreText.BranchOperation_CheckoutOnlyBranchOrTag, refName));
- monitor.beginTask(NLS.bind(CoreText.BranchOperation_performingBranch,
- refName), 6);
- lookupRefs();
- monitor.worked(1);
+ IWorkspaceRunnable action = new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask(NLS.bind(
+ CoreText.BranchOperation_performingBranch, refName), 6);
+ lookupRefs();
+ monitor.worked(1);
- mapObjects();
- monitor.worked(1);
+ mapObjects();
+ monitor.worked(1);
- checkoutTree();
- monitor.worked(1);
+ checkoutTree();
+ monitor.worked(1);
- writeIndex();
- monitor.worked(1);
+ writeIndex();
+ monitor.worked(1);
- updateHeadRef();
- monitor.worked(1);
+ updateHeadRef();
+ monitor.worked(1);
- ProjectUtil.refreshProjects(repository, new SubProgressMonitor(monitor,
- 1));
- monitor.worked(1);
+ ProjectUtil.refreshProjects(repository, new SubProgressMonitor(
+ monitor, 1));
+ monitor.worked(1);
- monitor.done();
+ monitor.done();
+ }
+ };
+ // lock workspace to protect working tree changes
+ ResourcesPlugin.getWorkspace().run(action, monitor);
}
private void updateHeadRef() throws TeamException {

Back to the top