Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-12-02 16:42:25 -0500
committerMichael Valenta2003-12-02 16:42:25 -0500
commit940db671df89804ca21b03b416141c18b3b00c6c (patch)
tree32e5d9c8ad9493dd7caa103df7f0ac038e29396d
parent3976060e65cbae68c74c0f85f2ef38904afac17c (diff)
downloadeclipse.platform.team-940db671df89804ca21b03b416141c18b3b00c6c.tar.gz
eclipse.platform.team-940db671df89804ca21b03b416141c18b3b00c6c.tar.xz
eclipse.platform.team-940db671df89804ca21b03b416141c18b3b00c6c.zip
47719: Error while updating to undo folder move
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/OverrideAndUpdateOperation.java46
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java51
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java9
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java12
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateAction.java22
5 files changed, 112 insertions, 28 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/OverrideAndUpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/OverrideAndUpdateOperation.java
new file mode 100644
index 000000000..2db8d08a8
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/OverrideAndUpdateOperation.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui.operations;
+
+import java.util.*;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.internal.ccvs.core.*;
+
+/**
+ * A specialized Replace operation that will update managed resources and
+ * unmanaged resources that are conflicting additions (so that the remote is fetched)
+ */
+public class OverrideAndUpdateOperation extends ReplaceOperation {
+
+ private IResource[] conflictingAdditions;
+
+ public OverrideAndUpdateOperation(Shell shell, IResource[] allResources, IResource[] conflictingAdditions, CVSTag tag, boolean recurse) {
+ super(shell, allResources, tag, recurse);
+ this.conflictingAdditions = conflictingAdditions;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation#getResourcesToUpdate(org.eclipse.team.internal.ccvs.core.ICVSResource[])
+ */
+ protected ICVSResource[] getResourcesToUpdate(ICVSResource[] resources) throws CVSException {
+ // Add the conflicting additions to the list of resources to update
+ Set update = new HashSet();
+ ICVSResource[] conflicts = getCVSArguments(conflictingAdditions);
+ update.addAll(Arrays.asList(conflicts));
+ update.addAll(Arrays.asList(super.getResourcesToUpdate(resources)));
+ return (ICVSResource[]) update.toArray(new ICVSResource[update.size()]);
+ }
+
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java
index 9e67c5573..e9cb631c7 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java
@@ -18,14 +18,9 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.client.Update;
+import org.eclipse.team.internal.ccvs.core.client.*;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
+import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.PrepareForReplaceVisitor;
import org.eclipse.team.internal.ccvs.ui.Policy;
@@ -71,16 +66,9 @@ public class ReplaceOperation extends UpdateOperation {
throws CVSException, InterruptedException {
monitor.beginTask(null, 100);
- // Accumulate the managed resources from the list of provided resources
- List managedResources = new ArrayList();
- for (int i = 0; i < resources.length; i++) {
- ICVSResource resource = resources[i];
- if (resource.isManaged() ||
- (resource.isFolder() && ((ICVSFolder)resource).isCVSFolder())) {
- managedResources.add(resource);
- }
- }
+ ICVSResource[] managedResources = getResourcesToUpdate(resources);
try {
+ // Purge any unmanaged or added files
new PrepareForReplaceVisitor().visitResources(
provider.getProject(),
resources,
@@ -88,16 +76,43 @@ public class ReplaceOperation extends UpdateOperation {
recurse ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO,
Policy.subMonitorFor(monitor, 30)); //$NON-NLS-1$
+ // Prune any empty folders left after the resources were purged
+ new PruneFolderVisitor().visit(session, resources);
+
// Only perform the remote command if some of the resources being replaced were managed
- if (managedResources.isEmpty()) {
+ if (managedResources.length == 0) {
return OK;
} else {
// Perform an update, ignoring any local file modifications
- return super.executeCommand(session, provider, resources, Policy.subMonitorFor(monitor, 70));
+ return super.executeCommand(session, provider, managedResources, Policy.subMonitorFor(monitor, 70));
}
} finally {
monitor.done();
}
}
+
+ /**
+ * Return the resources that need to be updated from the server.
+ * By default, this is all resources that are managed.
+ * @param resources all resources being replaced
+ * @return resources that ae to be updated from the server
+ * @throws CVSException
+ */
+ protected ICVSResource[] getResourcesToUpdate(ICVSResource[] resources) throws CVSException {
+ // Accumulate the managed resources from the list of provided resources
+ List managedResources = new ArrayList();
+ for (int i = 0; i < resources.length; i++) {
+ ICVSResource resource = resources[i];
+ if ((resource.isFolder() && ((ICVSFolder)resource).isCVSFolder())) {
+ managedResources.add(resource);
+ } else if (!resource.isFolder()){
+ byte[] syncBytes = ((ICVSFile)resource).getSyncBytes();
+ if (syncBytes != null && !ResourceSyncInfo.isAddition(syncBytes)) {
+ managedResources.add(resource);
+ }
+ }
+ }
+ return (ICVSResource[]) managedResources.toArray(new ICVSResource[managedResources.size()]);
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java
index e1a725adb..959380e68 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java
@@ -14,10 +14,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
+import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.Session;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
@@ -45,9 +42,7 @@ public abstract class SingleCommandOperation extends RepositoryProviderOperation
// TODO: This does not properly count the number of operations
// Changing it causes an error in the test cases
IStatus status = executeCommand(session, provider, getCVSArguments(resources), Policy.subMonitorFor(monitor, 90));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- addError(status);
- }
+ collectStatus(status);
} finally {
session.close();
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java
index ac97ce0c1..eb6892df2 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java
@@ -26,6 +26,7 @@ import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.Session;
import org.eclipse.team.internal.ccvs.core.client.Update;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
+import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
import org.eclipse.team.internal.ccvs.ui.Policy;
/**
@@ -78,7 +79,7 @@ public class UpdateOperation extends SingleCommandOperation {
Command.NO_GLOBAL_OPTIONS,
commandOptions,
resources,
- null,
+ getCommandOutputListener(),
monitor);
}
@@ -88,5 +89,14 @@ public class UpdateOperation extends SingleCommandOperation {
protected String getTaskName() {
return Policy.bind("UpdateOperation.taskName"); //$NON-NLS-1$;
}
+
+ /**
+ * Return the listener that is used to process E and M messages.
+ * The default is <code>null</code>.
+ * @return
+ */
+ protected ICommandOutputListener getCommandOutputListener() {
+ return null;
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateAction.java
index ee498f1a5..df66843de 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OverrideAndUpdateAction.java
@@ -11,13 +11,16 @@
package org.eclipse.team.internal.ccvs.ui.subscriber;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation;
+import org.eclipse.team.internal.ccvs.ui.operations.OverrideAndUpdateOperation;
import org.eclipse.team.ui.synchronize.actions.SyncInfoFilter;
import org.eclipse.team.ui.synchronize.actions.SyncInfoSet;
import org.eclipse.team.ui.synchronize.actions.SyncInfoFilter.SyncInfoDirectionFilter;
@@ -34,13 +37,28 @@ public class OverrideAndUpdateAction extends CVSSubscriberAction {
protected SyncInfoFilter getSyncInfoFilter() {
return new SyncInfoDirectionFilter(new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING});
}
+
+ private SyncInfoFilter getConflictingAdditionFilter() {
+ return new SyncInfoFilter.AndSyncInfoFilter(
+ new SyncInfoFilter[] {
+ new SyncInfoFilter.SyncInfoDirectionFilter(new int[] {SyncInfo.CONFLICTING}),
+ new SyncInfoFilter.SyncInfoChangeTypeFilter(new int[] {SyncInfo.ADDITION})
+ });
+ }
+
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction#run(org.eclipse.team.ui.sync.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
*/
protected void run(SyncInfoSet syncSet, IProgressMonitor monitor) throws TeamException {
try {
if(promptForOverwrite(syncSet)) {
- new ReplaceOperation(getShell(), syncSet.getResources(), null /* tag */, false /* recurse */).run(monitor);
+ SyncInfo[] conflicts = syncSet.getNodes(getConflictingAdditionFilter());
+ List conflictingResources = new ArrayList();
+ for (int i = 0; i < conflicts.length; i++) {
+ SyncInfo info = conflicts[i];
+ conflictingResources.add(info.getLocal());
+ }
+ new OverrideAndUpdateOperation(getShell(), syncSet.getResources(), (IResource[]) conflictingResources.toArray(new IResource[conflictingResources.size()]), null /* tag */, false /* recurse */).run(monitor);
}
} catch (InvocationTargetException e) {
throw CVSException.wrapException(e);

Back to the top