Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDariusz Luksza2011-06-01 10:58:00 +0000
committerMatthias Sohn2011-06-04 01:01:31 +0000
commit63bc5e3c6edb47795e900f8d1dadbb0e41e64b25 (patch)
tree752219657f1e8f9d7c2e6680d3bc4c27b1ce265d
parent4eab0e6cdf8987437bf31d9c9f724e4f9cfdbeea (diff)
downloadegit-63bc5e3c6edb47795e900f8d1dadbb0e41e64b25.tar.gz
egit-63bc5e3c6edb47795e900f8d1dadbb0e41e64b25.tar.xz
egit-63bc5e3c6edb47795e900f8d1dadbb0e41e64b25.zip
[sync] Allow push to multiple repositories from sync-view
Bug: 345804 Change-Id: I4323f1d91164a69ef29b0b61cda5079d5202b179 Signed-off-by: Dariusz Luksza <dariusz@luksza.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/action/PushAction.java66
1 files changed, 36 insertions, 30 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/action/PushAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/action/PushAction.java
index 02e24e775..2a2f56251 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/action/PushAction.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/action/PushAction.java
@@ -9,12 +9,12 @@
package org.eclipse.egit.ui.internal.synchronize.action;
import static org.eclipse.egit.ui.internal.synchronize.GitModelSynchronizeParticipant.SYNCHRONIZATION_DATA;
+import static org.eclipse.jgit.lib.Constants.HEAD;
import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.egit.core.synchronize.dto.GitSynchronizeData;
import org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet;
@@ -22,6 +22,9 @@ import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.credentials.EGitCredentialsProvider;
import org.eclipse.egit.ui.internal.push.PushOperationUI;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.SynchronizeModelAction;
@@ -49,30 +52,9 @@ public class PushAction extends SynchronizeModelAction {
.getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
return new SynchronizeModelOperation(configuration, elements) {
-
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
- GitSynchronizeDataSet gsds = (GitSynchronizeDataSet) getConfiguration()
- .getProperty(SYNCHRONIZATION_DATA);
- GitSynchronizeData gsd = gsds.iterator().next();
-
- String remoteName = gsd.getSrcRemoteName();
- if (remoteName == null)
- return;
-
- RemoteConfig rc;
- try {
- rc = new RemoteConfig(gsd.getRepository().getConfig(),
- remoteName);
- PushOperationUI push = new PushOperationUI(gsd.getRepository(),
- rc, timeout, false);
- push.setCredentialsProvider(new EGitCredentialsProvider());
- push.execute(monitor);
- } catch (URISyntaxException e) {
- throw new InvocationTargetException(e);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
+ runPushOperation(timeout);
}
};
}
@@ -81,16 +63,40 @@ public class PushAction extends SynchronizeModelAction {
public boolean isEnabled() {
GitSynchronizeDataSet gsds = (GitSynchronizeDataSet) getConfiguration()
.getProperty(SYNCHRONIZATION_DATA);
+ for (GitSynchronizeData gsd : gsds)
+ if (gsd.getDstRemoteName() != null)
+ return true;
- if (gsds == null || gsds.size() != 1)
- return false;
+ return false;
+ }
- GitSynchronizeData gsd = gsds.iterator().next();
- String srcRemoteName = gsd.getSrcRemoteName();
- String dstRemoteName = gsd.getDstRemoteName();
+ private void runPushOperation(final int timeout) {
+ GitSynchronizeDataSet gsds = (GitSynchronizeDataSet) getConfiguration()
+ .getProperty(SYNCHRONIZATION_DATA);
+
+ for (GitSynchronizeData gsd : gsds) {
+ String remoteName = gsd.getSrcRemoteName();
+ if (remoteName == null)
+ continue;
+
+ RemoteConfig rc;
+ Repository repo = gsd.getRepository();
+ StoredConfig config = repo.getConfig();
+ try {
+ rc = new RemoteConfig(config, remoteName);
+ } catch (URISyntaxException e) {
+ Activator
+ .logError(
+ "Unable to create RemoteConfiguration for remote: " + remoteName, e); //$NON-NLS-1$
+ continue;
+ }
- return srcRemoteName != dstRemoteName
- && (srcRemoteName != null || dstRemoteName != null);
+ if (rc.getPushRefSpecs().isEmpty())
+ rc.addPushRefSpec(new RefSpec(HEAD + ":" + gsd.getDstMerge())); //$NON-NLS-1$
+ PushOperationUI push = new PushOperationUI(repo, rc, timeout, false);
+ push.setCredentialsProvider(new EGitCredentialsProvider());
+ push.start();
+ }
}
}

Back to the top