Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-01-22 15:17:41 +0000
committerJean Michel-Lemieux2002-01-22 15:17:41 +0000
commitb0af11d5ad395f14a2bb6fff9a47a9b6d394a3e5 (patch)
tree545d97b1d70a5eecfff27273fa2dafd75c5a59e5
parentceff15f67ba20d197a909e5693bfb469e57a6e54 (diff)
downloadeclipse.platform.team-b0af11d5ad395f14a2bb6fff9a47a9b6d394a3e5.tar.gz
eclipse.platform.team-b0af11d5ad395f14a2bb6fff9a47a9b6d394a3e5.tar.xz
eclipse.platform.team-b0af11d5ad395f14a2bb6fff9a47a9b6d394a3e5.zip
Fixed up checkout and file transfer progress, the scale for work still doesn't show up right.
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java57
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/requests/RequestSender.java530
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSFile.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java116
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java33
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/response/Updated.java2
7 files changed, 350 insertions, 394 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
index 7f56dd76c..689212f5e 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
@@ -33,6 +33,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
@@ -53,10 +54,11 @@ import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
import org.eclipse.team.internal.ccvs.core.resources.Synchronizer;
import org.eclipse.team.internal.ccvs.core.util.ProjectDescriptionManager;
+import org.eclipse.team.internal.ccvs.core.Policy;
public class CVSProvider implements ICVSProvider {
- private static final String STATE_FILE = ".cvsProviderState";
+ private static final String STATE_FILE = ".cvsProviderState"; //$NON-NLS-1$
private static CVSProvider instance;
private PrintStream printStream;
@@ -93,7 +95,7 @@ public class CVSProvider implements ICVSProvider {
}
// Set or cahce the password
- String password = configuration.getProperty("password");
+ String password = configuration.getProperty("password"); //$NON-NLS-1$
if (password != null) {
if (cachePassword)
location.storePassword(password);
@@ -153,7 +155,7 @@ public class CVSProvider implements ICVSProvider {
// Add the option to load into a directory of a different name
String module = project.getName();
if (sourceModule != null) {
- localOptions.add("-d");
+ localOptions.add("-d"); //$NON-NLS-1$
localOptions.add(module);
module = sourceModule;
}
@@ -213,7 +215,7 @@ public class CVSProvider implements ICVSProvider {
boolean alreadyExists = isCached(location);
addToCache(location);
try {
- checkout(location, project, configuration.getProperty("module"), getTagFromProperties(configuration), monitor);
+ checkout(location, project, configuration.getProperty("module"), getTagFromProperties(configuration), monitor); //$NON-NLS-1$
} catch (TeamException e) {
// The checkout may have triggered password caching
// Therefore, if this is a newly created location, we want to clear its cache
@@ -231,28 +233,27 @@ public class CVSProvider implements ICVSProvider {
/**
* @see ICVSProvider#checkout(ICVSRemoteResource[], IProject[], IProgressMonitor)
*/
- public void checkout(
- final ICVSRemoteFolder[] resources,
- final IProject[] projects,
- final IProgressMonitor monitor)
- throws TeamException {
-
+ public void checkout(final ICVSRemoteFolder[] resources, final IProject[] projects, IProgressMonitor monitor) throws TeamException {
final TeamException[] eHolder = new TeamException[1];
try {
IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
public void run(IProgressMonitor pm) throws CoreException {
try {
+ pm.setTaskName(Policy.bind("Checking_out_from_CVS..._5")); //$NON-NLS-1$
+ pm.beginTask(null, 1000 * resources.length);
for (int i=0;i<resources.length;i++) {
IProject project = null;
RemoteFolder resource = (RemoteFolder)resources[i];
if (projects != null)
project = projects[i];
- checkout(resource.getRepository(), project, resource.getRemotePath(), resource.getTag(), monitor);
+ checkout(resource.getRepository(), project, resource.getRemotePath(), resource.getTag(), Policy.subMonitorFor(pm, 1000));
}
}
catch (TeamException e) {
// Pass it outside the workspace runnable
eHolder[0] = e;
+ } finally {
+ pm.done();
}
// CoreException and OperationCanceledException are propagated
}
@@ -260,13 +261,13 @@ public class CVSProvider implements ICVSProvider {
ResourcesPlugin.getWorkspace().run(workspaceRunnable, monitor);
} catch (CoreException e) {
throw wrapException(e);
- }
-
+ } finally {
+ monitor.done();
+ }
// Re-throw the TeamException, if one occurred
if (eHolder[0] != null) {
throw eHolder[0];
}
-
}
/**
@@ -302,8 +303,8 @@ public class CVSProvider implements ICVSProvider {
String extension = resource.getFileExtension();
if (extension == null) {
result.add(resource.getName());
- } else if (!("true".equals(registry.getValue(extension, "isAscii")))) {
- result.add("*." + extension);
+ } else if (!("true".equals(registry.getValue(extension, "isAscii")))) { //$NON-NLS-1$ //$NON-NLS-2$
+ result.add("*." + extension); //$NON-NLS-1$
}
}
// Always return true and let the depth determine if children are visited
@@ -402,7 +403,7 @@ public class CVSProvider implements ICVSProvider {
addToCache(location);
try {
importProject(location, project, configuration, monitor);
- checkout(location, project, configuration.getProperty("module"), getTagFromProperties(configuration), monitor);
+ checkout(location, project, configuration.getProperty("module"), getTagFromProperties(configuration), monitor); //$NON-NLS-1$
} catch (TeamException e) {
// The checkout may have triggered password caching
// Therefore, if this is a newly created location, we want to clear its cache
@@ -418,10 +419,10 @@ public class CVSProvider implements ICVSProvider {
}
private CVSTag getTagFromProperties(Properties configuration) {
- String date = configuration.getProperty("date");
- String tagName = configuration.getProperty("tag");
+ String date = configuration.getProperty("date"); //$NON-NLS-1$
+ String tagName = configuration.getProperty("tag"); //$NON-NLS-1$
if (tagName == null)
- tagName = configuration.getProperty("branch");
+ tagName = configuration.getProperty("branch"); //$NON-NLS-1$
if (tagName == null)
return CVSTag.DEFAULT;
return new CVSTag(tagName, CVSTag.BRANCH);
@@ -437,22 +438,22 @@ public class CVSProvider implements ICVSProvider {
ICVSFolder root = Client.getManagedFolder(project.getLocation().toFile());
// Get the message
- String message = configuration.getProperty("message");
+ String message = configuration.getProperty("message"); //$NON-NLS-1$
if (message == null)
message = Policy.bind("CVSProvider.initialImport");
// Get the vendor
- String vendor = configuration.getProperty("vendor");
+ String vendor = configuration.getProperty("vendor"); //$NON-NLS-1$
if (vendor == null)
vendor = location.getUsername();
// Get the vendor
- String tag = configuration.getProperty("tag");
+ String tag = configuration.getProperty("tag"); //$NON-NLS-1$
if (tag == null)
- tag = "start";
+ tag = "start"; //$NON-NLS-1$
// Get the module name
- String module = configuration.getProperty("module");
+ String module = configuration.getProperty("module"); //$NON-NLS-1$
if (module == null)
module = project.getName();
@@ -464,7 +465,7 @@ public class CVSProvider implements ICVSProvider {
String[] patterns = getBinaryFilePatterns(project);
for (int i=0;i<patterns.length;i++) {
localOptions.add(Client.WRAPPER_OPTION);
- localOptions.add(patterns[i] + " -k 'b'");
+ localOptions.add(patterns[i] + " -k 'b'"); //$NON-NLS-1$
}
// Perform a import
@@ -498,7 +499,7 @@ public class CVSProvider implements ICVSProvider {
// Assume files with no extension are binary
if (lastDot == -1) return false;
String extension = filename.substring(lastDot + 1);
- return ((extension != null) && ("true".equals(registry.getValue(extension, "isAscii"))));
+ return ((extension != null) && ("true".equals(registry.getValue(extension, "isAscii")))); //$NON-NLS-1$ //$NON-NLS-2$
}
private void removeFromCache(ICVSRepositoryLocation repository) {
@@ -598,7 +599,7 @@ public class CVSProvider implements ICVSProvider {
private void saveState() throws TeamException {
IPath pluginStateLocation = CVSProviderPlugin.getPlugin().getStateLocation();
- File tempFile = pluginStateLocation.append(STATE_FILE + ".tmp").toFile();
+ File tempFile = pluginStateLocation.append(STATE_FILE + ".tmp").toFile(); //$NON-NLS-1$
File stateFile = pluginStateLocation.append(STATE_FILE).toFile();
try {
DataOutputStream dos = new DataOutputStream(new FileOutputStream(tempFile));
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
index 2ea65547a..855b2df79 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
@@ -59,6 +59,7 @@ FileProperties.invalidEntryLine=Invalid entry line: {0}
LocalFile.receiving=Receiving file {0}
LocalFile.sending=Sending file {0}
LocalFile.transfer={0} ({1}K of {2}K bytes)
+LocalFile.transferNoSize={0}
RemoteFolder.errorFetchingRevisions=Error fetching file revision numbers
RemoteManagedResource.invalidOperation=Invalid operation performed on remote resource
@@ -96,3 +97,4 @@ ProjectDescriptionContentHandler.xml=Error parsing project description file
Util.invalidResource=Resource {1} is not relative to root {0}
Synchronizer.reload=Examining {0}
+Checking_out_from_CVS..._5=Checking out from CVS...
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/requests/RequestSender.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/requests/RequestSender.java
index 54dc65396..ce00b64d2 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/requests/RequestSender.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/requests/RequestSender.java
@@ -1,265 +1,265 @@
-package org.eclipse.team.internal.ccvs.core.requests;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.connection.Connection;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.response.IResponseHandler;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-
-/**
- * The reqest-sender is the only way to send messages to the
- * server.
- *
- * It has a lot of helper-methods like "sendGlobalOption, sendEntry ..."
- * this do send messages with parameter up to the server. These ways of
- * sending are discibed in the cvs-protocol specification
- *
- */
-public class RequestSender {
-
- /** Requests that don't expect any response from the server */
- public static final String ARGUMENT = "Argument";
- public static final String ARGUMENTX = "Argumentx";
- public static final String DIRECTORY = "Directory";
- public static final String ENTRY = "Entry";
- public static final String GLOBAL_OPTION = "Global_option";
- public static final String ROOT = "Root";
- public static final String UNCHANGED = "Unchanged";
- public static final String VALID_RESPONSES = "Valid-responses";
- public static final String QUESTIONABLE = "Questionable";
- public static final String KOPT = "Kopt";
- public static final String STATIC_DIRECTORY = "Static-directory";
- public static final String STICKY = "Sticky";
- public static final String MODIFIED = "Modified";
- public static final String IS_MODIFIED = "Is-modified";
-
- /** Requests that do expect any response from the server */
- public static final String CHECKOUT = "co";
- public static final String IMPORT = "import";
- public static final String VALID_REQUESTS = "valid-requests";
- public static final String EXPAND_MODULES = "expand-modules";
- public static final String CI = "ci";
- public static final String STATUS = "status";
- public static final String UPDATE = "update";
- public static final String HISTORY = "history";
- public static final String ADD = "add";
- public static final String REMOVE = "remove";
- public static final String LOG = "log";
- public static final String RTAG = "rtag";
- public static final String TAG = "tag";
- public static final String DIFF = "diff";
- public static final String ADMIN = "admin";
-
- /** Helper Constants that are not going to be send to server */
- public static final String SERVER_SEPERATOR = "/";
- private static final String EMPTY_LOCAL_FOLDER = ".";
- private static final String LINEFEED = "\n";
- private static final String CRETURN = "\r";
- private static final String STANDARD_PERMISSION = "u=rw,g=rw,o=r";
-
- /**
- * The link to the server to send things out
- */
- private Connection connection;
-
- /**
- * List of the valid-request as stated from the
- * server.
- * For future checking on that.
- */
- private String validRequests;
-
- /**
- * Constructor that takes the connection
- */
- public RequestSender (Connection connection) {
- this.connection = connection;
- }
-
- /**
- * Is the given request a valid server request.
- */
- public boolean isValidRequest(String requestName) {
- if (validRequests == null)
- return false;
- return validRequests.indexOf(requestName) != -1;
- }
-
- /**
- * Set the list of valid-request when you get
- * the list of valid request from the server.
- */
- void setValidRequest(String validRequests) {
- this.validRequests = validRequests;
- }
-
- /**
- * Get a Handler for the "valid-request", that does
- * collect the information to this class.
- */
- public IResponseHandler getValidRequestHandler() {
- return new ValidRequestHandler(this);
- }
-
- /**
- * This is the general way to send text to the server.
- * Most commonly it is used to send a single constant
- * to the server
- */
- public void writeLine(String data) throws CVSException {
- connection.writeLine(data);
- }
-
- /**
- * Sends an argument to the server. If arg contains newlines
- * of any kind the argument as one first argument and after
- * that as argument extentions.<br>
- * E.g.: sendArgument("Hello\nWorld\nHello\r World") is send as
- * <ul>
- * <li> Argument Hello
- * <li> Argumentx World
- * <li> Argumentx Hello
- * <li> Argumentx World
- * </ul>
- */
- public void sendArgument(String arg) throws CVSException {
-
- StringTokenizer tokenizer;
-
- if (arg.indexOf(LINEFEED) == -1 &&
- arg.indexOf(CRETURN) == -1) {
- connection.writeLine(ARGUMENT, arg);
- return;
- }
-
- // Create a tokenizer, that uses all newline-caracters as
- // delimitor
- tokenizer = new StringTokenizer(arg,LINEFEED + CRETURN);
-
- // We do not want an argument with a newlines only
- Assert.isTrue(tokenizer.hasMoreTokens());
-
- connection.writeLine(ARGUMENT, tokenizer.nextToken());
- while (tokenizer.hasMoreTokens()) {
- connection.writeLine(ARGUMENTX, tokenizer.nextToken());
- }
- }
-
- public void sendKopt(String arg) throws CVSException {
- connection.writeLine(KOPT, arg);
- }
-
- public void sendIsModified(String file) throws CVSException {
- connection.writeLine(IS_MODIFIED, file);
- }
-
- public void sendStaticDirectory() throws CVSException {
- connection.writeLine(STATIC_DIRECTORY);
- }
-
- /**
- * The Directory request is sent as:
- * <ul>
- * <li>Directory localdir
- * <li>repository_root/remotedir
- * </ul>
- *
- * This note is copied from an old version:
- * [Note: A CVS repository root can end with a trailing slash. The CVS server
- * expects that the repository root sent contain this extra slash. Including
- * the foward slash in addition to the absolute remote path makes for a string
- * containing two consecutive slashes (e.g. /home/cvs/repo//projecta/a.txt).
- * This is valid in the CVS protocol.]
- */
- public void sendConstructedDirectory(String local, String remote) throws CVSException {
-
- // FIXME I do not know wether this method is "ModuleFile-safe"
-
- connection.writeLine(DIRECTORY, local);
- connection.writeLine(connection.getRootDirectory() +
- SERVER_SEPERATOR + remote);
- }
-
- /**
- * The Directory request is sent as:
- * <ul>
- * <li>Directory localdir
- * <li>repository_root/remotedir
- * </ul>
- */
- public void sendDirectory(String local, String remote) throws CVSException {
-
- if (local.equals("")) {
- local = EMPTY_LOCAL_FOLDER;
- }
-
- connection.writeLine(DIRECTORY, local);
- connection.writeLine(remote);
- }
-
- public void sendEntry(String entryLine) throws CVSException {
- connection.writeLine(ENTRY, entryLine);
- }
-
- public void sendGlobalOption(String option) throws CVSException {
- connection.writeLine(GLOBAL_OPTION, option);
- }
-
- public void sendUnchanged(String filename) throws CVSException {
- connection.writeLine(UNCHANGED, filename);
- }
-
- public void sendQuestionable(String filename) throws CVSException {
- connection.writeLine(QUESTIONABLE, filename);
- }
-
- public void sendSticky(String tag) throws CVSException {
- connection.writeLine(STICKY, tag);
- }
-
- /**
- * This does not only send the message to the server that the
- * file is going to be uploaded.<br>
- * It does also acctually upload the file.<br>
- * NOTE: The entry line has to be send before calling this method
- */
- public void sendModified(ICVSFile file, IProgressMonitor monitor, boolean binary)
- throws CVSException {
-
- // boolean binary;
-
- // Send
- // - MODIFIED
- // - permissions
- // - size
- // - Content of the file
-
- // Does not send the entryLinde !!
- connection.writeLine(MODIFIED, file.getName());
-
- ResourceSyncInfo info = file.getSyncInfo();
- if (info == null ||
- info.getPermissions() == null) {
- connection.writeLine(STANDARD_PERMISSION);
- } else {
- connection.writeLine(info.getPermissions());
- }
-
- String progressTitle =
- Policy.bind("RequestSender.sendModified", file.getName());
- monitor.subTask(progressTitle);
- file.sendTo(connection.getRequestStream(),monitor,binary);
- }
-
-
-}
+package org.eclipse.team.internal.ccvs.core.requests;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.Policy;
+import org.eclipse.team.internal.ccvs.core.connection.Connection;
+import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
+import org.eclipse.team.internal.ccvs.core.resources.ResourceSyncInfo;
+import org.eclipse.team.internal.ccvs.core.response.IResponseHandler;
+import org.eclipse.team.internal.ccvs.core.util.Assert;
+
+/**
+ * The reqest-sender is the only way to send messages to the
+ * server.
+ *
+ * It has a lot of helper-methods like "sendGlobalOption, sendEntry ..."
+ * this do send messages with parameter up to the server. These ways of
+ * sending are discibed in the cvs-protocol specification
+ *
+ */
+public class RequestSender {
+
+ /** Requests that don't expect any response from the server */
+ public static final String ARGUMENT = "Argument";
+ public static final String ARGUMENTX = "Argumentx";
+ public static final String DIRECTORY = "Directory";
+ public static final String ENTRY = "Entry";
+ public static final String GLOBAL_OPTION = "Global_option";
+ public static final String ROOT = "Root";
+ public static final String UNCHANGED = "Unchanged";
+ public static final String VALID_RESPONSES = "Valid-responses";
+ public static final String QUESTIONABLE = "Questionable";
+ public static final String KOPT = "Kopt";
+ public static final String STATIC_DIRECTORY = "Static-directory";
+ public static final String STICKY = "Sticky";
+ public static final String MODIFIED = "Modified";
+ public static final String IS_MODIFIED = "Is-modified";
+
+ /** Requests that do expect any response from the server */
+ public static final String CHECKOUT = "co";
+ public static final String IMPORT = "import";
+ public static final String VALID_REQUESTS = "valid-requests";
+ public static final String EXPAND_MODULES = "expand-modules";
+ public static final String CI = "ci";
+ public static final String STATUS = "status";
+ public static final String UPDATE = "update";
+ public static final String HISTORY = "history";
+ public static final String ADD = "add";
+ public static final String REMOVE = "remove";
+ public static final String LOG = "log";
+ public static final String RTAG = "rtag";
+ public static final String TAG = "tag";
+ public static final String DIFF = "diff";
+ public static final String ADMIN = "admin";
+
+ /** Helper Constants that are not going to be send to server */
+ public static final String SERVER_SEPERATOR = "/";
+ private static final String EMPTY_LOCAL_FOLDER = ".";
+ private static final String LINEFEED = "\n";
+ private static final String CRETURN = "\r";
+ private static final String STANDARD_PERMISSION = "u=rw,g=rw,o=r";
+
+ /**
+ * The link to the server to send things out
+ */
+ private Connection connection;
+
+ /**
+ * List of the valid-request as stated from the
+ * server.
+ * For future checking on that.
+ */
+ private String validRequests;
+
+ /**
+ * Constructor that takes the connection
+ */
+ public RequestSender (Connection connection) {
+ this.connection = connection;
+ }
+
+ /**
+ * Is the given request a valid server request.
+ */
+ public boolean isValidRequest(String requestName) {
+ if (validRequests == null)
+ return false;
+ return validRequests.indexOf(requestName) != -1;
+ }
+
+ /**
+ * Set the list of valid-request when you get
+ * the list of valid request from the server.
+ */
+ void setValidRequest(String validRequests) {
+ this.validRequests = validRequests;
+ }
+
+ /**
+ * Get a Handler for the "valid-request", that does
+ * collect the information to this class.
+ */
+ public IResponseHandler getValidRequestHandler() {
+ return new ValidRequestHandler(this);
+ }
+
+ /**
+ * This is the general way to send text to the server.
+ * Most commonly it is used to send a single constant
+ * to the server
+ */
+ public void writeLine(String data) throws CVSException {
+ connection.writeLine(data);
+ }
+
+ /**
+ * Sends an argument to the server. If arg contains newlines
+ * of any kind the argument as one first argument and after
+ * that as argument extentions.<br>
+ * E.g.: sendArgument("Hello\nWorld\nHello\r World") is send as
+ * <ul>
+ * <li> Argument Hello
+ * <li> Argumentx World
+ * <li> Argumentx Hello
+ * <li> Argumentx World
+ * </ul>
+ */
+ public void sendArgument(String arg) throws CVSException {
+
+ StringTokenizer tokenizer;
+
+ if (arg.indexOf(LINEFEED) == -1 &&
+ arg.indexOf(CRETURN) == -1) {
+ connection.writeLine(ARGUMENT, arg);
+ return;
+ }
+
+ // Create a tokenizer, that uses all newline-caracters as
+ // delimitor
+ tokenizer = new StringTokenizer(arg,LINEFEED + CRETURN);
+
+ // We do not want an argument with a newlines only
+ Assert.isTrue(tokenizer.hasMoreTokens());
+
+ connection.writeLine(ARGUMENT, tokenizer.nextToken());
+ while (tokenizer.hasMoreTokens()) {
+ connection.writeLine(ARGUMENTX, tokenizer.nextToken());
+ }
+ }
+
+ public void sendKopt(String arg) throws CVSException {
+ connection.writeLine(KOPT, arg);
+ }
+
+ public void sendIsModified(String file) throws CVSException {
+ connection.writeLine(IS_MODIFIED, file);
+ }
+
+ public void sendStaticDirectory() throws CVSException {
+ connection.writeLine(STATIC_DIRECTORY);
+ }
+
+ /**
+ * The Directory request is sent as:
+ * <ul>
+ * <li>Directory localdir
+ * <li>repository_root/remotedir
+ * </ul>
+ *
+ * This note is copied from an old version:
+ * [Note: A CVS repository root can end with a trailing slash. The CVS server
+ * expects that the repository root sent contain this extra slash. Including
+ * the foward slash in addition to the absolute remote path makes for a string
+ * containing two consecutive slashes (e.g. /home/cvs/repo//projecta/a.txt).
+ * This is valid in the CVS protocol.]
+ */
+ public void sendConstructedDirectory(String local, String remote) throws CVSException {
+
+ // FIXME I do not know wether this method is "ModuleFile-safe"
+
+ connection.writeLine(DIRECTORY, local);
+ connection.writeLine(connection.getRootDirectory() +
+ SERVER_SEPERATOR + remote);
+ }
+
+ /**
+ * The Directory request is sent as:
+ * <ul>
+ * <li>Directory localdir
+ * <li>repository_root/remotedir
+ * </ul>
+ */
+ public void sendDirectory(String local, String remote) throws CVSException {
+
+ if (local.equals("")) {
+ local = EMPTY_LOCAL_FOLDER;
+ }
+
+ connection.writeLine(DIRECTORY, local);
+ connection.writeLine(remote);
+ }
+
+ public void sendEntry(String entryLine) throws CVSException {
+ connection.writeLine(ENTRY, entryLine);
+ }
+
+ public void sendGlobalOption(String option) throws CVSException {
+ connection.writeLine(GLOBAL_OPTION, option);
+ }
+
+ public void sendUnchanged(String filename) throws CVSException {
+ connection.writeLine(UNCHANGED, filename);
+ }
+
+ public void sendQuestionable(String filename) throws CVSException {
+ connection.writeLine(QUESTIONABLE, filename);
+ }
+
+ public void sendSticky(String tag) throws CVSException {
+ connection.writeLine(STICKY, tag);
+ }
+
+ /**
+ * This does not only send the message to the server that the
+ * file is going to be uploaded.<br>
+ * It does also acctually upload the file.<br>
+ * NOTE: The entry line has to be send before calling this method
+ */
+ public void sendModified(ICVSFile file, IProgressMonitor monitor, boolean binary)
+ throws CVSException {
+
+ // boolean binary;
+
+ // Send
+ // - MODIFIED
+ // - permissions
+ // - size
+ // - Content of the file
+
+ // Does not send the entryLinde !!
+ connection.writeLine(MODIFIED, file.getName());
+
+ ResourceSyncInfo info = file.getSyncInfo();
+ if (info == null ||
+ info.getPermissions() == null) {
+ connection.writeLine(STANDARD_PERMISSION);
+ } else {
+ connection.writeLine(info.getPermissions());
+ }
+
+ String progressTitle =
+ Policy.bind("RequestSender.sendModified", file.getName());
+ monitor.subTask(progressTitle);
+ file.sendTo(connection.getRequestStream(),binary,monitor);
+ }
+
+
+}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSFile.java
index ef5820665..8a1c499d2 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSFile.java
@@ -29,13 +29,13 @@ public interface ICVSFile extends ICVSResource {
* Transfer the contents of the file to the given output stream. If the file is
* not binary the line-endings may be converted.
*/
- void sendTo(OutputStream outputStream, IProgressMonitor monitor, boolean binary) throws CVSException;
+ void sendTo(OutputStream outputStream, boolean binary, IProgressMonitor monitor) throws CVSException;
/**
* Transfer the contents of an input stream to this file. If the file is
* not binary the line-endings may be converted.
*/
- void receiveFrom(InputStream inputStream, IProgressMonitor monitor, long size, boolean binary, boolean readOnly) throws CVSException;
+ void receiveFrom(InputStream inputStream, long size, boolean binary, boolean readOnly, IProgressMonitor monitor) throws CVSException;
/**
* Move the resource to another location. Does overwrite without
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java
index 0cb6160fa..af91531fb 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java
@@ -5,6 +5,8 @@ package org.eclipse.team.internal.ccvs.core.resources;
* All Rights Reserved.
*/
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -51,47 +53,38 @@ public class LocalFile extends LocalResource implements ICVSFile {
return ioResource.length();
}
- public void receiveFrom(InputStream in,
- IProgressMonitor monitor,
- long size,
- boolean binary,
- boolean readOnly)
-
- throws CVSException {
-
+ public void receiveFrom(InputStream in, long size, boolean binary, boolean readOnly, IProgressMonitor monitor) throws CVSException {
OutputStream out;
String title;
-
- title = Policy.bind("LocalFile.receiving",
- new Object[] {ioResource.getName()});
-
+
+ title = Policy.bind("LocalFile.receiving", ioResource.getName());
+
try {
// We don't need to buffer here because the methods used below do
out = new FileOutputStream(ioResource);
-
+
try {
if (binary) {
- transferWithProgress(in,out,size,monitor,title);
+ transferWithProgress(in, out, size, title, monitor);
} else {
- transferText(in,out,size,monitor,title,false);
+ transferText(in, out, size, title, false, monitor);
}
} finally {
out.close();
}
-
+
if (readOnly) {
ioResource.setReadOnly();
}
-
} catch (IOException e) {
throw CVSException.wrapException(e);
}
}
-
+
public void sendTo(
OutputStream out,
- IProgressMonitor monitor,
- boolean binary)
+ boolean binary,
+ IProgressMonitor monitor)
throws CVSException {
InputStream in;
@@ -110,12 +103,12 @@ public class LocalFile extends LocalResource implements ICVSFile {
// Send the size to the server
out.write(("" + getSize()).getBytes());
out.write(SERVER_NEWLINE.getBytes());
- transferWithProgress(in,out,size,monitor,title);
+ transferWithProgress(in,out,size,title,monitor);
} else {
// In this case the size has to be computed.
// Therefore we do send the size in transferText
- transferText(in,out,getSize(),monitor,title,true);
+ transferText(in,out,getSize(),title,true,monitor);
}
} finally {
in.close();
@@ -151,64 +144,36 @@ public class LocalFile extends LocalResource implements ICVSFile {
return false;
}
- protected static void transferText(InputStream in,
- OutputStream out,
- long size,
- IProgressMonitor monitor,
- String title,
- boolean toServer)
- throws IOException {
-
- // If we get a file bigger than 2 GigaByte, this does not
- // work
- Assert.isTrue(size < Integer.MAX_VALUE);
-
- if (size > 25000) {
-
- monitor.setTaskName(
- Policy.bind(
- "LocalFile.transfer",
- new Object[]{title,new Long(0),new Long(size/1024)}
- )
- );
+ protected static void transferText(InputStream in, OutputStream out, long size, String title, boolean toServer, IProgressMonitor monitor) throws IOException {
- }
-
- byte[] buffer = new byte[(int)size];
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ transferWithProgress(in, buffer, size, title, monitor);
- // Get the content from the file
- int num = in.read(buffer);
- int pos = num;
- while ((num != -1) && (size - pos > 0)) {
- Policy.checkCanceled(monitor);
- num = in.read(buffer, pos, ((int)size) - pos);
- pos += num;
- }
-
- // care about newlines
+ byte[] contents = null;
+ boolean needEOLConversion = !PLATFORM_NEWLINE.equals(SERVER_NEWLINE);
if (toServer) {
- buffer = Util.replace(buffer,PLATFORM_NEWBYTE,SERVER_NEWBYTE);
+ if (needEOLConversion) {
+ contents = Util.replace(buffer.toByteArray(), PLATFORM_NEWBYTE, SERVER_NEWBYTE);
+ } else {
+ contents = buffer.toByteArray();
+ }
// Send the size to the server
- out.write(("" + buffer.length).getBytes());
+ out.write(("" + contents.length).getBytes());
out.write(SERVER_NEWLINE.getBytes());
-
} else {
- buffer = Util.replace(buffer,PLATFORM_NEWBYTE,SERVER_NEWBYTE);
- buffer = Util.replace(buffer,SERVER_NEWBYTE,PLATFORM_NEWBYTE);
+ if (needEOLConversion) {
+ contents = Util.replace(buffer.toByteArray(), PLATFORM_NEWBYTE, SERVER_NEWBYTE);
+ contents = Util.replace(contents, SERVER_NEWBYTE, PLATFORM_NEWBYTE);
+ } else {
+ contents = buffer.toByteArray();
+ }
}
-
- out.write(buffer);
+ out.write(contents);
}
- protected static void transferWithProgress(
- InputStream in,
- OutputStream out,
- long size,
- IProgressMonitor monitor,
- String title)
- throws IOException {
-
- byte[] BUFFER = new byte[4096];
+ protected static void transferWithProgress(InputStream in, OutputStream out, long size, String title, IProgressMonitor monitor) throws IOException {
+
+ byte[] BUFFER = new byte[4096];
// This special transfer utility will show progress to
// the monitor for files that are bigger than 25K
@@ -216,16 +181,15 @@ public class LocalFile extends LocalResource implements ICVSFile {
int read = 0;
long totalRead = 0;
long ksize = size / 1024;
+
+ monitor.subTask(Policy.bind("LocalFile.transferNoSize", title));
+
// buffer size is smaller than MAXINT...
int toRead = (int) Math.min(BUFFER.length, size);
synchronized (BUFFER) {
while ((totalRead < size) && (read = in.read(BUFFER, 0, toRead)) != -1) {
if (progress && totalRead > 0) {
- monitor.subTask(
- Policy.bind(
- "LocalFile.transfer",
- new Object[] { title, new Long(totalRead / 1024), new Long(ksize)}));
- monitor.worked(read);
+ monitor.subTask(Policy.bind("LocalFile.transfer", new Object[] { title, new Long(totalRead / 1024), new Long(ksize)}));
}
totalRead += read;
out.write(BUFFER, 0, read);
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
index af502435a..31231cf25 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
@@ -254,39 +254,28 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
/**
* @see IManagedFile#sendTo(OutputStream, IProgressMonitor, boolean)
*/
- public void sendTo(
- OutputStream out,
- IProgressMonitor monitor,
- boolean binary)
- throws CVSException {
- try {
- String SERVER_NEWLINE = "\n";
- // Send the size to the server and no contents
- out.write(0);
- out.write(SERVER_NEWLINE.getBytes());
- } catch(IOException e) {
- }
+ public void sendTo(OutputStream out, boolean binary, IProgressMonitor monitor) throws CVSException {
+ try {
+ String SERVER_NEWLINE = "\n";
+ // Send the size to the server and no contents
+ out.write(0);
+ out.write(SERVER_NEWLINE.getBytes());
+ } catch(IOException e) {
+ }
}
/**
* @see IManagedFile#receiveFrom(InputStream, IProgressMonitor, long, boolean)
*/
- public void receiveFrom(
- InputStream inputStream,
- IProgressMonitor monitor,
- long size,
- boolean binary,
- boolean readOnly)
- throws CVSException {
-
+ public void receiveFrom(InputStream inputStream, long size, boolean binary, boolean readOnly, IProgressMonitor monitor) throws CVSException {
// NOTE: This should be changed such that the client or connection handles
// the proper transfer
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
if (binary)
- LocalFile.transferWithProgress(inputStream, bos, (long)size, monitor, "");
+ LocalFile.transferWithProgress(inputStream, bos, (long)size, "", monitor);
else
- LocalFile.transferText(inputStream, bos, (long)size, monitor, "", false);
+ LocalFile.transferText(inputStream, bos, (long)size, "", false, monitor);
contents = bos.toByteArray();
} catch (IOException ex) {
throw CVSException.wrapException(ex);
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/response/Updated.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/response/Updated.java
index 0e917eb97..b2bb9788a 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/response/Updated.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/response/Updated.java
@@ -119,7 +119,7 @@ class Updated extends ResponseHandler {
binary = entry.indexOf("/"+ResourceSyncInfo.BINARY_TAG) != -1;
readOnly = permissions.indexOf(READ_ONLY_FLAG) == -1;
- mFile.receiveFrom(in,monitor,size,binary,readOnly);
+ mFile.receiveFrom(in, size, binary, readOnly, monitor);
// Set the timestamp in the file, set the result in the fileInfo
String timestamp;

Back to the top