diff options
author | Mathias Kinzler | 2011-04-04 06:51:56 +0000 |
---|---|---|
committer | Chris Aniszczyk | 2011-04-05 19:40:50 +0000 |
commit | 63ddb5d201f4266fb0f0c407ea31b0cd71740bd5 (patch) | |
tree | 859fdb131d93bd5917a5e6ca57e6a1ecd3f6beba /org.eclipse.egit.core | |
parent | 6da9779fb769ea50b59e88553ad3bbf604a7c499 (diff) | |
download | egit-63ddb5d201f4266fb0f0c407ea31b0cd71740bd5.tar.gz egit-63ddb5d201f4266fb0f0c407ea31b0cd71740bd5.tar.xz egit-63ddb5d201f4266fb0f0c407ea31b0cd71740bd5.zip |
Proper result dialog when pulling from multiple Repositories
The dialog presents a list of Repositories and an overview about fetch
and update (merge/rebase) results for each Repository. Users can drill
down and see detailed information (i.e. the "normal" PullResultDialog)
by selecting a line in the list and hitting a "Details" button.
This also enables pull for multiple Repositories in the Git
Repositories View.
Bug: 340780
Change-Id: I8d4aaf3f3f0b5f47cf0db50b4588a2676bb8ccc2
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Diffstat (limited to 'org.eclipse.egit.core')
3 files changed, 59 insertions, 21 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 0366de5028..8a6a43ffb2 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 @@ -213,6 +213,15 @@ public class CoreText extends NLS { public static String ProjectUtil_refreshing; /** */ + public static String PullOperation_DetachedHeadMessage; + + /** */ + public static String PullOperation_PullNotConfiguredMessage; + + /** */ + public static String PullOperation_TaskName; + + /** */ public static String PushOperation_InternalExceptionOccurredMessage; /** */ 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 d859a41509..fab38065ca 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 @@ -83,6 +83,9 @@ ListRemoteOperation_title=Getting remote branches information ProjectUtil_refreshingProjects=Refreshing projects ProjectUtil_refreshing=Refreshing +PullOperation_DetachedHeadMessage=No local branch is currently checked out +PullOperation_PullNotConfiguredMessage=The current branch is not configured for pull +PullOperation_TaskName=Pulling {0} repositories PushOperation_InternalExceptionOccurredMessage=An internal Exception occurred during push: {0} PushOperation_resultCancelled=Operation was cancelled. PushOperation_taskNameDryRun=Trying pushing to remote repositories diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java index 16dfbd1528..206947dad0 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/PullOperation.java @@ -10,6 +10,10 @@ *******************************************************************************/ package org.eclipse.egit.core.op; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -17,40 +21,44 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.egit.core.Activator; import org.eclipse.egit.core.CoreText; import org.eclipse.egit.core.EclipseGitProgressTransformer; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.PullCommand; -import org.eclipse.jgit.api.PullResult; +import org.eclipse.jgit.api.errors.DetachedHeadException; import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidConfigurationException; import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.lib.Repository; +import org.eclipse.osgi.util.NLS; /** * Wraps the JGit API {@link PullCommand} into an operation */ public class PullOperation implements IEGitOperation { - private final Repository repository; + private final Repository[] repositories; - private PullResult pullResult; + private final Map<Repository, Object> results = new HashMap<Repository, Object>(); private final int timeout; /** - * @param repository + * @param repositories * the repository * @param timeout * in seconds */ - public PullOperation(Repository repository, int timeout) { + public PullOperation(Set<Repository> repositories, int timeout) { this.timeout = timeout; - this.repository = repository; + this.repositories = repositories.toArray(new Repository[repositories + .size()]); } public void execute(IProgressMonitor m) throws CoreException { - if (pullResult != null) + if (!results.isEmpty()) throw new CoreException(new Status(IStatus.ERROR, Activator .getPluginId(), CoreText.OperationAlreadyExecuted)); IProgressMonitor monitor; @@ -58,18 +66,37 @@ public class PullOperation implements IEGitOperation { monitor = new NullProgressMonitor(); else monitor = m; + monitor.beginTask(NLS.bind(CoreText.PullOperation_TaskName, Integer + .valueOf(repositories.length)), repositories.length); IWorkspaceRunnable action = new IWorkspaceRunnable() { public void run(IProgressMonitor mymonitor) throws CoreException { - PullCommand pull = new Git(repository).pull(); - try { - pull.setProgressMonitor(new EclipseGitProgressTransformer( - mymonitor)); - pull.setTimeout(timeout); - pullResult = pull.call(); - } catch (GitAPIException e) { - throw new CoreException(Activator.error(e.getMessage(), e)); - } catch (JGitInternalException e) { - throw new CoreException(Activator.error(e.getMessage(), e)); + for (int i = 0; i < repositories.length; i++) { + Repository repository = repositories[i]; + if (mymonitor.isCanceled()) + throw new CoreException(Status.CANCEL_STATUS); + PullCommand pull = new Git(repository).pull(); + try { + pull.setProgressMonitor(new EclipseGitProgressTransformer( + new SubProgressMonitor(mymonitor, 1))); + pull.setTimeout(timeout); + results.put(repository, pull.call()); + } catch (DetachedHeadException e) { + results.put(repository, Activator.error( + CoreText.PullOperation_DetachedHeadMessage, e)); + } catch (InvalidConfigurationException e) { + IStatus error = Activator + .error(CoreText.PullOperation_PullNotConfiguredMessage, + e); + results.put(repository, error); + } catch (GitAPIException e) { + results.put(repository, + Activator.error(e.getMessage(), e)); + } catch (JGitInternalException e) { + results.put(repository, + Activator.error(e.getMessage(), e)); + } finally { + mymonitor.worked(1); + } } } }; @@ -78,11 +105,10 @@ public class PullOperation implements IEGitOperation { } /** - * @return the merge result, or <code>null</code> if this has not been - * executed or if an exception occurred + * @return the results, or an empty Map if this has not been executed */ - public PullResult getResult() { - return this.pullResult; + public Map<Repository, Object> getResults() { + return this.results; } public ISchedulingRule getSchedulingRule() { |