diff options
Diffstat (limited to 'bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners')
18 files changed, 0 insertions, 1894 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java deleted file mode 100644 index 78341bb1e..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - - -import org.eclipse.core.runtime.*; -import org.eclipse.osgi.util.NLS; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; -import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * Used with 'admin -ksubst' to capture lines of text that are issued - * as confirmation that the remote keyword substitution mode has been - * changed. When encountered, updates the local ResourceSyncInfo for - * the file in question to reflect - * - * e.g. - * RCS file: path/filename,v - * done - * - * We don't expect to see anything special on stderr if the command succeeds. - */ -public class AdminKSubstListener extends CommandOutputListener { - private KSubstOption ksubstMode; - - public AdminKSubstListener(KSubstOption ksubstMode) { - this.ksubstMode = ksubstMode; - } - - public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, - IProgressMonitor monitor) { - if (line.startsWith("RCS file:")) { //$NON-NLS-1$ - String rcsFile = line.substring(10).trim(); - if (! rcsFile.endsWith(",v")) { //$NON-NLS-1$ - return new CVSStatus(IStatus.ERROR, - NLS.bind(CVSMessages.AdminKSubstListener_expectedRCSFile, new String[] { rcsFile })); - } - IPath rcsFilePath = new Path(null, Util.removeAtticSegment(rcsFile.substring(0, rcsFile.length() - 2))); - try { - ICVSFile file = findLocalFileFor(commandRoot, rcsFilePath); - //ResourceSyncInfo info = file.getSyncInfo(); - byte[] syncBytes = file.getSyncBytes(); - if (syncBytes != null) { - // only update sync info if we have it locally - file.setSyncBytes(ResourceSyncInfo.setKeywordMode(syncBytes, ksubstMode), ICVSFile.UNKNOWN); - } - } catch (CVSException e) { - return e.getStatus(); - } - } - return OK; - } - - private ICVSFile findLocalFileFor(ICVSFolder commandRoot, IPath rcsFilePath) throws CVSException { - - // First, look for the local file by following the remote path - FolderSyncInfo info = commandRoot.getFolderSyncInfo(); - String remoteRootLocation = info.getRemoteLocation(); - if (remoteRootLocation == null) { - throw new CVSException(new CVSStatus(IStatus.ERROR, - CVSMessages.AdminKSubstListener_commandRootNotManaged)); - } - IPath remoteRootPath = new Path(null, remoteRootLocation); - if (remoteRootPath.isPrefixOf(rcsFilePath)) { - IPath relativeFilePath = rcsFilePath.removeFirstSegments(remoteRootPath.segmentCount()); - ICVSFile file = commandRoot.getFile(relativeFilePath.toString()); - if (file.isManaged() && isMatchingPath(file, rcsFilePath)) { - return file; - } - } - - // We couldn't find the file that way which means we're working in a defined module. - // Scan all folders looking for a match - ICVSFolder parent = findFolder(commandRoot, rcsFilePath.removeLastSegments(1)); - if (parent != null) { - ICVSFile file = parent.getFile(rcsFilePath.lastSegment()); - if (file.isManaged()) { - return file; - } - } - - // No file was found so return null; - throw new CVSException(new CVSStatus(IStatus.ERROR, - NLS.bind(CVSMessages.AdminKSubstListener_expectedChildOfCommandRoot, new String[] { rcsFilePath.toString(), remoteRootPath.toString() }))); - } - - private ICVSFolder findFolder(ICVSFolder commandRoot, IPath path) throws CVSException { - final String remotePath = path.toString(); - final ICVSFolder[] result = new ICVSFolder[] { null }; - commandRoot.accept(new ICVSResourceVisitor() { - public void visitFile(ICVSFile file) throws CVSException { - // Nothing to do for files - } - public void visitFolder(ICVSFolder folder) throws CVSException { - FolderSyncInfo info = folder.getFolderSyncInfo(); - if (info != null && info.getRemoteLocation().equals(remotePath)) { - // We found the folder we're looking for - result[0] = folder; - } - if (result[0] == null) { - folder.acceptChildren(this); - } - } - }); - return result[0]; - } - - private boolean isMatchingPath(ICVSFile file, IPath rcsFilePath) throws CVSException { - FolderSyncInfo info = file.getParent().getFolderSyncInfo(); - return info != null - && info.getRemoteLocation().equals(rcsFilePath.removeLastSegments(1).toString()); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java deleted file mode 100644 index d7576883b..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import java.io.*; -import java.util.ArrayList; -import java.util.List; - -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.client.CommandOutputListener; - -public class AnnotateListener extends CommandOutputListener { - -/** - * Handle output from the CVS Annotate command. - */ - ByteArrayOutputStream aStream = new ByteArrayOutputStream(); - List blocks = new ArrayList(); - int lineNumber; - - public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - String error = null; - CVSAnnotateBlock aBlock = new CVSAnnotateBlock(line, lineNumber++); - if (!aBlock.isValid()) { - error = line; - } - - /** - * Make sure all lines have a line terminator. - */ - try { - aStream.write(line.substring(aBlock.getSourceOffset()).getBytes()); - if (!(line.endsWith("\r") || line.endsWith("\r\n"))) { //$NON-NLS-1$ //$NON-NLS-2$ - aStream.write(System.getProperty("line.separator").getBytes()); //$NON-NLS-1$ - } - } catch (IOException e) { - } - add(aBlock); - if (error != null) - return new CVSStatus(IStatus.ERROR, CVSStatus.ERROR_LINE_PARSE_FAILURE, error, commandRoot); - return OK; - } - - public InputStream getContents() { - return new ByteArrayInputStream(aStream.toByteArray()); - } - - public List getCvsAnnotateBlocks() { - return blocks; - } - /** - * Add an annotate block to the receiver merging this block with the - * previous block if it is part of the same change. - * @param aBlock - */ - private void add(CVSAnnotateBlock aBlock) { - - int size = blocks.size(); - if (size == 0) { - blocks.add(aBlock); - } else { - CVSAnnotateBlock lastBlock = (CVSAnnotateBlock) blocks.get(size - 1); - if (lastBlock.getRevision().equals(aBlock.getRevision())) { - lastBlock.setEndLine(aBlock.getStartLine()); - } else { - blocks.add(aBlock); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#errorLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - if(line.startsWith(CVSMessages.AnnotateListener_3)) { - String error = CVSMessages.AnnotateListener_4; - return new CVSStatus(IStatus.ERROR, CVSStatus.SERVER_ERROR, error, commandRoot); - } - return super.errorLine(line, location, commandRoot, monitor); - } - - /** - * Set the contents of the listener to the provided contents. - * This is done if the contents fetched by the annotate command - * has a charater set that may have been mangled by the transfer - * @param remoteContents the actual contens of the file - */ - public void setContents(InputStream remoteContents) { - try { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024]; - int n = remoteContents.read(buffer); - while (n != -1) { - stream.write(buffer, 0, n); - n = remoteContents.read(buffer); - } - aStream = stream; - } catch (IOException e) { - // Log and continue - CVSProviderPlugin.log(CVSException.wrapException(e)); - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java deleted file mode 100644 index 7de08ec0d..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - - -import java.io.PrintStream; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; -import org.eclipse.team.internal.ccvs.core.client.Session; - -public class DiffListener extends CommandOutputListener { - PrintStream patchStream; - boolean wroteToStream; - - //Error Messages returned by CVS - static final String ERR_NOSUCHDIRECTORY = "cvs [diff aborted]: no such directory"; //$NON-NLS-1$ - - public DiffListener(PrintStream patchStream) { - this.patchStream = patchStream; - wroteToStream=false; - } - - public IStatus messageLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - // Special handling to avoid getting duplicate CRs when generating a patch on windows. - // If the remote file has CR/LF in it, then the line will have a CR at the end. - // We need to remove it so we don't end up with two CRs (since the printStream will also add one). - // On *nix, we want to include the CR since it will not be added by the printStream (see bug 92162). - if (Session.IS_CRLF_PLATFORM && line.length() > 0 && line.charAt(line.length() - 1) == '\r') { - line = line.substring(0, line.length() - 1); - } - patchStream.println(line); - wroteToStream=true; - - return OK; - } - - public IStatus errorLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - // ignore server messages for now - this is used only with the diff - // request and the errors can be safely ignored. - if (getServerMessage(line, location) != null) { - return OK; - } - - //Check to see if this is a no such directory message - if (line.indexOf(ERR_NOSUCHDIRECTORY) != -1){ - return OK; - } - return super.errorLine(line, location, commandRoot, monitor); - } - - public boolean wroteToStream() { - return wroteToStream; - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/EditorsListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/EditorsListener.java deleted file mode 100644 index db5438fd3..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/EditorsListener.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CSC - Intial implementation - * IBM Corporation - ongoing maintenance - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import java.util.LinkedList; -import java.util.List; -import java.util.StringTokenizer; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.EditorsInfo; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; - - -/** - * - * - * Listener for the Editors command - * - * @author <a href="mailto:kohlwes@gmx.net">Gregor Kohlwes</a> - * - */ -public class EditorsListener extends CommandOutputListener { - /** - * List to store the EditorsInfos - */ - private List infos = new LinkedList(); - - /** - * Name of the current file - */ - private String fileName; - - /** - * Constructor EditorsListener. - */ - public EditorsListener() { - } - - /** - * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#messageLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus messageLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - // If there is a file with multiple editors - // then cvs will write the filename only - // in the first line and the following - // line will start with a Tab - if (line.startsWith("\t")) { //$NON-NLS-1$ - line = fileName + line; - } - EditorsInfo info = new EditorsInfo(); - StringTokenizer tokenizer = new StringTokenizer(line,"\t"); //$NON-NLS-1$ - int i = 0; - while(tokenizer.hasMoreTokens()) { - String token = tokenizer.nextToken(); - switch (i) { - case 0: - info.setFileName(token); - fileName = token; - break; - case 1: - info.setUserName(token); - break; - case 2: - info.setDateString(token); - break; - case 3: - info.setComputerName(token); - break; - default : - break; - } - i++; - } - - infos.add(info); - return OK; - - } - /** - * Method getEditorsInfos. - * @return IEditorsInfo[] - */ - public EditorsInfo[] getEditorsInfos() { - return (EditorsInfo[]) infos.toArray(new EditorsInfo[infos.size()]); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java deleted file mode 100644 index 051591325..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -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.CVSStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; - -/** - * Instances of this interface can be passed to the <code>Command#execute</code> methods - * and will receive notification when M or E messages are received from the server. - */ -public interface ICommandOutputListener { - - /*** Status to be returned when no error or warning occured ***/ - public static final IStatus OK = new CVSStatus(IStatus.OK, CVSMessages.ok); - - public static final String SERVER_PREFIX = "server: "; //$NON-NLS-1$ - public static final String SERVER_ABORTED_PREFIX = "[server aborted]: "; //$NON-NLS-1$ - public static final String RTAG_PREFIX = "rtag: "; //$NON-NLS-1$ - - /** - * Invoked when a message line is received from the server. - * <p> - * Any status other than ICommandOutputListener.OK will be accumulated - * by the command and returned. The severity of the status matches those of - * IStatus and must indicate whether this is a warning, error, or informational - * text.while the code should be one of the codes provided by CVSStatus. - * The status code must not be CVSStatus.SERVER_ERROR. - * </p> - * - * @param line the line of message text sent by the server - * @param commandRoot the root directory of the command - * @param monitor the progress monitor - * @return a status indicating success or failure based on the text - */ - public IStatus messageLine(String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor); - - /** - * Invoked when an error line is received from the server. - * <p> - * Any status other than ICommandOutputListener.OK will be accumulated - * by the command and returned. The severity of the status matches those of - * IStatus and must indicate whether this is a warning, error, or informational - * text.while the code should be one of the codes provided by CVSStatus. - * The status code must not be CVSStatus.SERVER_ERROR. - * </p> - * - * @param line the line of error text sent by the server - * @param commandRoot the root directory of the command - * @param monitor the progress monitor - * @return a status indicating success or failure based on the text - */ - public IStatus errorLine(String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java deleted file mode 100644 index a625735f3..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.client.Session; - -public interface IConsoleListener { - /** - * Called when a command is invoked. - * @param session the session that the command is being executed over - * @param line the command invocation string - */ - public void commandInvoked(Session session, String line); - - /** - * Called when a line of message text has been received. - * @param session the session that the command is being executed over - * @param line the line of text - * @param status the status returned from the command message parser - */ - public void messageLineReceived(Session session, String line, IStatus status); - - /** - * Called when a line of error text has been received. - * @param session the session that the command is being executed over - * @param line the line of text - * @param status the status returned from the command message parser - */ - public void errorLineReceived(Session session, String line, IStatus status); - - /** - * Called when a command has been completed. - * @param session the session that the command is being executed over - * @param status the status code, or null if not applicable - * @param exception an exception, or null if not applicable - */ - public void commandCompleted(Session session, IStatus status, Exception exception); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ILogEntryListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ILogEntryListener.java deleted file mode 100644 index 91a4c7bc3..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ILogEntryListener.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import org.eclipse.team.internal.ccvs.core.ILogEntry; - -/** - * Interface for receiving log entries from the <code>LogListener</code> - */ -public interface ILogEntryListener { - - /** - * A log entry was received for the current file - * @param entry the received log entry. - */ - void handleLogEntryReceived(ILogEntry entry); - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IMessagePatterns.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IMessagePatterns.java deleted file mode 100644 index 9d3a690df..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IMessagePatterns.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * This class contains the default server message patterns - */ -public interface IMessagePatterns { - - public static final String SERVER_MESSAGE_PREFIX = "\\w* \\w*: "; //$NON-NLS-1$ - public static final String SERVER_ABORTED_MESSAGE_PREFIX = "\\w* [\\w* aborted]: "; //$NON-NLS-1$ - - // TODO: These patterns could be more specific but this would require non-capturing - // groups which currently throw off variable matching - public static final String TAG_PATTERN = "\\w*"; //$NON-NLS-1$ - public static final String REVISION_PATTERN = ".*"; //$NON-NLS-1$ - public static final String FILE_PATH_PATTERN = ".*"; //$NON-NLS-1$ - - // TODO: It would be better if the prefix was optional but this requires the use of a capturing group which throws the group count off - public static final String RDIFF_DIRECTORY = SERVER_MESSAGE_PREFIX + "Diffing " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFolderPath"); //$NON-NLS-1$ //$NON-NLS-2$ - public static final String RDIFF_SUMMARY_FILE_DIFF = "File " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFilePath") + " changed from revision " + Util.getVariablePattern(REVISION_PATTERN, "leftRevision") + " to " + Util.getVariablePattern(REVISION_PATTERN, "rightRevision"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - public static final String RDIFF_SUMMARY_NEW_FILE = "File " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFilePath") + " is new; " + TAG_PATTERN + " revision " + Util.getVariablePattern(REVISION_PATTERN, "rightRevision"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - public static final String RDIFF_SUMMARY_DELETED_FILE = "File " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFilePath") + " is removed; not included in release tag " + TAG_PATTERN; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - // This format was introduced in 1.11.7 - public static final String RDIFF_SUMMARY_DELETED_FILE2 = "File " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFilePath") + " is removed; " + TAG_PATTERN + " revision " + Util.getVariablePattern(REVISION_PATTERN, "leftRevision"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - - public static final String MERGE_UPDATE_CONFLICTING_ADDITION = SERVER_MESSAGE_PREFIX + "file " + Util.getVariablePattern(FILE_PATH_PATTERN, "localFilePath") + " exists, but has been added in revision " + TAG_PATTERN; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java deleted file mode 100644 index 3e0093a37..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import org.eclipse.team.internal.ccvs.core.ICVSFolder; - -public interface IStatusListener { - - public static final String FOLDER_REVISION = ""; //$NON-NLS-1$ - - /** - * Provides access to the revision of a file through the use of the Status command. - * - * @param commandRoot the root directory of the command - * @param path the absolute remote path of the resource including the repository root directory - * @param remoteRevision the remote revision of the file - */ - public void fileStatus(ICVSFolder commandRoot, String path, String remoteRevision); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java deleted file mode 100644 index 009e8b42a..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import org.eclipse.team.internal.ccvs.core.ICVSFolder; - -/** - * This listener is used by RemoteFolder to listener for E and M messages - * from the CVS server in order to determine the files and folders contained in a parent folder. - */ -public interface IUpdateMessageListener { - /** - * Notification that a directory (which may or may not have been reported by - * directoryInformation()) does not exist. - * - * @param commandRoot the root directory of the command - * @param path the path of the directory relative to the commandRoot - */ - public void directoryDoesNotExist(ICVSFolder commandRoot, String path); - /** - * Notification of information about a directory. - * - * @param commandRoot the root directory of the command - * @param path the path of the directory relative to the commandRoot - * @param newDirectory true if the directory does not exist locally (i.e. in the commandRoot hierarchy) - */ - public void directoryInformation(ICVSFolder commandRoot, String path, boolean newDirectory); - /** - * Notification of information about a file - * - * @param type the type of update for the file (see Update for type constants) - * @param commandRoot the root directory of the command - * @param filename the path of the file relative to the commandRoot - */ - public void fileInformation(int type, ICVSFolder parent, String filename); - /** - * Notification that a file does not exists remotely - * - * @param commandRoot the root directory of the command - * @param filename the path of the file relative to the commandRoot - */ - public void fileDoesNotExist(ICVSFolder parent, String filename); -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java deleted file mode 100644 index af2937a40..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - - -import java.util.Date; - -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFile; - -public class LogEntry extends PlatformObject implements ILogEntry { - - private RemoteFile file; - private String author; - private Date date; - private String comment; - private String state; - private CVSTag[] tags; - private String[] revisions; - - /* - * Flatten the text in the multi-line comment - */ - public static String flattenText(String string) { - StringBuffer buffer = new StringBuffer(string.length() + 20); - boolean skipAdjacentLineSeparator = true; - for (int i = 0; i < string.length(); i++) { - char c = string.charAt(i); - if (c == '\r' || c == '\n') { - if (!skipAdjacentLineSeparator) - buffer.append(CVSMessages.LogEntry_0); - skipAdjacentLineSeparator = true; - } else { - buffer.append(c); - skipAdjacentLineSeparator = false; - } - } - return buffer.toString(); - } - - public LogEntry(RemoteFile file, String revision, String author, Date date, String comment, String state, CVSTag[] tags) { - this.file = file.toRevision(revision); - this.author = author; - this.date = date; - this.comment = comment; - this.state = state; - this.tags = tags; - } - - public LogEntry(RemoteFile file, String revision, String author, Date date, String comment, String state, CVSTag[] tags, String[] revisions) { - this(file,revision,author,date,comment,state,tags); - this.revisions=revisions; - } - - /** - * @see ILogEntry#getRevision() - */ - public String getRevision() { - return file.getRevision(); - } - - /** - * @see ILogEntry#getAuthor() - */ - public String getAuthor() { - return author; - } - - /** - * @see ILogEntry#getDate() - */ - public Date getDate() { - return date; - } - - /** - * @see ILogEntry#getComment() - */ - public String getComment() { - return comment; - } - - /** - * @see ILogEntry#getState() - */ - public String getState() { - return state; - } - - /** - * @see ILogEntry#getTags() - */ - public CVSTag[] getTags() { - CVSTag[] result = new CVSTag[tags.length]; - System.arraycopy(tags, 0, result, 0, tags.length); - return result; - } - - /** - * @see ILogEntry#getRemoteFile() - */ - public ICVSRemoteFile getRemoteFile() { - return file; - } - - /** - * @see ILogEntry#isDeletion() - */ - public boolean isDeletion() { - return getState().equals("dead"); //$NON-NLS-1$ - } - - /** - * In the case where files on a branch haven't been modified since their initial branch point, - * they keep the revision number of their predecessor. In this case no revision info will be displayed - * while doing a log, so all branch revision numbers are recorded. This allows the user to pick which revision - * they are interested in. - * @return an array of branch revision strings or an empty array if no branch revisions were recorded - */ - public String[] getBranchRevisions(){ - - if (revisions != null) - return revisions; - - return new String[0]; - } -} - diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java deleted file mode 100644 index aab7efce6..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java +++ /dev/null @@ -1,330 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Brock Janiczak <brockj@tpg.com.au> - Bug 179977 CVS log command doesn't scale well with lots of tags and versions - * Brock Janiczak <brockj@tpg.com.au> - Bug 194396 Reduce retained memory usage of LogEntry objects - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import java.text.*; -import java.util.*; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.osgi.util.NLS; -import org.eclipse.team.internal.ccvs.core.*; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; -import org.eclipse.team.internal.ccvs.core.resources.RemoteFile; -import org.eclipse.team.internal.ccvs.core.util.Util; - -/** - * Log listener that parses the log entries returned from the - * server but delegates the handling of the entries to a subclass. - */ -public class LogListener extends CommandOutputListener { - - /* - * A new format for log dates was introduced in 1.12.9 - */ - private static final String LOG_TIMESTAMP_FORMAT_OLD= "yyyy/MM/dd HH:mm:ss zzz";//$NON-NLS-1$ - private static final String LOG_TIMESTAMP_FORMAT= "yyyy-MM-dd HH:mm:ss zzz";//$NON-NLS-1$ - private static final Locale LOG_TIMESTAMP_LOCALE= Locale.US; - private final DateFormat LOG_DATE_FORMATTER_OLD = new SimpleDateFormat(LOG_TIMESTAMP_FORMAT_OLD, LOG_TIMESTAMP_LOCALE); - private final DateFormat LOG_DATE_FORMATTER = new SimpleDateFormat(LOG_TIMESTAMP_FORMAT, LOG_TIMESTAMP_LOCALE); - - // Server message prefix used for error detection - private static final String NOTHING_KNOWN_ABOUT = "nothing known about "; //$NON-NLS-1$ - - // States of log accumulation. - private final int DONE = 4; - private final int COMMENT = 3; - private final int REVISION = 2; - private final int SYMBOLIC_NAMES = 1; - private final int BEGIN = 0; - - //Tag used for accumulating all of a branch's revision info - public final static String BRANCH_REVISION = "branchRevision"; //$NON-NLS-1$ - - private static final CVSTag[] NO_TAGS = new CVSTag[0]; - private static final String[] NO_VERSIONS = new String[0]; - - // Instance variables for accumulating Log information - private RemoteFile currentFile; - private int state = BEGIN; - private StringBuffer comment; - private String fileState; - private String revision; - private String author; - private Date creationDate; - private List versions = new ArrayList(); - private Map internedStrings = new HashMap(); - private final ILogEntryListener listener; - - /** - * Create a log listener for receiving entries for one or more files. - */ - public LogListener(ILogEntryListener listener) { - this.listener = listener; - } - - public LogListener(RemoteFile file, ILogEntryListener listener) { - this(listener); - this.currentFile = file; - } - - private String getRelativeFilePath(ICVSRepositoryLocation location, String fileName) { - if (fileName.endsWith(",v")) { //$NON-NLS-1$ - fileName = fileName.substring(0, fileName.length() - 2); - } - fileName = Util.removeAtticSegment(fileName); - String rootDirectory = location.getRootDirectory(); - if (fileName.startsWith(rootDirectory)) { - try { - fileName = Util.getRelativePath(rootDirectory, fileName); - } catch (CVSException e) { - CVSProviderPlugin.log(e); - return null; - } - } - return fileName; - } - - public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - String serverMessage = getServerMessage(line, location); - if (serverMessage != null) { - // look for the following condition - // E cvs server: nothing known about fileName - if (serverMessage.startsWith(NOTHING_KNOWN_ABOUT)) { - return new CVSStatus(IStatus.ERROR, CVSStatus.DOES_NOT_EXIST, line, commandRoot); - } - } - return OK; - } - - public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - // Fields we will find in the log for a file - // keys = String (tag name), values = String (tag revision number) */ - switch (state) { - case BEGIN: - if (line.startsWith("RCS file: ")) { //$NON-NLS-1$ - // We are starting to recieve the log for a file - String fileName = getRelativeFilePath(location, line.substring(10).trim()); - if (fileName == null) { - currentFile = null; - handleInvalidFileName(location, fileName); - } else { - if (currentFile == null || !currentFile.getRepositoryRelativePath().equals(fileName)) { - // We are starting another file - beginFile(location, fileName); - } - } - } else if (line.startsWith("symbolic names:")) { //$NON-NLS-1$ - state = SYMBOLIC_NAMES; - } else if (line.startsWith("revision ")) { //$NON-NLS-1$ - revision = internAndCopyString(line.substring(9)); - state = REVISION; - } else if (line.startsWith("total revisions:")){ //$NON-NLS-1$ - //if there are no current revision selected and this is a branch then we are in the - //case where there have been no changes made on the branch since the initial branching - //and we need to get the revision that the branch was made from - int indexOfSelectedRevisions = line.lastIndexOf("selected revisions: "); //$NON-NLS-1$ - //20 for length of "selected revisions: " - String selectedRevisions = line.substring(indexOfSelectedRevisions + 20).trim(); - if (selectedRevisions.equals("0")){ //$NON-NLS-1$ - //ok put into comment state to await ======= and add info to log - state = COMMENT; - revision = BRANCH_REVISION; - comment = new StringBuffer(); - } - } - break; - case SYMBOLIC_NAMES: - if (line.startsWith("keyword substitution:")) { //$NON-NLS-1$ - state = BEGIN; - } else { - int firstColon = line.indexOf(':'); - String tagName = internAndCopyString(line.substring(1, firstColon)); - String tagRevision = internAndCopyString(line.substring(firstColon + 2)); - versions.add(new VersionInfo(tagRevision, tagName)); - } - break; - case REVISION: - // date: 2000/06/19 04:56:21; author: somebody; state: Exp; lines: +114 -45 - // get the creation date - int endOfDateIndex = line.indexOf(';', 6); - creationDate = convertFromLogTime(line.substring(6, endOfDateIndex) + " GMT"); //$NON-NLS-1$ - - // get the author name - int endOfAuthorIndex = line.indexOf(';', endOfDateIndex + 1); - author = internAndCopyString(line.substring(endOfDateIndex + 11, endOfAuthorIndex)); - - // get the file state (because this revision might be "dead") - fileState = internAndCopyString(line.substring(endOfAuthorIndex + 10, line.indexOf(';', endOfAuthorIndex + 1))); - comment = new StringBuffer(); - state = COMMENT; - break; - case COMMENT: - // skip next line (info about branches) if it exists, if not then it is a comment line. - if (line.startsWith("branches:")) break; //$NON-NLS-1$ - if (line.equals("=============================================================================") //$NON-NLS-1$ - || line.equals("----------------------------")) { //$NON-NLS-1$ - state = DONE; - break; - } - //check for null if we are in the waiting to finish case (brought on by branches) - if (comment == null) - break; - - if (comment.length() != 0) comment.append('\n'); - comment.append(line); - break; - } - if (state == DONE) { - // we are only interested in tag names for this revision, remove all others. - List thisRevisionTags = versions.isEmpty() ? Collections.EMPTY_LIST : new ArrayList(3); - //a parallel lists for revision tags (used only for branches with no commits on them) - List revisionVersions = versions.isEmpty() ? Collections.EMPTY_LIST : new ArrayList(3); - for (Iterator i = versions.iterator(); i.hasNext();) { - VersionInfo version = (VersionInfo) i.next(); - String tagName = version.getTagName(); - String tagRevision = version.getTagRevision(); - - if (tagRevision.equals(revision) || - revision.equals(BRANCH_REVISION)) { - int type = version.isBranch() ? CVSTag.BRANCH : CVSTag.VERSION; - thisRevisionTags.add(new CVSTag(tagName, type)); - if (revision.equals(BRANCH_REVISION)){ - //also record the tag revision - revisionVersions.add(tagRevision); - } - } - } - - if (currentFile != null) { - LogEntry entry = new LogEntry(currentFile, revision, author, creationDate, - internString(comment.toString()), fileState, !thisRevisionTags.isEmpty() ? (CVSTag[]) thisRevisionTags.toArray(new CVSTag[thisRevisionTags.size()]) : NO_TAGS, !revisionVersions.isEmpty() ? (String[]) revisionVersions.toArray(new String[revisionVersions.size()]) : NO_VERSIONS); - addEntry(entry); - } - state = BEGIN; - } - return OK; - } - - protected void beginFile(ICVSRepositoryLocation location, String fileName) { - currentFile = RemoteFile.create(fileName, location); - versions.clear(); - } - - protected void addEntry(LogEntry entry) { - listener.handleLogEntryReceived(entry); - } - - protected void handleInvalidFileName(ICVSRepositoryLocation location, String badFilePath) { - CVSProviderPlugin.log(IStatus.WARNING, "Invalid file path '" + badFilePath + "' received from " + location.toString(), null); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Converts a time stamp as sent from a cvs server for a "log" command into a - * <code>Date</code>. - */ - private Date convertFromLogTime(String modTime) { - DateFormat format = LOG_DATE_FORMATTER; - // Compatibility for older cvs version (pre 1.12.9) - if (modTime.length() > 4 && modTime.charAt(4) == '/') - format = LOG_DATE_FORMATTER_OLD; - - try { - return format.parse(modTime); - } catch (ParseException e) { - // fallback is to return null - return null; - } - } - - private String internAndCopyString(String string) { - String internedString = (String) internedStrings.get(string); - if (internedString == null) { - internedString = new String(string); - internedStrings.put(internedString, internedString); - } - return internedString; - } - - private String internString(String string) { - String internedString = (String) internedStrings.get(string); - if (internedString == null) { - internedString = string; - internedStrings.put(internedString, internedString); - } - return internedString; - } - - private static class VersionInfo { - private final String version; - private final boolean isBranch; - private String tagRevision; - private final String tagName; - - public VersionInfo(String version, String tagName) { - this.version = version; - this.tagName = tagName; - this.isBranch = isBranchTag(version); - tagRevision = version; - if (isBranch) { - int lastDot = version.lastIndexOf('.'); - if (lastDot == -1) { - CVSProviderPlugin.log(IStatus.ERROR, - NLS.bind(CVSMessages.LogListener_invalidRevisionFormat, new String[] { tagName, version }), null); - } else { - if (version.charAt(lastDot - 1) == '0' && version.charAt(lastDot - 2) == '.') { - lastDot = lastDot - 2; - } - tagRevision = version.substring(0, lastDot); - } - } - } - - public String getVersion() { - return this.version; - } - - public String getTagName() { - return this.tagName; - } - - public String getTagRevision() { - return this.tagRevision; - } - - public boolean isBranch() { - return isBranch; - } - - /** branch tags have odd number of segments or have - * an even number with a zero as the second last segment - * e.g: 1.1.1, 1.26.0.2 are branch revision numbers */ - private boolean isBranchTag(String tagName) { - // First check if we have an odd number of segments (i.e. even number of dots) - int numberOfDots = 0; - int lastDot = 0; - for (int i = 0; i < tagName.length(); i++) { - if (tagName.charAt(i) == '.') { - numberOfDots++; - lastDot = i; - } - } - if ((numberOfDots % 2) == 0) return true; - if (numberOfDots == 1) return false; - - // If not, check if the second lat segment is a zero - if (tagName.charAt(lastDot - 1) == '0' && tagName.charAt(lastDot - 2) == '.') return true; - return false; - } - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java deleted file mode 100644 index 99da58e17..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; - -/* - * This class pares the output of the "cvs checkout -c" command which returns the list of modules - * defined in the CVSROOT/modules file. - */ -public class ModuleDefinitionsListener extends CommandOutputListener { - - // the last line read from the context (used to accumulate multi-line definitions) - private String lastLine = ""; //$NON-NLS-1$ - - private Map moduleMap; - - public ModuleDefinitionsListener() { - reset(); - } - - /* - * @see ICommandOutputListener#messageLine(String, ICVSFolder, IProgressMonitor) - */ - public IStatus messageLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - // Lines that start with a space indicate a multi line entry - if( line.charAt(0) == ' ' ) { - lastLine += line; - line = lastLine; - } - else - lastLine = line; - - // Use the module name as the key so that multi-line modules will be recorded properly - int firstSpace = line.indexOf(" "); //$NON-NLS-1$ - if (firstSpace > -1) { - String module = line.substring(0, firstSpace); - moduleMap.put(module, line); - } - return OK; - } - - public String[] getModuleExpansions() { - return (String[])moduleMap.values().toArray(new String[moduleMap.size()]); - } - - public void reset() { - this.moduleMap = new HashMap(); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/RDiffSummaryListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/RDiffSummaryListener.java deleted file mode 100644 index ff704aacc..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/RDiffSummaryListener.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import java.util.Map; - -import org.eclipse.core.runtime.IProgressMonitor; -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.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; - -/** - * This class parses the messages recieved in response to an "cvs rdiff -s ..." command - */ -public class RDiffSummaryListener extends CommandOutputListener { - - private static final String RIGHT_REVISION_VARIABLE_NAME = "rightRevision"; //$NON-NLS-1$ - private static final String LEFT_REVISION_VARIABLE_NAME = "leftRevision"; //$NON-NLS-1$ - private static final String REMOTE_FILE_PATH_VARIABLE_NAME = "remoteFilePath"; //$NON-NLS-1$ - private static final String REMOTE_FOLDER_PATH_VARIABLE_NAME = "remoteFolderPath"; //$NON-NLS-1$ - - private IFileDiffListener listener; - private static ServerMessageLineMatcher DIRECTORY_MATCHER; - private static ServerMessageLineMatcher FILE_DIFF_MATCHER; - private static ServerMessageLineMatcher NEW_FILE_MATCHER; - private static ServerMessageLineMatcher DELETED_FILE_MATCHER; - private static ServerMessageLineMatcher DELETED_FILE_MATCHER2; - - static { - // TODO: temprary until proper lifecycle is defined - initializePatterns(); - } - public static void initializePatterns() { - try { - DIRECTORY_MATCHER = new ServerMessageLineMatcher( - IMessagePatterns.RDIFF_DIRECTORY, new String[] {REMOTE_FOLDER_PATH_VARIABLE_NAME}); - FILE_DIFF_MATCHER = new ServerMessageLineMatcher( - IMessagePatterns.RDIFF_SUMMARY_FILE_DIFF, new String[] {REMOTE_FILE_PATH_VARIABLE_NAME, LEFT_REVISION_VARIABLE_NAME, RIGHT_REVISION_VARIABLE_NAME}); - NEW_FILE_MATCHER = new ServerMessageLineMatcher( - IMessagePatterns.RDIFF_SUMMARY_NEW_FILE, new String[] {REMOTE_FILE_PATH_VARIABLE_NAME, RIGHT_REVISION_VARIABLE_NAME}); - DELETED_FILE_MATCHER = new ServerMessageLineMatcher( - IMessagePatterns.RDIFF_SUMMARY_DELETED_FILE, new String[] {REMOTE_FILE_PATH_VARIABLE_NAME}); - DELETED_FILE_MATCHER2 = new ServerMessageLineMatcher( - IMessagePatterns.RDIFF_SUMMARY_DELETED_FILE2, new String[] {REMOTE_FILE_PATH_VARIABLE_NAME, LEFT_REVISION_VARIABLE_NAME}); - } catch (CVSException e) { - // This is serious as the listener will not function properly - CVSProviderPlugin.log(e); - } - } - - public interface IFileDiffListener { - public void fileDiff( - String remoteFilePath, - String leftRevision, - String rightRevision); - public void newFile( - String remoteFilePath, - String rightRevision); - public void deletedFile( - String remoteFilePath, - String leftRevision); - public void directory(String remoteFolderPath); - } - - public RDiffSummaryListener(IFileDiffListener listener) { - this.listener = listener; - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#messageLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus messageLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - Map variables = FILE_DIFF_MATCHER.processServerMessage(line); - if (variables != null) { - listener.fileDiff( - (String)variables.get(REMOTE_FILE_PATH_VARIABLE_NAME), - (String)variables.get(LEFT_REVISION_VARIABLE_NAME), - (String)variables.get(RIGHT_REVISION_VARIABLE_NAME)); - return OK; - } - - variables = NEW_FILE_MATCHER.processServerMessage(line); - if (variables != null) { - listener.newFile( - (String)variables.get(REMOTE_FILE_PATH_VARIABLE_NAME), - (String)variables.get(RIGHT_REVISION_VARIABLE_NAME)); - return OK; - } - - variables = DELETED_FILE_MATCHER.processServerMessage(line); - if (variables != null) { - listener.deletedFile( - (String)variables.get(REMOTE_FILE_PATH_VARIABLE_NAME), - null); - return OK; - } - - variables = DELETED_FILE_MATCHER2.processServerMessage(line); - if (variables != null) { - listener.deletedFile( - (String)variables.get(REMOTE_FILE_PATH_VARIABLE_NAME), - (String)variables.get(LEFT_REVISION_VARIABLE_NAME)); - return OK; - } - - return super.messageLine(line, location, commandRoot, monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#errorLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus errorLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - Map variables = DIRECTORY_MATCHER.processServerMessage(line); - if (variables != null) { - listener.directory( - (String)variables.get(REMOTE_FOLDER_PATH_VARIABLE_NAME)); - return OK; - } - - return super.errorLine(line, location, commandRoot, monitor); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ServerMessageLineMatcher.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ServerMessageLineMatcher.java deleted file mode 100644 index 7be00a490..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ServerMessageLineMatcher.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.osgi.util.NLS; -import org.eclipse.team.internal.ccvs.core.*; - -/** - * This class extracts matches server lines to expected patterns and extracts - * required information from the line. - */ -public class ServerMessageLineMatcher { - - protected static final Pattern VARIABLE_MATCHING_PATTERN = Pattern.compile("(\\((\\w*):.*:\\2\\))"); //$NON-NLS-1$ - - Pattern pattern; - String[] variables; - - public ServerMessageLineMatcher(String template, String[] expectedVariables) throws CVSException { - // Extract the variable names from the template - Matcher matcher = VARIABLE_MATCHING_PATTERN.matcher(template); - List variables = new ArrayList(); - while (matcher.find()) { - if (matcher.groupCount() != 2) { - IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.ServerMessageLineMatcher_5, new String[] { template })); - throw new CVSException(status); - } - variables.add(matcher.group(2)); - } - ensureMatches(template, variables, expectedVariables); - this.variables = (String[]) variables.toArray(new String[variables.size()]); - - // Modify the template so it can be used to match message lines from the server - // (i.e. remove the variable markup) - for (Iterator iter = variables.iterator(); iter.hasNext();) { - String element = (String) iter.next(); - template = template.replaceAll(element + ":", ""); //$NON-NLS-1$ //$NON-NLS-2$ - template = template.replaceAll(":" + element, ""); //$NON-NLS-1$ //$NON-NLS-2$ - } - - // Ensure that the number of groups in the pattern match the number of variables - int count = 0; - int start = -1; - while ((start = template.indexOf('(', start + 1)) != -1) { - count++; - } - if (count != variables.size()) { - IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.ServerMessageLineMatcher_6, new String[] { template })); - throw new CVSException(status); - } - - // Create the pattern fir matching lines from the server - this.pattern = Pattern.compile(template); - } - - /* - * Throw an exception if the found variables do not match the expected variables - */ - private void ensureMatches(String template, List variables, String[] expectedVariables) throws CVSException { - for (int i = 0; i < expectedVariables.length; i++) { - String expected = expectedVariables[i]; - if (!variables.contains(expected)) { - IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.ServerMessageLineMatcher_7, new String[] { expected, template })); - throw new CVSException(status); - } - } - } - - public Map processServerMessage(String line) { - Matcher matcher = pattern.matcher(line); - if (!matcher.find()) return null; - Assert.isTrue(matcher.groupCount() == variables.length); - Map result = new HashMap(); - for (int i = 1; i <= matcher.groupCount(); i++) { - result.put(variables[i - 1], matcher.group(i)); - } - return result; - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java deleted file mode 100644 index e172f03a5..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -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.client.CommandOutputListener; -import org.eclipse.team.internal.ccvs.core.util.Util; - -public class StatusListener extends CommandOutputListener { - private static boolean isFolder = false; - private IStatusListener statusListener; - - public StatusListener(IStatusListener statusListener) { - this.statusListener = statusListener; - } - - public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, - IProgressMonitor monitor) { - - // We're only concerned about file revisions. - if (line.startsWith(" Repository revision:")) { //$NON-NLS-1$ - if (!line.startsWith(" Repository revision: No revision control file")) { //$NON-NLS-1$ - int separatingTabIndex = line.indexOf('\t', 24); - String remoteRevision = line.substring(24, separatingTabIndex); - - // This is the full location on the server (e.g. /home/cvs/repo/project/file.txt) - String fileLocation = line.substring(separatingTabIndex + 1, line.length() - 2); - - // Inform the listener about the file revision - statusListener.fileStatus(commandRoot, removeAtticSegment(fileLocation), remoteRevision); - } - } - return OK; - } - - public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) { - String serverMessage = getServerMessage(line, location); - if (serverMessage != null) { - if (serverMessage.startsWith("conflict:")) {//$NON-NLS-1$ - // We get this because we made up an entry line to send to the server - // Therefore, we make this a warning!!! - return new CVSStatus(IStatus.WARNING, CVSStatus.CONFLICT, line, commandRoot); - } - if (serverMessage.startsWith("Examining")) {//$NON-NLS-1$ - isFolder = true; - return OK; - } - } - if (isFolder) { - // This used to do something but it was obviously wrong and there was no indication - // why it was needed. Therefore, I have removed the code to see if anything is effected - isFolder = false; - } - return super.errorLine(line, location, commandRoot, monitor); - } - - /** - * If the status returns that the file is in the Attic, then remove the - * Attic segment. This is because files added to a branch that are not in - * the main trunk (HEAD) are added to the Attic but cvs does magic on - * updateto put them in the correct location. - * (e.g. /project/Attic/file.txt -> /project/file.txt) - */ - private String removeAtticSegment(String path) { - return Util.removeAtticSegment(path); - } -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java deleted file mode 100644 index a2e041c98..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; -import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener; - -public class TagListener extends CommandOutputListener { - - /* - * @see ICommandOutputListener#messageLine(String, ICVSFolder, IProgressMonitor) - */ - public IStatus messageLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - // Received a warning in the form: - // W folder/file : v1 already exists on version 1.2 : NOT MOVING tag to version 1.3 - // Indicate this as an error since no tagging was done - if(line.length() >= 2 && line.charAt(0) == 'W' && line.charAt(1) == ' ') { - return new CVSStatus(IStatus.ERROR, CVSStatus.TAG_ALREADY_EXISTS, line.substring(2), commandRoot); - } - - return OK; - } - - /* - * @see ICommandOutputListener#errorLine(String, ICVSFolder, IProgressMonitor) - */ - public IStatus errorLine( - String line, - ICVSRepositoryLocation location, - ICVSFolder commandRoot, - IProgressMonitor monitor) { - - // Ignore the lines: Tagging folder1/folder2 - String serverMessage = getServerMessage(line, location); - if ((serverMessage != null) && serverMessage.startsWith("Tagging")) { //$NON-NLS-1$ - return OK; - } - String rtagMessage = getServerRTagMessage(line, location); - if(rtagMessage != null && rtagMessage.startsWith("Tagging") ) { //$NON-NLS-1$ - return OK; - } - - return super.errorLine(line, location, commandRoot, monitor); - } - -} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java deleted file mode 100644 index 20ec349b3..000000000 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java +++ /dev/null @@ -1,294 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ccvs.core.client.listeners; - -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.osgi.util.NLS; -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.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.client.CommandOutputListener; -import org.eclipse.team.internal.ccvs.core.client.Update; -import org.eclipse.team.internal.ccvs.core.util.Util; - -public class UpdateListener extends CommandOutputListener { - - // Pattern matchers - private static ServerMessageLineMatcher MERGED_BINARY_FILE_LINE_1; - private static ServerMessageLineMatcher MERGED_BINARY_FILE_LINE_2; - - // Pattern Variables - private static final String REVISION_VARIABLE_NAME = "revision"; //$NON-NLS-1$ - private static final String LOCAL_FILE_PATH_VARIABLE_NAME = "localFilePath"; //$NON-NLS-1$ - private static final String BACKUP_FILE_VARIABLE_NAME = "backupFile"; //$NON-NLS-1$ - - static { - try { - String line1 = "revision " //$NON-NLS-1$ - + Util.getVariablePattern(IMessagePatterns.REVISION_PATTERN, REVISION_VARIABLE_NAME) - + " from repository is now in " //$NON-NLS-1$ - + Util.getVariablePattern(IMessagePatterns.FILE_PATH_PATTERN, LOCAL_FILE_PATH_VARIABLE_NAME); - MERGED_BINARY_FILE_LINE_1 = new ServerMessageLineMatcher( - line1, - new String[] {REVISION_VARIABLE_NAME, LOCAL_FILE_PATH_VARIABLE_NAME}); - String line2 = "file from working directory is now in " //$NON-NLS-1$ - + Util.getVariablePattern(IMessagePatterns.REVISION_PATTERN, BACKUP_FILE_VARIABLE_NAME); - MERGED_BINARY_FILE_LINE_2 = new ServerMessageLineMatcher( - line2, - new String[] {BACKUP_FILE_VARIABLE_NAME}); - - } catch (CVSException e) { - // Shouldn't happen - CVSProviderPlugin.log(e); - } - } - - IUpdateMessageListener updateMessageListener; - boolean merging = false; - boolean mergingBinary = false; - String mergedBinaryFileRevision, mergedBinaryFilePath; - - public UpdateListener(IUpdateMessageListener updateMessageListener) { - this.updateMessageListener = updateMessageListener; - } - - public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, - IProgressMonitor monitor) { - mergingBinary = false; - if (updateMessageListener == null) return OK; - if(line.startsWith("Merging differences")) { //$NON-NLS-1$ - merging = true; - } else if(line.indexOf(' ')==1) { - // We have a message that indicates the type of update. The possible messages are - // defined by the prefix constants MLP_*. - String path = line.substring(2); - char changeType = line.charAt(0); - - // calculate change type - int type = 0; - switch(changeType) { - case 'A': type = Update.STATE_ADDED_LOCAL; break; // new file locally that was added but not comitted to server yet - case '?': type = Update.STATE_UNKOWN; break; // new file locally but not added to server - case 'U': type = Update.STATE_REMOTE_CHANGES; break; // remote changes to an unmodified local file - case 'R': type = Update.STATE_DELETED; break; // removed locally but still exists on the server - case 'M': type = Update.STATE_MODIFIED; break; // modified locally - case 'C': type = Update.STATE_CONFLICT; break; // modified locally and on the server but cannot be auto-merged - case 'D': type = Update.STATE_DELETED; break; // deleted locally but still exists on server - default: type = Update.STATE_NONE; - } - - if (merging) { - // If we are merging the modified prefix is used both to show merges and - // local changes. We have to detect this case and use a more specific change - // type. - if (type == Update.STATE_MODIFIED) - type = Update.STATE_MERGEABLE_CONFLICT; - merging = false; - } - updateMessageListener.fileInformation(type, commandRoot, path); - } - return OK; - } - - /** - * This handler is used by the RemoteResource hierarchy to retrieve E messages - * from the CVS server in order to determine the folders contained in a parent folder. - * - * WARNING: This class parses the message output to determine the state of files in the - * repository. Unfortunately, these messages seem to be customizable on a server by server basis. - * - * Here's a list of responses we expect in various situations: - * - * Directory exists remotely: - * cvs server: Updating folder1/folder2 - * Directory doesn't exist remotely: - * cvs server: skipping directory folder1/folder2 - * New (or unknown) remote directory - * cvs server: New Directory folder1/folder2 - * File removed remotely - * cvs server: folder1/file.ext is no longer in the repository - * cvs server: warning: folder1/file.ext is not (any longer) pertinent - * Locally added file was added remotely as well - * cvs server: conflict: folder/file.ext created independently by second party - * File removed locally and modified remotely - * cvs server: conflict: removed file.txt was modified by second party - * File modified locally but removed remotely - * cvs server: conflict: file.txt is modified but no longer in the repository - * Ignored Messages - * cvs server: cannot open directory ... - * cvs server: nothing known about ... - * Tag error that really means there are no files in a directory - * cvs [server aborted]: no such tag - * Merge contained conflicts - * rcsmerge: warning: conflicts during merge - * Binary file conflict - * cvs server: nonmergeable file needs merge - * cvs server: revision 1.4 from repository is now in a1/a2/test - * cvs server: file from working directory is now in .#test.1.3 - */ - public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, - IProgressMonitor monitor) { - - try { - // Reset flag globally here because we have to many exit points - boolean wasMergingBinary = mergingBinary; - mergingBinary = false; - String serverMessage = getServerMessage(line, location); - if (serverMessage != null) { - // Strip the prefix from the line - String message = serverMessage; - if (message.startsWith("Updating")) { //$NON-NLS-1$ - if (updateMessageListener != null) { - String path = message.substring(9); - updateMessageListener.directoryInformation(commandRoot, path, false); - } - return OK; - } else if (message.startsWith("skipping directory")) { //$NON-NLS-1$ - if (updateMessageListener != null) { - String path = message.substring(18).trim(); - updateMessageListener.directoryDoesNotExist(commandRoot, path); - } - return OK; - } else if (message.startsWith("New directory")) { //$NON-NLS-1$ - if (updateMessageListener != null) { - String path = message.substring(15, message.lastIndexOf('\'')); - updateMessageListener.directoryInformation(commandRoot, path, true); - } - return OK; - } else if (message.endsWith("is no longer in the repository")) { //$NON-NLS-1$ - if (updateMessageListener != null) { - String filename = message.substring(0, message.length() - 31); - filename = stripQuotes(filename); - updateMessageListener.fileDoesNotExist(commandRoot, filename); - } - return OK; - } else if (message.startsWith("conflict:")) { //$NON-NLS-1$ - /* - * We can get the following conflict warnings - * cvs server: conflict: folder/file.ext created independently by second party - * cvs server: conflict: removed file.txt was modified by second party - * cvs server: conflict: file.txt is modified but no longer in the repository - * If we get the above line, we have conflicting additions or deletions and we can expect a server error. - * We still get "C foler/file.ext" so we don't need to do anything else (except in the remotely deleted case) - */ - if (updateMessageListener != null) { - if (message.endsWith("is modified but no longer in the repository")) { //$NON-NLS-1$ - // The "C foler/file.ext" will come after this so if whould be ignored! - String filename = message.substring(10, message.length() - 44); - filename = stripQuotes(filename); - updateMessageListener.fileDoesNotExist(commandRoot, filename); - } - } - return new CVSStatus(IStatus.WARNING, CVSStatus.CONFLICT, line, commandRoot); - } else if (message.startsWith("warning:")) { //$NON-NLS-1$ - /* - * We can get the following conflict warnings - * cvs server: warning: folder1/file.ext is not (any longer) pertinent - * If we get the above line, we have local changes to a remotely deleted file. - */ - if (updateMessageListener != null) { - if (message.endsWith("is not (any longer) pertinent")) { //$NON-NLS-1$ - String filename = message.substring(9, message.length() - 30); - updateMessageListener.fileDoesNotExist(commandRoot, filename); - } - } - return new CVSStatus(IStatus.WARNING, CVSStatus.CONFLICT, line, commandRoot); - } else if (message.startsWith("conflicts")) { //$NON-NLS-1$ - // This line is info only. The server doesn't report an error. - return new CVSStatus(IStatus.INFO, CVSStatus.CONFLICT, line, commandRoot); - } else if (message.startsWith("nonmergeable file needs merge")) { //$NON-NLS-1$ - mergingBinary = true; - mergedBinaryFileRevision = null; - mergedBinaryFilePath = null; - return OK; - } else if (wasMergingBinary) { - Map variables = MERGED_BINARY_FILE_LINE_1.processServerMessage(message); - if (variables != null) { - mergedBinaryFileRevision = (String)variables.get(REVISION_VARIABLE_NAME); - mergedBinaryFilePath = (String)variables.get(LOCAL_FILE_PATH_VARIABLE_NAME); - mergingBinary = true; - return OK; - } - variables = MERGED_BINARY_FILE_LINE_2.processServerMessage(message); - if (variables != null) { - String backupFile = (String)variables.get(BACKUP_FILE_VARIABLE_NAME); - try { - if (mergedBinaryFileRevision != null && mergedBinaryFilePath != null) { - ICVSFile file = commandRoot.getFile(mergedBinaryFilePath); - IResource resource = file.getIResource(); - if (resource != null) { - return new CVSStatus(IStatus.ERROR, CVSStatus.UNMEGERED_BINARY_CONFLICT, - NLS.bind(CVSMessages.UpdateListener_0, (new Object[] { - resource.getFullPath().toString(), - mergedBinaryFileRevision, - resource.getFullPath().removeLastSegments(1).append(backupFile).toString()})), commandRoot); - } - } - } catch (CVSException e1) { - CVSProviderPlugin.log(e1); - } - return OK; - } - } - - // Fallthrough case for "cvs server" messages - if (!message.startsWith("cannot open directory") //$NON-NLS-1$ - && !message.startsWith("nothing known about")) { //$NON-NLS-1$ - return super.errorLine(line, location, commandRoot, monitor); - } - } else { - String serverAbortedMessage = getServerAbortedMessage(line, location); - if (serverAbortedMessage != null) { - // Strip the prefix from the line - String message = serverAbortedMessage; - if (message.startsWith("no such tag")) { //$NON-NLS-1$ - // This is reported from CVS when a tag is used on the update there are no files in the directory - // To get the folders, the update request should be re-issued for HEAD - return new CVSStatus(IStatus.WARNING, CVSStatus.NO_SUCH_TAG, line, commandRoot); - } else if (message.startsWith("Numeric join") && message.endsWith("may not contain a date specifier")) { //$NON-NLS-1$ //$NON-NLS-2$ - // This error indicates a join failed because a date tag was used - return super.errorLine(line, location, commandRoot, monitor); - } else { - return super.errorLine(line, location, commandRoot, monitor); - } - } else if (line.equals("rcsmerge: warning: conflicts during merge")) { //$NON-NLS-1$ - // There were conflicts in the merge - return new CVSStatus(IStatus.WARNING, CVSStatus.CONFLICT, line, commandRoot); - } - } - } catch (StringIndexOutOfBoundsException e) { - // Something went wrong in the parsing of the message. - // Return a status indicating the problem - if (CVSProviderPlugin.getPlugin().isDebugging()) { - System.out.println("Error parsing E line: " + line); //$NON-NLS-1$ - } - return new CVSStatus(IStatus.ERROR, CVSStatus.ERROR_LINE_PARSE_FAILURE, line, commandRoot); - } - return super.errorLine(line, location, commandRoot, monitor); - } - - private String stripQuotes(String filename) { - // CVS version 12 fix - filenames are returned inside quotes - // Fixes bug 49056 - if (filename.startsWith("`") && filename.endsWith("'")) //$NON-NLS-1$ //$NON-NLS-2$ - filename = filename.substring(1,filename.length()-1); - return filename; - } - -} |