Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-12-03 20:39:33 +0000
committerMichael Valenta2003-12-03 20:39:33 +0000
commit02876108f03ef2e7517ab038a48da14f6d44f078 (patch)
tree17961d6f687f686f5343049528f76a1e2eba9a5c
parent79e5b8894920be0f52945d22bbedb5c226162c86 (diff)
downloadeclipse.platform.team-02876108f03ef2e7517ab038a48da14f6d44f078.tar.gz
eclipse.platform.team-02876108f03ef2e7517ab038a48da14f6d44f078.tar.xz
eclipse.platform.team-02876108f03ef2e7517ab038a48da14f6d44f078.zip
47878: error messages when committing with cvs 1.12.2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java30
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSStorage.java57
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java35
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java7
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java47
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java50
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java8
7 files changed, 141 insertions, 93 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
index 892f01906..babefbd3a 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.core;
-import java.io.InputStream;
import java.util.Date;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -25,7 +24,7 @@ import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
*
* @see ICVSResource
*/
-public interface ICVSFile extends ICVSResource {
+public interface ICVSFile extends ICVSResource, ICVSStorage {
// Constants used to indicate the type of updated response from the server
public static final int UPDATED = 1;
@@ -44,33 +43,6 @@ public interface ICVSFile extends ICVSResource {
public static final int UNKNOWN = 0;
public static final int CLEAN = 1;
public static final int DIRTY = 2;
-
- /**
- * Answers the size of the file.
- */
- long getSize();
-
- /**
- * Gets an input stream for reading from the file.
- * It is the responsibility of the caller to close the stream when finished.
- */
- InputStream getContents() throws CVSException;
-
- /**
- * Set the contents of the file to the contents of the provided input stream.
- *
- * This method is used by the command framework and should not be used by other clients.
- * Other clients should set the contents of the underlying <code>IFile</code> which
- * can be obtained using <code>getIResource()</code>.
- *
- * @param responseType the type of reponse that was received from the server
- *
- * UPDATED - could be a new file or an existing file
- * MERGED - merging remote changes with local changes. Failure could result in loss of local changes
- * CREATED - contents for a file that doesn't exist locally
- * UPDATE_EXISTING - Replacing a local file with no local changes with remote changes.
- */
- public void setContents(InputStream stream, int responseType, boolean keepLocalHistory, IProgressMonitor monitor) throws CVSException;
/**
* Answers the workspace synchronization information for this resource. This would
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSStorage.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSStorage.java
new file mode 100644
index 000000000..af87c02a7
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSStorage.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.core;
+
+import java.io.InputStream;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * This interface is used by the Session to transfer file contents.
+ * It is used for regular files in a local sandbox as well as special files
+ * such as the CVS/Template file.
+ */
+public interface ICVSStorage {
+
+ /**
+ * Return the name for this ICVSStorage.
+ * @return
+ */
+ String getName();
+
+ /**
+ * Set the contents of the file to the contents of the provided input stream.
+ *
+ * This method is used by the command framework and should not be used by other clients.
+ * Other clients should set the contents of the underlying <code>IFile</code> which
+ * can be obtained using <code>getIResource()</code>.
+ *
+ * @param responseType the type of reponse that was received from the server
+ *
+ * UPDATED - could be a new file or an existing file
+ * MERGED - merging remote changes with local changes. Failure could result in loss of local changes
+ * CREATED - contents for a file that doesn't exist locally
+ * UPDATE_EXISTING - Replacing a local file with no local changes with remote changes.
+ */
+ public void setContents(InputStream stream, int responseType, boolean keepLocalHistory, IProgressMonitor monitor) throws CVSException;
+
+ /**
+ * Answers the size of the file.
+ */
+ long getSize();
+
+ /**
+ * Gets an input stream for reading from the file.
+ * It is the responsibility of the caller to close the stream when finished.
+ */
+ InputStream getContents() throws CVSException;
+
+}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java
index 95f3f87a0..d4aac1251 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java
@@ -10,16 +10,11 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.core.client;
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.Policy;
+import org.eclipse.team.internal.ccvs.core.*;
/**
* Stream which detects CRLF in text file contents recieved from the server
@@ -30,7 +25,7 @@ public class CRLFDetectInputStream extends FilterInputStream {
private String filename;
private boolean reported = false;
- protected CRLFDetectInputStream(InputStream in, ICVSFile file) {
+ protected CRLFDetectInputStream(InputStream in, ICVSStorage file) {
super(in);
try {
this.filename = getFileName(file);
@@ -39,16 +34,22 @@ public class CRLFDetectInputStream extends FilterInputStream {
}
}
- private String getFileName(ICVSFile file) throws CVSException {
- String fileName = file.getRepositoryRelativePath();
- if (fileName == null) {
- IResource resource = file.getIResource();
- if (resource == null) {
- fileName = file.getName();
- } else {
- // Use the resource path if there is one since the remote pat
- fileName = file.getIResource().getFullPath().toString();
+ private String getFileName(ICVSStorage storage) throws CVSException {
+ String fileName;
+ if (storage instanceof ICVSFile) {
+ ICVSFile file = (ICVSFile)storage;
+ fileName = file.getRepositoryRelativePath();
+ if (fileName == null) {
+ IResource resource = file.getIResource();
+ if (resource == null) {
+ fileName = file.getName();
+ } else {
+ // Use the resource path if there is one since the remote pat
+ fileName = file.getIResource().getFullPath().toString();
+ }
}
+ } else {
+ fileName = storage.getName();
}
return fileName;
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java
index 1f52af4ba..649b08e8c 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java
@@ -12,10 +12,7 @@ package org.eclipse.team.internal.ccvs.core.client;
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.Policy;
+import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.util.Util;
/**
@@ -50,7 +47,7 @@ class CheckedInHandler extends ResponseHandler {
ICVSFile mFile = mParent.getFile(fileName);
// Marked the local file as checked-in
- monitor.subTask(Policy.bind("CheckInHandler.checkedIn", Util.toTruncatedPath(mFile, session.getLocalRoot(), 3))); //$NON-NLS-1$
+ monitor.subTask(Policy.bind("CheckInHandler.checkedIn", Util.toTruncatedPath((ICVSResource)mFile, session.getLocalRoot(), 3))); //$NON-NLS-1$
mFile.checkedIn(entryLine);
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
index 81ee0d46e..7e8a69605 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
@@ -10,42 +10,14 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.core.client;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.io.*;
+import java.util.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.Policy;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption;
import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
@@ -54,10 +26,7 @@ import org.eclipse.team.internal.ccvs.core.syncinfo.NotifyInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.Assert;
import org.eclipse.team.internal.ccvs.core.util.Util;
-import org.eclipse.team.internal.core.streams.CRLFtoLFInputStream;
-import org.eclipse.team.internal.core.streams.LFtoCRLFInputStream;
-import org.eclipse.team.internal.core.streams.ProgressMonitorInputStream;
-import org.eclipse.team.internal.core.streams.SizeConstrainedInputStream;
+import org.eclipse.team.internal.core.streams.*;
/**
* Maintains CVS communication state for the lifetime of a connection
@@ -803,7 +772,7 @@ public class Session {
sendFile(file, isBinary, true, monitor);
}
- public void sendFile(ICVSFile file, boolean isBinary, boolean sendBinary, IProgressMonitor monitor) throws CVSException {
+ public void sendFile(ICVSStorage file, boolean isBinary, boolean sendBinary, IProgressMonitor monitor) throws CVSException {
// check overrides
if (textTransferOverrideSet != null &&
textTransferOverrideSet.contains(file)) isBinary = false;
@@ -930,7 +899,7 @@ public class Session {
* indicating what repsonse type provided the file contents
* @param monitor the progress monitor
*/
- public void receiveFile(ICVSFile file, boolean isBinary, int responseType, IProgressMonitor monitor)
+ public void receiveFile(ICVSStorage file, boolean isBinary, int responseType, IProgressMonitor monitor)
throws CVSException {
// check overrides
if (textTransferOverrideSet != null &&
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 8fc729edc..e55ead110 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
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.core.client;
+import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.internal.ccvs.core.*;
@@ -40,10 +44,50 @@ public class TemplateHandler extends ResponseHandler {
String remoteDir = session.readLine();
ICVSFolder localFolder = getExistingFolder(session, localDir);
IContainer container = (IContainer)localFolder.getIResource();
- ICVSFile templateFile;
+ ICVSStorage templateFile;
if (container == null) {
- // TODO: Need to accept bytes from server
- return;
+ // Create a dummy storage handle to recieve the contents from the server
+ templateFile = new ICVSStorage() {
+ public String getName() {
+ return "Template"; //$NON-NLS-1$
+ }
+ public void setContents(
+ InputStream stream,
+ int responseType,
+ boolean keepLocalHistory,
+ IProgressMonitor monitor)
+ throws CVSException {
+
+ try {
+ // Transfer the contents
+ OutputStream out = new ByteArrayOutputStream();
+ try {
+ byte[] buffer = new byte[1024];
+ int read;
+ while ((read = stream.read(buffer)) >= 0) {
+ Policy.checkCanceled(monitor);
+ out.write(buffer, 0, read);
+ }
+ } finally {
+ out.close();
+ }
+ } catch (IOException e) {
+ throw CVSException.wrapException(e); //$NON-NLS-1$
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e1) {
+ // Ignore close errors
+ }
+ }
+ }
+ public long getSize() {
+ return 0;
+ }
+ public InputStream getContents() throws CVSException {
+ return new ByteArrayInputStream(new byte[0]);
+ }
+ };
} else {
templateFile = CVSWorkspaceRoot.getCVSFileFor(SyncFileWriter.getTemplateFile(container));
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
index da4944b69..0c3b4e609 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
@@ -24,6 +24,7 @@ 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.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTag;
@@ -563,4 +564,11 @@ public class Util {
return new int[0];
}
}
+
+ public static String toTruncatedPath(ICVSStorage file, ICVSFolder localRoot, int i) {
+ if (file instanceof ICVSResource) {
+ return toTruncatedPath((ICVSResource)file, localRoot, i);
+ }
+ return file.getName();
+ }
}

Back to the top