Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-04-06 14:34:02 -0500
committerMichael Valenta2002-04-06 14:34:02 -0500
commit8fed03e2f8bcdb288663c055f4aca95be731cbc2 (patch)
treea02334ea12348e241f4f7b6a0bbc241ff38f19ab
parent68de99e5c734fc9303a6a94090857ed9b1241138 (diff)
downloadeclipse.platform.team-8fed03e2f8bcdb288663c055f4aca95be731cbc2.tar.gz
eclipse.platform.team-8fed03e2f8bcdb288663c055f4aca95be731cbc2.tar.xz
eclipse.platform.team-8fed03e2f8bcdb288663c055f4aca95be731cbc2.zip
9734: Team2 (i0212): bug when using CVSNT greater then 1.11.1.1
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java98
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java26
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java21
3 files changed, 143 insertions, 2 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java
new file mode 100644
index 000000000..9f63f4bae
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ ******************************************************************************/
+package org.eclipse.team.internal.ccvs.core.client;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+
+public class MTHandler extends ResponseHandler {
+
+ private String nextLine;
+ private boolean isLineAvailable;
+
+ /**
+ * @see ResponseHandler#getResponseID()
+ */
+ public String getResponseID() {
+ return "MT"; // $NON-NLS-1$
+ }
+
+ /**
+ * @see ResponseHandler#handle(Session, String, IProgressMonitor)
+ */
+ public void handle(Session session, String argument, IProgressMonitor monitor)
+ throws CVSException {
+
+ // If there was a line available from before, clear it
+ if (isLineAvailable()) {
+ startNextLine();
+ }
+
+ if (argument.charAt(0) == '+') {
+ // Reset any previously accumulated text
+ startNextLine();
+ } else if (argument.charAt(0) == '-') {
+ // Mark the line as available in case there was no trailing newline
+ if (nextLine != null) {
+ isLineAvailable = true;
+ }
+ } else {
+ // Extract the tag and text from the line
+ String tag;
+ String text;
+ int spaceIndex = argument.indexOf(' ');
+ if (spaceIndex == -1) {
+ tag = argument;
+ text = null;
+ } else {
+ tag = argument.substring(0, spaceIndex);
+ text = argument.substring(spaceIndex + 1);
+ }
+
+ // Accumulate the line and indicate if its available for use
+ if (tag.equals("newline")) {
+ isLineAvailable = true;
+ } else if (text != null) {
+ // Reset the previous line if required
+ if (isLineAvailable()) {
+ startNextLine();
+ }
+ // Accumulate the line
+ if (nextLine == null) {
+ nextLine = text;
+ } else {
+ // The text from the sevrver contains spaces when appropriate so just append
+ nextLine = nextLine + text;
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if there is a line available. If there is, it should be fetched with
+ * getLine() immediatly before the next MT response is processed.
+ */
+ public boolean isLineAvailable() {
+ return isLineAvailable;
+ }
+
+ /**
+ * Get the available line. This purges the line from the handler
+ */
+ public String getLine() {
+ return nextLine;
+ }
+
+ private void startNextLine() {
+ isLineAvailable = false;
+ nextLine = null;
+ }
+}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java
index 3c7391aae..cebede287 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java
@@ -53,9 +53,12 @@ public abstract class Request {
registerResponseHandler(new ValidRequestsHandler());
registerResponseHandler(new ModuleExpansionHandler());
}
- private static void registerResponseHandler(ResponseHandler handler) {
+ protected static void registerResponseHandler(ResponseHandler handler) {
responseHandlers.put(handler.getResponseID(), handler);
}
+ protected static void removeResponseHandler(String responseID) {
+ responseHandlers.remove(responseID);
+ }
private static ResponseHandler getResponseHandler(String responseID) {
return (ResponseHandler)responseHandlers.get(responseID);
}
@@ -143,6 +146,27 @@ public abstract class Request {
(IStatus[]) accumulatedStatus.toArray(new IStatus[accumulatedStatus.size()]),
argument, null);
// handle message responses
+ } else if (response.equals("MT")) { //$NON-NLS-1$
+ // Handle the MT response
+ MTHandler handler = (MTHandler) responseHandlers.get(response);
+ if (handler != null) {
+ handler.handle(session, argument, monitor);
+ } else {
+ throw new CVSException(new org.eclipse.core.runtime.Status(IStatus.ERROR,
+ CVSProviderPlugin.ID, CVSException.IO_FAILED,
+ Policy.bind("Command.unsupportedResponse", response, argument), null)); //$NON-NLS-1$
+ }
+ // If a line is available, pass it on to the message listener
+ // and console as if it were an M response
+ if (handler.isLineAvailable()) {
+ String line = handler.getLine();
+ IStatus status = listener.messageLine(line, session.getLocalRoot(), monitor);
+ if (status != ICommandOutputListener.OK) accumulatedStatus.add(status);
+ if (session.isOutputToConsole()) {
+ IConsoleListener consoleListener = CVSProviderPlugin.getPlugin().getConsoleListener();
+ if (consoleListener != null) consoleListener.messageLineReceived(line);
+ }
+ }
} else if (response.equals("M")) { //$NON-NLS-1$
IStatus status = listener.messageLine(argument, session.getLocalRoot(), monitor);
if (status != ICommandOutputListener.OK) accumulatedStatus.add(status);
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 92a3116d7..47000b0e7 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
@@ -15,6 +15,7 @@ import java.util.Date;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.ICVSFile;
import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
@@ -146,6 +147,13 @@ public class Session {
connection = location.openConnection(Policy.subMonitorFor(monitor, 50));
hasBeenConnected = true;
+ // If we're connected to a CVSNT server, accept MT. Otherwise don't
+ if (isCVSNT()) {
+ Request.registerResponseHandler(new MTHandler());
+ } else {
+ Request.removeResponseHandler("MT");
+ }
+
// tell the server the names of the responses we can handle
connection.writeLine("Valid-responses " + Request.makeResponseList()); //$NON-NLS-1$
@@ -154,6 +162,17 @@ public class Session {
// set the root directory on the server for this connection
connection.writeLine("Root " + getRepositoryRoot()); //$NON-NLS-1$
+ } catch (CVSException e) {
+ // If there is a failure opening, make sure we're closed
+ if (connection != null) {
+ hasBeenConnected = false;
+ try {
+ close();
+ } catch (CVSException ex) {
+ CVSProviderPlugin.log(ex);
+ }
+ }
+ throw e;
} finally {
monitor.done();
}
@@ -189,7 +208,7 @@ public class Session {
}
public boolean isCVSNT() {
- return location.getRootDirectory().indexOf(':') >= 0;
+ return location.getRootDirectory().indexOf(':') == 1;
}
/**

Back to the top