diff options
author | Malgorzata Janczarska | 2011-11-17 13:37:16 +0000 |
---|---|---|
committer | Tomasz Zarna | 2011-11-17 13:37:16 +0000 |
commit | cfa9a16b8044938883a013f0f31a1919520603be (patch) | |
tree | 5e9660f8dc0b2e01ee155d16ea0404ea3e7445c9 | |
parent | 3f762b893c48833cd921ed0dda5d75a9a9f5524f (diff) | |
download | eclipse.platform.team-cfa9a16b8044938883a013f0f31a1919520603be.tar.gz eclipse.platform.team-cfa9a16b8044938883a013f0f31a1919520603be.tar.xz eclipse.platform.team-cfa9a16b8044938883a013f0f31a1919520603be.zip |
bug 263919: Synchronize must not abort when log-in to repository failsv20111117-1337
4 files changed, 41 insertions, 21 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java index e64b9b2c3..91220d35c 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,21 +10,10 @@ *******************************************************************************/ package org.eclipse.team.core.variants; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; +import java.util.*; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.resources.*; +import org.eclipse.core.runtime.*; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.TeamStatus; @@ -32,8 +21,6 @@ import org.eclipse.team.core.subscribers.Subscriber; import org.eclipse.team.core.subscribers.SubscriberChangeEvent; import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.internal.core.*; -import org.eclipse.team.internal.core.Policy; -import org.eclipse.team.internal.core.TeamPlugin; /** * A specialization of Subscriber that uses <code>IResourceVariantTree</code> objects @@ -118,13 +105,16 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber { public void refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException { monitor = Policy.monitorFor(monitor); List errors = new ArrayList(); + List cancels = new ArrayList(); try { monitor.beginTask(null, 1000 * resources.length); for (int i = 0; i < resources.length; i++) { IResource resource = resources[i]; if (resource.getProject().isAccessible()) { IStatus status = refresh(resource, depth, Policy.subMonitorFor(monitor, 1000)); - if (!status.isOK()) { + if (status.getSeverity() == IStatus.CANCEL) { + cancels.add(status); + } else if (!status.isOK()) { errors.add(status); } } @@ -133,11 +123,32 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber { monitor.done(); } if (!errors.isEmpty()) { - int numSuccess = resources.length - errors.size(); + int numSuccess = resources.length - errors.size() - cancels.size(); + if (!cancels.isEmpty()) { + errors.addAll(cancels); + throw new TeamException(new MultiStatus(TeamPlugin.ID, 0, + (IStatus[]) errors.toArray(new IStatus[errors.size()]), + NLS.bind( + Messages.ResourceVariantTreeSubscriber_3, + (new Object[] { getName(), + Integer.toString(numSuccess), + Integer.toString(resources.length), + Integer.toString(cancels.size()) })), + null) { + public int getSeverity() { + // we want to display status as an error + return IStatus.ERROR; + } + }); + } throw new TeamException(new MultiStatus(TeamPlugin.ID, 0, (IStatus[]) errors.toArray(new IStatus[errors.size()]), NLS.bind(Messages.ResourceVariantTreeSubscriber_1, (new Object[] {getName(), Integer.toString(numSuccess), Integer.toString(resources.length)})), null)); } + if (!cancels.isEmpty()) { + throw new OperationCanceledException( + ((IStatus) cancels.get(0)).getMessage()); + } } /** @@ -166,6 +177,11 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber { return Status.OK_STATUS; } catch (TeamException e) { return new TeamStatus(IStatus.ERROR, TeamPlugin.ID, 0, NLS.bind(Messages.ResourceVariantTreeSubscriber_2, new String[] { resource.getFullPath().toString(), e.getMessage() }), e, resource); + } catch (OperationCanceledException e) { + return new TeamStatus(IStatus.CANCEL, TeamPlugin.ID, 0, NLS.bind( + Messages.ResourceVariantTreeSubscriber_4, + new String[] { resource.getFullPath().toString() }), e, + resource); } finally { monitor.done(); } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Messages.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Messages.java index f547d578a..5c550403e 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Messages.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Messages.java @@ -88,6 +88,8 @@ public class Messages extends NLS { public static String SyncInfoTree_0; public static String ResourceVariantTreeSubscriber_1; public static String ResourceVariantTreeSubscriber_2; + public static String ResourceVariantTreeSubscriber_3; + public static String ResourceVariantTreeSubscriber_4; public static String SyncByteConverter_1; public static String BatchingLock_11; public static String SubscriberEventHandler_12; diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties index e3bacf8ef..608e4b55f 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties @@ -77,6 +77,8 @@ CachedResourceVariant_1=As error occurred computing the content type of resource SyncInfoTree_0=Sync info is missing for resource {0}. ResourceVariantTreeSubscriber_1=Problems reported while synchronizing {0}. {1} of {2} resources were synchronized. ResourceVariantTreeSubscriber_2=An error occurred synchronizing {0}: {1} +ResourceVariantTreeSubscriber_3=Problems reported while synchronizing {0}. {1} of {2} resources were synchronized, number of synchronizations canceled: {3}. +ResourceVariantTreeSubscriber_4=Synchronization of {0} canceled because login was canceled. SyncByteConverter_1=Malformed sync byte format detected in {0} BatchingLock_11=An error occurred while flushing batched changes SubscriberEventHandler_12=Synchronization state collection canceled by a user action. diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSResourceVariantTree.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSResourceVariantTree.java index 4af0c8aba..4482c459b 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSResourceVariantTree.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSResourceVariantTree.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -320,7 +320,7 @@ public class CVSResourceVariantTree extends ResourceVariantTree { try { Thread.sleep(waitTime); } catch (InterruptedException e) { - // Conitinue + // Continue } count++; if (count >= 10) { |