summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorRobin Stocker2011-03-17 08:54:23 (EDT)
committer Mathias Kinzler2011-03-24 12:52:09 (EDT)
commit4197370f09f23e4930ac80a045097cbd4946ea8e (patch)
treeb273d87042551b9ffe34387c8881277532431419
parent08a9e1397b98113e69669c648c91c3f304d060c9 (diff)
downloadegit-4197370f09f23e4930ac80a045097cbd4946ea8e.zip
egit-4197370f09f23e4930ac80a045097cbd4946ea8e.tar.gz
egit-4197370f09f23e4930ac80a045097cbd4946ea8e.tar.bz2
Enable pull for multiple repositoriesrefs/changes/55/2755/6
When having multiple projects (each corresponding to a different repository) and needing to regularly keep up to date with changes, EGit provides no easy way to deal with this. The only way at the moment is to select a single project and pull, and repeat that for every project. When the number of projects is two, this is okay, but for more than a couple of projects it's simply infeasible. This change enables pull for multiple repositories. The UI still has to be improved in a subsequent change, as it currently shows one result dialog per repository. It has to be changed so that only one result dialog is shown, see bug 340780 for that. Bug: 340308 Bug: 340780 Change-Id: If8a51bb9ad0c78dfeb73ec1f4ad0b4602c6feb1f Signed-off-by: Robin Stocker <robin@nibor.org>
-rw-r--r--org.eclipse.egit.ui/plugin.xml15
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PullFromUpstreamActionHandler.java28
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java23
3 files changed, 34 insertions, 32 deletions
diff --git a/org.eclipse.egit.ui/plugin.xml b/org.eclipse.egit.ui/plugin.xml
index cf24ebe..77946cb 100644
--- a/org.eclipse.egit.ui/plugin.xml
+++ b/org.eclipse.egit.ui/plugin.xml
@@ -824,16 +824,11 @@
class="org.eclipse.egit.ui.internal.actions.PullFromUpstreamActionHandler">
</class>
<activeWhen>
- <and>
- <count
- value="1">
- </count>
- <iterate>
- <adapt
- type="org.eclipse.core.resources.IProject">
- </adapt>
- </iterate>
- </and>
+ <iterate>
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ </adapt>
+ </iterate>
</activeWhen>
</handler>
<handler
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PullFromUpstreamActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PullFromUpstreamActionHandler.java
index 14dc880..025886c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PullFromUpstreamActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PullFromUpstreamActionHandler.java
@@ -23,10 +23,12 @@ import org.eclipse.jgit.lib.Repository;
*/
public class PullFromUpstreamActionHandler extends RepositoryActionHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
- final Repository repository = getRepository(true, event);
- if (repository == null)
+ Repository[] repos = getRepositories(event);
+ if (repos.length == 0)
return null;
- new PullOperationUI(repository).start();
+
+ for (Repository repo : repos)
+ new PullOperationUI(repo).start();
return null;
}
@@ -34,15 +36,17 @@ public class PullFromUpstreamActionHandler extends RepositoryActionHandler {
public boolean isEnabled() {
// we don't do the full canMerge check here, but
// ensure that a branch is checked out
- Repository repo = getRepository();
- if (repo == null)
- return false;
- try {
- String fullBranch = repo.getFullBranch();
- return (fullBranch.startsWith(Constants.R_REFS))
- && !repo.getAllRefs().isEmpty();
- } catch (IOException e) {
- return false;
+ Repository[] repos = getRepositories();
+ for (Repository repo : repos) {
+ try {
+ String fullBranch = repo.getFullBranch();
+ if (!fullBranch.startsWith(Constants.R_REFS)
+ || repo.getAllRefs().isEmpty())
+ return false;
+ } catch (IOException e) {
+ return false;
+ }
}
+ return true;
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java
index 56268db..5bb0e5e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java
@@ -243,21 +243,24 @@ abstract class RepositoryActionHandler extends AbstractHandler {
*
* @param event
*
- * @return repository for current project, or null
+ * @return repositories for selection, or an empty array
* @throws ExecutionException
*/
protected Repository[] getRepositories(ExecutionEvent event)
throws ExecutionException {
IProject[] selectedProjects = getSelectedProjects(event);
- Set<Repository> repos = new HashSet<Repository>(selectedProjects.length);
- for (IProject project : selectedProjects) {
- RepositoryMapping repositoryMapping = RepositoryMapping
- .getMapping(project);
- if (repositoryMapping == null)
- return new Repository[0];
- repos.add(repositoryMapping.getRepository());
- }
- return repos.toArray(new Repository[repos.size()]);
+ return getRepositoriesFor(selectedProjects);
+ }
+
+ /**
+ * Get the currently selected repositories. All selected projects must map
+ * to a repository.
+ *
+ * @return repositories for selection, or an empty array
+ */
+ protected Repository[] getRepositories() {
+ IProject[] selectedProjects = getSelectedProjects(getSelection());
+ return getRepositoriesFor(selectedProjects);
}
/**