summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorJens Baumgart2010-03-17 09:46:51 (EDT)
committer Stefan Lay2010-04-01 08:38:21 (EDT)
commitdfc277a9b2f0d15948f81235b010243f53cee334 (patch)
tree18376d86e7038128583ab873755c6b74a30f1aae
parent77beda4de51a204507a4e22dd01fff4172919e33 (diff)
downloadegit-dfc277a9b2f0d15948f81235b010243f53cee334.zip
egit-dfc277a9b2f0d15948f81235b010243f53cee334.tar.gz
egit-dfc277a9b2f0d15948f81235b010243f53cee334.tar.bz2
Fix unhandled CoreException in BranchOperation.refreshProjects refs/changes/61/361/3
Fix unhandled CoreException in BranchOperation.refreshProjects and ResetOperation.refreshProjects. The duplicated refreshProjects method was moved to a new class ProjectUtil. Bug: 303886 Change-Id: I540854bdf53cf7a2aa8f84e6491ea2a4c9cebc71 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/CoreText.java6
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/coretext.properties5
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java56
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/BranchOperation.java38
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java30
5 files changed, 78 insertions, 57 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/CoreText.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/CoreText.java
index 16978ec..11d8bcd 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/CoreText.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/CoreText.java
@@ -185,6 +185,9 @@ public class CoreText extends NLS {
public static String ListRemoteOperation_title;
/** */
+ public static String ProjectUtil_refreshingProjects;
+
+ /** */
public static String PushOperation_resultCancelled;
/** */
@@ -208,6 +211,9 @@ public class CoreText extends NLS {
/** */
public static String TrackOperation_writingIndex;
+ /** */
+ public static String BranchOperation_performingBranch;
+
static {
initializeMessages("org.eclipse.egit.core.coretext", //$NON-NLS-1$
CoreText.class);
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/coretext.properties b/org.eclipse.egit.core/src/org/eclipse/egit/core/coretext.properties
index 398cee7..0f0b76f 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/coretext.properties
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/coretext.properties
@@ -77,6 +77,7 @@ IndexFileRevision_indexEntryNotFound=Git index entry not found
ListRemoteOperation_title=Getting remote branches information
+ProjectUtil_refreshingProjects=Refreshing projects
PushOperation_resultCancelled=Operation was cancelled.
PushOperation_resultNotSupported=Can't push to {0}
PushOperation_resultTransportError=Transport error occured during push operation: {0}
@@ -86,4 +87,6 @@ PushOperation_taskNameNormalRun=Pushing to remote repositories
AddToIndexOperation_failed=Failed to add resource to index
-TrackOperation_writingIndex=Writing index for {0} \ No newline at end of file
+TrackOperation_writingIndex=Writing index for {0}
+
+BranchOperation_performingBranch=Performing branch to {0} \ No newline at end of file
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
new file mode 100644
index 0000000..246b504
--- /dev/null
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.egit.core.internal.util;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.egit.core.CoreText;
+import org.eclipse.jgit.lib.Repository;
+
+/**
+ * This class contains utility methods related to projects
+ *
+ */
+public class ProjectUtil {
+ /**
+ * The method refreshes all projects contained in the given Git repository
+ * @param repository
+ * @param monitor
+ * @throws CoreException
+ */
+ public static void refreshProjects(Repository repository,
+ IProgressMonitor monitor) throws CoreException {
+ final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
+ .getProjects();
+ try {
+ monitor.beginTask(CoreText.ProjectUtil_refreshingProjects,
+ projects.length);
+ final File parentFile = repository.getWorkDir();
+ for (IProject p : projects) {
+ if (monitor.isCanceled())
+ break;
+ final File file = p.getLocation().toFile();
+ if (file.getAbsolutePath().startsWith(
+ parentFile.getAbsolutePath())) {
+ p.refreshLocal(IResource.DEPTH_INFINITE,
+ new SubProgressMonitor(monitor, 1));
+ monitor.worked(1);
+ }
+ }
+ } finally {
+ monitor.done();
+ }
+ }
+}
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 bf629a4..a5ccd0a 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
@@ -10,19 +10,14 @@
*******************************************************************************/
package org.eclipse.egit.core.op;
-import java.io.File;
import java.io.IOException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
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;
import org.eclipse.egit.core.CoreText;
-import org.eclipse.egit.core.internal.trace.GitTraceLocation;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.TeamException;
+import org.eclipse.egit.core.internal.util.ProjectUtil;
import org.eclipse.jgit.errors.CheckoutConflictException;
import org.eclipse.jgit.lib.Commit;
import org.eclipse.jgit.lib.Constants;
@@ -31,6 +26,8 @@ import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.Tree;
import org.eclipse.jgit.lib.WorkDirCheckout;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.team.core.TeamException;
/**
* This class implements checkouts of a specific revision. A check
@@ -65,6 +62,8 @@ public class BranchOperation implements IWorkspaceRunnable {
public void run(IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask(NLS.bind(CoreText.BranchOperation_performingBranch,
+ refName), 6);
lookupRefs();
monitor.worked(1);
@@ -80,34 +79,13 @@ public class BranchOperation implements IWorkspaceRunnable {
updateHeadRef();
monitor.worked(1);
- refreshProjects();
+ ProjectUtil.refreshProjects(repository, new SubProgressMonitor(monitor,
+ 1));
monitor.worked(1);
monitor.done();
}
- private void refreshProjects() {
- final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
- .getProjects();
- final File parentFile = repository.getWorkDir();
- for (IProject p : projects) {
- final File file = p.getLocation().toFile();
- if (file.getAbsolutePath().startsWith(parentFile.getAbsolutePath())) {
- try {
- // TODO is this the right location?
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(
- GitTraceLocation.CORE.getLocation(),
- "Refreshing " + p); //$NON-NLS-1$
- p.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (CoreException e) {
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
- }
- }
- }
- }
-
private void updateHeadRef() throws TeamException {
try {
RefUpdate u = repository.updateRef(Constants.HEAD);
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java
index 2642432..870af40 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java
@@ -13,14 +13,12 @@ package org.eclipse.egit.core.op;
import java.io.File;
import java.io.IOException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
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;
import org.eclipse.egit.core.CoreText;
-import org.eclipse.egit.core.internal.trace.GitTraceLocation;
+import org.eclipse.egit.core.internal.util.ProjectUtil;
import org.eclipse.jgit.lib.Commit;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.GitIndex;
@@ -109,7 +107,8 @@ public class ResetOperation implements IWorkspaceRunnable {
monitor.worked(1);
- refreshProjects();
+ ProjectUtil.refreshProjects(repository, new SubProgressMonitor(monitor,
+ 1));
monitor.done();
}
@@ -128,27 +127,6 @@ public class ResetOperation implements IWorkspaceRunnable {
}
}
- private void refreshProjects() {
- final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- final File parentFile = repository.getWorkDir();
- for (IProject p : projects) {
- final File file = p.getLocation().toFile();
- if (file.getAbsolutePath().startsWith(parentFile.getAbsolutePath())) {
- try {
- // TODO is this the right location?
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(
- GitTraceLocation.CORE.getLocation(),
- "Refreshing " + p); //$NON-NLS-1$
- p.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (CoreException e) {
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
- }
- }
- }
- }
-
private void mapObjects() throws TeamException {
final ObjectId commitId;
try {