Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-12-03 19:51:06 +0000
committerMichael Valenta2003-12-03 19:51:06 +0000
commit5c409f63fad13e45b8aaf6aad5725d9e3ff2b0e9 (patch)
tree9b6b550a4a4cc8e8e486acd4d152e9397237b21a
parent2c9457975b3cf366eb60ec4752f3dfcc472adc2b (diff)
downloadeclipse.platform.team-5c409f63fad13e45b8aaf6aad5725d9e3ff2b0e9.tar.gz
eclipse.platform.team-5c409f63fad13e45b8aaf6aad5725d9e3ff2b0e9.tar.xz
eclipse.platform.team-5c409f63fad13e45b8aaf6aad5725d9e3ff2b0e9.zip
46730: CVS (Replace With.. --> Latest from HEAD)
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java1
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java13
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java7
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java6
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java66
5 files changed, 65 insertions, 28 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java
index afba8870a..8e49ad97f 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java
@@ -57,6 +57,7 @@ public abstract class Command extends Request {
public final static Tag CUSTOM_TAG = new Tag(true);
public final static RTag RTAG = new RTag();
public final static Update UPDATE = new Update();
+ public final static Update REPLACE = new UpdateWithOverwrite();
public final static SyncUpdate SYNCUPDATE = new SyncUpdate();
public final static Version VERSION = new Version();
public final static NOOPCommand NOOP = new NOOPCommand();
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java
index 1fa7c1fe3..8fc729edc 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java
@@ -12,9 +12,7 @@ package org.eclipse.team.internal.ccvs.core.client;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
+import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter;
@@ -42,8 +40,13 @@ public class TemplateHandler extends ResponseHandler {
String remoteDir = session.readLine();
ICVSFolder localFolder = getExistingFolder(session, localDir);
IContainer container = (IContainer)localFolder.getIResource();
- if (container == null) return;
- ICVSFile templateFile = CVSWorkspaceRoot.getCVSFileFor(SyncFileWriter.getTemplateFile(container));
+ ICVSFile templateFile;
+ if (container == null) {
+ // TODO: Need to accept bytes from server
+ return;
+ } else {
+ templateFile = CVSWorkspaceRoot.getCVSFileFor(SyncFileWriter.getTemplateFile(container));
+ }
session.receiveFile(templateFile, false, UpdatedHandler.HANDLE_UPDATED, monitor);
}
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 57b0cba54..9f2f558e1 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
@@ -119,4 +119,11 @@ public class ReplaceOperation extends UpdateOperation {
return (ICVSResource[]) managedResources.toArray(new ICVSResource[managedResources.size()]);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation#getUpdateCommand()
+ */
+ protected Update getUpdateCommand() {
+ return Command.REPLACE;
+ }
+
}
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 eb6892df2..3529111cf 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
@@ -74,7 +74,7 @@ public class UpdateOperation extends SingleCommandOperation {
localOptions.addAll(Arrays.asList(getLocalOptions()));
LocalOption[] commandOptions = (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]);
- return Command.UPDATE.execute(
+ return getUpdateCommand().execute(
session,
Command.NO_GLOBAL_OPTIONS,
commandOptions,
@@ -83,6 +83,10 @@ public class UpdateOperation extends SingleCommandOperation {
monitor);
}
+ protected Update getUpdateCommand() {
+ return Command.UPDATE;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
*/
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
index efe702dbc..31c55b716 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
@@ -9,34 +9,19 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.tests.ccvs.core.provider;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
import java.util.HashMap;
import java.util.Map;
import junit.framework.Test;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.IFileTypeInfo;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.Team;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.client.Command;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.team.core.*;
+import org.eclipse.team.internal.ccvs.core.*;
+import org.eclipse.team.internal.ccvs.core.client.*;
import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
+import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.tests.ccvs.core.EclipseTest;
@@ -525,5 +510,42 @@ public class CVSProviderTest extends EclipseTest {
IProject copy = checkoutCopy(project, tag);
assertEquals(project, copy);
}
+
+ public void testUpdateWithOverwrite() throws TeamException, CoreException {
+ // Create a project and ad an unmanaged resource
+ IProject project = createProject(new String[] { "a.txt", "b.txt" });
+ buildResources(project, new String[] { "new.txt" }, false);
+ // Checkout a copy and commit the same resource
+ IProject copy = checkoutCopy(project, "-copy");
+ addResources(copy, new String[] { "new.txt" }, true);
+ IStatus status;
+ try {
+ // Use the regular update and ensure that it fails
+ status = executeCommand(project, Command.UPDATE, Command.NO_LOCAL_OPTIONS);
+ fail();
+ } catch (CVSException e) {
+ // This is expected as the creation of the file failed;
+ }
+ // Use the update and overwrite and ensure that it works
+ status = executeCommand(project, Command.REPLACE, Command.NO_LOCAL_OPTIONS);
+ assertTrue(status.isOK());
+ }
+
+ private IStatus executeCommand(IProject project, Update update, LocalOption[] options) throws CVSException {
+ Session session = new Session(getRepository(), CVSWorkspaceRoot.getCVSFolderFor(project));
+ session.open(DEFAULT_MONITOR);
+ try {
+ return update.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ options,
+ new String[] { "." },
+ null,
+ DEFAULT_MONITOR);
+ } finally {
+ session.close();
+ }
+
+ }
}

Back to the top