aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDariusz Luksza2010-06-20 17:54:11 (EDT)
committerMatthias Sohn2010-06-20 17:54:11 (EDT)
commit29b7ae92f1e4dec4a17ba6078e499342f2df83ea (patch)
treebdf321755004253b37b9d03c3b232da2203d95e9
parenta58311f91838f1c8a6f6f31d99cb343f1acc1d18 (diff)
downloadegit-29b7ae92f1e4dec4a17ba6078e499342f2df83ea.zip
egit-29b7ae92f1e4dec4a17ba6078e499342f2df83ea.tar.gz
egit-29b7ae92f1e4dec4a17ba6078e499342f2df83ea.tar.bz2
Simplify API of GitSynchronizeData class.refs/changes/09/909/3
Fourth parameter (Set<IProject>) of GitSynchronizeData constructor can be removed. We can obtain list of projects connected with this repository in constructor. Change-Id: Ia97b80a686c8cdacdb83891e09fc38dd203bca27 Signed-off-by: Dariusz Luksza <dariusz@luksza.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java48
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryAction.java16
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SynchronizeWithAction.java9
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/SynchronizeCommand.java24
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitSynchronizeWizard.java8
5 files changed, 33 insertions, 72 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java
index 1233a36..4f66e4e 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java
@@ -10,13 +10,14 @@ package org.eclipse.egit.core.synchronize.dto;
import java.io.File;
import java.io.IOException;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.jgit.lib.Commit;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
@@ -25,7 +26,8 @@ import org.eclipse.jgit.lib.Tag;
import org.eclipse.jgit.lib.Tree;
/**
- *
+ * Simple data transfer object containing all necessary information for
+ * launching synchronization
*/
public class GitSynchronizeData {
@@ -42,33 +44,32 @@ public class GitSynchronizeData {
private final String repoParentPath;
/**
- * @param repository
- * @param srcRef
- * @param dstRef
- * @param project
- * @param includeLocal <code>true</code> if local changes should be included in comparison
- */
- public GitSynchronizeData(Repository repository, String srcRef,
- String dstRef, IProject project, boolean includeLocal) {
- this(repository, srcRef, dstRef, new HashSet<IProject>(Arrays
- .asList(project)), includeLocal);
- }
-
- /**
+ * Constructs {@link GitSynchronizeData} object
+ *
* @param repository
* @param srcRev
* @param dstRev
- * @param projects
- * @param includeLocal <code>true</code> if local changes should be included in comparison
+ * @param includeLocal
+ * <code>true</code> if local changes should be included in
+ * comparison
*/
public GitSynchronizeData(Repository repository, String srcRev,
- String dstRev, Set<IProject> projects, boolean includeLocal) {
+ String dstRev, boolean includeLocal) {
repo = repository;
this.srcRev = srcRev;
this.dstRev = dstRev;
- this.projects = projects;
this.includeLocal = includeLocal;
repoParentPath = repo.getDirectory().getParentFile().getAbsolutePath();
+
+ projects = new HashSet<IProject>();
+ final IProject[] workspaceProjects = ResourcesPlugin.getWorkspace()
+ .getRoot().getProjects();
+ for (IProject project : workspaceProjects) {
+ RepositoryMapping mapping = RepositoryMapping.getMapping(project);
+ if (mapping != null && mapping.getRepository() == repo)
+ projects.add(project);
+ }
+
}
/**
@@ -149,7 +150,8 @@ public class GitSynchronizeData {
}
/**
- * @return <code>true</code> if local changes should be included in comparison
+ * @return <code>true</code> if local changes should be included in
+ * comparison
*/
public boolean shouldIncludeLocal() {
return includeLocal;
@@ -160,17 +162,15 @@ public class GitSynchronizeData {
Tag tag = repo.mapTag(rev);
Commit commit = repo.mapCommit(tag.getObjId());
return commit.getTree();
- } else {
+ } else
return repo.mapTree(rev);
- }
}
private ObjectId getObjecId(String rev) throws IOException {
if (rev.startsWith(Constants.R_TAGS)) {
return repo.mapTag(rev).getObjId();
- } else {
+ } else
return repo.mapCommit(rev).getCommitId();
- }
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryAction.java
index 40ac4d0..9fca0df 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryAction.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryAction.java
@@ -76,22 +76,6 @@ public abstract class RepositoryAction extends TeamAction {
}
/**
- * @param repo
- * @return set of project connected with this particular repository
- */
- protected Set<IProject> getProcjetsInRepository(Repository repo) {
- Set<IProject> ret = new HashSet<IProject>();
- final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (IProject project : projects) {
- RepositoryMapping mapping = RepositoryMapping.getMapping(project);
- if (mapping != null && mapping.getRepository() == repo) {
- ret.add(project);
- }
- }
- return ret;
- }
-
- /**
* Figure out which repository to use. All selected
* resources must map to the same Git repository.
*
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SynchronizeWithAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SynchronizeWithAction.java
index d7a781e..54850cc 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SynchronizeWithAction.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SynchronizeWithAction.java
@@ -46,9 +46,8 @@ public class SynchronizeWithAction extends RepositoryAction {
InterruptedException {
Repository[] repos = getRepositories();
- if (repos.length != repos.length) {
+ if (repos.length != repos.length)
return;
- }
GitSynchronizeDataSet gsdSet = new GitSynchronizeDataSet();
for (Repository repo : repos) {
@@ -60,7 +59,7 @@ public class SynchronizeWithAction extends RepositoryAction {
return;
gsdSet.add(new GitSynchronizeData(repo, dialog.getSrcRef(), dialog
- .getDstRef(), getProcjetsInRepository(repo), dialog.shouldIncludeLocal()));
+ .getDstRef(), dialog.shouldIncludeLocal()));
}
new GitSynchronize(gsdSet);
@@ -73,9 +72,9 @@ public class SynchronizeWithAction extends RepositoryAction {
List<SyncRepoEntity> syncRepoEntitys = new ArrayList<SyncRepoEntity>();
syncRepoEntitys.add(getLocalSyncRepo(repo));
- for (RemoteConfig rc : remoteConfigs) {
+ for (RemoteConfig rc : remoteConfigs)
syncRepoEntitys.add(getRemoteSyncRepo(refDatabase, rc));
- }
+
return syncRepoEntitys;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/SynchronizeCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/SynchronizeCommand.java
index 0e38eab..ff7f79d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/SynchronizeCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/SynchronizeCommand.java
@@ -11,18 +11,12 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.repository.tree.command;
-import java.util.HashSet;
-import java.util.Set;
-
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.core.synchronize.dto.GitSynchronizeData;
import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode;
@@ -33,8 +27,7 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.osgi.util.NLS;
/**
- * Implements "Synchornize"
- *
+ * Implements "Synchronize"
*/
public class SynchronizeCommand extends
RepositoriesViewCommandHandler<RepositoryTreeNode> {
@@ -42,9 +35,8 @@ public class SynchronizeCommand extends
public Object execute(ExecutionEvent event) throws ExecutionException {
final RepositoryTreeNode node = getSelectedNodes(event).get(0);
Object object = node.getObject();
- if (!(object instanceof Ref)) {
+ if (!(object instanceof Ref))
return null;
- }
final Ref ref = (Ref) object;
final Repository repo = node.getRepository();
@@ -54,18 +46,8 @@ public class SynchronizeCommand extends
@Override
protected IStatus run(IProgressMonitor monitor) {
- Set<IProject> repoProjects = new HashSet<IProject>();
- final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (IProject project : projects) {
- RepositoryMapping mapping = RepositoryMapping.getMapping(project);
- if (mapping != null && mapping.getRepository() == repo) {
- repoProjects.add(project);
- }
- }
-
GitSynchronizeData data = new GitSynchronizeData(node
- .getRepository(), Constants.HEAD, ref.getName(),
- repoProjects, false);
+ .getRepository(), Constants.HEAD, ref.getName(), false);
new GitSynchronize(data);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitSynchronizeWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitSynchronizeWizard.java
index a7db49e..42e418c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitSynchronizeWizard.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitSynchronizeWizard.java
@@ -12,9 +12,7 @@
package org.eclipse.egit.ui.internal.synchronize;
import java.util.Map;
-import java.util.Set;
-import org.eclipse.core.resources.IProject;
import org.eclipse.egit.core.synchronize.dto.GitSynchronizeData;
import org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet;
import org.eclipse.egit.ui.UIText;
@@ -45,13 +43,11 @@ public class GitSynchronizeWizard extends Wizard {
@Override
public boolean performFinish() {
- Set<IProject> projects = page.getSelectedProjects();
GitSynchronizeDataSet gsdSet = new GitSynchronizeDataSet();
Map<Repository, String> branches = page.getSelectedBranches();
- for (Repository repo : branches.keySet()) {
- gsdSet.add(new GitSynchronizeData(repo, Constants.HEAD, branches.get(repo), projects, false));
- }
+ for (Repository repo : branches.keySet())
+ gsdSet.add(new GitSynchronizeData(repo, Constants.HEAD, branches.get(repo), false));
new GitSynchronize(gsdSet);