summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorPhilipp Thun2011-02-25 08:09:11 (EST)
committer Philipp Thun2011-02-25 08:09:11 (EST)
commit4e4f0d27182d0318a9eefd57ad9264504ca073f4 (patch)
tree000feea8da6e3adea1826befd835afa749388a30
parentaf995baba72d1ea74b71b9109fd0bbff79ca267b (diff)
downloadegit-4e4f0d27182d0318a9eefd57ad9264504ca073f4.zip
egit-4e4f0d27182d0318a9eefd57ad9264504ca073f4.tar.gz
egit-4e4f0d27182d0318a9eefd57ad9264504ca073f4.tar.bz2
Remove redundant initialization of GitProjectDatarefs/changes/98/2598/1
This change adds a static 'add()' method to GitProjectData in order to put a project data object into the cache that has been created using the constructor. This change affects the ConnectProviderOperation. Previously for each newly imported project GitProjectData was initialized twice. Change-Id: Id3df0345167dd2cb51f3ffca336f74c21868ab45 Signed-off-by: Philipp Thun <philipp.thun@sap.com>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java2
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java16
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/nonswt/decoration/DecoratableResourceHelperTest.java1
3 files changed, 17 insertions, 2 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java
index 77050e1..4dfb0fc 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java
@@ -118,6 +118,7 @@ public class ConnectProviderOperation implements IEGitOperation {
try {
projectData.setRepositoryMappings(Arrays.asList(actualMapping));
projectData.store();
+ GitProjectData.add(project, projectData);
} catch (CoreException ce) {
try {
GitProjectData.delete(project);
@@ -145,7 +146,6 @@ public class ConnectProviderOperation implements IEGitOperation {
}
RepositoryProvider
.map(project, GitProvider.class.getName());
- projectData = GitProjectData.get(project);
project.refreshLocal(IResource.DEPTH_INFINITE,
new SubProgressMonitor(monitor, 50));
monitor.worked(10);
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
index bde093e..bd1fed2 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
@@ -192,6 +192,20 @@ public class GitProjectData {
d.deletePropertyFilesAndUncache();
}
+ /**
+ * Add the Eclipse project to our association of projects/repositories
+ *
+ * @param p
+ * Eclipse project
+ * @param d
+ * {@link GitProjectData} associated with this project
+ */
+ public static void add(final IProject p, final GitProjectData d) {
+ trace("add(" + p.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ cache(p, d);
+ }
+
static void trace(final String m) {
// TODO is this the right location?
if (GitTraceLocation.CORE.isActive())
@@ -254,7 +268,7 @@ public class GitProjectData {
}
/**
- * TODO: is this right?
+ * Set repository mappings
*
* @param newMappings
*/
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/nonswt/decoration/DecoratableResourceHelperTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/nonswt/decoration/DecoratableResourceHelperTest.java
index 0f2a3c7..c31951d 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/nonswt/decoration/DecoratableResourceHelperTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/nonswt/decoration/DecoratableResourceHelperTest.java
@@ -71,6 +71,7 @@ public class DecoratableResourceHelperTest extends LocalDiskRepositoryTestCase {
GitProjectData projectData = new GitProjectData(project);
projectData.setRepositoryMappings(Collections.singleton(mapping));
projectData.store();
+ GitProjectData.add(project, projectData);
RepositoryProvider.map(project, GitProvider.class.getName());