Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.cvs.core/src/org/eclipse')
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java83
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java642
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java519
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java55
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTag.java83
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java1147
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/DateUtil.java82
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java90
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java154
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSListener.java15
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSProvider.java155
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java44
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java56
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java53
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java97
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java138
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java17
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java36
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IConnectionMethod.java31
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ILogEntry.java60
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IResourceStateChangeListener.java65
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IServerConnection.java1
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java32
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserInfo.java34
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java124
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java31
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java223
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java70
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java65
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Admin.java16
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java60
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java173
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java727
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java73
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java55
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java53
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java66
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java31
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java110
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java64
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java133
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java27
-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/ModTimeHandler.java43
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModifiedFileSender.java35
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModuleExpansionHandler.java29
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java45
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java58
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java92
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java39
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java31
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java50
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java58
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java220
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java114
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java1075
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java59
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Status.java15
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java66
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java92
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java50
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java128
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java122
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java26
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequestsHandler.java37
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java91
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java95
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java39
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java54
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java40
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java28
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java52
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java93
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java146
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java70
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleExpansion.java120
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java83
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java48
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java179
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException.java55
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException.java46
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSFileException.java35
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java805
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java72
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java202
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java149
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java26
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java272
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnectionMethod.java1
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/UserInfo.java58
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties265
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSEntryLineTag.java58
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java103
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java392
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java148
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java220
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java307
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipsePhantomSynchronizer.java450
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java247
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java820
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java509
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java750
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java61
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java704
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java311
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java161
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/CRLFtoLFInputStream.java155
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/LFtoCRLFInputStream.java146
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/PollingInputStream.java162
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/PollingOutputStream.java162
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/ProgressMonitorInputStream.java140
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/SizeConstrainedInputStream.java138
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/TimeoutInputStream.java313
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/TimeoutOutputStream.java313
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java184
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableResourceSyncInfo.java131
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ReentrantLock.java71
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java502
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AddDeleteMoveListener.java442
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Assert.java98
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AssertionFailedException.java28
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java74
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/EmptyTokenizer.java132
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileNameMatcher.java69
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/InfiniteSubProgressMonitor.java72
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/MoveDeleteHook.java267
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java100
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionContentHandler.java160
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionManager.java282
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionWriter.java104
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java128
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/StringMatcher.java389
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java202
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java375
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java89
135 files changed, 0 insertions, 22165 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java
deleted file mode 100644
index b81366f82..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.core.TeamException;
-
-/**
- * A checked expection representing a failure in the CVS plugin.
- * <p>
- * CVS exceptions contain a status object describing the cause of
- * the exception.
- * </p>
- *
- * @see IStatus
- */
-public class CVSException extends TeamException {
-
- /*
- * Helpers for creating CVS exceptions
- */
- public CVSException(int severity, int code, String message, Exception e) {
- super(new CVSStatus(severity, code, message, null));
- }
-
- public CVSException(int severity, int code, String message) {
- this(severity, code, message, null);
- }
-
- public CVSException(String message) {
- super(new CVSStatus(IStatus.ERROR, UNABLE, message, null));
- }
-
- public CVSException(String message, Exception e) {
- this(IStatus.ERROR, UNABLE, message, e);
- }
-
- public CVSException(String message, IPath path, Throwable throwable) {
- this(new CVSStatus(IStatus.ERROR, path, message, throwable));
- }
-
- public CVSException(IStatus status) {
- super(status);
- }
-
- /*
- * Static helper methods for creating exceptions
- */
- public static CVSException wrapException(
- IResource resource,
- String message,
- IOException e) {
- // NOTE: we should record the resource somehow
- // We should also inlcude the IO message
- return new CVSException(new CVSStatus(IStatus.ERROR, IO_FAILED, message, e));
- }
-
- /*
- * Static helper methods for creating exceptions
- */
- public static CVSException wrapException(IResource resource, String message, CoreException e) {
- return new CVSException(new CVSStatus(IStatus.ERROR, e.getStatus().getCode(), message, e));
- }
-
- /*
- * Static helper methods for creating exceptions
- */
- public static CVSException wrapException(Exception e) {
- return new CVSException(new CVSStatus(IStatus.ERROR, UNABLE, e.getMessage() != null ? e.getMessage() : "", e)); //$NON-NLS-1$
- }
- public static CVSException wrapException(CoreException e) {
- return new CVSException(e.getStatus());
- }
-} \ No newline at end of file
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
deleted file mode 100644
index f372c5811..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
+++ /dev/null
@@ -1,642 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.Team;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.client.Checkout;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Import;
-import org.eclipse.team.internal.ccvs.core.client.Request;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTree;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteModule;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-public class CVSProvider implements ICVSProvider {
-
- private static final String STATE_FILE = ".cvsProviderState"; //$NON-NLS-1$
-
- private static CVSProvider instance;
- private Map repositories;
-
- private List listeners = new ArrayList();
-
- private CVSProvider() {
- repositories = new HashMap();
- }
-
- /*
- * Add the repository location to the cahced locations
- */
- private void addToCache(ICVSRepositoryLocation repository) {
- repositories.put(repository.getLocation(), repository);
- }
-
- private void repositoryAdded(ICVSRepositoryLocation repository) {
- Iterator it = listeners.iterator();
- while (it.hasNext()) {
- ICVSListener listener = (ICVSListener)it.next();
- listener.repositoryAdded(repository);
- }
- }
-
- public void addRepositoryListener(ICVSListener listener) {
- listeners.add(listener);
- }
-
- public void removeRepositoryListener(ICVSListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * @see ICVSProvider#checkout(ICVSRepositoryLocation, IProject, String, String, IProgressMonitor)
- */
- public void checkout(
- ICVSRepositoryLocation repository,
- IProject project,
- String sourceModule,
- CVSTag tag,
- IProgressMonitor monitor)
- throws TeamException {
-
- if (sourceModule == null)
- sourceModule = project.getName();
- checkout(new ICVSRemoteFolder[] { new RemoteFolder(null, repository, new Path(sourceModule), tag)},
- new IProject[] { project }, monitor);
- }
-
- /*
- * Delete the target projects before checking out
- */
- private void scrubProjects(IProject[] projects, IProgressMonitor monitor) throws CVSException {
- if (projects == null) {
- monitor.done();
- return;
- }
- monitor.beginTask(Policy.bind("CVSProvider.Scrubbing_projects_1"), projects.length * 100); //$NON-NLS-1$
- try {
- for (int i=0;i<projects.length;i++) {
- IProject project = projects[i];
- if (project != null && project.exists()) {
- if(!project.isOpen()) {
- project.open(Policy.subMonitorFor(monitor, 10));
- }
- // XXX: temporary code to support creating a java project for sources in CVS
- // should be removed once nature support is added to the UI.
- // delete children, keep project
- monitor.subTask(Policy.bind("CVSProvider.Scrubbing_local_project_1")); //$NON-NLS-1$
- EclipseSynchronizer.getInstance().prepareForDeletion(project);
- IResource[] children = project.members(IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
- IProgressMonitor subMonitor = Policy.subMonitorFor(monitor, 80);
- subMonitor.beginTask(null, children.length * 100);
- try {
- for (int j = 0; j < children.length; j++) {
- if ( ! children[j].getName().equals(".project")) {//$NON-NLS-1$
- children[j].delete(true /*force*/, Policy.subMonitorFor(subMonitor, 100));
- }
- }
- } finally {
- subMonitor.done();
- }
- CVSWorkspaceRoot.getCVSFolderFor(project).unmanage(Policy.subMonitorFor(monitor, 10));
- } else if (project != null) {
- // Make sure there is no directory in the local file system.
- File location = new File(project.getParent().getLocation().toFile(), project.getName());
- if (location.exists()) {
- deepDelete(location);
- }
- }
- }
- } catch (CoreException e) {
- throw wrapException(e);
- } finally {
- monitor.done();
- }
- }
-
- private void deepDelete(File resource) {
- if (resource.isDirectory()) {
- File[] fileList = resource.listFiles();
- for (int i = 0; i < fileList.length; i++) {
- deepDelete(fileList[i]);
- }
- }
- resource.delete();
- }
-
- /*
- * Bring the provied projects into the workspace
- */
- private void refreshProjects(IProject[] projects, IProgressMonitor monitor) throws CoreException, TeamException {
- monitor.beginTask(Policy.bind("CVSProvider.Creating_projects_2"), projects.length * 100); //$NON-NLS-1$
- try {
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- // Register the project with Team
- // (unless the project already has the proper nature from the project meta-information)
- if (!project.getDescription().hasNature(CVSProviderPlugin.getTypeId())) {
- Team.addNatureToProject(project, CVSProviderPlugin.getTypeId(), Policy.subMonitorFor(monitor, 100));
- }
- }
-
- } finally {
- monitor.done();
- }
- }
-
-
- /**
- * @see ICVSProvider#checkout(ICVSRemoteResource[], IProject[], IProgressMonitor)
- */
- public void checkout(final ICVSRemoteFolder[] resources, final IProject[] projects, final IProgressMonitor monitor) throws TeamException {
- final TeamException[] eHolder = new TeamException[1];
- try {
- IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor pm) throws CoreException {
- try {
- pm.beginTask(null, 1000 * resources.length);
-
- // Get the location of the workspace root
- ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot());
-
- for (int i=0;i<resources.length;i++) {
- IProject project = null;
- RemoteFolder resource = (RemoteFolder)resources[i];
-
- // Determine the provided target project if there is one
- if (projects != null)
- project = projects[i];
-
- // Determine the remote module to be checked out
- String moduleName;
- if (resource instanceof RemoteModule) {
- moduleName = ((RemoteModule)resource).getName();
- } else {
- moduleName = resource.getRepositoryRelativePath();
- }
-
- // Open a connection session to the repository
- ICVSRepositoryLocation repository = resource.getRepository();
- Session session = new Session(repository, root);
- try {
- session.open(Policy.subMonitorFor(pm, 50));
-
- // Determine the local target projects (either the project provider or the module expansions)
- final Set targetProjects = new HashSet();
- if (project == null) {
-
- // Fetch the module expansions
- IStatus status = Request.EXPAND_MODULES.execute(session, new String[] {moduleName}, Policy.subMonitorFor(pm, 50));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- // XXX Should we cleanup any partially checked out projects?
- throw new CVSServerException(status);
- }
-
- // Convert the module expansions to local projects
- String[] expansions = session.getModuleExpansions();
- for (int j = 0; j < expansions.length; j++) {
- targetProjects.add(ResourcesPlugin.getWorkspace().getRoot().getProject(new Path(expansions[j]).segment(0)));
- }
-
- } else {
- targetProjects.add(project);
- }
-
- // Prepare the target projects to receive resources
- root.run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- scrubProjects((IProject[]) targetProjects.toArray(new IProject[targetProjects.size()]), monitor);
- }
- }, Policy.subMonitorFor(pm, 100));
-
- // Build the local options
- List localOptions = new ArrayList();
- // Add the option to load into the target project if one was supplied
- if (project != null) {
- localOptions.add(Checkout.makeDirectoryNameOption(project.getName()));
- }
- // Prune empty directories if pruning enabled
- if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories())
- localOptions.add(Checkout.PRUNE_EMPTY_DIRECTORIES);
- // Add the options related to the CVSTag
- CVSTag tag = resource.getTag();
- if (tag == null) {
- // A null tag in a remote resource indicates HEAD
- tag = CVSTag.DEFAULT;
- }
- localOptions.add(Update.makeTagOption(tag));
-
- // Perform the checkout
- IStatus status = Command.CHECKOUT.execute(session,
- getDefaultGlobalOptions(),
- (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]),
- new String[]{moduleName},
- null,
- Policy.subMonitorFor(pm, 800));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- // XXX Should we cleanup any partially checked out projects?
- throw new CVSServerException(status);
- }
-
- // Bring the project into the workspace
- refreshProjects((IProject[])targetProjects.toArray(new IProject[targetProjects.size()]), Policy.subMonitorFor(pm, 100));
-
- } finally {
- session.close();
- }
- }
- }
- catch (TeamException e) {
- // Pass it outside the workspace runnable
- eHolder[0] = e;
- } finally {
- pm.done();
- }
- // CoreException and OperationCanceledException are propagated
- }
- };
- 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];
- }
- }
-
- /**
- * @see ICVSProvider#createRepository(Properties)
- */
- public ICVSRepositoryLocation createRepository(Properties configuration) throws CVSException {
- // Create a new repository location
- CVSRepositoryLocation location = CVSRepositoryLocation.fromProperties(configuration);
-
- // Check the cache for an equivalent instance and if there is one, throw an exception
- CVSRepositoryLocation existingLocation = (CVSRepositoryLocation)repositories.get(location.getLocation());
- if (existingLocation != null) {
- throw new CVSException(new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSProvider.alreadyExists"))); //$NON-NLS-1$
- }
-
- return location;
- }
-
- /**
- * @see ICVSProvider#addRepository(ICVSRepositoryLocation)
- */
- public void addRepository(ICVSRepositoryLocation repository) throws CVSException {
- // Check the cache for an equivalent instance and if there is one, just update the cache
- CVSRepositoryLocation existingLocation = (CVSRepositoryLocation)repositories.get(repository.getLocation());
- if (existingLocation != null) {
- ((CVSRepositoryLocation)repository).updateCache();
- } else {
- // Cache the password and register the repository location
- addToCache(repository);
- ((CVSRepositoryLocation)repository).updateCache();
- repositoryAdded(repository);
- }
- }
-
- /**
- * @see ICVSProvider#disposeRepository(ICVSRepositoryLocation)
- */
- public void disposeRepository(ICVSRepositoryLocation repository) throws CVSException {
- ((CVSRepositoryLocation)repository).dispose();
- removeFromCache(repository);
- }
-
- public boolean isKnownRepository(String location) {
- return repositories.get(location) != null;
- }
-
- public static GlobalOption[] getDefaultGlobalOptions() {
- QuietOption option = CVSProviderPlugin.getPlugin().getQuietness();
- if (option == null)
- return Command.NO_GLOBAL_OPTIONS;
- else
- return new GlobalOption[] {option};
- }
-
- /**
- * Return the singleton instance of CVSProvider
- */
- public static CVSProvider getInstance() {
- return instance;
- }
-
- public String[] getExpansions(ICVSRemoteFolder[] resources, IProgressMonitor monitor) throws CVSException {
-
- if (resources.length == 0) return new String[0];
-
- // Get the location of the workspace root
- ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot());
-
- // Get the command arguments
- String[] arguments = new String[resources.length];
- for (int i = 0; i < resources.length; i++) {
- if (resources[i] instanceof RemoteModule) {
- arguments[i] = ((RemoteModule)resources[i]).getName();
- } else {
- arguments[i] = resources[i].getRepositoryRelativePath();
- }
- }
-
- // Perform the Expand-Modules command
- IStatus status;
- Session s = new Session(resources[0].getRepository(), root);
- s.open(monitor);
- try {
- status = Request.EXPAND_MODULES.execute(s, arguments, monitor);
- } finally {
- s.close();
- }
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
-
- return s.getModuleExpansions();
- }
-
- /**
- * @see ICVSProvider#getKnownRepositories()
- */
- public ICVSRepositoryLocation[] getKnownRepositories() {
- return (ICVSRepositoryLocation[])repositories.values().toArray(new ICVSRepositoryLocation[repositories.size()]);
- }
-
-
-
- /**
- * @see ICVSProvider#getRepository(String)
- */
- public ICVSRepositoryLocation getRepository(String location) throws CVSException {
- ICVSRepositoryLocation repository = (ICVSRepositoryLocation)repositories.get(location);
- if (repository == null) {
- repository = CVSRepositoryLocation.fromString(location);
- addToCache(repository);
- repositoryAdded(repository);
- }
- return repository;
- }
-
- /**
- * @see ICVSProvider#getSupportedConnectionMethods()
- */
- public String[] getSupportedConnectionMethods() {
- IConnectionMethod[] methods = CVSRepositoryLocation.getPluggedInConnectionMethods();
- String[] result = new String[methods.length];
- for (int i=0;i<methods.length;i++)
- result[i] = methods[i].getName();
- return result;
- }
-
- /**
- * @see ICVSProvider#createModule()
- */
- public void createModule(ICVSRepositoryLocation location, IProject project, String moduleName, IProgressMonitor monitor) throws TeamException {
-
- // Determine if the repository is known
- boolean alreadyExists = isCached(location);
- // Set the folder sync info of the project to point to the remote module
- ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project);
-
- try {
- // Get the import properties
- String message = Policy.bind("CVSProvider.initialImport"); //$NON-NLS-1$
- String vendor = "vendor"; //$NON-NLS-1$
- String tag = "start"; //$NON-NLS-1$
- String projectName = project.getName();
- if (moduleName == null)
- moduleName = projectName;
-
- // Perform the import using a dummy root so the local project is not traversed
- Session s = new Session(location, new RemoteFolderTree(null, location, Path.EMPTY, null));
- s.open(monitor);
- try {
- IStatus status = Command.IMPORT.execute(s,
- getDefaultGlobalOptions(),
- new LocalOption[] {Import.makeArgumentOption(Command.MESSAGE_OPTION, message)},
- new String[] { moduleName, vendor, tag },
- null,
- monitor);
- // If we get a warning, the operation most likely failed so check that the status is OK
- if (status.getCode() == CVSStatus.SERVER_ERROR || ! status.isOK()) {
- throw new CVSServerException(status);
- }
- } finally {
- s.close();
- }
-
- folder.setFolderSyncInfo(new FolderSyncInfo(moduleName, location.getLocation(), null, false));
-
- // Register the project with Team
- // (unless the project already has the proper nature from the project meta-information)
- try {
- if (!project.getDescription().hasNature(CVSProviderPlugin.getTypeId())) {
- Team.addNatureToProject(project, CVSProviderPlugin.getTypeId(), Policy.subMonitorFor(monitor, 1));
- }
- } catch (CoreException e) {
- throw wrapException(e);
- }
- } catch (TeamException e) {
- // The checkout may have triggered password caching
- // Therefore, if this is a newly created location, we want to clear its cache
- if ( ! alreadyExists)
- disposeRepository(location);
- throw e;
- }
- // Add the repository if it didn't exist already
- if ( ! alreadyExists)
- addRepository(location);
- }
-
- private CVSTag getTagFromProperties(Properties configuration) {
- String date = configuration.getProperty("date"); //$NON-NLS-1$
- String tagName = configuration.getProperty("tag"); //$NON-NLS-1$
- if (tagName == null)
- tagName = configuration.getProperty("branch"); //$NON-NLS-1$
- if (tagName == null)
- return CVSTag.DEFAULT;
- return new CVSTag(tagName, CVSTag.BRANCH);
- }
-
- private boolean isCached(ICVSRepositoryLocation repository) {
- return repositories.containsKey(repository.getLocation());
- }
-
- public static boolean isText(IFile file) {
- return Team.getType(file) == Team.TEXT;
- }
-
- private void removeFromCache(ICVSRepositoryLocation repository) {
- if (repositories.remove(repository.getLocation()) != null) {
- Iterator it = listeners.iterator();
- while (it.hasNext()) {
- ICVSListener listener = (ICVSListener)it.next();
- listener.repositoryRemoved(repository);
- }
- }
- }
-
- public void setSharing(IProject project, FolderSyncInfo info, IProgressMonitor monitor) throws TeamException {
-
- // Ensure provided info matches that of the project
- ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project);
- FolderSyncInfo folderInfo = folder.getFolderSyncInfo();
- if ( ! info.equals(folderInfo)) {
- throw new CVSException(new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSProvider.infoMismatch", project.getName())));//$NON-NLS-1$
- }
-
- // Ensure that the provided location is managed
- ICVSRepositoryLocation location = getRepository(info.getRoot());
- if (! isCached(location)) {
- addToCache(location);
- repositoryAdded(location);
- }
-
- // Register the project with Team
- // (unless the project already has the proper nature from the project meta-information)
- try {
- if (!project.getDescription().hasNature(CVSProviderPlugin.getTypeId()))
- Team.addNatureToProject(project, CVSProviderPlugin.getTypeId(), monitor);
- } catch (CoreException e) {
- throw wrapException(e);
- }
- }
-
- private CVSException wrapException(CoreException e) {
- return new CVSException(e.getStatus()); //$NON-NLS-1$
- }
-
- public static void startup() {
- if (instance == null) {
- instance = new CVSProvider();
- }
- try {
- getInstance().loadState();
- } catch (TeamException e) {
- Util.logError(Policy.bind("CVSProvider.errorSaving"), e);//$NON-NLS-1$
- }
- }
-
- public static void shutdown() {
- try {
- getInstance().saveState();
- } catch (TeamException e) {
- Util.logError(Policy.bind("CVSProvider.errorLoading"), e);//$NON-NLS-1$
- }
- }
-
- private void loadState() throws TeamException {
- IPath pluginStateLocation = CVSProviderPlugin.getPlugin().getStateLocation().append(STATE_FILE);
- File file = pluginStateLocation.toFile();
- if (file.exists()) {
- try {
- DataInputStream dis = new DataInputStream(new FileInputStream(file));
- readState(dis);
- dis.close();
- } catch (IOException e) {
- throw new TeamException(new Status(Status.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, Policy.bind("CVSProvider.ioException"), e)); //$NON-NLS-1$
- }
- } else {
- // If the file did not exist, then prime the list of repositories with
- // the providers with which the projects in the workspace are shared.
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0; i < projects.length; i++) {
- RepositoryProvider provider = RepositoryProvider.getProvider(projects[i], CVSProviderPlugin.getTypeId());
- if (provider!=null) {
- ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(projects[i]);
- FolderSyncInfo info = folder.getFolderSyncInfo();
- if (info != null) {
- ICVSRepositoryLocation result = getRepository(info.getRoot());
- addToCache(result);
- repositoryAdded(result);
- }
- }
- }
- }
- }
-
- private void saveState() throws TeamException {
- IPath pluginStateLocation = CVSProviderPlugin.getPlugin().getStateLocation();
- 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));
- writeState(dos);
- dos.close();
- if (stateFile.exists()) {
- stateFile.delete();
- }
- boolean renamed = tempFile.renameTo(stateFile);
- if (!renamed) {
- throw new TeamException(new Status(Status.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, Policy.bind("CVSProvider.rename", tempFile.getAbsolutePath()), null)); //$NON-NLS-1$
- }
- } catch (IOException e) {
- throw new TeamException(new Status(Status.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, Policy.bind("CVSProvider.save",stateFile.getAbsolutePath()), e)); //$NON-NLS-1$
- }
- }
- private void readState(DataInputStream dis) throws IOException, CVSException {
- int count = dis.readInt();
- for (int i = 0; i < count; i++) {
- getRepository(dis.readUTF());
- }
- }
-
- private void writeState(DataOutputStream dos) throws IOException {
- // Write the repositories
- Collection repos = repositories.values();
- dos.writeInt(repos.size());
- Iterator it = repos.iterator();
- while (it.hasNext()) {
- ICVSRepositoryLocation root = (ICVSRepositoryLocation)it.next();
- dos.writeUTF(root.getLocation());
- }
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java
deleted file mode 100644
index 24ad316a2..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java
+++ /dev/null
@@ -1,519 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption;
-import org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener;
-import org.eclipse.team.internal.ccvs.core.util.AddDeleteMoveListener;
-import org.eclipse.team.internal.ccvs.core.util.MoveDeleteHook;
-import org.eclipse.team.internal.ccvs.core.util.ProjectDescriptionManager;
-import org.eclipse.team.internal.ccvs.core.util.SyncFileChangeListener;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-public class CVSProviderPlugin extends Plugin {
-
- // external command to run for ext connection method
- public static final String DEFAULT_CVS_RSH = "ssh"; //$NON-NLS-1$
- // remote command to run for ext connection method
- public static final String DEFAULT_CVS_SERVER = "cvs"; //$NON-NLS-1$
- // determines if empty directories received from the server should be pruned.
- public static final boolean DEFAULT_PRUNE = true;
- // determines if new directories should be discovered during update.
- public static final boolean DEFAULT_FETCH = true;
- // communication timeout with the server
- public static final int DEFAULT_TIMEOUT = 60;
- // file transfer compression level (0 - 9)
- public static final int DEFAULT_COMPRESSION_LEVEL = 0;
- // default text keyword substitution mode
- public static final KSubstOption DEFAULT_TEXT_KSUBST_OPTION = Command.KSUBST_TEXT;
-
- // cvs plugin extension points and ids
- public static final String ID = "org.eclipse.team.cvs.core"; //$NON-NLS-1$
- public static final String PT_AUTHENTICATOR = "authenticator"; //$NON-NLS-1$
- public static final String PT_CONNECTIONMETHODS = "connectionmethods"; //$NON-NLS-1$
-
- // Directory to cache file contents
- private static final String CACHE_DIRECTORY = ".cache"; //$NON-NLS-1$
-
- private QuietOption quietness;
- private int compressionLevel = DEFAULT_COMPRESSION_LEVEL;
- private KSubstOption defaultTextKSubstOption = DEFAULT_TEXT_KSUBST_OPTION;
- private int communicationsTimeout = DEFAULT_TIMEOUT;
- private boolean pruneEmptyDirectories = DEFAULT_PRUNE;
- private boolean fetchAbsentDirectories = DEFAULT_FETCH;
- private boolean promptOnFileDelete = true;
- private boolean promptOnFolderDelete = true;
- private boolean showTasksOnAddAndDelete = false;
- private boolean replaceUnmanaged = true;
- private String cvsRshCommand = DEFAULT_CVS_RSH;
- private String cvsServer = DEFAULT_CVS_SERVER;
- private IConsoleListener consoleListener;
-
- private static CVSProviderPlugin instance;
-
- // CVS specific resource delta listeners
- private IResourceChangeListener projectDescriptionListener;
- private IResourceChangeListener metaFileSyncListener;
- private AddDeleteMoveListener addDeleteMoveListener;
-
- /**
- * The identifier for the CVS nature
- * (value <code>"org.eclipse.team.cvs.core.nature"</code>).
- * The presence of this nature on a project indicates that it is
- * CVS-capable.
- *
- * @see org.eclipse.core.resources.IProject#hasNature
- */
- private static final String NATURE_ID = ID + ".cvsnature"; //$NON-NLS-1$
-
- /**
- * Constructor for CVSProviderPlugin.
- * @param descriptor
- */
- public CVSProviderPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- instance = this;
- }
-
- /**
- * Convenience method for logging CVSExceptiuons to the plugin log
- */
- public static void log(TeamException e) {
- // For now, we'll log the status. However we should do more
- instance.getLog().log(e.getStatus());
- }
- public static void log(IStatus status) {
- // For now, we'll log the status. However we should do more
- instance.getLog().log(status);
- }
-
- /**
- * Returns the singleton plug-in instance.
- *
- * @return the plugin instance
- */
- public static CVSProviderPlugin getPlugin() {
- return instance;
- }
-
- /**
- * Get the ICVSProvider
- */
- public static ICVSProvider getProvider() {
- return CVSProvider.getInstance();
- }
-
- /**
- * Answers the repository provider type id for the cvs plugin
- */
- public static String getTypeId() {
- return NATURE_ID;
- }
-
- /**
- * Sets the file transfer compression level. (if supported)
- * Valid levels are: 0 (disabled), 1 (worst/fastest) - 9 (best/slowest)
- */
- public void setCompressionLevel(int level) {
- compressionLevel = level;
- }
-
- /**
- * Gets the file transfer compression level.
- */
- public int getCompressionLevel() {
- return compressionLevel;
- }
-
- /**
- * Sets the default keyword substitution mode for text files.
- */
- public void setDefaultTextKSubstOption(KSubstOption ksubst) {
- defaultTextKSubstOption = ksubst;
- }
-
-
- /**
- * Gets the default keyword substitution mode for text files.
- */
- public KSubstOption getDefaultTextKSubstOption() {
- return defaultTextKSubstOption;
- }
-
- /**
- * Should the CVS adapter prune empty directories
- */
- public boolean getPruneEmptyDirectories() {
- return pruneEmptyDirectories;
- }
-
- /**
- * Set whether the CVS adapter should prune empty directories
- */
- public void setPruneEmptyDirectories(boolean prune) {
- pruneEmptyDirectories = prune;
- }
-
- /**
- * Get the communications timeout value in seconds
- */
- public int getTimeout() {
- return communicationsTimeout;
- }
-
- /**
- * Set the timeout value for communications to a value in seconds.
- * The value must be greater than or equal 0. If is it 0, there is no timeout.
- */
- public void setTimeout(int timeout) {
- this.communicationsTimeout = Math.max(0, timeout);
- }
-
- /**
- * Set the quietness option to use with cvs commands.
- * Can be "", "-q" or "-Q"
- */
- public void setQuietness(QuietOption option) {
- this.quietness = option;
- }
-
- /**
- * Get the quietness option for commands
- */
- public QuietOption getQuietness() {
- return quietness;
- }
-
- /**
- * Set the console listener for commands.
- * @param consoleListener the listener
- */
- public void setConsoleListener(IConsoleListener consoleListener) {
- this.consoleListener = consoleListener;
- }
-
- /**
- * Get the console listener for commands.
- * @return the consoleListener, or null
- */
- public IConsoleListener getConsoleListener() {
- return consoleListener;
- }
-
- /**
- * @see Plugin#startup()
- */
- public void startup() throws CoreException {
- super.startup();
- Policy.localize("org.eclipse.team.internal.ccvs.core.messages"); //$NON-NLS-1$
-
- // Start the synchronizer first as the startup of CVSProvider may use it.
- CVSProvider.startup();
-
- // Initialize CVS change listeners. Note tha the report type is important.
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- projectDescriptionListener = new ProjectDescriptionManager();
- metaFileSyncListener = new SyncFileChangeListener();
- addDeleteMoveListener = new AddDeleteMoveListener();
- workspace.addResourceChangeListener(projectDescriptionListener, IResourceChangeEvent.PRE_AUTO_BUILD);
- workspace.addResourceChangeListener(metaFileSyncListener, IResourceChangeEvent.PRE_AUTO_BUILD);
- workspace.addResourceChangeListener(addDeleteMoveListener, IResourceChangeEvent.POST_AUTO_BUILD);
- CVSProviderPlugin.getPlugin().addResourceStateChangeListener(addDeleteMoveListener);
-
- createCacheDirectory();
-
- CVSTeamProvider.setMoveDeleteHook(new MoveDeleteHook());
- }
-
- /**
- * @see Plugin#shutdown()
- */
- public void shutdown() throws CoreException {
- super.shutdown();
- CVSProvider.shutdown();
-
- // remove listeners
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- workspace.removeResourceChangeListener(projectDescriptionListener);
- workspace.removeResourceChangeListener(metaFileSyncListener);
- workspace.removeResourceChangeListener(addDeleteMoveListener);
-
- deleteCacheDirectory();
- }
-
- /*
- * Add a resource change listener to the workspace in order to respond to
- * resource deletions and moves and to ensure or project desription file is up to date.
- */
- private void initializeChangeListener() {
-
- // Build a change listener for changes to thr project meta-information
- IResourceChangeListener projectChangeListener = new IResourceChangeListener() {
- public void resourceChanged(IResourceChangeEvent event) {
- try {
- IResourceDelta root = event.getDelta();
- IResourceDelta[] projectDeltas = root.getAffectedChildren(IResourceDelta.CHANGED);
- for (int i = 0; i < projectDeltas.length; i++) {
- IResourceDelta delta = projectDeltas[i];
- IResource resource = delta.getResource();
- if (resource.getType() == IResource.PROJECT) {
- IProject project = (IProject)resource;
- // Get the team provider for the project and
- RepositoryProvider provider = RepositoryProvider.getProvider(project, getTypeId());
- if(provider==null) continue;
- /* Check if the project description changed. */
- if ((delta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
- /* The project description changed. Write the file. */
- ProjectDescriptionManager.writeProjectDescriptionIfNecessary((CVSTeamProvider)provider, project, Policy.monitorFor(null));
- }
-
- /* Check if the .vcm_meta file for the project is in the delta. */
- IResourceDelta[] children = delta.getAffectedChildren(IResourceDelta.REMOVED);
- for (int j = 0; j < children.length; j++) {
- IResourceDelta childDelta = children[j];
- IResource childResource = childDelta.getResource();
- if (ProjectDescriptionManager.isProjectDescription(childResource)) {
- ProjectDescriptionManager.writeProjectDescriptionIfNecessary((CVSTeamProvider)provider, project, Policy.monitorFor(null));
- }
- }
- }
- }
- } catch (CVSException ex) {
- Util.logError(Policy.bind("CVSProviderPlugin.cannotUpdateDescription"), ex); //$NON-NLS-1$
- }
- }
- };
- ResourcesPlugin.getWorkspace().addResourceChangeListener(projectChangeListener, IResourceChangeEvent.POST_AUTO_BUILD);
- }
-
- /**
- * Gets the cvsRshCommand.
- * @return Returns a String
- */
- public String getCvsRshCommand() {
- return cvsRshCommand;
- }
-
- /**
- * Sets the cvsRshCommand.
- * @param cvsRshCommand The cvsRshCommand to set
- */
- public void setCvsRshCommand(String cvsRshCommand) {
- this.cvsRshCommand = cvsRshCommand;
- }
-
- /**
- * Gets the cvsServer.
- * @return Returns a String
- */
- public String getCvsServer() {
- return cvsServer;
- }
-
- /**
- * Sets the cvsServer.
- * @param cvsServer The cvsServer to set
- */
- public void setCvsServer(String cvsServer) {
- this.cvsServer = cvsServer;
- }
-
- /**
- * Gets the etchAbsentDirectories.
- * @return Returns a boolean
- */
- public boolean getFetchAbsentDirectories() {
- return fetchAbsentDirectories;
- }
-
- /**
- * Sets the fetchAbsentDirectories.
- * @param etchAbsentDirectories The etchAbsentDirectories to set
- */
- public void setFetchAbsentDirectories(boolean fetchAbsentDirectories) {
- this.fetchAbsentDirectories = fetchAbsentDirectories;
- }
-
- public boolean getPromptOnFileDelete() {
- return promptOnFileDelete;
- }
-
- public void setPromptOnFileDelete(boolean prompt) {
- promptOnFileDelete = prompt;
- }
-
- public boolean getPromptOnFolderDelete() {
- return promptOnFolderDelete;
- }
-
- public void setPromptOnFolderDelete(boolean prompt) {
- promptOnFolderDelete = prompt;
- }
-
- private static List listeners = new ArrayList();
-
- /*
- * @see ITeamManager#addResourceStateChangeListener(IResourceStateChangeListener)
- */
- public static void addResourceStateChangeListener(IResourceStateChangeListener listener) {
- listeners.add(listener);
- }
-
- /*
- * @see ITeamManager#removeResourceStateChangeListener(IResourceStateChangeListener)
- */
- public static void removeResourceStateChangeListener(IResourceStateChangeListener listener) {
- listeners.remove(listener);
- }
-
- /*
- * @see ITeamManager#broadcastResourceStateChanges(IResource[])
- */
- public static void broadcastResourceStateChanges(final IResource[] resources) {
- for(Iterator it=listeners.iterator(); it.hasNext();) {
- final IResourceStateChangeListener listener = (IResourceStateChangeListener)it.next();
- ISafeRunnable code = new ISafeRunnable() {
- public void run() throws Exception {
- listener.resourceStateChanged(resources);
- }
- public void handleException(Throwable e) {
- // don't log the exception....it is already being logged in Platform#run
- }
- };
- Platform.run(code);
- }
- }
-
- protected static void broadcastProjectConfigured(final IProject project) {
- for(Iterator it=listeners.iterator(); it.hasNext();) {
- final IResourceStateChangeListener listener = (IResourceStateChangeListener)it.next();
- ISafeRunnable code = new ISafeRunnable() {
- public void run() throws Exception {
- listener.projectConfigured(project);
- }
- public void handleException(Throwable e) {
- // don't log the exception....it is already being logged in Platform#run
- }
- };
- Platform.run(code);
- }
- }
- protected static void broadcastProjectDeconfigured(final IProject project) {
- for(Iterator it=listeners.iterator(); it.hasNext();) {
- final IResourceStateChangeListener listener = (IResourceStateChangeListener)it.next();
- ISafeRunnable code = new ISafeRunnable() {
- public void run() throws Exception {
- listener.projectDeconfigured(project);
- }
- public void handleException(Throwable e) {
- // don't log the exception....it is already being logged in Platform#run
- }
- };
- Platform.run(code);
- }
- }
-
- /**
- * Gets the showTasksOnAddAndDelete.
- * @return Returns a boolean
- */
- public boolean getShowTasksOnAddAndDelete() {
- return showTasksOnAddAndDelete;
- }
-
- /**
- * Sets the showTasksOnAddAndDelete.
- * @param showTasksOnAddAndDelete The showTasksOnAddAndDelete to set
- */
- public void setShowTasksOnAddAndDelete(boolean showTasksOnAddAndDelete) {
- this.showTasksOnAddAndDelete = showTasksOnAddAndDelete;
- }
- /**
- * Gets the replaceUnmanaged.
- * @return Returns a boolean
- */
- public boolean isReplaceUnmanaged() {
- return replaceUnmanaged;
- }
-
- /**
- * Sets the replaceUnmanaged.
- * @param replaceUnmanaged The replaceUnmanaged to set
- */
- public void setReplaceUnmanaged(boolean replaceUnmanaged) {
- this.replaceUnmanaged = replaceUnmanaged;
- }
-
- private void createCacheDirectory() {
- try {
- IPath cacheLocation = getStateLocation().append(CACHE_DIRECTORY);
- File file = cacheLocation.toFile();
- if (file.exists()) {
- deleteFile(file);
- }
- file.mkdir();
- } catch (IOException e) {
- log(new Status(IStatus.ERROR, ID, 0, Policy.bind("CVSProviderPlugin.errorCreatingCache", e.getMessage()), e)); //$NON-NLS-1$
- }
- }
-
- private void deleteCacheDirectory() {
- try {
- IPath cacheLocation = getStateLocation().append(CACHE_DIRECTORY);
- File file = cacheLocation.toFile();
- if (file.exists()) {
- deleteFile(file);
- }
- } catch (IOException e) {
- log(new Status(IStatus.ERROR, ID, 0, Policy.bind("CVSProviderPlugin.errorDeletingCache", e.getMessage()), e)); //$NON-NLS-1$
- }
- }
-
- private void deleteFile(File file) throws IOException {
- if (file.isDirectory()) {
- File[] children = file.listFiles();
- for (int i = 0; i < children.length; i++) {
- deleteFile(children[i]);
- }
- }
- file.delete();
- }
-
- public File getCacheFileFor(String path) throws IOException {
- return new File(getStateLocation().append(CACHE_DIRECTORY).toFile(), path);
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java
deleted file mode 100644
index 7929d11b8..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Status;
-
-public class CVSStatus extends Status {
-
- /*** Status codes ***/
- public static final int SERVER_ERROR = -10; // XXX What should this number be?
- public static final int NO_SUCH_TAG = -11;
- public static final int CONFLICT = -12;
- public static final int ERROR_LINE = -14; // generic uninterpreted E line from the server
- public static final int TAG_ALREADY_EXISTS = -15;
- public static final int COMMITTING_SYNC_INFO_FAILED = -16;
- public static final int DOES_NOT_EXIST = -17;
- public static final int FOLDER_NEEDED_FOR_FILE_DELETIONS = -18;
- public static final int CASE_VARIANT_EXISTS = -19;
- public static final int UNSUPPORTED_SERVER_VERSION = -20;
- public static final int SERVER_IS_CVSNT = -21;
- public static final int SERVER_IS_UNKNOWN = -22;
-
- // Path for resource related status
- private IPath path;
-
- public CVSStatus(int severity, int code, String message, Throwable t) {
- super(severity, CVSProviderPlugin.ID, code, message, t);
- }
-
- public CVSStatus(int severity, int code, String message) {
- this(severity, code, message, null);
- }
-
- public CVSStatus(int severity, IPath path, String message, Throwable t) {
- this(severity, message);
- this.path = path;
- }
-
- public CVSStatus(int severity, String message) {
- this(severity, severity, message, null);
- }
-
- public IPath getPath() {
- return path;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTag.java
deleted file mode 100644
index 7b667286c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTag.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * A tag in CVS gives a label to a collection of revisions. The labels can represent a version, a branch,
- * or a date.
- */
-public class CVSTag {
-
- public final static int HEAD = 0;
- public final static int BRANCH = 1;
- public final static int VERSION = 2;
- public final static int DATE = 3;
-
- public static final CVSTag DEFAULT = new CVSTag();
- public static final CVSTag BASE = new CVSTag("BASE", VERSION); //$NON-NLS-1$
-
- protected String name;
- protected int type;
-
- public CVSTag() {
- this("HEAD", HEAD); //$NON-NLS-1$
- }
-
- public CVSTag(String name, int type) {
- this.name = name;
- this.type = type;
- }
-
- public boolean equals(Object other) {
- if(other == this) return true;
- if (!(other instanceof CVSTag)) return false;
-
- CVSTag tag = ((CVSTag)other);
- if (getType() != tag.getType()) return false;
- if (!getName().equals(tag.getName())) return false;
- return true;
- }
-
- public String getName() {
- return name;
- }
-
- public int getType() {
- return type;
- }
-
- public int hashCode() {
- return name.hashCode();
- }
-
- public int compareTo(CVSTag other) {
- return getName().compareTo(other.getName());
- }
-
- public static boolean equalTags(CVSTag tag1, CVSTag tag2) {
- if (tag1 == null) tag1 = CVSTag.DEFAULT;
- if (tag2 == null) tag2 = CVSTag.DEFAULT;
- return tag1.equals(tag2);
- }
-
- public static IStatus validateTagName(String tagName) {
- if (tagName == null)
- return new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSTag.nullName")); //$NON-NLS-1$
- if (tagName.equals("")) //$NON-NLS-1$
- return new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSTag.emptyName")); //$NON-NLS-1$
- if (!Character. isLetter(tagName.charAt(0)))
- return new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSTag.beginName")); //$NON-NLS-1$
-
- for (int i = 0; i < tagName.length(); i++) {
- char c = tagName.charAt(i);
- if ( Character.isSpaceChar(c) || c == '$' || c == ',' || c == '.' || c == ':' || c == ';' || c == '@' || c == '|')
- return new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSTag.badCharName")); //$NON-NLS-1$
- }
- return new CVSStatus(CVSStatus.OK, Policy.bind("ok")); //$NON-NLS-1$
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java
deleted file mode 100644
index 45408076a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java
+++ /dev/null
@@ -1,1147 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.resources.team.IMoveDeleteHook;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.Team;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteSyncElement;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Commit;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.client.Tag;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.client.listeners.AdminKSubstListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.DiffListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.resources.CVSRemoteSyncElement;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.ccvs.core.streams.CRLFtoLFInputStream;
-import org.eclipse.team.internal.ccvs.core.streams.LFtoCRLFInputStream;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-import org.eclipse.team.internal.ccvs.core.util.PrepareForReplaceVisitor;
-import org.eclipse.team.internal.ccvs.core.util.ReplaceWithBaseVisitor;
-
-/**
- * This class acts as both the ITeamNature and the ITeamProvider instances
- * required by the Team core.
- *
- * The current stat of this class and it's plugin is EXPERIMENTAL.
- * As such, it is subject to change except in it's conformance to the
- * TEAM API which it implements.
- *
- * Questions:
- *
- * How should a project/reource rename/move effect the provider?
- *
- * Currently we always update with -P. Is this OK?
- * - A way to allow customizable options would be nice
- *
- * Is the -l option valid for commit and does it work properly for update and commit?
- *
- * Do we need an IUserInteractionProvider in the CVS core
- * - prompt for user info (caching could be separate)
- * - get release comments
- * - prompt for overwrite of unmanaged files
- *
- * Need a mechanism for communicating meta-information (provided by Team?)
- *
- * Should pass null when there are no options for a cvs command
- *
- * We currently write the files to disk and do a refreshLocal to
- * have them appear in Eclipse. This may be changed in the future.
- */
-public class CVSTeamProvider extends RepositoryProvider {
- private static final boolean IS_CRLF_PLATFORM = Arrays.equals(
- System.getProperty("line.separator").getBytes(), new byte[] { '\r', '\n' }); //$NON-NLS-1$
-
- private CVSWorkspaceRoot workspaceRoot;
- private IProject project;
- private String comment = ""; //$NON-NLS-1$
-
- private static IMoveDeleteHook moveDeleteHook;
-
- /**
- * No-arg Constructor for IProjectNature conformance
- */
- public CVSTeamProvider() {
- }
-
-
-
- /**
- * @see IProjectNature#deconfigure()
- */
- public void deconfigure() throws CoreException {
- // when a nature is removed from the project, notify the synchronizer that
- // we no longer need the sync info cached. This does not affect the actual CVS
- // meta directories on disk, and will remain unless a client calls unmanage().
- try {
- EclipseSynchronizer.getInstance().flush(getProject(), true, true /*flush deep*/, null);
- } catch(CVSException e) {
- throw new CoreException(e.getStatus());
- } finally {
- CVSProviderPlugin.broadcastProjectDeconfigured(getProject());
- }
- }
-
- /**
- * @see IProjectNature#getProject()
- */
- public IProject getProject() {
- return project;
- }
-
-
-
- /**
- * @see IProjectNature#setProject(IProject)
- */
- public void setProject(IProject project) {
- this.project = project;
- try {
- this.workspaceRoot = new CVSWorkspaceRoot(project);
- // Ensure that the project has CVS info
- if (workspaceRoot.getLocalRoot().getFolderSyncInfo() == null) {
- throw new CVSException(new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSTeamProvider.noFolderInfo", project.getName()))); //$NON-NLS-1$
- }
- } catch (CVSException e) {
- // Log any problems creating the CVS managed resource
- CVSProviderPlugin.log(e);
- }
- }
-
-
-
- /**
- * Add the given resources to the project.
- * <p>
- * The sematics follow that of CVS in the sense that any folders
- * being added are created remotely as a result of this operation
- * while files are created remotely on the next commit.
- * </p>
- * <p>
- * This method uses the team file type registry to determine the type
- * of added files. If the extension of the file is not in the registry,
- * the file is assumed to be binary.
- * </p>
- * <p>
- * NOTE: for now we do three operations: one each for folders, text files and binary files.
- * We should optimize this when time permits to either use one operations or defer server
- * contact until the next commit.
- * </p>
- *
- * <p>
- * There are special semantics for adding the project itself to the repo. In this case, the project
- * must be included in the resources array.
- * </p>
- */
- public void add(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException {
-
- // Visit the children of the resources using the depth in order to
- // determine which folders, text files and binary files need to be added
- // A TreeSet is needed for the folders so they are in the right order (i.e. parents created before children)
- final SortedSet folders = new TreeSet();
- // Sets are required for the files to ensure that files will not appear twice if there parent was added as well
- // and the depth isn't zero
- final Map /* from KSubstOption to Set */ files = new HashMap();
- final TeamException[] eHolder = new TeamException[1];
- for (int i=0; i<resources.length; i++) {
-
- final IResource currentResource = resources[i];
-
- // Throw an exception if the resource is not a child of the receiver
- checkIsChild(currentResource);
-
- try {
- // Auto-add parents if they are not already managed
- IContainer parent = currentResource.getParent();
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(currentResource);
- while (parent.getType() != IResource.ROOT && parent.getType() != IResource.PROJECT && ! cvsResource.isManaged()) {
- folders.add(parent.getProjectRelativePath().toString());
- parent = parent.getParent();
- }
-
- // Auto-add children
- currentResource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) {
- ICVSResource mResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- // Add the resource is its not already managed and it was either
- // added explicitly (is equal currentResource) or is not ignored
- if (! mResource.isManaged() && (currentResource.equals(resource) || ! mResource.isIgnored())) {
- String name = resource.getProjectRelativePath().toString();
- if (resource.getType() == IResource.FILE) {
- KSubstOption ksubst = KSubstOption.fromFile((IFile) resource);
- Set set = (Set) files.get(ksubst);
- if (set == null) {
- set = new HashSet();
- files.put(ksubst, set);
- }
- set.add(name);
- } else {
- folders.add(name);
- }
- }
- // Always return true and let the depth determine if children are visited
- return true;
- }
- }, depth, false);
- } catch (CoreException e) {
- throw new CVSException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, Policy.bind("CVSTeamProvider.visitError", new Object[] {resources[i].getFullPath()}), e)); //$NON-NLS-1$
- }
- }
- // If an exception occured during the visit, throw it here
- if (eHolder[0] != null)
- throw eHolder[0];
-
- // XXX Do we need to add the project
-
- // Add the folders, followed by files!
- IStatus status;
- Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
- progress.beginTask(null, 10 + files.size() * 10 + (folders.isEmpty() ? 0 : 10));
- try {
- // Opening the session takes 10 units of time
- s.open(Policy.subMonitorFor(progress, 10));
- if (!folders.isEmpty()) {
- status = Command.ADD.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- (String[])folders.toArray(new String[folders.size()]),
- null,
- Policy.subMonitorFor(progress, 10));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- }
- for (Iterator it = files.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- KSubstOption ksubst = (KSubstOption) entry.getKey();
- Set set = (Set) entry.getValue();
- status = Command.ADD.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] { ksubst },
- (String[])set.toArray(new String[set.size()]),
- null,
- Policy.subMonitorFor(progress, 10));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- }
- } finally {
- s.close();
- progress.done();
- }
- }
-
- /**
- * Checkin any local changes using "cvs commit ...".
- *
- * @see ITeamProvider#checkin(IResource[], int, IProgressMonitor)
- */
- public void checkin(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException {
-
- // Build the local options
- List localOptions = new ArrayList();
- localOptions.add(Commit.makeArgumentOption(Command.MESSAGE_OPTION, comment));
-
- // If the depth is not infinite, we want the -l option
- if (depth != IResource.DEPTH_INFINITE) {
- localOptions.add(Commit.DO_NOT_RECURSE);
- }
- LocalOption[] commandOptions = (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]);
-
- // Build the arguments list
- String[] arguments = getValidArguments(resources, commandOptions);
-
- // Commit the resources
- IStatus status;
- Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
- progress.beginTask(null, 100);
- try {
- // Opening the session takes 20% of the time
- s.open(Policy.subMonitorFor(progress, 20));
- status = Command.COMMIT.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- commandOptions,
- arguments, null,
- Policy.subMonitorFor(progress, 80));
- } finally {
- s.close();
- progress.done();
- }
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- }
-
- /**
- * Checkout the provided resources so they can be modified locally and committed.
- *
- * Currently, we support only the optimistic model so checkout does nothing.
- *
- * @see ITeamProvider#checkout(IResource[], int, IProgressMonitor)
- */
- public void checkout(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException {
- }
-
- /**
- * @see ITeamProvider#delete(IResource[], int, IProgressMonitor)
- */
- public void delete(IResource[] resources, final IProgressMonitor progress) throws TeamException {
- try {
- progress.beginTask(null, 100);
-
- // Delete any files locally and record the names.
- // Use a resource visitor to ensure the proper depth is obtained
- final IProgressMonitor subProgress = Policy.infiniteSubMonitorFor(progress, 30);
- subProgress.beginTask(null, 256);
- final List files = new ArrayList(resources.length);
- final TeamException[] eHolder = new TeamException[1];
- for (int i=0;i<resources.length;i++) {
- IResource resource = resources[i];
- checkIsChild(resource);
- try {
- if (resource.exists()) {
- resource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) {
- try {
- ICVSResource cvsResource = workspaceRoot.getCVSResourceFor(resource);
- if (cvsResource.isManaged()) {
- String name = resource.getProjectRelativePath().toString();
- if (resource.getType() == IResource.FILE) {
- files.add(name);
- ((IFile)resource).delete(false, true, subProgress);
- }
- }
- } catch (CoreException e) {
- eHolder[0] = wrapException(e);
- // If there was a problem, don't visit the children
- return false;
- }
- // Always return true and let the depth determine if children are visited
- return true;
- }
- }, IResource.DEPTH_INFINITE, false);
- } else if (resource.getType() == IResource.FILE) {
- // If the resource doesn't exist but is a file, queue it for removal
- files.add(resource.getProjectRelativePath().toString());
- }
- } catch (CoreException e) {
- throw wrapException(e);
- }
- }
- subProgress.done();
- // If an exception occured during the visit, throw it here
- if (eHolder[0] != null) throw eHolder[0];
- // If there are no files to delete, we are done
- if (files.isEmpty()) return;
-
- // Remove the files remotely
- IStatus status;
- Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
- s.open(progress);
- try {
- status = Command.REMOVE.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- (String[])files.toArray(new String[files.size()]),
- null,
- Policy.subMonitorFor(progress, 70));
- } finally {
- s.close();
- }
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- progress.done();
- }
- }
-
- /**
- * Diff the resources against the repository and write the output to the provided
- * PrintStream in a form that is usable as a patch. The patch is rooted at the
- * project.
- */
- public void diff(IResource resource, LocalOption[] options, PrintStream stream,
- IProgressMonitor progress) throws TeamException {
-
- // Determine the command root and arguments arguments list
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- ICVSFolder commandRoot;
- String[] arguments;
- if (cvsResource.isFolder()) {
- commandRoot = (ICVSFolder)cvsResource;
- arguments = new String[] {Session.CURRENT_LOCAL_FOLDER};
- } else {
- commandRoot = cvsResource.getParent();
- arguments = new String[] {cvsResource.getName()};
- }
-
- Session s = new Session(workspaceRoot.getRemoteLocation(), commandRoot);
- progress.beginTask(null, 100);
- try {
- s.open(Policy.subMonitorFor(progress, 20));
- Command.DIFF.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- options,
- arguments,
- new DiffListener(stream),
- Policy.subMonitorFor(progress, 80));
- } finally {
- s.close();
- progress.done();
- }
- }
-
- /**
- * Replace the local version of the provided resources with the remote using "cvs update -C ..."
- *
- * @see ITeamProvider#get(IResource[], int, IProgressMonitor)
- */
- public void get(IResource[] resources, final int depth, IProgressMonitor progress) throws TeamException {
- get(resources, depth, null, progress);
- }
-
- public void get(final IResource[] resources, final int depth, CVSTag tag, IProgressMonitor progress) throws TeamException {
- try {
- progress.beginTask(null, 100);
-
- // Handle the retrival of the base in a special way
- if (tag != null && tag.equals(CVSTag.BASE)) {
- new ReplaceWithBaseVisitor().replaceWithBase(getProject(), resources, depth, Policy.subMonitorFor(progress, 100)); //$NON-NLS-1$
- return;
- }
-
- // Prepare for the replace (special handling for "cvs added" and "cvs removed" resources
- new PrepareForReplaceVisitor().visitResources(getProject(), resources, "CVSTeamProvider.scrubbingResource", depth, Policy.subMonitorFor(progress, 30)); //$NON-NLS-1$
-
- // Perform an update, ignoring any local file modifications
- List options = new ArrayList();
- options.add(Update.IGNORE_LOCAL_CHANGES);
- if(depth != IResource.DEPTH_INFINITE) {
- options.add(Command.DO_NOT_RECURSE);
- }
- LocalOption[] commandOptions = (LocalOption[]) options.toArray(new LocalOption[options.size()]);
- update(resources, commandOptions, tag, true /*createBackups*/, Policy.subMonitorFor(progress, 70));
- } finally {
- progress.done();
- }
- }
-
- /**
- * Return the remote location to which the receiver's project is mapped.
- */
- public ICVSRepositoryLocation getRemoteLocation() throws CVSException {
- try {
- return workspaceRoot.getRemoteLocation();
- } catch (CVSException e) {
- // If we can't get the remote location, we should disconnect since nothing can be done with the provider
- try {
- Team.removeNatureFromProject(project, CVSProviderPlugin.getTypeId(), Policy.monitorFor(null));
- } catch (TeamException ex) {
- CVSProviderPlugin.log(ex);
- }
- // We need to trigger a decorator refresh
- throw e;
- }
- }
-
- /**
- * @see ITeamProvider#hasRemote(IResource)
- * XXX to be removed when sync methods are removed from ITeamProvider
- */
- public boolean hasRemote(IResource resource) {
- try {
- ICVSResource cvsResource = workspaceRoot.getCVSResourceFor(resource);
- int type = resource.getType();
- if(type!=IResource.FILE) {
- if(type==IResource.PROJECT) {
- return ((ICVSFolder)cvsResource).isCVSFolder();
- } else {
- return cvsResource.isManaged();
- }
- } else {
- ResourceSyncInfo info = cvsResource.getSyncInfo();
- if(info!=null) {
- return !info.isAdded();
- } else {
- return false;
- }
- }
- } catch(CVSException e) {
- return false;
- }
- }
-
- /**
- * @see ITeamProvider#isLocallyCheckedOut(IResource)
- * XXX to be removed when sync methods are removed from ITeamProvider
- */
- public boolean isCheckedOut(IResource resource) {
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- return cvsResource.isManaged();
- }
-
- /*
- * Use specialiazed tagging to move all local changes (including additions and
- * deletions) to the specified branch.
- */
- public void makeBranch(IResource[] resources, CVSTag versionTag, CVSTag branchTag, boolean moveToBranch, boolean eclipseWay, IProgressMonitor monitor) throws TeamException {
-
- // Determine the total amount of work
- int totalWork = 10 + (versionTag!= null ? 60 : 40) + (moveToBranch ? 20 : 0);
- monitor.beginTask(Policy.bind("CVSTeamProvider.makeBranch"), totalWork); //$NON-NLS-1$
- try {
-
- // Determine which tag command to used depending on whether the Eclipse specific
- // method of branching is requested
- Tag tagCommand = Command.TAG;
- if (eclipseWay) {
- tagCommand = Command.CUSTOM_TAG;
- }
-
- // Build the arguments list
- String[] arguments = getValidArguments(resources, Command.NO_LOCAL_OPTIONS);
-
- // Tag the remote resources
- Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
- try {
- s.open(Policy.subMonitorFor(monitor, 10));
-
- IStatus status;
- if (versionTag != null) {
- // Version using tag and braqnch using rtag
- status = tagCommand.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- versionTag,
- arguments,
- null,
- Policy.subMonitorFor(monitor, 40));
- if (status.getCode() != CVSStatus.SERVER_ERROR) {
- // XXX Could use RTAG here when it works
- status = tagCommand.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- branchTag,
- arguments,
- null,
- Policy.subMonitorFor(monitor, 20));
- }
- } else {
- // Just branch using tag
- status = tagCommand.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- branchTag,
- arguments,
- null,
- Policy.subMonitorFor(monitor, 40));
-
- }
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- s.close();
- }
-
- // Set the tag of the local resources to the branch tag (The update command will not
- // properly update "cvs added" and "cvs removed" resources so a custom visitor is used
- if (moveToBranch) {
- if (eclipseWay) {
- setTag(resources, branchTag, Policy.subMonitorFor(monitor, 20));
- } else {
- update(resources, Command.NO_LOCAL_OPTIONS, branchTag, true /*createBackups*/, Policy.subMonitorFor(monitor, 20));
- }
- }
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Update the sync info of the local resource associated with the sync element such that
- * the revision of the local resource matches that of the remote resource.
- * This will allow commits on the local resource to succeed.
- *
- * Only file resources can be merged.
- */
- public void merged(IRemoteSyncElement[] elements) throws TeamException {
- for (int i=0;i<elements.length;i++) {
- ((CVSRemoteSyncElement)elements[i]).makeOutgoing(Policy.monitorFor(null));
- }
- }
-
- /**
- * @see ITeamProvider#move(IResource, IPath, IProgressMonitor)
- */
- public void moved(IPath source, IResource resource, IProgressMonitor progress) throws TeamException {
- }
-
- /**
- * Set the comment to be used on the next checkin
- */
- public void setComment(String comment) {
- this.comment = comment;
- }
-
- /**
- * Set the connection method for the given resource's
- * project. If the conection method name is invalid (i.e.
- * no corresponding registered connection method), false is returned.
- */
- public boolean setConnectionInfo(IResource resource, String methodName, IUserInfo userInfo, IProgressMonitor monitor) throws TeamException {
- checkIsChild(resource);
- try {
- monitor.beginTask(Policy.bind("CVSTeamProvider.connectionInfo", project.getName()), 100); //$NON-NLS-1$
-
- if (!CVSRepositoryLocation.validateConnectionMethod(methodName))
- return false;
-
- // Get the original location
- ICVSRepositoryLocation location = workspaceRoot.getRemoteLocation();
-
- // Make a copy to work on
- CVSRepositoryLocation newLocation = CVSRepositoryLocation.fromString(location.getLocation());
- newLocation.setMethod(methodName);
- newLocation.setUserInfo(userInfo);
-
- // Validate that a connection can be made with the new location
- try {
- newLocation.validateConnection(Policy.subMonitorFor(monitor, 20));
- } catch (CVSException e) {
- // XXX We should really only do this if it didn't exist previously
- CVSProviderPlugin.getProvider().disposeRepository(newLocation);
- throw e;
- }
-
- // Add the location to the provider
- CVSProvider.getInstance().addRepository(newLocation);
-
- // Set the project to use the new Locations
- setRemoteRoot(newLocation, Policy.subMonitorFor(monitor, 80));
- return true;
- } finally {
- monitor.done();
- }
- }
-
- /*
- * This method sets the tag for a project.
- * It expects to be passed an InfiniteSubProgressMonitor
- */
- private void setTag(final IResource[] resources, final CVSTag tag, IProgressMonitor monitor) throws TeamException {
-
- workspaceRoot.getLocalRoot().run(new ICVSRunnable() {
- public void run(IProgressMonitor progress) throws CVSException {
- try {
- // 512 ticks gives us a maximum of 2048 which seems reasonable for folders and files in a project
- progress.beginTask(null, 100);
- final IProgressMonitor monitor = Policy.infiniteSubMonitorFor(progress, 100);
- monitor.beginTask(Policy.bind("CVSTeamProvider.folderInfo", project.getName()), 512); //$NON-NLS-1$
-
- // Visit all the children folders in order to set the root in the folder sync info
- for (int i = 0; i < resources.length; i++) {
- CVSWorkspaceRoot.getCVSResourceFor(resources[i]).accept(new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {
- monitor.worked(1);
- ResourceSyncInfo info = file.getSyncInfo();
- if (info != null) {
- monitor.subTask(Policy.bind("CVSTeamProvider.updatingFile", info.getName())); //$NON-NLS-1$
- MutableResourceSyncInfo newInfo = info.cloneMutable();
- newInfo.setTag(tag);
- file.setSyncInfo(newInfo);
- }
- };
- public void visitFolder(ICVSFolder folder) throws CVSException {
- monitor.worked(1);
- FolderSyncInfo info = folder.getFolderSyncInfo();
- if (info != null) {
- monitor.subTask(Policy.bind("CVSTeamProvider.updatingFolder", info.getRepository())); //$NON-NLS-1$
- folder.setFolderSyncInfo(new FolderSyncInfo(info.getRepository(), info.getRoot(), tag, info.getIsStatic()));
- folder.acceptChildren(this);
- }
- };
- });
- }
- } finally {
- progress.done();
- }
- }
- }, monitor);
- }
-
- /**
- * Tag the resources in the CVS repository with the given tag.
- *
- * The returned IStatus will be a status containing any errors or warnings.
- * If the returned IStatus is a multi-status, the code indicates the severity.
- * Possible codes are:
- * CVSStatus.OK - Nothing to report
- * CVSStatus.SERVER_ERROR - The server reported an error
- * any other code - warning messages received from the server
- */
- public IStatus tag(IResource[] resources, int depth, CVSTag tag, IProgressMonitor progress) {
-
- // Build the local options
- List localOptions = new ArrayList();
- // If the depth is not infinite, we want the -l option
- if (depth != IResource.DEPTH_INFINITE)
- localOptions.add(Tag.DO_NOT_RECURSE);
- LocalOption[] commandOptions = (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]);
-
- IStatus status;
- try {
- // Build the arguments list
- String[] arguments = getValidArguments(resources, commandOptions);
-
- Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
- progress.beginTask(null, 100);
- try {
- // Opening the session takes 20% of the time
- s.open(Policy.subMonitorFor(progress, 20));
- status = Command.TAG.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- commandOptions,
- tag,
- arguments,
- null,
- Policy.subMonitorFor(progress, 80));
- } finally {
- s.close();
- progress.done();
- }
- } catch(CVSException e) {
- status = e.getStatus();
- }
- return status;
- }
-
- /**
- * Currently, we support only the optimistic model so uncheckout dores nothing.
- *
- * @see ITeamProvider#uncheckout(IResource[], int, IProgressMonitor)
- */
- public void uncheckout(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException {
- }
-
- /**
- * Generally useful update.
- *
- * The tag parameter determines any stickyness after the update is run. If tag is null, any tagging on the
- * resources being updated remain the same. If the tag is a branch, version or date tag, then the resources
- * will be appropriatly tagged. If the tag is HEAD, then there will be no tag on the resources (same as -A
- * clear sticky option).
- *
- * @param createBackups if true, creates .# files for updated files
- */
- public void update(IResource[] resources, LocalOption[] options, CVSTag tag, boolean createBackups, IProgressMonitor progress) throws TeamException {
- // Build the local options
- List localOptions = new ArrayList();
-
- // Use the appropriate tag options
- if (tag != null) {
- localOptions.add(Update.makeTagOption(tag));
- }
-
- // Build the arguments list
- localOptions.addAll(Arrays.asList(options));
- LocalOption[] commandOptions = (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]);
- String[] arguments = getValidArguments(resources, commandOptions);
-
- IStatus status;
- Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
- progress.beginTask(null, 100);
- try {
- // Opening the session takes 20% of the time
- s.open(Policy.subMonitorFor(progress, 20));
- status = Command.UPDATE.execute(s, Command.NO_GLOBAL_OPTIONS, commandOptions, arguments,
- null, Policy.subMonitorFor(progress, 80), createBackups);
- } finally {
- progress.done();
- s.close();
- }
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- // XXX diff errors??
- throw new CVSServerException(status);
- }
- }
-
- public static String getMessageFor(Exception e) {
- String message = Policy.bind(e.getClass().getName(), new Object[] {e.getMessage()});
- if (message.equals(e.getClass().getName()))
- message = Policy.bind("CVSTeamProvider.exception", new Object[] {e.toString()}); //$NON-NLS-1$
- return message;
- }
-
-
- /*
- * @see ITeamProvider#refreshState(IResource[], int, IProgressMonitor)
- */
- public void refreshState(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException {
- Assert.isTrue(false);
- }
- /*
- * @see ITeamProvider#isOutOfDate(IResource)
- * XXX to be removed when sync methods are removed from ITeamProvider
- */
- public boolean isOutOfDate(IResource resource) {
- Assert.isTrue(false);
- return false;
- }
-
- /*
- * @see ITeamProvider#isDirty(IResource)
- */
- public boolean isDirty(IResource resource) {
- Assert.isTrue(false);
- return false;
- }
-
- public CVSWorkspaceRoot getCVSWorkspaceRoot() {
- return workspaceRoot;
- }
-
- /*
- * Generate an exception if the resource is not a child of the project
- */
- private void checkIsChild(IResource resource) throws CVSException {
- if (!isChildResource(resource))
- throw new CVSException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE,
- Policy.bind("CVSTeamProvider.invalidResource", //$NON-NLS-1$
- new Object[] {resource.getFullPath().toString(), project.getName()}),
- null));
- }
-
- /*
- * Get the arguments to be passed to a commit or update
- */
- private String[] getValidArguments(IResource[] resources, LocalOption[] options) throws CVSException {
- List arguments = new ArrayList(resources.length);
- for (int i=0;i<resources.length;i++) {
- checkIsChild(resources[i]);
- IPath cvsPath = resources[i].getFullPath().removeFirstSegments(1);
- if (cvsPath.segmentCount() == 0) {
- arguments.add(Session.CURRENT_LOCAL_FOLDER);
- } else {
- arguments.add(cvsPath.toString());
- }
- }
- return (String[])arguments.toArray(new String[arguments.size()]);
- }
-
- /*
- * This method expects to be passed an InfiniteSubProgressMonitor
- */
- public void setRemoteRoot(ICVSRepositoryLocation location, IProgressMonitor monitor) throws TeamException {
-
- // Check if there is a differnece between the new and old roots
- final String root = location.getLocation();
- if (root.equals(workspaceRoot.getRemoteLocation()))
- return;
-
- try {
- workspaceRoot.getLocalRoot().run(new ICVSRunnable() {
- public void run(IProgressMonitor progress) throws CVSException {
- try {
- // 256 ticks gives us a maximum of 1024 which seems reasonable for folders is a project
- progress.beginTask(null, 100);
- final IProgressMonitor monitor = Policy.infiniteSubMonitorFor(progress, 100);
- monitor.beginTask(Policy.bind("CVSTeamProvider.folderInfo", project.getName()), 256); //$NON-NLS-1$
-
- // Visit all the children folders in order to set the root in the folder sync info
- workspaceRoot.getLocalRoot().accept(new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {};
- public void visitFolder(ICVSFolder folder) throws CVSException {
- monitor.worked(1);
- FolderSyncInfo info = folder.getFolderSyncInfo();
- if (info != null) {
- monitor.subTask(Policy.bind("CVSTeamProvider.updatingFolder", info.getRepository())); //$NON-NLS-1$
- folder.setFolderSyncInfo(new FolderSyncInfo(info.getRepository(), root, info.getTag(), info.getIsStatic()));
- folder.acceptChildren(this);
- }
- };
- });
- } finally {
- progress.done();
- }
- }
- }, monitor);
- } finally {
- monitor.done();
- }
- }
-
- /*
- * Helper to indicate if the resource is a child of the receiver's project
- */
- private boolean isChildResource(IResource resource) {
- return resource.getProject().getName().equals(project.getName());
- }
-
- private static TeamException wrapException(CoreException e) {
- return new TeamException(statusFor(e));
- }
-
- private static IStatus statusFor(CoreException e) {
- // We should be taking out any status from the CVSException
- // and creating an array of IStatus!
- return new Status(IStatus.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, getMessageFor(e), e);
- }
-
- public void configureProject() throws CoreException {
- CVSProviderPlugin.broadcastProjectConfigured(getProject());
- }
- /**
- * Sets the keyword substitution mode for the specified resources.
- * <p>
- * Applies the following rules in order:<br>
- * <ul>
- * <li>If a file is not managed, skips it.</li>
- * <li>If a file is not changing modes, skips it.</li>
- * <li>If a file is being changed from binary to text, corrects line delimiters
- * then commits it, then admins it.</li>
- * <li>If a file is added, changes the resource sync information locally.</li>
- * <li>Otherwise commits the file (with FORCE to create a new revision), then admins it.</li>
- * </ul>
- * All files that are admin'd are committed with FORCE to prevent other developers from
- * casually trying to commit pending changes to the repository without first checking out
- * a new copy. This is not a perfect solution, as they could just as easily do an UPDATE
- * and not obtain the new keyword sync info.
- * </p>
- *
- * @param changeSet a map from IFile to KSubstOption
- * @param monitor the progress monitor
- * @return a status code indicating success or failure of the operation
- *
- * @throws TeamException
- */
- public IStatus setKeywordSubstitution(final Map /* from IFile to KSubstOption */ changeSet,
- IProgressMonitor monitor) throws TeamException {
- final IStatus[] result = new IStatus[] { ICommandOutputListener.OK };
- workspaceRoot.getLocalRoot().run(new ICVSRunnable() {
- public void run(final IProgressMonitor monitor) throws CVSException {
- final Map /* from KSubstOption to List of String */ filesToAdmin = new HashMap();
- final List /* of String */ filesToCommit = new ArrayList();
- final Collection /* of ICVSFile */ filesToCommitAsText = new HashSet(); // need fast lookup
-
- /*** determine the resources to be committed and/or admin'd ***/
- for (Iterator it = changeSet.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- IFile file = (IFile) entry.getKey();
- KSubstOption toKSubst = (KSubstOption) entry.getValue();
-
- // only set keyword substitution if resource is a managed file
- checkIsChild(file);
- ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor(file);
- if (! mFile.isManaged()) continue;
-
- // only set keyword substitution if new differs from actual
- ResourceSyncInfo info = mFile.getSyncInfo();
- KSubstOption fromKSubst = info.getKeywordMode();
- if (toKSubst.equals(fromKSubst)) continue;
-
- // change resource sync info immediately for an outgoing addition
- if (info.isAdded()) {
- MutableResourceSyncInfo newInfo = info.cloneMutable();
- newInfo.setKeywordMode(toKSubst);
- mFile.setSyncInfo(newInfo);
- continue;
- }
-
- // nothing do to for deletions
- if (info.isDeleted()) continue;
-
- // file exists remotely so we'll have to commit it
- String remotePath = mFile.getRelativePath(workspaceRoot.getLocalRoot());
- if (fromKSubst.isBinary() && ! toKSubst.isBinary()) {
- // converting from binary to text
- cleanLineDelimiters(file, IS_CRLF_PLATFORM, new NullProgressMonitor()); // XXX need better progress monitoring
- // remember to commit the cleaned resource as text before admin
- filesToCommitAsText.add(mFile);
- }
- // force a commit to bump the revision number
- makeDirty(file);
- filesToCommit.add(remotePath);
- // remember to admin the resource
- List list = (List) filesToAdmin.get(toKSubst);
- if (list == null) {
- list = new ArrayList();
- filesToAdmin.put(toKSubst, list);
- }
- list.add(remotePath);
- }
-
- /*** commit then admin the resources ***/
- // compute the total work to be performed
- int totalWork = filesToCommit.size();
- for (Iterator it = filesToAdmin.values().iterator(); it.hasNext();) {
- List list = (List) it.next();
- totalWork += list.size();
- }
- if (totalWork != 0) {
- Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
- monitor.beginTask(Policy.bind("CVSTeamProvider.settingKSubst"), 5 + totalWork); //$NON-NLS-1$
- try {
- s.open(Policy.subMonitorFor(monitor, 5));
-
- // commit files that changed from binary to text
- // NOTE: The files are committed as text with conversions even if the
- // resource sync info still says "binary".
- if (filesToCommit.size() != 0) {
- s.setTextTransferOverride(filesToCommitAsText);
- result[0] = Command.COMMIT.execute(s, Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] { Commit.DO_NOT_RECURSE, Commit.FORCE,
- Commit.makeArgumentOption(Command.MESSAGE_OPTION, comment) },
- (String[]) filesToCommit.toArray(new String[filesToCommit.size()]),
- null, Policy.subMonitorFor(monitor, filesToCommit.size()));
- s.setTextTransferOverride(null);
- // if errors were encountered, abort
- if (! result[0].isOK()) return;
- }
-
- // admin files that changed keyword substitution mode
- // NOTE: As confirmation of the completion of a command, the server replies
- // with the RCS command output if a change took place. Rather than
- // assume that the command succeeded, we listen for these lines
- // and update the local ResourceSyncInfo for the particular files that
- // were actually changed remotely.
- for (Iterator it = filesToAdmin.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- KSubstOption toKSubst = (KSubstOption) entry.getKey();
- List list = (List) entry.getValue();
- // do it
- result[0] = Command.ADMIN.execute(s, Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] { toKSubst },
- (String[]) list.toArray(new String[list.size()]),
- new AdminKSubstListener(toKSubst),
- Policy.subMonitorFor(monitor, list.size()));
- // if errors were encountered, abort
- if (! result[0].isOK()) return;
- }
- } finally {
- s.close();
- monitor.done();
- }
- }
- }
- }, Policy.monitorFor(monitor));
- return result[0];
- }
-
- /**
- * Fixes the line delimiters in the local file to reflect the platform's
- * native encoding. Performs CR/LF -> LF or LF -> CR/LF conversion
- * depending on the platform but does not affect delimiters that are
- * already correctly encoded.
- */
- public static void cleanLineDelimiters(IFile file, boolean useCRLF, IProgressMonitor progress)
- throws CVSException {
- try {
- // convert delimiters in memory
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- InputStream is = new BufferedInputStream(file.getContents());
- try {
- is = new CRLFtoLFInputStream(is);
- if (useCRLF) is = new LFtoCRLFInputStream(is);
- for (int b; (b = is.read()) != -1;) bos.write(b);
- bos.close();
- } finally {
- is.close();
- }
- // write file back to disk with corrected delimiters if changes were made
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- file.setContents(bis, false /*force*/, false /*keepHistory*/, progress);
- } catch (CoreException e) {
- throw CVSException.wrapException(file, Policy.bind("CVSTeamProvider.cleanLineDelimitersException"), e); //$NON-NLS-1$
- } catch (IOException e) {
- throw CVSException.wrapException(file, Policy.bind("CVSTeamProvider.cleanLineDelimitersException"), e); //$NON-NLS-1$
- }
- }
-
- /*
- * Marks a file as dirty.
- */
- private static void makeDirty(IFile file) throws CVSException {
- ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor(file);
- mFile.setTimeStamp(null /*set the timestamp to current time*/);
- }
-
- /*
- * @see RepositoryProvider#getID()
- */
- public String getID() {
- return CVSProviderPlugin.getTypeId();
- }
-
- /*
- * @see RepositoryProvider#getMoveDeleteHook()
- */
- public IMoveDeleteHook getMoveDeleteHook() {
- return moveDeleteHook;
- }
-
- /*
- * Return the currently registered Move/Delete Hook
- */
- public static IMoveDeleteHook getRegisteredMoveDeleteHook() {
- return moveDeleteHook;
- }
-
- /*
- * Set the Move/Delete hook of the CVS Team Provider. This is for internal use by CVS only.
- * It is not to be used by other clients
- */
- public static void setMoveDeleteHook(IMoveDeleteHook hook) {
- moveDeleteHook = hook;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/DateUtil.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/DateUtil.java
deleted file mode 100644
index c49174fb5..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/DateUtil.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone;
-
-/**
- * Utilities to handle time stamps in a cvs client.
- */
-public class DateUtil {
-
- private static final String ENTRY_TIMESTAMP_FORMAT= "EEE MMM dd HH:mm:ss yyyy";//$NON-NLS-1$
- private static final String ENTRY_TIMESTAMP_TIME_ZONE= "GMT";//$NON-NLS-1$
- private static final Locale ENTRY_TIMESTAMP_LOCALE= Locale.US;
-
- private static final String MODTIME_TIMESTAMP_FORMAT= "dd MMM yyyy HH:mm:ss zz";//$NON-NLS-1$
- private static final Locale MODTIME_TIMESTAMP_LOCALE= Locale.US;
-
- 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 static final String HISTORY_TIMESTAMP_FORMAT= "yyyy-MM-dd HH:mm zzzz";//$NON-NLS-1$
- private static final Locale HISTORY_TIMESTAMP_LOCALE= Locale.US;
-
- /**
- * Converts a time stamp as sent from a cvs server for a "log" command into a
- * <code>Date</code>.
- */
- public static Date convertFromLogTime(String modTime) {
- SimpleDateFormat format= new SimpleDateFormat(LOG_TIMESTAMP_FORMAT,
- LOG_TIMESTAMP_LOCALE);
- try {
- return format.parse(modTime);
- } catch (ParseException e) {
- // fallback is to return null
- return null;
- }
- }
- /**
- * Converts a modifcation time stamp as send from a cvs server into a
- * <code>Date</code>. The format of the modification time stamp is defined
- * in the document CVS Client/Server for CVS 1.11 section 5.6 Dates
- */
- public static Date convertFromModTime(String modTime) {
- SimpleDateFormat format= new SimpleDateFormat(MODTIME_TIMESTAMP_FORMAT,
- MODTIME_TIMESTAMP_LOCALE);
- try {
- return format.parse(modTime);
- } catch (ParseException e) {
- // fallback is to return null
- return null;
- }
- }
- /**
- * Converts a history time stamp as sent from a cvs server into a
- * <code>Date</code>.
- */
- public static Date convertFromHistoryTime(String historyTime) {
- SimpleDateFormat format= new SimpleDateFormat(HISTORY_TIMESTAMP_FORMAT,
- HISTORY_TIMESTAMP_LOCALE);
- try {
- return format.parse(historyTime);
- } catch (ParseException e) {
- // fallback is to return null
- return null;
- }
- }
- /**
- * Converts a date into an entry time format as specified in the document
- * Version Management with CVS for CVS 1.10.6 page 14. Note that the
- * time format is always in GMT also not specified in the document.
- */
- public static String toEntryFormat(Date date) {
- SimpleDateFormat format= new SimpleDateFormat(ENTRY_TIMESTAMP_FORMAT,
- ENTRY_TIMESTAMP_LOCALE);
- format.setTimeZone(TimeZone.getTimeZone(ENTRY_TIMESTAMP_TIME_ZONE));
- return format.format(date);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
deleted file mode 100644
index 3e5508e41..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.InputStream;
-import java.util.Date;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-
-/**
- * The CVS analog of a file. CVS files have access to synchronization information
- * that describes their association with the CVS repository. CVS files also provide
- * mechanisms for sending and receiving content.
- *
- * @see ICVSResource
- */
-public interface ICVSFile extends ICVSResource {
-
- // Constants used to indicate the type of updated response from the server
- public static final int UPDATED = 1;
- public static final int MERGED = 2;
- public static final int UPDATE_EXISTING = 3;
- public static final int CREATED = 4;
-
- /**
- * Answers the size of the file.
- */
- long getSize();
-
- /**
- * Gets an input stream for reading from the file.
- * It is the responsibility of the caller to close the stream when finished.
- */
- InputStream getContents() throws CVSException;
-
- /**
- * Set the contents of the file to the contents of the provided input stream
- *
- * @param responseType the type of reponse that was received from the server
- *
- * UPDATED - could be a new file or an existing file
- * MERGED - merging remote changes with local changes. Failure could result in loss of local changes
- * CREATED - contents for a file that doesn't exist locally
- * UPDATE_EXISTING - Replacing a local file with no local changes with remote changes.
- */
- public void setContents(InputStream stream, int responseType, boolean keepLocalHistory, IProgressMonitor monitor) throws CVSException;
-
- /**
- * Sets the file's read-only permission.
- */
- void setReadOnly(boolean readOnly) throws CVSException;
-
- /**
- * Answers if the file is read-only.
- */
- boolean isReadOnly() throws CVSException;
-
- /**
- * Move the resource to another location. Does overwrite without
- * promting.
- */
- void copyTo(String filename) throws CVSException;
-
- /**
- * Answers the current timestamp for this file with second precision.
- */
- Date getTimeStamp();
-
- /**
- * If the date is <code>null</code> then the current time is used.
- */
- void setTimeStamp(Date date) throws CVSException;
-
- /**
- * Answers <code>true</code> if the file has changed since it was last updated
- * from the repository, if the file does not exist, or is not managed. And <code>false</code>
- * if it has not changed.
- */
- boolean isModified() throws CVSException;
-
- /**
- * Answers the revision history for this file. This is similar to the
- * output of the log command.
- */
- public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws TeamException;
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java
deleted file mode 100644
index 9eb204404..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java
+++ /dev/null
@@ -1,154 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-
-/**
- * The CVS analog of a directory. CVS folders have access to synchronization information
- * that describes the association between the folder and the remote repository.
- *
- * @see ICVSResource
- * @see ICVSFile
- */
-public interface ICVSFolder extends ICVSResource {
-
- public static final int FILE_MEMBERS = 1;
- public static final int FOLDER_MEMBERS = 2;
- public static final int IGNORED_MEMBERS = 4;
- public static final int UNMANAGED_MEMBERS = 8;
- public static final int MANAGED_MEMBERS = 16;
- public static final int ALL_MEMBERS = FILE_MEMBERS | FOLDER_MEMBERS | IGNORED_MEMBERS | UNMANAGED_MEMBERS | MANAGED_MEMBERS;
-
- /**
- * Answers and array of <code>ICVSResource</code> elements that are immediate
- * children of this remote resource, in no particular order. The server may be contacted.
- *
- * @param monitor a progress monitor to indicate the duration of the operation, or
- * <code>null</code> if progress reporting is not required.
- *
- * @return array of immediate children of this remote resource.
- */
- public ICVSResource[] fetchChildren(IProgressMonitor monitor) throws CVSException;
-
- /**
- * Answer the immediate children of the resource that are known
- * at the time of invocation. The server is never contacted.
- * The flags indicate the type of members to be included.
- * Here are the rules for specifying just one flag:
- *
- * a) FILE_MEMBERS and FOLDER_MEMBERS will return managed
- * and unmanaged resource of the corresponding type
- * b) IGNORED_MEMBERS, MANAGED_RESOURCES and UNMANAGED_RESOURCES
- * will return files and folders of the given type
- *
- * Note: Unmanaged resources are those tat are neither managed
- * or ignored.
- *
- * If all of the flags from either group a) or group b)
- * are not present, the same rule for default types applies.
- * For example,
- * - FILE_MEMBERS | FOLDER_MEMBERS will return all managed
- * and unmanaged files and folders.
- * - IGNORED_MEMBERS | UNMANAGED_MEMBERS will return all
- * ignored or unmanaged files and folders
- * If a flag from each group is present, the result is the
- * union of the sets. For example,
- * - FILE_MEMBERS | IGNORED_MEMBERS will return all
- * ignored files.
- */
- public ICVSResource[] members(int flags) throws CVSException;
-
- /**
- * Answers a child folder of this resource with the given name or <code>null</code> if
- * the given folder does not have a child with that name.
- */
- public ICVSFolder getFolder(String name) throws CVSException;
-
- /**
- * Answers a child file of this resource with the given name or <code>null</code> if
- * the given folder does not have a child with that name.
- */
- public ICVSFile getFile(String name) throws CVSException;
-
- /**
- * Return the child resource at the given path relative to
- * the receiver.
- */
- public ICVSResource getChild(String path) throws CVSException;
-
- /**
- * Create the folder if it did not exist before. Does only
- * work if the direct subfolder did exist.
- *
- * @throws CVSException if for some reason it was not possible to create the folder
- */
- public void mkdir() throws CVSException;
-
- /**
- * Answers the folder's synchronization information or <code>null</code> if the folder
- * is not a CVS folder.
- * <p>
- * To modify the folder sync info the caller must call <code>setFolderSyncInfo</code> with
- * new sync information.</p>
- */
- public FolderSyncInfo getFolderSyncInfo() throws CVSException;
-
- /**
- * Set the folder sync information for this folder. Setting the folder information
- * to <code>null</code> is not supported. The only mechanism for removing an existing
- * CVS folder is to delete the resource.
- */
- public void setFolderSyncInfo(FolderSyncInfo folderInfo) throws CVSException;
-
- /**
- * Accepts the visitor on all files and all subFolder in the folder. Files are
- * visited first, then all the folders..
- */
- public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException;
-
- /**
- * Answers <code>true</code> if the folder has valid CVS synchronization information and
- * <code>false</code> otherwise.
- *
- * Note: This method does not throw an exception so this method does not differentiate
- * between a folder not be shared with CVS and a folder that is shared but whose sync info has
- * become corrupt. Use getFolderSyncInfo() to differentiate between these situations.
- *
- * Also Note: A folder that is a CVS folder may not exist in the workspace. The purpose of
- * such a folder is to act as a remotely existing folder that does not exist locally.
- * This is normally done in order to remember outgoing file deletions when a parent
- * folder is deleted.
- * Creating the folder will result in a folder that is mapped to a remote folder.
- */
- public boolean isCVSFolder();
-
- /**
- * Runs the given action as an atomic cvs local workspace operation
- * rooted at this cvs folder.
- * <p>
- * After running a method that modifies cvs resource state in the
- * local workspace, registered listeners receive after-the-fact
- * notification in the form of a resource state change event. In addition,
- * any resource state information persistance is batched.
- * This method allows clients to call a number of
- * methods that modify resources and only have resource
- * change event notifications reported at the end of the entire
- * batch.
- * </p>
- * <p>
- * If this method is called in the dynamic scope of another such
- * call, this method simply runs the action.
- * </p>
- *
- * @param action the action to perform
- * @param monitor a progress monitor, or <code>null</code> if progress
- * reporting and cancellation are not desired
- * @exception CVSException if the operation failed.
- */
- public void run(ICVSRunnable job, IProgressMonitor monitor) throws CVSException;
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSListener.java
deleted file mode 100644
index fa957c20d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSListener.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-
-public interface ICVSListener {
- public void repositoryAdded(ICVSRepositoryLocation root);
- public void repositoryRemoved(ICVSRepositoryLocation root);
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSProvider.java
deleted file mode 100644
index fa76e2d6b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSProvider.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.io.PrintStream;
-import java.util.Properties;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-
-/**
- * The ICVSProvider interface provides access to CVS operations that create repository locations,
- * support retrieval of repository information and import and checkout CVS modules
- */
-public interface ICVSProvider {
-
- /**
- * Register to receive notification of repository creation and disposal
- */
- public void addRepositoryListener(ICVSListener listener);
-
- /**
- * De-register a listener
- */
- public void removeRepositoryListener(ICVSListener listener);
-
- /**
- * Checkout a CVS module.
- *
- * The provided project represents the target project. Any existing contents
- * may or may not get overwritten. If project is <code>null</code> then a project
- * will be created based on the provided sourceModule. If soureModule is null,
- * then the project name will be used as the module to
- * check out. If both are absent, an exception is thrown.
- *
- * Resources existing in the local file system at the target project location but now
- * known to the workbench will be overwritten.
- *
- * After the successful completion of this method, the project will exist
- * and be open.
- */
- public void checkout(ICVSRepositoryLocation repository, IProject project, String sourceModule, CVSTag tag, IProgressMonitor monitor) throws TeamException;
-
- /**
- * Checkout the remote resources into the local workspace. Each resource will
- * be checked out into the corresponding project. If the corresponding project is
- * null or if projects is null, the name of the remote resource is used as the name of the project.
- *
- * Resources existing in the local file system at the target project location but now
- * known to the workbench will be overwritten.
- */
- public void checkout(ICVSRemoteFolder[] resources, IProject[] projects, IProgressMonitor monitor) throws TeamException;
-
- /**
- * Create a remote module in the CVS repository and link the project directory to this remote module.
- * The contents of the project are not imported.
- *
- * Consideration: What if the project already exists?
- */
- public void createModule(ICVSRepositoryLocation location, IProject project, String moduleName, IProgressMonitor monitor) throws TeamException;
-
- /**
- * Create a repository instance from the given properties.
- * The supported properties are:
- *
- * connection The connection method to be used
- * user The username for the connection
- * password The password used for the connection (optional)
- * host The host where the repository resides
- * port The port to connect to (optional)
- * root The server directory where the repository is located
- *
- * The created instance is not known by the provider and it's user information is not cached.
- * The purpose of the created location is to allow connection validation before adding the
- * location to the provider.
- *
- * This method will throw a CVSException if the location for the given configuration already
- * exists.
- */
- public ICVSRepositoryLocation createRepository(Properties configuration) throws CVSException;
-
- /**
- * Add the repository to the receiver's list of known repositories. Doing this will enable
- * password caching accross platform invokations.
- */
- public void addRepository(ICVSRepositoryLocation repository) throws CVSException;
-
- /**
- * Dispose of the repository location
- *
- * Removes any cached information about the repository such as a remembered password.
- */
- public void disposeRepository(ICVSRepositoryLocation repository) throws CVSException;
-
- /**
- * Answer whether the provided repository location is known by the provider or not.
- * The location string corresponds to the Strin returned by ICVSRepositoryLocation#getLocation()
- */
- public boolean isKnownRepository(String location);
-
- /**
- * Answer the list of directories that a checkout of the given resources would expand to.
- * In other words, the returned strings represent the root paths that the given resources would
- * be loaded into.
- */
- public String[] getExpansions(ICVSRemoteFolder[] resources, IProgressMonitor monitor) throws CVSException;
-
- /**
- * Return a list of the know repository locations
- */
- public ICVSRepositoryLocation[] getKnownRepositories();
-
- /**
- * Get the repository instance which matches the given String. The format of the String is
- * the same as that returned by ICVSRepositoryLocation#getLocation().
- * The format is:
- *
- * connection:user[:password]@host[#port]:root
- *
- * where [] indicates optional and the identier meanings are:
- *
- * connection The connection method to be used
- * user The username for the connection
- * password The password used for the connection (optional)
- * host The host where the repository resides
- * port The port to connect to (optional)
- * root The server directory where the repository is located
- *
- * It is expected that the instance requested by using this method exists.
- * If the repository location does not exist, it will be automatically created
- * and cached with the provider.
- *
- * WARNING: Providing the password as part of the String will result in the password being part
- * of the location permanently. This means that it cannot be modified by the authenticator.
- */
- public ICVSRepositoryLocation getRepository(String location) throws CVSException;
-
- /**
- * Set the sharing for a project to enable it to be used with the CVSTeamProvider.
- * This method only sets the folder sync info for the project folder and the info
- * is only set to the provided parameters if there is no sync info already.
- */
- public void setSharing(IProject project, FolderSyncInfo info, IProgressMonitor monitor) throws TeamException;
-
- /**
- * Get the names of the registered connection methods.
- */
- public String[] getSupportedConnectionMethods();
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java
deleted file mode 100644
index ffe7fcab7..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.InputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-
- /**
- * This interface represents a file in a repository.
- * Instances of this interface can be used to fetch the contents
- * of the remote file.
- *
- * In the future, additional information should be available (tags, revisions, etc.)
- *
- * Clients are not expected to implement this interface.
- */
-public interface ICVSRemoteFile extends ICVSRemoteResource, ICVSFile {
-
- /**
- * Get the log entry for the revision the remote file represents.
- * This method will return null until after the getContents(IProgressMonitor)
- * method is called (i.e. the call to getContents also fetches the entry.
- */
- public ILogEntry getLogEntry(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Get all the log entries of the remote file
- */
- public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Get the revision of the remote file (e.g. 1.1)
- *
- * The revision depends on any tagging associated with the remote parent used
- * to access the file.
- */
- public String getRevision() throws TeamException;
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java
deleted file mode 100644
index 75ae8ffb2..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-
- /**
- * This interface represents a remote folder in a repository. It provides
- * access to the members (remote files and folders) of a remote folder
- *
- * Clients are not expected to implement this interface.
- */
-public interface ICVSRemoteFolder extends ICVSRemoteResource, ICVSFolder {
-
- /**
- * Allows a client to change the context of a remote folder handle. For
- * example, if a remote folder was created with the HEAD context (e.g. can
- * be used to browse the main branch) use this method to change the
- * context to another branch tag or to a version tag.
- */
- public void setTag(CVSTag tagName);
-
- /**
- * Return the context of this handle. The returned tag can be a branch or
- * version tag.
- */
- public CVSTag getTag();
-
- /**
- * Return the local options that are used to determine how memebers are retrieved.
- *
- * Interesting options are:
- * Checkout.ALIAS
- * Command.DO_NOT_RECURSE
- */
- public LocalOption[] getLocalOptions();
-
- /**
- * Indicates whether the remote folder can be expanded.
- *
- * This is a temporary (hopefully) means of indicating certain types of folders
- * (i.e. module definitions) that are not expandable due to lack of mdoule expansion.
- * They can still be checked out.
- */
- public boolean isExpandable();
-
- /**
- * Tag the remote resources referenced by the remote folder (using rtag)
- */
- public IStatus tag(CVSTag tag, LocalOption[] localOptions, IProgressMonitor monitor) throws CVSException;
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java
deleted file mode 100644
index ccebcd1b1..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteResource;
-
-/**
- * The interface represents a resource that exists in a CVS repository.
- * It purpose is to provide information about the remote resource from
- * the repository.
- *
- * Clients are not expected to implement this interface.
- */
-public interface ICVSRemoteResource extends IRemoteResource, ICVSResource {
-
- /**
- * Return the repository
- */
- public ICVSRepositoryLocation getRepository();
-
- /**
- * Returns the parent of this remote resource or <code>null</code> if the
- * remote resource does not have a parent.
- */
- public ICVSRemoteResource getRemoteParent();
-
- /**
- * Does the remote resource represented by this handle exist on the server. This
- * method may contact the server and be long running.
- */
- public boolean exists(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Answers the repository relative path of this remote folder.
- */
- public String getRepositoryRelativePath();
-
- /**
- * Compares two objects for equality; for cvs remote resources, equality is defined in
- * terms of their handles: same cvs resource type, equal relative paths, and
- * for files, identical revision numbers. Remote resources are not equal to objects other
- * than cvs remote resources.
- *
- * @param other the other object
- * @return an indication of whether the objects are equals
- */
- public boolean equals(Object other);
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java
deleted file mode 100644
index 7c4387787..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.sync.IRemoteResource;
-
-/**
- * This interface provides access to the specific portions of
- * the repository location string for use by connection methods
- * and the user authenticator.
- *
- * It is not intended to implemented by clients.
- *
- * @see IUserAuthenticator
- * @see IConnectionMethod
- */
-public interface ICVSRepositoryLocation extends IAdaptable {
-
- /**
- * port value which indicates to a connection method to use the default port
- */
- public static int USE_DEFAULT_PORT = 0;
-
- /**
- * Return the connection method for making the connection
- */
- public IConnectionMethod getMethod();
-
- /**
- * Returns the host where the repository is located
- */
- public String getHost();
-
- /**
- * Returns the port to connect to or USE_DEFAULT_PORT if
- * the connection method is to use its default port.
- */
- public int getPort();
-
- /**
- * Returns the root directory of the repository.
- */
- public String getRootDirectory();
-
- /**
- * Returns the string representing the receiver. This string
- * should contain enough information to recreate the receiver.
- */
- public String getLocation();
-
- /**
- * Returns the immediate children of this location. If tag is <code>null</code> the
- * HEAD branch is assumed.
- *
- * If modules is true, then the module definitions from the CVSROOT/modules file are returned.
- * Otherwise, the root level projects are returned.
- *
- * @param tag the context in which to return the members (e.g. branch or version).
- */
- public ICVSRemoteResource[] members(CVSTag tag, boolean modules, IProgressMonitor progress) throws CVSException;
-
- /**
- * Returns a handle to a remote folder at this repository location using the given tag as the
- * context. The corresponding remote folder may not exist.
- */
- public ICVSRemoteFolder getRemoteFolder(String remotePath, CVSTag tag);
-
- /**
- * Return the conection timeout value in milliseconds.
- * A value of 0 means there is no timeout value.
- */
- public int getTimeout();
-
- /**
- * Return the username
- */
- public String getUsername();
-
- /**
- * Returns the user information for the location.
- */
- public IUserInfo getUserInfo(boolean allowModificationOfUsername);
-
- /**
- * Validate that the receiver can be used to connect to a repository.
- * An exception is thrown if connection fails
- *
- * @param monitor the progress monitor used while validating
- */
- public void validateConnection(IProgressMonitor monitor) throws CVSException;
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java
deleted file mode 100644
index 49802a66d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java
+++ /dev/null
@@ -1,138 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
-
-/**
- * The CVS analog of file system files and directories. These are handles to
- * state maintained by a CVS client. That is, the CVS resource does not
- * actually contain data but rather represents CVS state and behavior. You are
- * free to manipulate handles for CVS resources that do not exist but be aware
- * that some methods require that an actual resource be available.
- * <p>
- * The CVS client has been designed to work on these handles uniquely. As such, the
- * handle could be to a remote resource or a local resource and the client could
- * perform CVS operations ignoring the actual location of the resources.</p>
- *
- * @see ICVSFolder
- * @see ICVSFile
- */
-public interface ICVSResource {
-
- /**
- * Answers the name of the resource.
- *
- * @return the name of the resource this handle represents. It can never
- * be <code>null</code>.
- */
- public String getName();
-
- /**
- * Answers if this resource has CVS synchronization information associated
- * with it.
- *
- * @return <code>true</code> if the resource is
- */
- public boolean isManaged();
-
- /**
- * Unmanage the given resource by purging any CVS synchronization associated with the
- * resource. The only way a resource can become managed is by running the
- * appropriate CVS commands (e.g. add/commit/update).
- */
- public void unmanage(IProgressMonitor monitor) throws CVSException;
-
- /**
- * Answer whether the resource could be ignored because it is in the one of the
- * ignore lists maintained by CVS. Even if a resource is ignored, it can still be
- * added to a repository, at which time it should never be ignored by the CVS
- * client.
- *
- * @return <code>true</code> if this resource is listed in one of the ignore
- * files maintained by CVS and <code>false</code> otherwise.
- */
- public boolean isIgnored();
-
- /**
- * Add the following file to the parent's ignore list
- */
- public void setIgnored() throws CVSException;
-
- /**
- * Add the following pattern to the file's parent ignore list
- */
- public void setIgnoredAs(String pattern) throws CVSException;
-
- /**
- * Answers if the handle is a file or a folder handle.
- *
- * @return <code>true</code> if this is a folder handle and <code>false</code> if
- * it is a file handle.
- */
- public boolean isFolder();
-
- /**
- * Answers if the resource identified by this handle exists.
- *
- * @return <code>true</code> if the resource represented by this handle
- * exists and <code>false</code> false otherwise.
- */
- public boolean exists() throws CVSException;
-
- /**
- * Answers the local relative path from the given ancestor to the receiver.
- *
- * @return the ancestor relative path for this resource.
- */
- public String getRelativePath(ICVSFolder ancestor) throws CVSException;
-
- /**
- * Get the remote location of a resource.
- *
- * @return the remote location.
- */
- public String getRemoteLocation(ICVSFolder stopSearching) throws CVSException;
-
- /**
- * Answers the workspace synchronization information for this resource. This would
- * typically include information from the <b>Entries</b> file that is used to track
- * the base revisions of local CVS resources.
- *
- * @return the synchronization information for this resource, or <code>null</code>
- * if the resource does not have synchronization information available.
- */
- public ResourceSyncInfo getSyncInfo() throws CVSException;
-
- /**
- * Called to set the workspace synchronization information for a resource. To
- * clear sync information call <code>unmanage</code>. The sync info will
- * become the persisted between workbench sessions.
- *
- * @param info the resource synchronization to associate with this resource.
- */
- public void setSyncInfo(ResourceSyncInfo info) throws CVSException;
-
- /**
- * Deletes the resource represented by the handle.
- */
- public void delete() throws CVSException;
-
- /**
- * Give the folder that contains this resource. If the resource is not managed
- * then the result of the operation is not specified.
- *
- * @return a handle to the parent of this resource.
- */
- public ICVSFolder getParent();
-
- /**
- * Accept a vistor to this resource.
- */
- public void accept(ICVSResourceVisitor visitor) throws CVSException;
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java
deleted file mode 100644
index 28eaf953f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-
-/**
- * Interface for an visitor of the IManagedResources.
- */
-public interface ICVSResourceVisitor {
- public void visitFile(ICVSFile file) throws CVSException;
- public void visitFolder(ICVSFolder folder) throws CVSException;
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java
deleted file mode 100644
index c102b4047..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2001, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * A runnable which executes as a batch operation within a specific cvs local
- * workspace.
- * The <code>ICVSRunnable</code> interface should be implemented by any class whose
- * instances are intended to be run by <code>IWorkspace.run</code>.
- * <p>
- * Clients may implement this interface.
- * </p>
- * @see
- */
-public interface ICVSRunnable {
- /**
- * Runs the operation reporting progress to and accepting
- * cancellation requests from the given progress monitor.
- * <p>
- * Implementors of this method should check the progress monitor
- * for cancellation when it is safe and appropriate to do so. The cancellation
- * request should be propagated to the caller by throwing
- * <code>OperationCanceledException</code>.
- * </p>
- *
- * @param monitor a progress monitor, or <code>null</code> if progress
- * reporting and cancellation are not desired
- * @exception CoreException if this operation fails.
- */
- public void run(IProgressMonitor monitor) throws CVSException;
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IConnectionMethod.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IConnectionMethod.java
deleted file mode 100644
index 98c360546..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IConnectionMethod.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * Implementators of this class can act as factories for creating connections to a CVS server
- * with the desired custom communication protocol. Providers of CVS connection methods must implement
- * this interface and register the implementation with the extension point:
- *
- * org.eclipse.team.cvs.core.connectionmethods
- *
- * The <code>createConnection()</code> method will be invoked by the CVS client when the user
- * is attempting to make a connection to the server using the connection name which matches
- * the <code>String</code> returned by <code>getName()</code> (e.g. "pserver", "ext", etc.).
- */
-public interface IConnectionMethod {
-
- /**
- * Returns the name of this connection method (e.g."local", "ext").
- */
- public String getName();
-
- /**
- * Creates a new server connection using the given repository root
- * (which includes the user name) and the given password.
- */
- public IServerConnection createConnection(ICVSRepositoryLocation location, String password);
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ILogEntry.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ILogEntry.java
deleted file mode 100644
index 2b5b5aa40..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ILogEntry.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.Date;
-
-import org.eclipse.core.runtime.IAdaptable;
-
-/**
- * Instances of ILogEntry represent an entry for a CVS file that results
- * from the cvs log command.
- *
- * Clients are not expected to implement this interface
- */
-public interface ILogEntry extends IAdaptable {
-
- /**
- * Get the revision for the entry
- */
- public String getRevision();
-
- /**
- * Get the author of the revision
- */
- public String getAuthor();
-
- /**
- * Get the date the revision was committed
- */
- public Date getDate();
-
- /**
- * Get the comment for the revision
- */
- public String getComment();
-
- /**
- * Get the state
- */
- public String getState();
-
- /**
- * Get the tags associated with the revision
- */
- public CVSTag[] getTags();
-
- /**
- * Get the remote file for this entry
- */
- public ICVSRemoteFile getRemoteFile();
-
- /**
- * Does the log entry represent a deletion (stat = "dead")
- */
- public boolean isDeletion();
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IResourceStateChangeListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IResourceStateChangeListener.java
deleted file mode 100644
index a829c543a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IResourceStateChangeListener.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.EventListener;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-
-/**
- * A resource state change listener is notified of changes to resources
- * regarding their team state.
- * <p>
- * Clients may implement this interface.
- * </p>
- * @see ITeamManager#addResourceStateChangeListener(IResourceStateChangeListener)
- */
-public interface IResourceStateChangeListener extends EventListener{
-
- /**
- * Notifies this listener that some resource state changes have already
- * happened. For example, a resource's team state has changed from checked-in
- * to checked-out.
- * <p>
- * Note: This method is called by team core; it is not intended to be called
- * directly by clients.
- * </p>
- *
- * @param resources that have changed state
- *
- * [Note: The changed state event is purposely vague. For now it is only
- * a hint to listeners that they should query the provider to determine the
- * resources new team state.]
- */
- public void resourceStateChanged(IResource[] changedResources);
-
- /**
- * Notifies this listener that the project has just been configured
- * to be a CVS project (i.e has the CVS nature).
- * <p>
- * Note: This method is called by team core; it is not intended to be called
- * directly by clients.
- * </p>
- *
- * @param project The project that has just been configured
- */
- public void projectConfigured(IProject project);
-
- /**
- * Notifies this listener that the project has just been deconfigured
- * and no longer has the CVS nature.
- * <p>
- * Note: This method is called by team core; it is not intended to be called
- * directly by clients.
- * </p>
- *
- * @param project The project that has just been configured
- */
- public void projectDeconfigured(IProject project);
-
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IServerConnection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IServerConnection.java
deleted file mode 100644
index 310f64180..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IServerConnection.java
+++ /dev/null
@@ -1 +0,0 @@
-package org.eclipse.team.internal.ccvs.core; /* * (c) Copyright IBM Corp. 2000, 2002. * All Rights Reserved. */ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException; /** * CVS supports different connection methods for communicating between a client and the server. * Furthermore, custom connection methods can be added. Connection methods are added * to the CVS client as an IConnectionMethod, which can be used to create connections of * type IServerConnection. * * @see IConnectionMethod */ public interface IServerConnection { /** * Open a connection to the CVS server. * * Throw CVSAuthenticationException if the username or password is invalid. * Throw IOExceptions for other failures. */ public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException; /** * Close the connection * * Throw IOException on failures */ public void close() throws IOException; /** * Get the input stream to receive responses from the server */ public InputStream getInputStream(); /** * Get the output stream to send requests to the server */ public OutputStream getOutputStream(); } \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java
deleted file mode 100644
index 6eb4b8475..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-
-/**
- * IUserAuthenticators are used to ensure that the user
- * is validated for access to a given repository. The
- * user is prompted for a username and password as
- * appropriate for the given repository type.
- */
-public interface IUserAuthenticator {
- /**
- * Authenticates the user for access to a given repository.
- * The obtained values for user name and password will be placed
- * into the supplied user info object. Implementors are allowed to
- * save user names and passwords. The user should be prompted for
- * user name and password if there is no saved one, or if <code>retry</code>
- * is <code>true</code>.
- *
- * @param location The repository location to authenticate the user for.
- * @param info The object to place user validation information into.
- * @param retry <code>true</code> if a previous attempt to log in failed.
- * @param message An optional message to display if, e.g., previous authentication failed.
- * @return true if the validation was successful, and false otherwise.
- */
- public void promptForUserInfo(ICVSRepositoryLocation location, IUserInfo userInfo, String message) throws CVSException;
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserInfo.java
deleted file mode 100644
index cfe65d0aa..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserInfo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * Instances of this class represent a username password pair.
- * Both values can be set and the username can be retrieved.
- * However, it is possible that the username is not mutable.
- * Users must check before trying to set the username.
- *
- * Clients are not expected to implement this interface
- */
-public interface IUserInfo {
- /**
- * Get the username for this user.
- */
- public String getUsername();
- /**
- * Return true if the username is mutable. If not, setUsername should not be called.
- */
- public boolean isUsernameMutable();
- /**
- * Sets the password for this user.
- */
- public void setPassword(String password);
- /**
- * Sets the username for this user. This should not be called if
- * isUsernameMutable() returns false.
- */
- public void setUsername(String username);
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java
deleted file mode 100644
index 1f667a4ed..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package org.eclipse.team.internal.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.util.InfiniteSubProgressMonitor;
-
-public class Policy {
- protected static ResourceBundle bundle = null;
-
- //debug constants
- public static boolean DEBUG_METAFILE_CHANGES = false;
- public static boolean DEBUG_CVS_PROTOCOL = false;
- public static boolean DEBUG_STREAMS = false;
- public static boolean DEBUG_THREADING = false;
-
- static {
- //init debug options
- if (CVSProviderPlugin.getPlugin().isDebugging()) {
- DEBUG_METAFILE_CHANGES = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/metafiles"));//$NON-NLS-1$ //$NON-NLS-2$
- DEBUG_CVS_PROTOCOL = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/cvsprotocol"));//$NON-NLS-1$ //$NON-NLS-2$
- DEBUG_STREAMS = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/streams"));//$NON-NLS-1$ //$NON-NLS-2$
- DEBUG_THREADING = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/threading"));//$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * Creates a NLS catalog for the given locale.
- */
- public static void localize(String bundleName) {
- bundle = ResourceBundle.getBundle(bundleName);
- }
-
- /**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string.
- */
- public static String bind(String id, String binding) {
- return bind(id, new String[] { binding });
- }
-
- /**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given strings.
- */
- public static String bind(String id, String binding1, String binding2) {
- return bind(id, new String[] { binding1, binding2 });
- }
-
- /**
- * Gets a string from the resource bundle. We don't want to crash because of a missing String.
- * Returns the key if not found.
- */
- public static String bind(String key) {
- try {
- return bundle.getString(key);
- } catch (MissingResourceException e) {
- return key;
- } catch (NullPointerException e) {
- return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * Gets a string from the resource bundle and binds it with the given arguments. If the key is
- * not found, return the key.
- */
- public static String bind(String key, Object[] args) {
- try {
- return MessageFormat.format(bind(key), args);
- } catch (MissingResourceException e) {
- return key;
- } catch (NullPointerException e) {
- return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * Progress monitor helpers
- */
- public static void checkCanceled(IProgressMonitor monitor) {
- if (monitor.isCanceled())
- throw new OperationCanceledException();
- }
- public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
- if (monitor == null)
- return new NullProgressMonitor();
- return monitor;
- }
-
- public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
- if (monitor == null)
- return new NullProgressMonitor();
- if (monitor instanceof NullProgressMonitor)
- return monitor;
- return new SubProgressMonitor(monitor, ticks);
- }
- public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks, int style) {
- if (monitor == null)
- return new NullProgressMonitor();
- if (monitor instanceof NullProgressMonitor)
- return monitor;
- return new SubProgressMonitor(monitor, ticks, style);
- }
-
- public static IProgressMonitor infiniteSubMonitorFor(IProgressMonitor monitor, int ticks) {
- if (monitor == null)
- return new NullProgressMonitor();
- if (monitor instanceof NullProgressMonitor)
- return monitor;
- return new InfiniteSubProgressMonitor(monitor, ticks);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java
deleted file mode 100644
index a517eb508..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-
-/**
- * Superclass for commands that do not change the structure on
- * the local working copy (it can change the content of the files).<br>
- * Most of the subclasses are asking the server for response in
- * message format (log, status)
- */
-abstract class AbstractMessageCommand extends Command {
-
- protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // Send all folders that are already managed to the server
- new FileStructureVisitor(session, false, false, monitor).visit(session, resources);
- }
-
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java
deleted file mode 100644
index f80e22fa3..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java
+++ /dev/null
@@ -1,223 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * An ICVSResourceVisitor that is superclass to all ICVSResourceVisitor's used
- * by Command and it's subclasses.
- * Provides helper methods to send files and folders with modifications
- * to the server.
- */
-abstract class AbstractStructureVisitor implements ICVSResourceVisitor {
-
- protected Session session;
- private ICVSFolder lastFolderSent;
- protected IProgressMonitor monitor;
- protected boolean sendQuestionable;
- protected boolean sendModifiedContents;
-
- public AbstractStructureVisitor(Session session, boolean sendQuestionable, boolean sendModifiedContents, IProgressMonitor monitor) {
- this.session = session;
- this.sendQuestionable = sendQuestionable;
- this.sendModifiedContents = sendModifiedContents;
- this.monitor = Policy.infiniteSubMonitorFor(monitor, 256);
- }
-
- /**
- * Helper method to indicate if a directory has already been sent to the server
- */
- protected boolean isLastSent(ICVSFolder folder) {
- return folder.equals(lastFolderSent);
- }
-
- /**
- * Helper method to record if a directory has already been sent to the server
- */
- protected void recordLastSent(ICVSFolder folder) {
- lastFolderSent = folder;
- }
-
- /**
- * Helper which indicates if a folder is an orphaned subtree.
- * That is, a directory which contains a CVS subdirectory but is
- * not managed by its parent. The root directory of the session
- * is not considered orphaned even if it is not managed by its
- * parent.
- */
- protected boolean isOrphanedSubtree(ICVSFolder mFolder) {
- return mFolder.isCVSFolder() && ! mFolder.isManaged() && ! mFolder.equals(session.getLocalRoot()) && mFolder.getParent().isCVSFolder();
- }
-
- /**
- * Send the folder relative to the root to the server. Send all
- * appropiate modifier like Sticky, Questionable, Static-directory.
- * <br>
- * Folders will only be sent once.
- */
- protected void sendFolder(ICVSFolder mFolder) throws CVSException {
-
- Policy.checkCanceled(monitor);
-
- boolean exists = mFolder.exists();
- boolean isCVSFolder = mFolder.isCVSFolder();
-
- // We are only interested in folders that exist or are CVS folders
- // A folder could be a non-existant CVS folder if it is a holder for outgoing file deletions
- if ( ! exists && ! isCVSFolder) return;
-
- // Do not send the same folder twice
- if (isLastSent(mFolder)) return;
-
- String localPath = mFolder.getRelativePath(session.getLocalRoot());
-
- monitor.subTask(Policy.bind("AbstractStructureVisitor.sendingFolder", localPath)); //$NON-NLS-1$
-
- // Deal with questionable directories
- boolean isQuestionable = exists && (! isCVSFolder || isOrphanedSubtree(mFolder));
- if (isQuestionable) {
- if (sendQuestionable) {
- // We need to make sure the parent folder was sent
- sendFolder(mFolder.getParent());
- session.sendQuestionable(mFolder);
- }
- return;
- }
-
- // Send the directory to the server
- String remotePath = mFolder.getRemoteLocation(session.getLocalRoot());
- if (remotePath == null) {
- throw new CVSException(Policy.bind("AbstractStructureVisitor.noRemote")); //$NON-NLS-1$
- }
- session.sendDirectory(localPath, remotePath);
-
- // Send any directory properties to the server
- FolderSyncInfo info = mFolder.getFolderSyncInfo();
- if (info != null) {
-
- if (info.getIsStatic()) {
- session.sendStaticDirectory();
- }
-
- CVSEntryLineTag tag = info.getTag();
-
- if (tag != null && tag.getType() != tag.HEAD) {
- session.sendSticky(tag.toEntryLineFormat(false));
- }
- }
-
- // Record that we sent this folder
- recordLastSent(mFolder);
-
- monitor.worked(1);
- }
-
- /**
- * Send the information about the file to the server.
- *
- * If the file is modified, its contents are sent as well.
- */
- protected void sendFile(ICVSFile mFile) throws CVSException {
-
- Policy.checkCanceled(monitor);
-
- // Send the file's entry line to the server
- ResourceSyncInfo info = null;
- boolean isManaged = mFile.isManaged();
- if (isManaged) {
- info = mFile.getSyncInfo();
- session.sendEntry(info.getServerEntryLine(mFile.getTimeStamp()));
- } else {
- // If the file is not managed, send a questionable to the server if the file exists locally
- // A unmanaged, locally non-existant file results from the explicit use of the file name as a command argument
- if (sendQuestionable) {
- if (mFile.exists()) {
- session.sendQuestionable(mFile);
- }
- return;
- }
- }
-
- // If the file exists, send the appropriate indication to the server
- if (mFile.exists()) {
- if (mFile.isModified()) {
- boolean binary = info != null && info.getKeywordMode().isBinary();
- if (sendModifiedContents) {
- session.sendModified(mFile, binary, monitor);
- } else {
- session.sendIsModified(mFile, binary, monitor);
- }
- } else {
- session.sendUnchanged(mFile);
- }
- }
- }
-
- /**
- * This method is used to visit a set of ICVSResources. Using it ensures
- * that a common parent between the set of resources is only sent once
- */
- public void visit(Session session, ICVSResource[] resources) throws CVSException {
-
- // Sort the resources to avoid sending the same directory multiple times
- List resourceList = new ArrayList(resources.length);
- resourceList.addAll(Arrays.asList(resources));
- final ICVSFolder localRoot = session.getLocalRoot();
- Collections.sort(resourceList, new Comparator() {
- public int compare(Object object1, Object object2) {
- ICVSResource resource1 = (ICVSResource)object1;
- ICVSResource resource2 = (ICVSResource)object2;
- try {
- String path1 = resource1.getParent().getRelativePath(localRoot);
- String path2 = resource2.getParent().getRelativePath(localRoot);
- int pathCompare = path1.compareTo(path2);
- if (pathCompare == 0) {
- if (resource1.isFolder() == resource2.isFolder()) {
- return resource1.getName().compareTo(resource2.getName());
- } else if (resource1.isFolder()) {
- return 1;
- } else {
- return -1;
- }
- } else {
- return pathCompare;
- }
- } catch (CVSException e) {
- return resource1.getName().compareTo(resource2.getName());
- }
- }
- });
-
- // Visit all the resources
- session.setSendFileTitleKey(getSendFileTitleKey());
- for (int i = 0; i < resourceList.size(); i++) {
- ((ICVSResource)resourceList.get(i)).accept(this);
- }
-
- monitor.done();
- }
-
- protected String getSendFileTitleKey() {
- return "AbstractStructureVisitor.sendingFile"; //$NON-NLS-1$
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java
deleted file mode 100644
index c8cf33a6c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-
-public class Add extends Command {
- /*** Local options: specific to add ***/
-
- protected Add() { }
- protected String getRequestId() {
- return "add"; //$NON-NLS-1$
- }
-
- protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // Check that all the arguments can give you an
- // repo that you will need while traversing the
- // file-structure
- for (int i = 0; i < resources.length; i++) {
- Assert.isNotNull(resources[i].getRemoteLocation(session.getLocalRoot()));
- }
-
- // Get a vistor and use it on every resource we should
- // work on
- AddStructureVisitor visitor = new AddStructureVisitor(session, monitor);
- visitor.visit(session, resources);
- }
-
- /**
- * If the add succeeded then folders have to be initialized with the
- * sync info
- */
- protected void commandFinished(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor,
- boolean succeeded) throws CVSException {
-
- ICVSFolder mFolder;
- ICVSResource[] mWorkResources;
-
- if (! succeeded) {
- return;
- }
-
- for (int i = 0; i < resources.length; i++) {
- if (resources[i].isFolder()) {
- mFolder = (ICVSFolder) resources[i];
- FolderSyncInfo info = mFolder.getParent().getFolderSyncInfo();
- if (info == null)
- throw new CVSException(new CVSStatus(CVSStatus.ERROR, Policy.bind("Add.invalidParent", mFolder.getRelativePath(session.getLocalRoot())))); //$NON-NLS-1$
- String repository = info.getRepository() + "/" + mFolder.getName(); //$NON-NLS-1$
- mFolder.setFolderSyncInfo(new FolderSyncInfo(repository, info.getRoot(), info.getTag(), info.getIsStatic()));
- }
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java
deleted file mode 100644
index b517e58a1..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-
-/**
- * This visitor is used by the Add command to ensure that the parent
- * folder is sent along with the added resource.
- */
-class AddStructureVisitor extends AbstractStructureVisitor {
- private boolean forceSend = false;
- private Set visitedFolders = new HashSet();
- private ICVSFolder lastVisitedFolder;
-
- public AddStructureVisitor(Session session, IProgressMonitor monitor) {
- super(session, false, true, monitor);
- }
-
- /**
- * @see ICVSResourceVisitor#visitFile(IManagedFile)
- */
- public void visitFile(ICVSFile mFile) throws CVSException {
-
- // Send the parent folder
- sendFolder(mFile.getParent());
-
- // Sends the Is-modified request if it is supported, otherwise
- // the file contents are sent as binary. The server does not
- // need the contents at this stage so this should not be a problem.
- session.sendIsModified(mFile, true, monitor);
-
- }
-
- /**
- * @see ICVSResourceVisitor#visitFolder(ICVSFolder)
- */
- public void visitFolder(ICVSFolder mFolder) throws CVSException {
-
- Assert.isNotNull(mFolder);
-
- // Send the parent folder
- sendFolder(mFolder.getParent());
-
- // Send the directory
- String localPath = mFolder.getRelativePath(session.getLocalRoot());
- String remotePath = mFolder.getRemoteLocation(session.getLocalRoot());
- session.sendDirectory(localPath, remotePath);
-
- // Record that we sent this folder
- recordLastSent(mFolder);
- }
-
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Admin.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Admin.java
deleted file mode 100644
index e985839d4..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Admin.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-public class Admin extends AbstractMessageCommand {
- /*** Local options: specific to admin ***/
-
- protected Admin() { }
- protected String getRequestId() {
- return "admin"; //$NON-NLS-1$
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java
deleted file mode 100644
index a70c78499..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * Handles a "Checked-in" response from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Checked-in ??? \n
- * [...]
- * </pre>
- * Then
- * </p>
- */
-class CheckedInHandler extends ResponseHandler {
- public String getResponseID() {
- return "Checked-in"; //$NON-NLS-1$
- }
-
- public void handle(Session session, String localDir,
- IProgressMonitor monitor) throws CVSException {
- // read additional data for the response
- String repositoryFile = session.readLine();
- String entryLine = session.readLine();
-
- // clear file update modifiers
- session.setModTime(null);
-
- // Get the local file
- String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$
- ICVSFolder mParent = session.getLocalRoot().getFolder(localDir);
- ICVSFile mFile = mParent.getFile(fileName);
-
- ResourceSyncInfo newInfo = mFile.getSyncInfo();
-
- if (newInfo==null) {
- // cvs add of a file
- newInfo = new ResourceSyncInfo(entryLine, null, null);
- } else {
- // commit of a changed file
- ResourceSyncInfo fileInfo = mFile.getSyncInfo();
- newInfo = new ResourceSyncInfo(entryLine, fileInfo.getPermissions(), mFile.getTimeStamp());
- }
-
- mFile.setSyncInfo(newInfo);
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java
deleted file mode 100644
index d781bf17a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-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.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.Option;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ModuleDefinitionsListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteModule;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-
-public class Checkout extends Command {
- /*** Local options: specific to checkout ***/
- public static final LocalOption DO_NOT_SHORTEN = new LocalOption("-N"); //$NON-NLS-1$
- public static final LocalOption FETCH_MODULE_ALIASES = new LocalOption("-c"); //$NON-NLS-1$
- public static LocalOption makeDirectoryNameOption(String moduleName) {
- return new LocalOption("-d", moduleName); //$NON-NLS-1$
- }
-
- /** Command options found in the CVSROOT/modules file */
- public static LocalOption ALIAS = new LocalOption("-a"); //$NON-NLS-1$
- public static LocalOption makeStatusOption(String status) {
- return new LocalOption("-s", status); //$NON-NLS-1$
- }
-
- protected Checkout() { }
- protected String getRequestId() {
- return "co"; //$NON-NLS-1$
- }
-
- protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions,
- String[] arguments) throws CVSException {
-
- // We shouldn't have any arguments if we're fetching the module definitions
- if (arguments.length < 1 && ! FETCH_MODULE_ALIASES.isElementOf(localOptions)) throw new IllegalArgumentException();
-
- // We can determine the local directories using either the -d option or the module expansions
- Option dOption = findOption(localOptions, "-d"); //$NON-NLS-1$
- if (dOption != null) {
- // XXX Should we append the expansions to the -d argument?
- return new ICVSResource[] {session.getLocalRoot().getFolder(dOption.argument)};
- }
- String[] modules = session.getModuleExpansions();
- ICVSResource[] resources = new ICVSResource[modules.length];
- for (int i = 0; i < resources.length; i++) {
- resources[i] = session.getLocalRoot().getFolder(modules[i]);
- }
- return resources;
- }
-
- /**
- * Start the Checkout command:
- * Send the module that is going to be checked-out to the server
- * by reading the name of the resource given
- * (This has to change to we give it the name of the modul and the
- * Checkout creates everything for us)
- */
- protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // We need a folder to put the project(s) we checkout into
- Assert.isTrue(session.getLocalRoot().isFolder());
-
- // Send the information about the local workspace resources to the server
- List resourcesToSend = new ArrayList(resources.length);
- for (int i = 0; i < resources.length; i++) {
- ICVSResource resource = resources[i];
- if (resource.exists() && resource.isFolder() && ((ICVSFolder)resource).isCVSFolder()) {
- resourcesToSend.add(resource);
- }
- }
- if ( ! resourcesToSend.isEmpty()) {
- resources = (ICVSResource[]) resourcesToSend.toArray(new ICVSResource[resourcesToSend.size()]);
- new FileStructureVisitor(session, true, true, monitor).visit(session, resources);
- }
- }
-
- protected void sendLocalWorkingDirectory(Session session) throws CVSException {
- session.sendConstructedRootDirectory();
- }
-
- /**
- * On sucessful finish, prune empty directories if
- * the -P option was specified (or is implied by -D or -r)
- */
- protected void commandFinished(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor,
- boolean succeeded) throws CVSException {
- // If we didn't succeed, don't do any post processing
- if (! succeeded) return;
-
- // If we are retrieving the modules file, ignore other options
- if (FETCH_MODULE_ALIASES.isElementOf(localOptions)) return;
-
- // If we are pruning (-P) or getting a sticky copy (-D or -r), then prune empty directories
- if (PRUNE_EMPTY_DIRECTORIES.isElementOf(localOptions) ||
- (findOption(localOptions, "-D") != null) || //$NON-NLS-1$
- (findOption(localOptions, "-r") != null)) { //$NON-NLS-1$
-
- // Prune empty directories
- new PruneFolderVisitor().visit(session, resources);
- }
-
- session.handleCaseCollisions();
- }
-
- /**
- * Override execute to perform a expand-modules before the checkout
- */
- protected IStatus doExecute(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener,
- IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(null, 100);
-
- if ( ! FETCH_MODULE_ALIASES.isElementOf(localOptions)) {
- // Execute the expand-modules command.
- // This will put the expansions in the session for later retrieval
- IStatus status = Request.EXPAND_MODULES.execute(session, arguments, Policy.subMonitorFor(monitor, 10));
- if (status.getCode() == CVSStatus.SERVER_ERROR)
- return status;
-
- // If -d is not included in the local options, then send -N (do not shorten directory paths)
- // to the server (as is done by other cvs clients)
- if (findOption(localOptions, "-d") == null) { //$NON-NLS-1$
- if ( ! DO_NOT_SHORTEN.isElementOf(localOptions)) {
- LocalOption[] newLocalOptions = new LocalOption[localOptions.length + 1];
- newLocalOptions[0] = DO_NOT_SHORTEN;
- System.arraycopy(localOptions, 0, newLocalOptions, 1, localOptions.length);
- localOptions = newLocalOptions;
- }
- }
- }
-
- return super.doExecute(session, globalOptions, localOptions, arguments, listener, Policy.subMonitorFor(monitor, 90));
- }
-
- /**
- * Perform a checkout to get the module expansions defined in the CVSROOT/modules file
- */
- public RemoteModule[] getRemoteModules(Session session, CVSTag tag, IProgressMonitor monitor)
- throws CVSException {
-
- ModuleDefinitionsListener moduleDefinitionListener = new ModuleDefinitionsListener();
-
- IStatus status = super.execute(session, NO_GLOBAL_OPTIONS, new LocalOption[] {FETCH_MODULE_ALIASES}, NO_ARGUMENTS,
- moduleDefinitionListener, monitor);
-
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- // XXX diff errors??
- throw new CVSServerException(status);
- }
-
- return RemoteModule.createRemoteModules(moduleDefinitionListener.getModuleExpansions(), session.getCVSRepositoryLocation(), tag);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java
deleted file mode 100644
index d4f9450f9..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java
+++ /dev/null
@@ -1,727 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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 java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-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.CVSProvider;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-
-/**
- * Abstract base class for command requests.
- * Provides a framework for implementing command execution.
- */
-public abstract class Command extends Request {
- /*** Command singleton instances ***/
- public final static Add ADD = new Add();
- public final static Admin ADMIN = new Admin();
- public final static Checkout CHECKOUT = new Checkout();
- public final static Commit COMMIT = new Commit();
- public final static Diff DIFF = new Diff();
- public final static Import IMPORT = new Import();
- public final static Log LOG = new Log();
- public final static Remove REMOVE = new Remove();
- public final static Status STATUS = new Status();
- public final static Tag TAG = new Tag();
- // The CUSTOM_TAG command has special handling for added and removed resources.
- // This behavior supports branching with local changes in the workspace
- public final static Tag CUSTOM_TAG = new Tag(true);
- public final static RTag RTAG = new RTag();
- public final static Update UPDATE = new Update();
- public final static Version VERSION = new Version();
-
- // Empty argument array
- public final static String[] NO_ARGUMENTS = new String[0];
-
- /*** Global options ***/
- // Empty global option array
- public static final GlobalOption[] NO_GLOBAL_OPTIONS = new GlobalOption[0];
- // Do not change file contents
- public static final GlobalOption DO_NOT_CHANGE = new GlobalOption("-n"); //$NON-NLS-1$
- // Do not record this operation into CVS command history
- public static final GlobalOption DO_NOT_LOG = new GlobalOption("-l"); //$NON-NLS-1$
- // Make new working files read-only
- public static final GlobalOption MAKE_READ_ONLY = new GlobalOption("-r"); //$NON-NLS-1$
- // Trace command execution
- public static final GlobalOption TRACE_EXECUTION = new GlobalOption("-t"); //$NON-NLS-1$
-
- /*** Global options: quietness ***/
- // Don't be quiet (normal verbosity)
- public static final QuietOption VERBOSE = new QuietOption(""); //$NON-NLS-1$
- // Be somewhat quiet (suppress informational messages)
- public static final QuietOption PARTLY_QUIET = new QuietOption("-q"); //$NON-NLS-1$
- // Be really quiet (silent but for serious problems)
- public static final QuietOption SILENT = new QuietOption("-Q"); //$NON-NLS-1$
-
- /*** Local options: common to many commands ***/
- // Empty local option array
- public static final LocalOption[] NO_LOCAL_OPTIONS = new LocalOption[0];
- // valid for: annotate checkout commit diff export log rdiff remove rtag status tag update
- public static final LocalOption DO_NOT_RECURSE = new LocalOption("-l"); //$NON-NLS-1$
- // valid for: checkout export update
- public static final LocalOption PRUNE_EMPTY_DIRECTORIES = new LocalOption("-P"); //$NON-NLS-1$
- // valid for: checkout export update
- public static final LocalOption MESSAGE_OPTION = new LocalOption("-m"); //$NON-NLS-1$
-
- /*** Local options: keyword substitution mode ***/
- // valid for: add admin checkout export import update
- private static final Map ksubstOptionMap = new HashMap();
- public static final KSubstOption KSUBST_BINARY = new KSubstOption("-kb"); //$NON-NLS-1$
- public static final KSubstOption KSUBST_TEXT = new KSubstOption("-ko"); //$NON-NLS-1$
- public static final KSubstOption KSUBST_TEXT_EXPAND = new KSubstOption("-kkv"); //$NON-NLS-1$
- public static final KSubstOption KSUBST_TEXT_EXPAND_LOCKER = new KSubstOption("-kkvl"); //$NON-NLS-1$
- public static final KSubstOption KSUBST_TEXT_VALUES_ONLY = new KSubstOption("-kv"); //$NON-NLS-1$
- public static final KSubstOption KSUBST_TEXT_KEYWORDS_ONLY = new KSubstOption("-kk"); //$NON-NLS-1$
-
- /*** Default command output listener ***/
- protected static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER =
- new ICommandOutputListener() {
- public IStatus messageLine(String line, ICVSFolder commandRoot, IProgressMonitor monitor) {
- return OK;
- }
- public IStatus errorLine(String line, ICVSFolder commandRoot, IProgressMonitor monitor) {
- return new CVSStatus(CVSStatus.ERROR, CVSStatus.ERROR_LINE, line);
- }
-
- };
-
- /**
- * Prevents client code from instantiating us.
- */
- protected Command() { }
-
- /**
- * Provides the default command output listener which is used to accumulate errors.
- *
- * Subclasses can override this method in order to properly interpret information
- * received from the server.
- */
- protected ICommandOutputListener getDefaultCommandOutputListener() {
- return DEFAULT_OUTPUT_LISTENER;
- }
-
- /**
- * Sends the command's arguments to the server.
- * [template method]
- * <p>
- * The default implementation sends all arguments. Subclasses may override
- * this method to provide alternate behaviour.
- * </p>
- *
- * @param session the CVS session
- * @param arguments the arguments that were supplied by the caller of execute()
- */
- protected void sendArguments(Session session, String[] arguments) throws CVSException {
- for (int i = 0; i < arguments.length; ++i) {
- session.sendArgument(arguments[i]);
- }
- }
-
- /**
- * Describes the local resource state to the server prior to command execution.
- * [template method]
- * <p>
- * Commands must override this method to inform the server about the state of
- * local resources using the Entries, Modified, Unchanged, and Questionable
- * requests as needed.
- * </p>
- *
- * @param session the CVS session
- * @param globalOptions the global options for the command
- * @param localOptions the local options for the command
- * @param resources the resource arguments for the command
- * @param monitor the progress monitor
- */
- protected abstract void sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException;
-
- /**
- * Cleans up after command execution.
- * [template method]
- * <p>
- * The default implementation is a no-op. Subclasses may override this
- * method to follow up command execution on the server with clean up
- * operations on local resources.
- * </p>
- *
- * @param session the CVS session
- * @param globalOptions the global options for the command
- * @param localOptions the local options for the command
- * @param resources the resource arguments for the command
- * @param monitor the progress monitor
- * @param serverError true iff the server returned the "ok" response
- */
- protected void commandFinished(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor,
- boolean serverError) throws CVSException {
- }
-
- /**
- * Sends the local working directory path prior to command execution.
- * [template method]
- * <p>
- * The default implementation sends the paths of local root directory
- * (assuming it exists). Subclasses may override this method to provide
- * alternate behaviour.
- * </p>
- *
- * @param session the CVS session
- */
- protected void sendLocalWorkingDirectory(Session session) throws CVSException {
- ICVSFolder localRoot = session.getLocalRoot();
- if (localRoot.isCVSFolder()) {
- session.sendLocalRootDirectory();
- } else {
- session.sendConstructedRootDirectory();
- }
- }
-
- /**
- * Computes an array of ICVSResources corresponding to command arguments.
- * [template method]
- * <p>
- * The default implementation assumes that all arguments supplied to the
- * command represent resources in the local root that are to be manipulated.
- * Subclasses must override this method if this assumption does not hold.
- * </p>
- * @param session the CVS session
- * @param localOptions the command local options
- * @param arguments the command arguments
- * @return the resource arguments for the command
- */
- protected ICVSResource[] computeWorkResources(Session session,
- LocalOption[] localOptions, String[] arguments) throws CVSException {
- ICVSFolder localRoot = session.getLocalRoot();
-
- if (arguments.length == 0) {
- // As a convenience, passing no arguments to the CVS command
- // implies the command will operate on the local root folder.
- return new ICVSResource[] { localRoot };
- } else {
- // Assume all arguments represent resources that are descendants
- // of the local root folder.
- ICVSResource[] resources = new ICVSResource[arguments.length];
- for (int i = 0; i < arguments.length; i++) {
- ICVSResource resource = localRoot.getChild(arguments[i]);
- // file does not exist, it could have been deleted. It doesn't matter
- // which type we return since only the name of the resource is used
- // and sent to the server.
- if(resource==null) {
- if(localRoot.getName().length()==0) {
- // XXX returning a folder because it is the safest choice when
- // localRoot is a handle to the IWorkspaceRoot!
- resource = localRoot.getFolder(arguments[i]);
- } else {
- resource = localRoot.getFile(arguments[i]);
- }
- }
- resources[i] = resource;
- }
- return resources;
- }
- }
-
- /**
- * Send an array of Resources.
- *
- * @see Command#sendFileStructure(ICVSResource,IProgressMonitor,boolean,boolean,boolean)
- */
- protected void sendFileStructure(Session session, ICVSResource[] resources,
- boolean emptyFolders, IProgressMonitor monitor) throws CVSException {
- checkResourcesManaged(resources);
-
- new FileStructureVisitor(session, emptyFolders, true, monitor).visit(session, resources);
- }
-
- /**
- * Checks that all work resources are managed.
- *
- * @param resources the resource arguments for the command
- * @throws CVSException if some resources are not managed
- */
- protected void checkResourcesManaged(ICVSResource[] resources) throws CVSException {
- for (int i = 0; i < resources.length; ++i) {
- ICVSFolder folder;
- if (resources[i].isFolder()) {
- folder = (ICVSFolder) resources[i];
- }
- else {
- folder = resources[i].getParent();
- }
- if (folder==null || (!folder.isCVSFolder() && folder.exists())) {
- throw new CVSException(Policy.bind("Command.argumentNotManaged", folder.getName()));//$NON-NLS-1$
- }
- }
- }
-
- /**
- * Executes a CVS command.
- * <p>
- * Dispatches the commands, retrieves the results, and determines whether or
- * not an error occurred. A listener may be supplied to capture message text
- * that would normally be written to the standard error and standard output
- * streams of a command line CVS client.
- * </p>
- * @param session the open CVS session
- * @param globalOptions the array of global options, or NO_GLOBAL_OPTIONS
- * @param localOptions the array of local options, or NO_LOCAL_OPTIONS
- * @param arguments the array of arguments (usually filenames relative to localRoot), or NO_ARGUMENTS
- * @param listener the command output listener, or null to discard all messages
- * @param monitor the progress monitor
- * @return a status code indicating success or failure of the operation
- * @throws CVSException if a fatal error occurs (e.g. connection timeout)
- */
- public final IStatus execute(final Session session, final GlobalOption[] globalOptions,
- final LocalOption[] localOptions, final String[] arguments, final ICommandOutputListener listener,
- IProgressMonitor pm) throws CVSException {
- final IStatus[] status = new IStatus[1];
- ICVSRunnable job = new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- // update the global and local options
- GlobalOption[] gOptions = filterGlobalOptions(session, globalOptions);
- LocalOption[] lOptions = filterLocalOptions(session, gOptions, localOptions);
-
- // print the invocation string to the console
- if (session.isOutputToConsole() || Policy.DEBUG_CVS_PROTOCOL) {
- String line = constructCommandInvocationString(gOptions, lOptions, arguments);
- if (session.isOutputToConsole()) {
- IConsoleListener consoleListener = CVSProviderPlugin.getPlugin().getConsoleListener();
- if (consoleListener != null) consoleListener.commandInvoked(line);
- }
- if (Policy.DEBUG_CVS_PROTOCOL) System.out.println("CMD> " + line); //$NON-NLS-1$
- }
-
- // run the command
- try {
- status[0] = doExecute(session, gOptions, lOptions, arguments, listener, monitor);
- notifyConsoleOnCompletion(session, status[0], null);
- } catch (CVSException e) {
- notifyConsoleOnCompletion(session, null, e);
- throw e;
- } catch (RuntimeException e) {
- notifyConsoleOnCompletion(session, null, e);
- throw e;
- }
- }
- };
- session.getLocalRoot().run(job, pm);
- return status[0];
- }
-
- private void notifyConsoleOnCompletion(Session session, IStatus status, Exception exception) {
- if (session.isOutputToConsole()) {
- IConsoleListener consoleListener = CVSProviderPlugin.getPlugin().getConsoleListener();
- if (consoleListener != null) consoleListener.commandCompleted(status, exception);
- }
- if (Policy.DEBUG_CVS_PROTOCOL) {
- if (status != null) System.out.println("RESULT> " + status.toString()); //$NON-NLS-1$
- else System.out.println("RESULT> " + exception.toString()); //$NON-NLS-1$
- }
- }
-
- protected IStatus doExecute(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener,
- IProgressMonitor monitor) throws CVSException {
- ICVSResource[] resources = null;
- /*** setup progress monitor ***/
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(Policy.bind("Command.server"), 100); //$NON-NLS-1$
- Policy.checkCanceled(monitor);
- try {
- /*** prepare for command ***/
- // clear stale command state from previous runs
- session.setNoLocalChanges(DO_NOT_CHANGE.isElementOf(globalOptions));
- session.setModTime(null);
-
- /*** initiate command ***/
- // send global options
- for (int i = 0; i < globalOptions.length; i++) {
- globalOptions[i].send(session);
- }
- Policy.checkCanceled(monitor);
- // send local options
- for (int i = 0; i < localOptions.length; i++) {
- localOptions[i].send(session);
- }
- Policy.checkCanceled(monitor);
- // compute the work resources
- resources = computeWorkResources(session, localOptions, arguments);
- Policy.checkCanceled(monitor);
- // send local working directory state contributes 25% of work
- sendLocalResourceState(session, globalOptions, localOptions,
- resources, Policy.subMonitorFor(monitor, 25));
- Policy.checkCanceled(monitor);
- // send arguments
- sendArguments(session, arguments);
- // send local working directory path
- sendLocalWorkingDirectory(session);
-
- // if no listener was provided, use the command's default in order to get error reporting
- if (listener == null) listener = getDefaultCommandOutputListener();
-
- /*** execute command and process responses ***/
- // Processing responses contributes 70% of work.
- IStatus status = executeRequest(session, listener, Policy.subMonitorFor(monitor, 70));
-
- // Finished adds last 5% of work.
- commandFinished(session, globalOptions, localOptions, resources, Policy.subMonitorFor(monitor, 5),
- status.getCode() != CVSStatus.SERVER_ERROR);
- return status;
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Constucts the CVS command invocation string corresponding to the arguments.
- *
- * @param globalOptions the global options
- * @param localOption the local options
- * @param arguments the arguments
- * @return the command invocation string
- */
- private String constructCommandInvocationString(GlobalOption[] globalOptions,
- LocalOption[] localOptions, String[] arguments) {
- StringBuffer commandLine = new StringBuffer("cvs"); //$NON-NLS-1$
- for (int i = 0; i < globalOptions.length; ++i) {
- String option = globalOptions[i].toString();
- if (option.length() == 0) continue;
- commandLine.append(' ');
- commandLine.append(option);
- }
- commandLine.append(' ');
- commandLine.append(getRequestId());
- for (int i = 0; i < localOptions.length; ++i) {
- String option = localOptions[i].toString();
- if (option.length() == 0) continue;
- commandLine.append(' ');
- commandLine.append(option);
- }
- for (int i = 0; i < arguments.length; ++i) {
- if (arguments[i].length() == 0) continue;
- commandLine.append(" \""); //$NON-NLS-1$
- commandLine.append(arguments[i]);
- commandLine.append('"'); //$NON-NLS-1$
- }
- return commandLine.toString();
- }
-
- /**
- * Superclass for all CVS command options
- */
- protected static abstract class Option {
- protected String option, argument;
- protected Option(String option, String argument) {
- this.option = option;
- this.argument = argument;
- }
- /**
- * Determines if this option is an element of an array of options
- * @param array the array of options
- * @return true iff the array contains this option
- */
- public boolean isElementOf(Option[] array) {
- return findOption(array, option) != null;
- }
- /**
- * Returns the option part of the option
- */
- String getOption() {
- return option;
- }
- /**
- * Compares two options for equality.
- * @param other the other option
- */
- public boolean equals(Object other) {
- if (this == other) return true;
- if (other instanceof Option) {
- Option otherOption = (Option) other;
- return option.equals(otherOption.option);
- }
- return false;
- }
- /**
- * Sends the option to a CVS server
- * @param session the CVS session
- */
- public abstract void send(Session session) throws CVSException;
- /*
- * To make debugging a tad easier.
- */
- public String toString() {
- if (argument != null && argument.length() != 0) {
- return option + " \"" + argument + '"'; //$NON-NLS-1$
- } else {
- return option;
- }
- }
- }
- /**
- * Option subtype for global options that are common to all commands.
- */
- public static class GlobalOption extends Option {
- protected GlobalOption(String option) {
- super(option, null);
- }
- public void send(Session session) throws CVSException {
- session.sendGlobalOption(option);
- }
- }
- /**
- * Option subtype for global quietness options.
- */
- public static final class QuietOption extends GlobalOption {
- private QuietOption(String option) {
- super(option);
- }
- public void send(Session session) throws CVSException {
- if (option.length() != 0) super.send(session);
- }
- }
- /**
- * Option subtype for local options that vary from command to command.
- */
- public static class LocalOption extends Option {
- protected LocalOption(String option) {
- super(option, null);
- }
- protected LocalOption(String option, String argument) {
- super(option, argument);
- }
- public void send(Session session) throws CVSException {
- session.sendArgument(option);
- if (argument != null) session.sendArgument(argument);
- }
- }
- /**
- * Options subtype for keyword substitution options.
- */
- public static class KSubstOption extends LocalOption {
- private boolean isUnknownMode;
- private KSubstOption(String option) {
- this(option, false);
- }
- private KSubstOption(String option, boolean isUnknownMode) {
- super(option);
- this.isUnknownMode = isUnknownMode;
- ksubstOptionMap.put(option, this);
- }
- /**
- * Gets the KSubstOption instance for the specified mode.
- *
- * @param mode the mode, e.g. -kb
- * @return an instance for that mode
- */
- public static KSubstOption fromMode(String mode) {
- if (mode.length() == 0) mode = "-kkv"; // use default //$NON-NLS-1$
- KSubstOption option = (KSubstOption) ksubstOptionMap.get(mode);
- if (option == null) option = new KSubstOption(mode, true);
- return option;
- }
- /**
- * Gets the KSubstOption instance for the specified file.
- *
- * @param file the file to get the option for
- * @return an instance for that mode
- */
- public static KSubstOption fromFile(IFile file) {
- if (CVSProvider.isText(file))
- return CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption();
- return KSUBST_BINARY;
- }
- /**
- * Returns an array of all valid modes.
- */
- public static KSubstOption[] getAllKSubstOptions() {
- return (KSubstOption[]) ksubstOptionMap.values().toArray(new KSubstOption[ksubstOptionMap.size()]);
- }
- /**
- * Returns the entry line mode string for this instance.
- */
- public String toMode() {
- if (KSUBST_TEXT_EXPAND.equals(this)) return ""; //$NON-NLS-1$
- return getOption();
- }
- /**
- * Returns true if the substitution mode requires no data translation
- * during file transfer.
- */
- public boolean isBinary() {
- return KSUBST_BINARY.equals(this);
- }
- /**
- * Returns a short localized text string describing this mode.
- */
- public String getShortDisplayText() {
- if (isUnknownMode) return Policy.bind("KSubstOption.unknown.short", option); //$NON-NLS-1$
- return Policy.bind("KSubstOption." + option + ".short"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- /**
- * Returns a long localized text string describing this mode.
- */
- public String getLongDisplayText() {
- if (isUnknownMode) return Policy.bind("KSubstOption.unknown.long", option); //$NON-NLS-1$
- return Policy.bind("KSubstOption." + option + ".long"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * Makes a -m log message option.
- * Valid for: add commit import
- */
- public static LocalOption makeArgumentOption(LocalOption option, String argument) {
- return new LocalOption(option.getOption(), argument); //$NON-NLS-1$
- }
-
- /**
- * Makes a -r or -D option for a tag.
- * Valid for: checkout export history rdiff update
- */
- public static LocalOption makeTagOption(CVSTag tag) {
- int type = tag.getType();
- switch (type) {
- case CVSTag.BRANCH:
- case CVSTag.VERSION:
- return new LocalOption("-r", tag.getName()); //$NON-NLS-1$
- case CVSTag.DATE:
- return new LocalOption("-D", tag.getName()); //$NON-NLS-1$
- default:
- // tag must not be HEAD
- throw new IllegalArgumentException(Policy.bind("Command.invalidTag")); //$NON-NLS-1$
- }
- }
-
- /**
- * Find a specific option in an array of options
- * @param array the array of options
- * @param option the option string to search for
- * @return the first element matching the option string, or null if none
- */
- public static Option findOption(Option[] array, String option) {
- for (int i = 0; i < array.length; ++i) {
- if (array[i].getOption().equals(option)) return array[i];
- }
- return null;
- }
-
- /**
- * Collect all arguments of a specific option from an array of options
- * @param array the array of options
- * @param option the option string to search for
- * @return an array of all arguments of belonging to matching options
- */
- protected static String[] collectOptionArguments(Option[] array, String option) {
- List /* of String */ list = new ArrayList();
- for (int i = 0; i < array.length; ++i) {
- if (array[i].getOption().equals(option)) {
- list.add(array[i].argument);
- }
- }
- return (String[]) list.toArray(new String[list.size()]);
- }
-
- /**
- * Allows commands to filter the set of global options to be sent.
- * Subclasses that override this method should call the superclass.
- *
- * @param session the session
- * @param globalOptions the global options, read-only
- * @return the filtered global options
- */
- protected GlobalOption[] filterGlobalOptions(Session session, GlobalOption[] globalOptions) {
- if (! DO_NOT_CHANGE.isElementOf(globalOptions)) {
- QuietOption quietOption = CVSProviderPlugin.getPlugin().getQuietness();
- if (quietOption != null) {
- GlobalOption[] oldOptions = globalOptions;
- globalOptions = new GlobalOption[oldOptions.length + 1];
- System.arraycopy(oldOptions, 0, globalOptions, 1, oldOptions.length);
- globalOptions[0] = quietOption;
- }
- }
- return globalOptions;
- }
-
- /**
- * Allows commands to filter the set of local options to be sent.
- * Subclasses that override this method should call the superclass.
- *
- * @param session the session
- * @param globalOptions the global options, read-only
- * @param localOptions the local options, read-only
- * @return the filtered local options
- */
- protected LocalOption[] filterLocalOptions(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions) {
- return localOptions;
- }
-
- /**
- * Execute a CVS command inside an ICVSRunnable passed to Session.run()
- * <p>
- * Dispatches the commands, retrieves the results, and determines whether or
- * not an error occurred. A listener may be supplied to capture message text
- * that would normally be written to the standard error and standard output
- * streams of a command line CVS client.
- * </p>
- * @param globalOptions the array of global options, or NO_GLOBAL_OPTIONS
- * @param localOptions the array of local options, or NO_LOCAL_OPTIONS
- * @param arguments the array of arguments (usually filenames relative to localRoot), or NO_ARGUMENTS
- * @param listener the command output listener, or null to discard all messages
- * @param monitor the progress monitor
- * @return a status code indicating success or failure of the operation
- * @throws CVSException if a fatal error occurs (e.g. connection timeout)
- */
- public final IStatus execute(GlobalOption[] globalOptions, LocalOption[] localOptions, ICVSResource[] arguments,
- ICommandOutputListener listener, IProgressMonitor pm) throws CVSException {
-
- Session openSession = getOpenSession(arguments);
- if (openSession == null) {
- throw new CVSException(Policy.bind("Command.noOpenSession")); //$NON-NLS-1$
- } else {
- // Convert arguments
- List stringArguments = new ArrayList(arguments.length);
- for (int i = 0; i < arguments.length; i++) {
- stringArguments.add(arguments[i].getRelativePath(openSession.getLocalRoot()));
- }
- return execute(openSession, globalOptions, localOptions, (String[]) stringArguments.toArray(new String[stringArguments.size()]), listener, pm);
- }
- }
-
- protected Session getOpenSession(ICVSResource[] arguments) {
- // We assume that all the passed resources have the same root
- Session openSession;
- if (arguments == null || arguments.length == 0) {
- // If there are no arguments to the command, assume that the command is rooted at the workspace root
- openSession = Session.getOpenSession(CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot()));
- } else {
- openSession = Session.getOpenSession(arguments[0]);
- }
- return openSession;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java
deleted file mode 100644
index 55dcc405a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-
-public class Commit extends Command {
- /*** Local options: specific to commit ***/
- // Forces a file to be committed even if it has not been modified; implies -l.
- // NOTE: This option is not fully supported -- a file will not be sent
- // unless it is dirty. The primary use is to resend a file that may
- // or may not be changed (e.g. could depend on CR/LF translations, etc...)
- // and force the server to create a new revision and reply Checked-in.
- public static final LocalOption FORCE = new LocalOption("-f"); //$NON-NLS-1$
-
- protected Commit() { }
- protected String getRequestId() {
- return "ci"; //$NON-NLS-1$
- }
-
- /**
- * Send all files under the workingFolder as changed files to
- * the server.
- */
- protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // Get the folders we want to work on
- checkResourcesManaged(resources);
-
- // Send all changed files to the server
- ModifiedFileSender visitor = new ModifiedFileSender(session, monitor);
- visitor.visit(session, resources);
-
- // Send the changed files as arguments (because this is what other cvs clients do)
- ICVSFile[] changedFiles = visitor.getSentFiles();
- for (int i = 0; i < changedFiles.length; i++) {
- session.sendArgument(changedFiles[i].getRelativePath(session.getLocalRoot()));
- }
- }
-
- /**
- * On successful finish, prune empty directories if the -P or -D option was specified.
- */
- protected void commandFinished(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor,
- boolean succeeded) throws CVSException {
- // If we didn't succeed, don't do any post processing
- if (! succeeded) return;
-
- // If pruning is enable, prune empty directories after a commit
- if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories()) { //$NON-NLS-1$
- new PruneFolderVisitor().visit(session, resources);
- }
- }
-
- /**
- * We do not want to send the arguments here, because we send
- * them in sendRequestsToServer (special handling).
- */
- protected void sendArguments(Session session, String[] arguments) throws CVSException {
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java
deleted file mode 100644
index 080213b0c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-
-/**
- * Handles a "Copy-file" response from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Copy-file myproject/ \n
- * /u/cvsroot/myproject/oldfile.txt \n
- * newfile.txt
- * [...]
- * </pre>
- * Then we copy (or optionally rename) the local file "oldfile.txt" in
- * folder "myproject" to "newfile.txt". This response is used to create
- * a backup copy of an existing file before merging in new changes.
- * </p>
- */
-class CopyHandler extends ResponseHandler {
- public String getResponseID() {
- return "Copy-file"; //$NON-NLS-1$
- }
-
- public void handle(Session session, String localDir,
- IProgressMonitor monitor) throws CVSException {
- // read additional data for the response
- String repositoryFile = session.readLine();
- String newFile = session.readLine();
- if (session.isNoLocalChanges() || ! session.isCreateBackups()) return;
-
- // Get the local file
- String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$
- ICVSFolder mParent = session.getLocalRoot().getFolder(localDir);
- ICVSFile mFile = mParent.getFile(fileName);
-
- Assert.isTrue(mParent.exists());
- Assert.isTrue(mFile.exists() && mFile.isManaged());
-
- // rename the file
- mFile.copyTo(newFile);
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java
deleted file mode 100644
index c409935e4..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-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.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-
-/**
- * Runs the CVS diff command.
- */
-public class Diff extends Command {
- /*** Local options: specific to diff ***/
- public static final LocalOption UNIFIED_FORMAT = new LocalOption("-u"); //$NON-NLS-1$
- public static final LocalOption CONTEXT_FORMAT = new LocalOption("-c"); //$NON-NLS-1$
- public static final LocalOption INCLUDE_NEWFILES = new LocalOption("-N"); //$NON-NLS-1$
-
- protected Diff() { }
- protected String getRequestId() {
- return "diff"; //$NON-NLS-1$
- }
-
- /**
- * Overwritten to throw the CVSDiffException if the server returns an error, because it just does
- * so when there is a difference between the checked files.
- */
- protected IStatus doExecute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions,
- String[] arguments, ICommandOutputListener listener, IProgressMonitor monitor) throws CVSException {
- try {
- return super.doExecute(session, globalOptions, localOptions, arguments, listener, monitor);
- } catch (CVSServerException e) {
- if (e.containsErrors()) throw e;
- return e.getStatus();
- }
- }
-
- protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- checkResourcesManaged(resources);
- DiffStructureVisitor visitor = new DiffStructureVisitor(session, monitor);
- visitor.visit(session, resources);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java
deleted file mode 100644
index 2a4447c47..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseFile;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * The diff command needs to send a file structure to the server that differs somewhat from the canonical
- * format sent by other commands. Instead of sending new files as questionables this class sends
- * new files as modified and fakes them being added. The contents are sent to the server and are
- * included in the returned diff report.
- */
-class DiffStructureVisitor extends FileStructureVisitor {
-
- public DiffStructureVisitor(Session session, IProgressMonitor monitor) {
- super(session, false, true, monitor);
- }
-
- /**
- * Send unmanaged files as modified with a default entry line.
- */
- protected void sendFile(ICVSFile mFile) throws CVSException {
- KSubstOption ksubst;
- ResourceSyncInfo info = mFile.getSyncInfo();
- boolean addedFile = (info==null);
-
- // Send the parent folder if it hasn't been sent already
- sendFolder(mFile.getParent());
-
- Policy.checkCanceled(monitor);
-
- if (addedFile) {
- if (mFile instanceof EclipseFile) {
- EclipseFile file = (EclipseFile)mFile;
- ksubst = KSubstOption.fromFile(file.getIFile());
- } else {
- ksubst = Command.KSUBST_BINARY;
- }
- MutableResourceSyncInfo newInfo = new MutableResourceSyncInfo(mFile.getName(), null);
- newInfo.setKeywordMode(ksubst);
- info = newInfo;
- } else {
- // existing file
- ksubst = info.getKeywordMode();
- }
- session.sendEntry(info.getServerEntryLine(null));
-
- if (!mFile.exists()) {
- return;
- }
-
- if (mFile.isModified() || addedFile) {
- session.sendModified(mFile, ksubst.isBinary(), monitor);
- } else {
- session.sendUnchanged(mFile);
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java
deleted file mode 100644
index 7dcb27033..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * 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.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-public class ExpandModules extends Request {
- protected ExpandModules() { }
- protected String getRequestId() {
- return "expand-modules"; //$NON-NLS-1$
- }
-
- public IStatus execute(Session session, String[] modules, IProgressMonitor monitor) throws CVSException {
- // Reset the module expansions before the responses arrive
- session.resetModuleExpansion();
- for (int i = 0; i < modules.length; ++i) {
- session.sendArgument(modules[i]);
- }
- return executeRequest(session, Command.DEFAULT_OUTPUT_LISTENER, monitor);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java
deleted file mode 100644
index 61b4d85f5..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-
-/**
- * Visitor to send the local file structure to the CVS Server.
- *
- * Files are sent as Unchanged or Modified.
- * Folders are sent if they contain files unless sendEmptyFolders is true
- * in which case all folders are sent.
- *
- * @param sendEmptyFolders sends the folder-entrie even if there is no file
- to send in it
- */
-
-class FileStructureVisitor extends AbstractStructureVisitor {
-
- private final boolean sendEmptyFolders;
- private final Set sentFiles;
-
- /**
- * Constructor for the visitor
- *
- * @param modifiedOnly sends files that are modified only to the server
- * @param emptyFolders sends the folder-entrie even if there is no file to send in it
- */
- public FileStructureVisitor(Session session, boolean sendEmptyFolders, boolean sendModifiedContents, IProgressMonitor monitor) {
-
- super(session, true, sendModifiedContents, monitor);
- this.sendEmptyFolders = sendEmptyFolders;
- sentFiles = new HashSet();
- }
-
- /**
- * @see ICVSResourceVisitor#visitFile(IManagedFile)
- */
- public void visitFile(ICVSFile mFile) throws CVSException {
- sendFile(mFile);
- }
-
- /**
- * @see ICVSResourceVisitor#visitFolder(ICVSFolder)
- */
- public void visitFolder(ICVSFolder mFolder) throws CVSException {
-
- if (sendEmptyFolders) {
- // If we want to send empty folder, that just send it when
- // we come to it
- sendFolder(mFolder);
- }
-
- boolean exists = mFolder.exists();
- boolean isCVSFolder = mFolder.isCVSFolder();
-
- // We are only interested in folders that exist or are CVS folders
- // A folder could be a non-existant CVS folder if it is a holder for outgoing file deletions
- if ( ! exists && ! isCVSFolder) return;
-
- if (exists && isOrphanedSubtree(mFolder)) {
- return;
- }
-
- // Send files, then the questionable folders, then the managed folders
- ICVSResource[] files = mFolder.members(ICVSFolder.FILE_MEMBERS);
- for (int i = 0; i < files.length; i++) {
- files[i].accept(this);
- }
- ICVSResource[] folders = mFolder.members(ICVSFolder.FOLDER_MEMBERS | ICVSFolder.UNMANAGED_MEMBERS);
- for (int i = 0; i < folders.length; i++) {
- folders[i].accept(this);
- }
- folders = mFolder.members(ICVSFolder.FOLDER_MEMBERS | ICVSFolder.MANAGED_MEMBERS);
- for (int i = 0; i < folders.length; i++) {
- folders[i].accept(this);
- }
- }
-
- protected void sendFile(ICVSFile mFile) throws CVSException {
-
- // Send the parent folder if it hasn't been sent already
- sendFolder(mFile.getParent());
-
- // Send the file
- super.sendFile(mFile);
-
- // Record all managed files we sent
- if (mFile.isManaged()) {
- sentFiles.add(mFile);
- }
- }
-
- /**
- * Return all the files that have been send to the server
- */
- public ICVSFile[] getSentFiles() {
- return (ICVSFile[]) sentFiles.toArray(new ICVSFile[sentFiles.size()]);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java
deleted file mode 100644
index 4a2d3e616..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-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.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-
-
-public class Import extends Command {
- /*** Local options: specific to import ***/
- public static LocalOption makeBinaryWrapperOption(String pattern) {
- return new LocalOption("-W", pattern + " -k 'b'"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- protected Import() { }
- protected String getRequestId() {
- return "import"; //$NON-NLS-1$
- }
-
- protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions,
- String[] arguments) throws CVSException {
- if (arguments.length < 3) throw new IllegalArgumentException();
- return new ICVSResource[0];
- }
-
- protected IStatus doExecute(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener,
- IProgressMonitor monitor) throws CVSException {
-
- // If the branch option is not provided, a default value of 1.1.1 is used.
- // This is done to maintain reference client compatibility
- if (findOption(localOptions, "-b") == null) { //$NON-NLS-1$
- LocalOption[] newLocalOptions = new LocalOption[localOptions.length + 1];
- newLocalOptions[0] = new LocalOption("-b", "1.1.1"); //$NON-NLS-1$ //$NON-NLS-2$
- System.arraycopy(localOptions, 0, newLocalOptions, 1, localOptions.length);
- localOptions = newLocalOptions;
- }
- return super.doExecute(session, globalOptions, localOptions, arguments, listener, monitor);
- }
-
- protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- ICVSResourceVisitor visitor = new ImportStructureVisitor(session,
- collectOptionArguments(localOptions, "-W"), monitor); //$NON-NLS-1$
- session.getLocalRoot().accept(visitor);
- }
-
- protected void sendLocalWorkingDirectory(Session session) throws CVSException {
- session.sendConstructedRootDirectory();
- }
-
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java
deleted file mode 100644
index fd7d3ccd0..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.Set;
-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.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.util.FileNameMatcher;
-
-/**
- * The ImportStructureVisitor sends the content of the folder it is
- * used on to the server. It constructs the locations of the resources
- * because the resources do not yet have a remote-location.<br>
- * It can also ignore certain files and decides wether to send
- * a file in binary or text mode due to a specification that is passed
- * as a "wrapper" argument.
- */
-class ImportStructureVisitor implements ICVSResourceVisitor {
-
- private static final String KEYWORD_OPTION = "-k"; //$NON-NLS-1$
- private static final String QUOTE = "'"; //$NON-NLS-1$
-
- protected Session session;
- private Set sentFolders;
- protected IProgressMonitor monitor;
- private String[] wrappers;
-
- private FileNameMatcher ignoreMatcher;
- private FileNameMatcher wrapMatcher;
-
- /**
- * Constructor for ImportStructureVisitor.
- * @param requestSender
- * @param mRoot
- * @param monitor
- */
- public ImportStructureVisitor(Session session,
- String[] wrappers, IProgressMonitor monitor) {
-
- this.session = session;
- this.monitor = Policy.infiniteSubMonitorFor(monitor, 512);
- this.wrappers = wrappers;
- wrapMatcher = initWrapMatcher(wrappers);
- }
-
-
- /**
- * Inits the wrapMatcher, that is responsible to find out
- * whether a file is to be send as a binary (on an import)
- * or not.
- *
- * Takes wrappers of this format:
- * *.class -k 'o'
- *
- * and inits the FileNameMatcher to give
- * -ko back if you call it with match("somename.class")
- *
- * ignores all wrappers, that do not contain -k
- */
- private FileNameMatcher initWrapMatcher(String[] wrappers) {
-
- FileNameMatcher wrapMatcher;
-
- if (wrappers == null) {
- return null;
- }
-
- wrapMatcher = new FileNameMatcher();
-
- for (int i = 0; i < wrappers.length; i++) {
-
- if (wrappers[i].indexOf(KEYWORD_OPTION) == -1) {
- continue;
- }
-
- StringTokenizer st = new StringTokenizer(wrappers[i]);
- String pattern = st.nextToken();
- String option = st.nextToken();
- // get rid of the quotes
- StringTokenizer quoteSt =
- new StringTokenizer(st.nextToken(),QUOTE);
- option += quoteSt.nextToken();
-
- wrapMatcher.register(pattern,option);
- }
-
- return wrapMatcher;
- }
-
- /**
- * @see ICVSResourceVisitor#visitFile(IManagedFile)
- */
- public void visitFile(ICVSFile mFile) throws CVSException {
- if (ignoreMatcher != null && ignoreMatcher.match(mFile.getName())) {
- return;
- }
-
- // XXX should we default to text or to binary?
- boolean binary = false;
- if (wrapMatcher != null) {
- String mode = wrapMatcher.getMatch(mFile.getName());
- if (mode != null) binary = KSubstOption.fromMode(mode).isBinary();
- }
- session.sendModified(mFile, binary, monitor);
- }
-
- /**
- * @see ICVSResourceVisitor#visitFolder(ICVSFolder)
- */
- public void visitFolder(ICVSFolder mFolder) throws CVSException {
-
- if (ignoreMatcher != null && ignoreMatcher.match(mFolder.getName())) {
- return;
- }
-
- String localPath = mFolder.getRelativePath(session.getLocalRoot());
- monitor.subTask(Policy.bind("AbstractStructureVisitor.sendingFolder", localPath)); //$NON-NLS-1$
-
- session.sendConstructedDirectory(localPath);
- mFolder.acceptChildren(this);
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java
deleted file mode 100644
index e33f34218..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.team.internal.ccvs.core.client.Command.LocalOption;
-
-public class Log extends AbstractMessageCommand {
- /*** Local options: specific to log ***/
-
- public static LocalOption makeRevisionOption(String revision) {
- return new LocalOption("-r" + revision, null); //$NON-NLS-1$
- }
-
- protected Log() { }
- protected String getRequestId() {
- return "log"; //$NON-NLS-1$
- }
-}
-
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
deleted file mode 100644
index 104ef426a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * 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")) { //$NON-NLS-1$
- 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/ModTimeHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java
deleted file mode 100644
index a4fda8c30..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.text.ParseException;
-
-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.util.CVSDateFormatter;
-
-/**
- * Handles a "Mod-time" response from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Mod-time 18 Oct 2001 20:21:13 -0330\n
- * [...]
- * </pre>
- * Then we parse and remember the date for use in subsequent
- * file transfer responses such as Updated.
- * </p>
- */
-class ModTimeHandler extends ResponseHandler {
- public String getResponseID() {
- return "Mod-time"; //$NON-NLS-1$
- }
-
- public void handle(Session session, String timeStamp,
- IProgressMonitor monitor) throws CVSException {
- try {
- session.setModTime(CVSDateFormatter.serverStampToDate(timeStamp));
- } catch (ParseException e) {
- throw new CVSException(Policy.bind("ModTimeHandler.invalidFormat", timeStamp), e); //$NON-NLS-1$
- }
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModifiedFileSender.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModifiedFileSender.java
deleted file mode 100644
index f2054ae9d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModifiedFileSender.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-
-/**
- * Visit the CVS file structure, only sending files if they are modified.
- */
-class ModifiedFileSender extends FileStructureVisitor {
-
- public ModifiedFileSender(Session session, IProgressMonitor monitor) {
- super(session, false, true, monitor);
- }
-
- /**
- * Override sendFile to only send modified files
- */
- protected void sendFile(ICVSFile mFile) throws CVSException {
-
- // Only send the file if its modified
- if (mFile.isModified()) {
- super.sendFile(mFile);
- }
- }
-
- protected String getSendFileTitleKey() {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModuleExpansionHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModuleExpansionHandler.java
deleted file mode 100644
index 657377c44..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModuleExpansionHandler.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-public class ModuleExpansionHandler extends ResponseHandler {
-
- /*
- * @see ResponseHandler#getResponseID()
- */
- public String getResponseID() {
- return "Module-expansion";//$NON-NLS-1$
- }
-
- /*
- * @see ResponseHandler#handle(Session, String, IProgressMonitor)
- */
- public void handle(Session session, String expansion, IProgressMonitor monitor)
- throws CVSException {
-
- session.addModuleExpansion(expansion);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java
deleted file mode 100644
index c86c9a030..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-public class NewEntryHandler extends ResponseHandler {
-
- /*
- * @see ResponseHandler#getResponseID()
- */
- public String getResponseID() {
- return "New-entry"; //$NON-NLS-1$
- }
-
- /*
- * @see ResponseHandler#handle(Session, String, IProgressMonitor)
- */
- public void handle(Session session, String localDir, IProgressMonitor monitor)
- throws CVSException {
-
- // read additional data for the response
- String repositoryFile = session.readLine();
- String entryLine = session.readLine();
-
- // Clear the recorded mod-time
- session.setModTime(null);
-
- // Get the local file
- String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$
- ICVSFolder mParent = session.getLocalRoot().getFolder(localDir);
- ICVSFile mFile = mParent.getFile(fileName);
-
- ResourceSyncInfo fileInfo = mFile.getSyncInfo();
- ResourceSyncInfo newInfo = new ResourceSyncInfo(entryLine, fileInfo.getPermissions(), null);
- mFile.setSyncInfo(newInfo);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java
deleted file mode 100644
index 6eeb0d7c9..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-
-/**
- * Goes recursivly through the folders checks if they are empyty
- * and deletes them. Of course it is starting at the leaves of the
- * recusion (the folders that do not have subfolders).
- */
-class PruneFolderVisitor implements ICVSResourceVisitor {
-
- private Session session;
-
- public PruneFolderVisitor() {
- }
-
- /**
- * This method is used to visit a set of ICVSResources.
- */
- public void visit(Session s, ICVSResource[] resources) throws CVSException {
- session = s;
-
- // Visit the resources
- for (int i = 0; i < resources.length; i++) {
- resources[i].accept(this);
- }
- }
-
- /**
- * @see ICVSResourceVisitor#visitFile(IManagedFile)
- */
- public void visitFile(ICVSFile file) throws CVSException {
- }
-
- /**
- * @see ICVSResourceVisitor#visitFolder(ICVSFolder)
- */
- public void visitFolder(ICVSFolder folder) throws CVSException {
- // First prune any empty children
- folder.acceptChildren(this);
- // Then prune the folder if it is managed, not the command root and is empty
- if (folder.isManaged() &&
- ! folder.equals(session.getLocalRoot()) &&
- folder.members(ICVSFolder.ALL_MEMBERS).length == 0) {
- folder.delete();
- folder.unmanage(null);
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java
deleted file mode 100644
index cb98a6799..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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 java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-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.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-
-public class RTag extends RemoteCommand {
- /*** Local options: specific to tag ***/
- public static final LocalOption CREATE_BRANCH = Tag.CREATE_BRANCH;
- public static final LocalOption CLEAR_FROM_REMOVED = new LocalOption("-a", null); //$NON-NLS-1$
- public static final LocalOption FORCE_REASSIGNMENT = new LocalOption("-F", null); //$NON-NLS-1$
-
- /**
- * Makes a -r or -D option for a tag.
- * Valid for: checkout export history rdiff update
- */
- public static LocalOption makeTagOption(CVSTag tag) {
- int type = tag.getType();
- switch (type) {
- case CVSTag.BRANCH:
- case CVSTag.VERSION:
- case CVSTag.HEAD:
- return new LocalOption("-r", tag.getName()); //$NON-NLS-1$
- case CVSTag.DATE:
- return new LocalOption("-D", tag.getName()); //$NON-NLS-1$
- default:
- // Unknow tag type!!!
- throw new IllegalArgumentException();
- }
- }
-
- protected String getRequestId() {
- return "rtag"; //$NON-NLS-1$
- }
-
- protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions,
- String[] arguments) throws CVSException {
- if (arguments.length < 2) throw new IllegalArgumentException();
- return super.computeWorkResources(session, localOptions, arguments);
- }
-
- public IStatus execute(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, CVSTag sourceTag, CVSTag tag, String[] arguments,
- IProgressMonitor monitor) throws CVSException {
-
- if(tag.getType() != CVSTag.VERSION && tag.getType() != CVSTag.BRANCH) {
- throw new CVSException(new CVSStatus(IStatus.ERROR, Policy.bind("Tag.notVersionOrBranchError"))); //$NON-NLS-1$
- }
-
- // Add the source tag to the local options
- List modifiedLocalOptions = new ArrayList(localOptions.length + 1);
- if (sourceTag==null) sourceTag = CVSTag.DEFAULT;
- modifiedLocalOptions.addAll(Arrays.asList(localOptions));
- modifiedLocalOptions.add(makeTagOption(sourceTag));
-
- // Add the CREATE_BRANCH option for a branch tag
- if (tag.getType() == tag.BRANCH) {
- if ( ! CREATE_BRANCH.isElementOf(localOptions)) {
- modifiedLocalOptions.add(CREATE_BRANCH);
- }
- }
-
- // Add the tag name to the start of the arguments
- String[] newArguments = new String[arguments.length + 1];
- newArguments[0] = tag.getName();
- System.arraycopy(arguments, 0, newArguments, 1, arguments.length);
-
- return execute(session, globalOptions,
- (LocalOption[]) modifiedLocalOptions.toArray(new LocalOption[modifiedLocalOptions.size()]),
- newArguments, null, monitor);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java
deleted file mode 100644
index 2460bcf4e..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * 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;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-
-/**
- * This class acts as a super class for those CVS commands that do not send up the local file structure
- */
-public abstract class RemoteCommand extends Command {
-
- protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions,
- String[] arguments) throws CVSException {
- return new ICVSResource[0];
- }
-
- protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
- // do nothing
- }
-
- protected void sendLocalWorkingDirectory(Session session) throws CVSException {
- // do nothing
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java
deleted file mode 100644
index d34a1de62..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-
-public class Remove extends Command {
- /*** Local options: specific to remove ***/
-
- protected Remove() { }
- protected String getRequestId() {
- return "remove"; //$NON-NLS-1$
- }
-
- protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // Send all modified files to the server
- // XXX Does the command line client send all modified files?
- new ModifiedFileSender(session, monitor).visit(session, resources);
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java
deleted file mode 100644
index ca2124fca..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-
-/**
- * Handles a "Remove-entry" response from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Remove-entry ??? \n
- * [...]
- * </pre>
- * Then
- * </p>
- */
-
-/**
- * It removes the file from both the entries of the parent-folder.
- * This happen, when the folder has allready been removed locally
- * what happens on a checkin that includes a removed file.
- */
-class RemoveEntryHandler extends ResponseHandler {
- public String getResponseID() {
- return "Remove-entry"; //$NON-NLS-1$
- }
-
- public void handle(Session session, String localDir,
- IProgressMonitor monitor) throws CVSException {
- // read additional data for the response
- String repositoryFile = session.readLine();
-
- // Get the local file
- String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$
- ICVSFolder mParent = session.getLocalRoot().getFolder(localDir);
- ICVSFile mFile = mParent.getFile(fileName);
- mFile.unmanage(null);
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java
deleted file mode 100644
index 49ee8dbcc..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.Policy;
-
-/**
- * Handles a "Removed" response from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Removed ??? \n
- * [...]
- * </pre>
- * Then
- * </p>
- */
-
-/**
- * It removes the file from both the entries of the parent-folder
- * and from the local filesystem.
- */
-class RemovedHandler extends ResponseHandler {
- public String getResponseID() {
- return "Removed"; //$NON-NLS-1$
- }
-
- public void handle(Session session, String localDir, IProgressMonitor monitor) throws CVSException {
-
- // read additional data for the response
- String repositoryFile = session.readLine();
-
- // Get the local file
- String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$
- ICVSFolder mParent = session.getLocalRoot().getFolder(localDir);
- ICVSFile mFile = mParent.getFile(fileName);
-
- if ( ! mFile.isManaged()) {
- throw new CVSException(Policy.bind("RemovedHandler.invalid", new Path(localDir).append(fileName).toString())); //$NON-NLS-1$
- }
-
- // delete then unmanage the file
- if (mFile.isReadOnly()) mFile.setReadOnly(false);
- mFile.delete();
- mFile.unmanage(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
deleted file mode 100644
index 8cb1bb9e2..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * 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 java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-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.Policy;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener;
-
-/**
- * Abstract base class for requests that are to be sent to the server.
- */
-public abstract class Request {
- public static final ExpandModules EXPAND_MODULES = new ExpandModules();
- public static final ValidRequests VALID_REQUESTS = new ValidRequests();
-
- /*** Response handler map ***/
- private static final Map responseHandlers = new HashMap();
- static {
- registerResponseHandler(new CheckedInHandler());
- registerResponseHandler(new CopyHandler());
- registerResponseHandler(new ModTimeHandler());
- registerResponseHandler(new NewEntryHandler());
- registerResponseHandler(new RemovedHandler());
- registerResponseHandler(new RemoveEntryHandler());
- registerResponseHandler(new StaticHandler(true));
- registerResponseHandler(new StaticHandler(false));
- registerResponseHandler(new StickyHandler(true));
- registerResponseHandler(new StickyHandler(false));
- registerResponseHandler(new UpdatedHandler(UpdatedHandler.HANDLE_UPDATED));
- registerResponseHandler(new UpdatedHandler(UpdatedHandler.HANDLE_UPDATE_EXISTING));
- registerResponseHandler(new UpdatedHandler(UpdatedHandler.HANDLE_CREATED));
- registerResponseHandler(new UpdatedHandler(UpdatedHandler.HANDLE_MERGED));
- registerResponseHandler(new ValidRequestsHandler());
- registerResponseHandler(new ModuleExpansionHandler());
- registerResponseHandler(new MTHandler());
- }
- protected static void registerResponseHandler(ResponseHandler handler) {
- responseHandlers.put(handler.getResponseID(), handler);
- }
- protected static void removeResponseHandler(String responseID) {
- responseHandlers.remove(responseID);
- }
- protected static ResponseHandler getResponseHandler(String responseID) {
- return (ResponseHandler)responseHandlers.get(responseID);
- }
-
- /**
- * Prevents client code from instantiating us.
- */
- protected Request() { }
-
- /**
- * Returns the string used to invoke this request on the server.
- * [template method]
- *
- * @return the request identifier string
- */
- protected abstract String getRequestId();
-
- /**
- * Executes a request and processes the responses.
- *
- * @param session the open CVS session
- * @param listener the command output listener, or null to discard all messages
- * @param monitor the progress monitor
- * @return a status code indicating success or failure of the operation
- */
- protected IStatus executeRequest(Session session, ICommandOutputListener listener,
- IProgressMonitor monitor) throws CVSException {
- // send request
- session.sendRequest(getRequestId());
-
- // This number can be tweaked if the monitor is judged to move too
- // quickly or too slowly. After some experimentation this is a good
- // number for both large projects (it doesn't move so quickly as to
- // give a false sense of speed) and smaller projects (it actually does
- // move some rather than remaining still and then jumping to 100).
- final int TOTAL_WORK = 300;
- monitor.beginTask(Policy.bind("Command.receivingResponses"), TOTAL_WORK); //$NON-NLS-1$
- int halfWay = TOTAL_WORK / 2;
- int currentIncrement = 4;
- int nextProgress = currentIncrement;
- int worked = 0;
-
- // If the session is connected to a CVSNT server (1.11.1.1), we'll need to do some special handling for
- // some errors. Unfortunately, CVSNT 1.11.1.1 will drop the connection after so some functionality is
- // still effected
- boolean isCVSNT = session.isCVSNT();
-
- List accumulatedStatus = new ArrayList();
- for (;;) {
- // update monitor work amount
- if (--nextProgress <= 0) {
- monitor.worked(1);
- worked++;
- if (worked >= halfWay) {
- // we have passed the current halfway point, so double the
- // increment and reset the halfway point.
- currentIncrement *= 2;
- halfWay += (TOTAL_WORK - halfWay) / 2;
- }
- // reset the progress counter to another full increment
- nextProgress = currentIncrement;
- }
- Policy.checkCanceled(monitor);
-
- // retrieve a response line
- String response = session.readLine();
- int spacePos = response.indexOf(' ');
- String argument;
- if (spacePos != -1) {
- argument = response.substring(spacePos + 1);
- response = response.substring(0, spacePos);
- } else argument = ""; //$NON-NLS-1$
-
- // handle completion responses
- if (response.equals("ok")) { //$NON-NLS-1$
- break;
- } else if (response.equals("error") || (isCVSNT && response.equals(""))) { //$NON-NLS-1$ //$NON-NLS-2$
- if (argument.trim().length() == 0) {
- argument = Policy.bind("Command.serverError", Policy.bind("Command." + getRequestId())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (accumulatedStatus.isEmpty()) {
- accumulatedStatus.add(new CVSStatus(CVSStatus.ERROR, CVSStatus.SERVER_ERROR, Policy.bind("Command.noMoreInfoAvailable")));//$NON-NLS-1$
- }
- return new MultiStatus(CVSProviderPlugin.ID, CVSStatus.SERVER_ERROR,
- (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);
- if (session.isOutputToConsole()) {
- IConsoleListener consoleListener = CVSProviderPlugin.getPlugin().getConsoleListener();
- if (consoleListener != null) consoleListener.messageLineReceived(argument);
- }
- } else if (response.equals("E")) { //$NON-NLS-1$
- IStatus status = listener.errorLine(argument, session.getLocalRoot(), monitor);
- if (status != ICommandOutputListener.OK) accumulatedStatus.add(status);
- if (session.isOutputToConsole()) {
- IConsoleListener consoleListener = CVSProviderPlugin.getPlugin().getConsoleListener();
- if (consoleListener != null) consoleListener.errorLineReceived(argument);
- }
- // handle other responses
- } else {
- ResponseHandler handler = (ResponseHandler) 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 (accumulatedStatus.isEmpty()) {
- return ICommandOutputListener.OK;
- } else {
- return new MultiStatus(CVSProviderPlugin.ID, CVSStatus.INFO,
- (IStatus[]) accumulatedStatus.toArray(new IStatus[accumulatedStatus.size()]),
- Policy.bind("Command.warnings", Policy.bind("Command." + getRequestId())), null); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * Makes a list of all valid responses; for initializing a session.
- * @return a space-delimited list of all valid response strings
- */
- static String makeResponseList() {
- StringBuffer result = new StringBuffer("ok error M E"); //$NON-NLS-1$
- Iterator elements = responseHandlers.keySet().iterator();
- while (elements.hasNext()) {
- result.append(' ');
- result.append((String) elements.next());
- }
-
- return result.toString();
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java
deleted file mode 100644
index aa52aae52..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * Handles server responses that arise as a result of issuing a request
- * (usually a command) to a CVS server. The processing of each such
- * response is deferred to subclasses.
- */
-public abstract class ResponseHandler {
- /**
- * Returns the text string of the server response handled by this object.
- * @return the id
- */
- public abstract String getResponseID();
-
- /**
- * Handles a server response.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Clear-sticky myDirectory \n
- * /u/cvsroot/myDirectory \n
- * [...]
- * </pre>
- * Then the <code>handle</code> method of the <code>ResponseHandler</code>
- * for <em>Clear-sticky</em> will be invoked with <code>argument</code>
- * set to <em>"myDirectory"</em>. It must then read the remaining
- * response data from the connection (<em>"/u/cvsroot/myDirectory"</em>
- * including the newline) and take any necessary action.
- * </p><p>
- * Note: The type and quantity of additional data that must be read
- * from the connection varies on a per-response basis.
- * </p>
- * @param session the Session used for CVS communication
- * @param argument the argument supplied with the response
- * @param monitor the progress monitor for the current CVS command
- */
- public abstract void handle(Session session, String argument,
- IProgressMonitor monitor) throws CVSException;
-
- /**
- * Creates a new CVS folder.
- * @param localDir the local path of the folder relative to root
- * @param repositoryDir the remote path of the folder relative to the repository
- * @return the new folder
- */
- protected static ICVSFolder createFolder(Session session,
- String localDir, String repositoryDir) throws CVSException {
- ICVSFolder folder = session.getLocalRoot().getFolder(localDir);
- if (! folder.exists()) {
- try {
- folder.mkdir();
- } catch (CVSException original) {
- boolean caseInvariant = false;
- if (original.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
- // We will try to create the mapped child below.
- caseInvariant = true;
- } else if (original.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND) {
- // The parent of the folder doesn't exist. It could be due to case invariance.
- // Check if there is a case invariant mapping for the folder
- String actualLocalDir = session.getUniquePathForCaseSensitivePath(localDir, false);
- folder = session.getLocalRoot().getFolder(actualLocalDir);
- try {
- if (! folder.exists()) folder.mkdir();
- // We succeed in creating the child of a mapped parent
- // Since caseInvariant is false, we will fall through
- } catch (CVSException ex) {
- if (ex.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
- // We will try to create he mapped child below.
- caseInvariant = true;
- } else {
- // The atempt to get the mapped parent failed.
- // Throw the original exception
- throw original;
- }
- }
- } else {
- throw original;
- }
- if (caseInvariant) {
- // Change the name (last segment) of the localDir to a unique name for the case invariant one
- String newlocalDir = session.getUniquePathForCaseSensitivePath(localDir, true);
- folder = session.getLocalRoot().getFolder(newlocalDir);
- if (! folder.exists()) folder.mkdir();
- // Signal to the session that there is a renamed folder.
- session.addCaseCollision(localDir, newlocalDir);
- }
- }
- }
- if (! folder.isCVSFolder()) {
- folder.setFolderSyncInfo(new FolderSyncInfo(
- Util.getRelativePath(session.getRepositoryRoot(), repositoryDir),
- session.getCVSRepositoryLocation().getLocation(),
- null, false));
- }
- return folder;
- }
-}
-
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
deleted file mode 100644
index 15f729538..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
+++ /dev/null
@@ -1,1075 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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 java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.connection.Connection;
-import org.eclipse.team.internal.ccvs.core.streams.CRLFtoLFInputStream;
-import org.eclipse.team.internal.ccvs.core.streams.LFtoCRLFInputStream;
-import org.eclipse.team.internal.ccvs.core.streams.ProgressMonitorInputStream;
-import org.eclipse.team.internal.ccvs.core.streams.SizeConstrainedInputStream;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * Maintains CVS communication state for the lifetime of a connection
- * to a remote repository. This class covers the initialization, use,
- * and eventual shutdown of a dialogue between a CVS client and a
- * remote server. This dialogue may be monitored through the use of
- * a console.
- *
- * Initially the Session is in a CLOSED state during which communication
- * with the server cannot take place. Once OPENED, any number of commands
- * may be issued serially to the server, one at a time. When finished, the
- * Session MUST be CLOSED once again to prevent eventual local and/or
- * remote resource exhaustion. The session can either be discarded, or
- * re-opened for use with the same server though no state is persisted from
- * previous connections except for console attributes.
- *
- * CVSExceptions are thrown only as a result of unrecoverable errors. Once
- * this happens, commands must no longer be issued to the server. If the
- * Session is in the OPEN state, it is still the responsibility of the
- * caller to CLOSE it before moving on.
- */
-public class Session {
- public static final String CURRENT_LOCAL_FOLDER = "."; //$NON-NLS-1$
- public static final String CURRENT_REMOTE_FOLDER = ""; //$NON-NLS-1$
- public static final String SERVER_SEPARATOR = "/"; //$NON-NLS-1$
-
- // default file transfer buffer size (in bytes)
- private static final int TRANSFER_BUFFER_SIZE = 8192;
- // update progress bar in increments of this size (in bytes)
- // no incremental progress shown for files smaller than this size
- private static final int TRANSFER_PROGRESS_INCREMENT = 32768;
-
- private static final boolean IS_CRLF_PLATFORM = Arrays.equals(
- System.getProperty("line.separator").getBytes(), new byte[] { '\r', '\n' }); //$NON-NLS-1$
-
- private static Map currentOpenSessions = null;
- private static final int MAX_SESSIONS_OPEN = 10;
-
- private CVSRepositoryLocation location;
- private ICVSFolder localRoot;
- private boolean outputToConsole;
- private Connection connection = null;
- private String validRequests = null;
- private Date modTime = null;
- private boolean noLocalChanges = false;
- private boolean createBackups = true;
- private int compressionLevel = 0;
- private List expansions;
- private Collection /* of ICVSFile */ textTransferOverrideSet = null;
- private boolean hasBeenConnected = false;
- private Map caseMappings;
-
- // The resource bundle key that provides the file sending message
- private String sendFileTitleKey;
-
- /**
- * Creates a new CVS session, initially in the CLOSED state.
- * By default, command output is directed to the console.
- *
- * @param location the CVS repository location used for this session
- * @param localRoot represents the current working directory of the client
- */
- public Session(ICVSRepositoryLocation location, ICVSFolder localRoot) {
- this(location, localRoot, true);
- }
-
- /**
- * Creates a new CVS session, initially in the CLOSED state.
- *
- * @param location the CVS repository location used for this session
- * @param localRoot represents the current working directory of the client
- * @param outputToConsole if true, command output is directed to the console
- */
- public Session(ICVSRepositoryLocation location, ICVSFolder localRoot, boolean outputToConsole) {
- this.location = (CVSRepositoryLocation) location;
- this.localRoot = localRoot;
- this.outputToConsole = outputToConsole;
- }
-
- /**
- * Execute the given runnable in a context that has access to an open session
- *
- * A session will be opened for the provided root. If the root is null, no session is opened.
- * However, sessions will be open for nested calls to run and these sessions will not be closed
- * until the outer most run finishes.
- */
- public static void run(ICVSRepositoryLocation location, ICVSFolder root, boolean outputToConsole,
- ICVSRunnable runnable, IProgressMonitor monitor) throws CVSException {
-
- // Determine if we are nested or not
- boolean isOuterRun = false;
- if (currentOpenSessions == null) {
- // Initialize the variable to be a map
- currentOpenSessions = new HashMap();
- isOuterRun = true;
- }
-
- try {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- if (root == null) {
- // We don't have a root, so just run the runnable
- // (assuming that nested runs will create sessions)
- runnable.run(Policy.subMonitorFor(monitor, 90));
- } else {
- // Open a session on the root as far up the chain as possible
- ICVSFolder actualRoot = root;
- while (actualRoot.isManaged()) {
- actualRoot = actualRoot.getParent();
- }
- // Look for the root in the current open sessions
- Session session = (Session)currentOpenSessions.get(actualRoot);
- if (session == null) {
- // Make sure we don't exceed our maximum
- if (currentOpenSessions.size() == MAX_SESSIONS_OPEN) {
- // Pick one at random and close it
- Object key = currentOpenSessions.keySet().iterator().next();
- try {
- ((Session)currentOpenSessions.get(key)).close();
- } catch (CVSException e) {
- CVSProviderPlugin.log(e.getStatus());
- } finally {
- currentOpenSessions.remove(key);
- }
- }
- // If it's not there, open a session for the given root and remember it
- session = new Session(location, actualRoot, outputToConsole);
- session.open(Policy.subMonitorFor(monitor, 10));
- currentOpenSessions.put(actualRoot, session);
- }
-
- try {
- root.run(runnable, Policy.subMonitorFor(monitor, 100));
- } catch (CVSException e) {
- // The run didn't succeed so close the session and forget it ever existed
- try {
- // The session may have been close by a nested run
- if (currentOpenSessions.get(actualRoot) != null) session.close();
- } finally {
- currentOpenSessions.remove(actualRoot);
- throw e;
- }
- }
- }
- } finally {
- monitor.done();
- if (isOuterRun) {
- // Close all open sessions
- try {
- Iterator iter = currentOpenSessions.keySet().iterator();
- while (iter.hasNext()) {
- Session session = (Session)currentOpenSessions.get(iter.next());
- try {
- session.close();
- } catch (CVSException e) {
- CVSProviderPlugin.log(e.getStatus());
- }
- }
- } finally {
- currentOpenSessions = null;
- }
- }
- }
- }
-
- /**
- * Answer the currently open session
- */
- protected static Session getOpenSession(ICVSResource resource) {
- ICVSFolder root;
- if (resource.isFolder()) {
- root = (ICVSFolder)resource;
- } else {
- root = resource.getParent();
- }
- while (root.isManaged()) {
- root = root.getParent();
- }
- // Look for the root in the current open sessions
- return (Session)currentOpenSessions.get(root);
- }
-
- /**
- * Register a case collision with the session.
- *
- * For folders, the desired path is where the folder should be and the actual path
- * is where is was put temporarily. If one of the folders involved is pruned, the
- * other can be placed properly (see Session#handleCaseCollisions())
- *
- * For files, the desired path is where the file should be and the actual path is
- * the emtpy path indicating that the resource was not loaded.
- *
- * This makes sense because the files in a folder are always communicated before the folders
- * so a file can only collide with anothe file which can never be pruned so there's no
- * point in loading the file in a temporary place.
- */
- protected void addCaseCollision(String desiredLocalPath, String actualLocalPath) {
- if (caseMappings == null) caseMappings = new HashMap();
- IPath desiredPath = new Path(desiredLocalPath);
- IPath actualPath = new Path(actualLocalPath);
- Assert.isTrue(actualPath.equals(Path.EMPTY) || (desiredPath.segmentCount() == actualPath.segmentCount()));
- caseMappings.put(desiredPath, actualPath);
- }
- /*
- * Add a module expansion receivered from the server.
- * This is only used by the ModuleExpansionsHandler
- */
- protected void addModuleExpansion(String expansion) {
- expansions.add(expansion);
- }
-
- /*
- * Add a module expansion receivered from the server.
- * This is only used by the ExpandModules command
- */
- protected void resetModuleExpansion() {
- if (expansions == null)
- expansions = new ArrayList();
- else
- expansions.clear();
- }
-
- /**
- * Opens, authenticates and initializes a connection to the server specified
- * for the remote location.
- *
- * @param monitor the progress monitor
- * @throws IllegalStateException if the Session is not in the CLOSED state
- */
- public void open(IProgressMonitor monitor) throws CVSException {
- if (connection != null) throw new IllegalStateException();
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- try {
- connection = location.openConnection(Policy.subMonitorFor(monitor, 50));
- hasBeenConnected = true;
-
- ResponseHandler mtHandler = Request.getResponseHandler("MT"); //$NON-NLS-1$
- // accept MT messages for all non-standard server
- boolean useMT = ! (location.getServerPlatform() == location.CVS_SERVER);
- try {
- // If we're connected to a CVSNT server or we don't know the platform,
- // accept MT. Otherwise don't.
- // We only want to disable MT messages for this particular session
- // since there may be multiple sessions open.
- if ( ! useMT) {
- Request.removeResponseHandler("MT"); //$NON-NLS-1$
- }
-
- // tell the server the names of the responses we can handle
- connection.writeLine("Valid-responses " + Request.makeResponseList()); //$NON-NLS-1$
- } finally {
- // Re-register the MT handler since there may be more than one session open
- if ( ! useMT) {
- Request.registerResponseHandler(mtHandler);
- }
- }
-
- // ask for the set of valid requests
- Request.VALID_REQUESTS.execute(this, Policy.subMonitorFor(monitor, 40));
-
- // set the root directory on the server for this connection
- connection.writeLine("Root " + getRepositoryRoot()); //$NON-NLS-1$
-
- // enable compression
- compressionLevel = CVSProviderPlugin.getPlugin().getCompressionLevel();
- if (compressionLevel != 0 && isValidRequest("gzip-file-contents")) { //$NON-NLS-1$
- // Enable the use of CVS 1.8 per-file compression mechanism.
- // The newer Gzip-stream request seems to be problematic due to Java's
- // GZIPInputStream tendency to block on read() rather than to return a
- // partially filled buffer. The latter option would be better since it
- // can make more effective use of the code dictionary, if it can be made
- // to work...
- connection.writeLine("gzip-file-contents " + Integer.toString(compressionLevel)); //$NON-NLS-1$
- } else {
- compressionLevel = 0;
- }
-
- // get the server platform if it is unknown
- if (location.getServerPlatform() == location.UNDETERMINED_PLATFORM) {
- Command.VERSION.execute(this, location, Policy.subMonitorFor(monitor, 10));
- }
- } 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();
- }
- }
-
- /**
- * Closes a connection to the server.
- *
- * @throws IllegalStateException if the Session is not in the OPEN state
- */
- public void close() throws CVSException {
- if (connection == null) {
- if (hasBeenConnected) {
- throw new IllegalStateException();
- } else {
- return;
- }
- }
- connection.close();
- connection = null;
- validRequests = null;
- }
-
- /**
- * Determines if the server supports the specified request.
- *
- * @param request the request string to verify
- * @return true iff the request is supported
- */
- public boolean isValidRequest(String request) {
- return (validRequests == null) ||
- (validRequests.indexOf(" " + request + " ") != -1); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public boolean isCVSNT() {
- if (location.getServerPlatform() == location.UNDETERMINED_PLATFORM) {
- return location.getRootDirectory().indexOf(':') == 1;
- } else {
- return location.getServerPlatform() == location.CVSNT_SERVER;
- }
- }
-
- /**
- * Return a local path that can be used to uniquely identify a resource
- * if the platform does not support case variant names and there is a name collision
- */
- protected String getUniquePathForCaseSensitivePath(String localPath, boolean creatingFolder) {
- IPath path = new Path(localPath);
- IPath existingMapping = null;
- if (caseMappings != null) {
- // Look for an existing parent path that has already been mapped
- for (int i = 0; i < path.segmentCount(); i++) {
- IPath key = path.removeLastSegments(i);
- existingMapping = (IPath)caseMappings.get(key);
- if (existingMapping != null) break;
- }
- }
- if (existingMapping != null) {
- if (existingMapping.segmentCount() == path.segmentCount()) {
- return existingMapping.toString();
- }
- // Convert the path to the mapped path
- path = existingMapping.append(path.removeFirstSegments(existingMapping.segmentCount()));
- }
- if (creatingFolder) {
- // Change the name of the folder to a case insensitive one
- String folderName = path.lastSegment();
- // XXX We should ensure that each permutation of characters is unique
- folderName = getUniqueNameForCaseVariant(folderName);
- path = path.removeLastSegments(1).append(folderName);
- }
- return path.toString();
- }
-
- /*
- * Return a name that is unique for a give case variant.
- */
- private String getUniqueNameForCaseVariant(String name) {
- char[] buffer = new char[name.length() * 2];
- int position = 0;
- for (int i = 0; i < name.length(); i++) {
- char c = name.charAt(i);
- buffer[position++] = c;
- if (Character.isLetter(c)) {
- if (Character.isUpperCase(c)) {
- buffer[position++] = '-';
- } else {
- buffer[position++] = '_';
- }
- }
- }
- return new String(buffer, 0, position);
- }
-
- /**
- * Returns the local root folder for this session.
- * <p>
- * Generally speaking, specifies the "current working directory" at
- * the time of invocation of an equivalent CVS command-line client.
- * </p>
- *
- * @return the local root folder
- */
- public ICVSFolder getLocalRoot() {
- return localRoot;
- }
-
- /**
- * Return the list of module expansions communicated from the server.
- *
- * The modules expansions are typically a directory path of length 1
- * but can be of greater length on occasion.
- */
- public String[] getModuleExpansions() {
- if (expansions == null) return new String[0];
- return (String[]) expansions.toArray(new String[expansions.size()]);
- }
-
- /**
- * Returns the repository root folder for this session.
- * <p>
- * Specifies the unqualified path to the CVS repository root folder
- * on the server.
- * </p>
- *
- * @return the repository root folder
- */
- public String getRepositoryRoot() {
- return location.getRootDirectory();
- }
-
- /**
- * Returns an object representing the CVS repository location for this session.
- *
- * @return the CVS repository location
- */
- public ICVSRepositoryLocation getCVSRepositoryLocation() {
- return location;
- }
-
- private IContainer getIResourceFor(ICVSFolder cvsFolder) throws CoreException {
- if (cvsFolder.isManaged()) {
- return getIResourceFor(cvsFolder.getParent()).getFolder(new Path(cvsFolder.getName()));
- } else {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(cvsFolder.getName());
- }
- }
-
- protected void handleCaseCollisions() throws CVSException {
- // Handle any case variant mappings
- Map mappings = caseMappings;
- if (mappings == null || mappings.size() == 0) return;
- // We need to start at the longest paths and work to the shortest
- // in case there are nested case collisions
- List sortedCollisions = new ArrayList();
- sortedCollisions.addAll(mappings.keySet());
- Collections.sort(sortedCollisions, new Comparator() {
- public int compare(Object arg0, Object arg1) {
- int length0 = ((IPath)arg0).segmentCount();
- int length1 = ((IPath)arg1).segmentCount();
- if (length0 == length1) {
- return arg0.toString().compareTo(arg1.toString());
- }
- return length0 > length1 ? -1 : 1;
- }
- });
- // For each mapping, we need to see if one of the culprits was pruned
- List unhandledMappings = new ArrayList();
- Iterator iterator = sortedCollisions.iterator();
- while (iterator.hasNext()) {
- IPath desiredPath = (IPath)iterator.next();
- IPath actualPath = (IPath)mappings.get(desiredPath);
- // Check for the empty path (i.e. unloaded file)
- if (actualPath.equals(Path.EMPTY)) {
- unhandledMappings.add(desiredPath);
- continue;
- }
- // Check if the actualPath still exists (it may have been pruned)
- ICVSFolder actualFolder = getLocalRoot().getFolder(actualPath.toString());
- if ( ! actualFolder.exists()) continue;
- // Check if the desiredPath exists (we can only do this by trying to create it
- ICVSFolder desiredFolder = getLocalRoot().getFolder(desiredPath.toString());
- try {
- desiredFolder.mkdir();
- desiredFolder.delete();
- } catch (CVSException e) {
- // Must still exists. Delete the collision
- actualFolder.delete();
- actualFolder.unmanage(null);
- unhandledMappings.add(desiredPath);
- continue;
- }
- // The desired location is open (probably due to pruning)
- try {
- // We need to get the IResource for the actual and desired locations
- IResource actualResource = getIResourceFor(actualFolder);
- IResource desiredResource = actualResource.getParent().getFolder(new Path(desiredFolder.getName()));
- // Move the actual to the desired location
- actualResource.move(desiredResource.getFullPath(), false, null);
- // We need to also move the sync info. Since sync info is a session property
- // of the object, we can simpy reset the info for each moved resource
- desiredFolder.accept(new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {
- file.setSyncInfo(file.getSyncInfo());
- }
- public void visitFolder(ICVSFolder folder) throws CVSException {
- folder.setFolderSyncInfo(folder.getFolderSyncInfo());
- folder.acceptChildren(this);
- }
- });
- // Unmanage the old location in order to remove the entry from the parent
- actualFolder.unmanage(null);
- } catch (CoreException e) {
- CVSProviderPlugin.log(e.getStatus());
- unhandledMappings.add(desiredPath);
- }
- }
-
- if (unhandledMappings.size() > 0) {
- MultiStatus status = new MultiStatus(CVSProviderPlugin.ID, CVSStatus.CASE_VARIANT_EXISTS, Policy.bind("PruneFolderVisitor.caseVariantsExist"), null);//$NON-NLS-1$
- Iterator iter = unhandledMappings.iterator();
- while (iter.hasNext()) {
- IPath desiredPath = (IPath) iter.next();
- IPath actualPath = (IPath)mappings.get(desiredPath);
- status.add(new CVSStatus(IStatus.ERROR, CVSStatus.CASE_VARIANT_EXISTS,
- Policy.bind("PruneFolderVisitor.caseVariantExists", desiredPath.toString())));//$NON-NLS-1$
- }
- if (status.getChildren().length == 1) {
- throw new CVSException(status.getChildren()[0]);
- } else {
- throw new CVSException(status);
- }
- }
- }
-
- /**
- * Receives a line of text minus the newline from the server.
- *
- * @return the line of text
- */
- public String readLine() throws CVSException {
- return connection.readLine();
- }
-
- /**
- * Sends a line of text followed by a newline to the server.
- *
- * @param line the line of text
- */
- public void writeLine(String line) throws CVSException {
- connection.writeLine(line);
- }
-
- /**
- * Sends an argument to the server.
- * <p>e.g. sendArgument("Hello\nWorld\n Hello World") sends:
- * <pre>
- * Argument Hello \n
- * Argumentx World \n
- * Argumentx Hello World \n
- * </pre></p>
- *
- * @param arg the argument to send
- */
- public void sendArgument(String arg) throws CVSException {
- connection.write("Argument "); //$NON-NLS-1$
- int oldPos = 0;
- for (;;) {
- int pos = arg.indexOf('\n', oldPos);
- if (pos == -1) break;
- connection.writeLine(arg.substring(oldPos, pos));
- connection.write("Argumentx "); //$NON-NLS-1$
- oldPos = pos + 1;
- }
- connection.writeLine(arg.substring(oldPos));
- }
-
- /**
- * Sends a request to the server and flushes any output buffers.
- *
- * @param requestId the string associated with the request to be executed
- */
- public void sendRequest(String requestId) throws CVSException {
- connection.writeLine(requestId);
- connection.flush();
- }
-
- /**
- * Sends an Is-modified request to the server without the file contents.
- * <p>e.g. if a file called "local_file" was modified, sends:
- * <pre>
- * Is-modified local_file \n
- * </pre></p><p>
- * This request is an optimized form of the Modified request and may not
- * be supported by all servers. Hence, if it is not supported, a Modified
- * request is sent instead along with the file's contents. According to
- * the CVS protocol specification, this request is only safe for use with
- * some forms of: admin, annotate, diff, editors, log, watch-add, watch-off,
- * watch-on, watch-remove, and watchers.<br>
- * It may be possible to use this for: add, export, remove and status.<br>
- * Do not use with co, ci, history, init, import, release, rdiff, rtag, or update.
- * </p><p>
- * Note: The most recent Directory request must have specified the file's
- * parent folder.
- * </p>
- *
- * @param file the file that was modified
- * @see #sendModified
- */
- public void sendIsModified(ICVSFile file, boolean isBinary, IProgressMonitor monitor)
- throws CVSException {
- if (isValidRequest("Is-modified")) { //$NON-NLS-1$
- connection.writeLine("Is-modified " + file.getName()); //$NON-NLS-1$
- } else {
- sendModified(file, isBinary, monitor);
- }
- }
-
- /**
- * Sends a Static-directory request to the server.
- * <p>
- * Indicates that the directory specified in the most recent Directory request
- * is static. No new files will be checked out into this directory unless
- * explicitly requested.
- * </p>
- */
- public void sendStaticDirectory() throws CVSException {
- connection.writeLine("Static-directory"); //$NON-NLS-1$
- }
-
- /**
- * Sends a Directory request to the server with a constructed path.
- * <p>
- * It may be necessary at times to guess the remote path of a directory since
- * it does not exist yet. In this case we construct a remote path based on the
- * local path by prepending the local path with the repository root. This may
- * not work in the presence of modules, so only use it for creating new projects.
- * </p><p>
- * 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.
- * </p>
- */
- public void sendConstructedDirectory(String localDir) throws CVSException {
- sendDirectory(localDir, getRepositoryRoot() + "/" + localDir); //$NON-NLS-1$
- }
-
- /**
- * Sends a Directory request to the server.
- * <p>e.g. sendDirectory("local_dir", "remote_dir") sends:
- * <pre>
- * Directory local_dir
- * repository_root/remote_dir
- * </pre></p>
- *
- * @param localDir the path of the local directory relative to localRoot
- * @param remoteDir the path of the remote directory relative to repositoryRoot
- */
- public void sendDirectory(String localDir, String remoteDir) throws CVSException {
- if (localDir.length() == 0) localDir = "."; //$NON-NLS-1$
- connection.writeLine("Directory " + localDir); //$NON-NLS-1$
- connection.writeLine(remoteDir);
- }
-
- /**
- * Sends a Directory request for the localRoot.
- */
- public void sendLocalRootDirectory() throws CVSException {
- sendDirectory(".", localRoot.getRemoteLocation(localRoot)); //$NON-NLS-1$
- }
-
- /**
- * Sends a Directory request for the localRoot with a constructed path.
- * <p>
- * Use this when creating a new project that does not exist in the repository.
- * </p>
- * @see #sendConstructedDirectory
- */
- public void sendConstructedRootDirectory() throws CVSException {
- sendConstructedDirectory(""); //$NON-NLS-1$
- }
-
- /**
- * Sends an Entry request to the server.
- * <p>
- * Indicates that a file is managed (but it may not exist locally). Sends
- * the file's entry line to the server to indicate the version that was
- * previously checked out.
- * </p><p>
- * Note: The most recent Directory request must have specified the file's
- * parent folder.
- * </p>
- *
- * @param entryLine the formatted entry line of the managed file.
- */
- public void sendEntry(String entryLine) throws CVSException {
- connection.writeLine("Entry " + entryLine); //$NON-NLS-1$
- }
-
- /**
- * Sends a global options to the server.
- * <p>e.g. sendGlobalOption("-n") sends:
- * <pre>
- * Global_option -n \n
- * </pre></p>
- *
- * @param option the global option to send
- */
- public void sendGlobalOption(String option) throws CVSException {
- connection.writeLine("Global_option " + option); //$NON-NLS-1$
- }
-
- /**
- * Sends an Unchanged request to the server.
- * <p>e.g. if a file called "local_file" was not modified, sends:
- * <pre>
- * Unchanged local_file \n
- * </pre></p><p>
- * Note: The most recent Directory request must have specified the file's
- * parent folder.
- * </p>
- *
- * @param file the file that was not modified
- */
- public void sendUnchanged(ICVSFile file) throws CVSException {
- connection.writeLine("Unchanged " + file.getName()); //$NON-NLS-1$
- }
-
- /**
- * Sends a Questionable request to the server.
- * <p>
- * Indicates that a file exists locally but is unmanaged. Asks the server
- * whether or not the file should be ignored in subsequent CVS operations.
- * The reply to the request occurs in the form of special M-type message
- * responses prefixed with '?' when the next command is executed.
- * </p><p>
- * Note: The most recent Directory request must have specified the file's
- * parent folder.
- * </p>
- *
- * @param resource the local file or folder
- */
- public void sendQuestionable(ICVSResource resource) throws CVSException {
- connection.writeLine("Questionable " + resource.getName()); //$NON-NLS-1$
- }
-
- /**
- * Sends a Sticky tag request to the server.
- * <p>
- * Indicates that the directory specified in the most recent Directory request
- * has a sticky tag or date, and sends the tag's contents.
- * </p>
- *
- * @param tag the sticky tag associated with the directory
- */
- public void sendSticky(String tag) throws CVSException {
- connection.writeLine("Sticky " + tag); //$NON-NLS-1$
- }
-
- /**
- * Sends a Modified request to the server along with the file contents.
- * <p>e.g. if a file called "local_file" was modified, sends:
- * <pre>
- * Modified local_file \n
- * file_permissions \n
- * file_size \n
- * [... file_contents ...]
- * </pre></p><p>
- * Under some circumstances, Is-modified may be used in place of this request.<br>
- * Do not use with history, init, import, rdiff, release, rtag, or update.
- * </p><p>
- * Note: The most recent Directory request must have specified the file's
- * parent folder.
- * </p>
- *
- * @param file the file that was modified
- * @param isBinary if true the file is sent without translating line delimiters
- * @param monitor the progress monitor
- * @see #sendIsModified
- */
- public void sendModified(ICVSFile file, boolean isBinary, IProgressMonitor monitor)
- throws CVSException {
-
- String filename = file.getName();
- connection.writeLine("Modified " + filename); //$NON-NLS-1$
- ResourceSyncInfo info = file.getSyncInfo();
- if (info != null) {
- connection.writeLine(info.getPermissions());
- } else {
- // for new resources send the default permissions
- connection.writeLine(ResourceSyncInfo.getDefaultPermissions());
- }
- sendFile(file, isBinary, monitor);
- }
-
- /**
- * Sends a file to the remote CVS server, possibly translating line delimiters.
- * <p>
- * Line termination sequences are automatically converted to linefeeds only
- * (required by the CVS specification) when sending non-binary files. This
- * may alter the actual size and contents of the file that is sent.
- * </p><p>
- * Note: Non-binary files must be small enough to fit in available memory.
- * </p>
- * @param file the file to be sent
- * @param isBinary is true if the file should be sent without translation
- * @param monitor the progress monitor
- */
- public void sendFile(ICVSFile file, boolean isBinary, IProgressMonitor monitor) throws CVSException {
- // check overrides
- if (textTransferOverrideSet != null &&
- textTransferOverrideSet.contains(file)) isBinary = false;
-
- // update progress monitor
- final String title = Policy.bind(getSendFileTitleKey(), new Object[]{ Util.toTruncatedPath(file, localRoot, 3) }); //$NON-NLS-1$
- monitor.subTask(Policy.bind("Session.transferNoSize", title)); //$NON-NLS-1$
- // obtain an input stream for the file and its size
- long size = file.getSize();
- OutputStream out = connection.getOutputStream();
- try {
- InputStream in = file.getContents();
- try {
- boolean compressed = false;
- byte[] buffer = new byte[TRANSFER_BUFFER_SIZE];
- if (! isBinary && IS_CRLF_PLATFORM || compressionLevel != 0) {
- // this affects the file size, spool the converted copy to an in-memory buffer
- if (! isBinary && IS_CRLF_PLATFORM) in = new CRLFtoLFInputStream(in);
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- OutputStream zout;
- if (compressionLevel != 0) {
- try {
- zout = new GZIPOutputStream(bout); // apparently does not support specifying compression level
- compressed = true;
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- } else {
- zout = bout;
- }
- for (int count; (count = in.read(buffer)) != -1;) zout.write(buffer, 0, count);
- zout.close();
- in.close();
- byte[] contents = bout.toByteArray();
- in = new ByteArrayInputStream(contents);
- size = contents.length;
- }
- // setup progress monitoring
- in = new ProgressMonitorInputStream(in, size, TRANSFER_PROGRESS_INCREMENT, monitor) {
- protected void updateMonitor(long bytesRead, long bytesTotal, IProgressMonitor monitor) {
- if (bytesRead == 0) return;
- Assert.isTrue(bytesRead <= bytesTotal);
- monitor.subTask(Policy.bind("Session.transfer", //$NON-NLS-1$
- new Object[] { title, Long.toString(bytesRead >> 10), Long.toString(bytesTotal >> 10) }));
- }
- };
- // send the file
- String sizeLine = Long.toString(size);
- if (compressed) sizeLine = "z" + sizeLine; //$NON-NLS-1$
- writeLine(sizeLine);
- for (int count; (count = in.read(buffer)) != -1;) out.write(buffer, 0, count);
- } finally {
- in.close();
- }
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Receives a file from the remote CVS server, possibly translating line delimiters.
- * <p>
- * Line termination sequences are automatically converted to platform format
- * only when receiving non-binary files. This may alter the actual size and
- * contents of the file that is received.
- * </p><p>
- * Translation is performed on-the-fly, so the file need not fit in available memory.
- * </p>
- * @param file the file to be received
- * @param isBinary is true if the file should be received without translation
- * @param responseType one of the ICVSFile updated types (UPDATED, CREATED, MERGED, UPDATE_EXISTING)
- * indicating what repsonse type provided the file contents
- * @param monitor the progress monitor
- */
- public void receiveFile(ICVSFile file, boolean isBinary, int responseType, IProgressMonitor monitor)
- throws CVSException {
- // check overrides
- if (textTransferOverrideSet != null &&
- textTransferOverrideSet.contains(file)) isBinary = false;
-
- // update progress monitor
- final String title = Policy.bind("Session.receiving", new Object[]{ Util.toTruncatedPath(file, localRoot, 3) }); //$NON-NLS-1$
- monitor.subTask(Policy.bind("Session.transferNoSize", title)); //$NON-NLS-1$
- // get the file size from the server
- long size;
- boolean compressed = false;
- try {
- String sizeLine = readLine();
- if (sizeLine.charAt(0) == 'z') {
- compressed = true;
- sizeLine = sizeLine.substring(1);
- }
- size = Long.parseLong(sizeLine, 10);
- } catch (NumberFormatException e) {
- throw new CVSException(Policy.bind("Session.badInt"), e); //$NON-NLS-1$
- }
- // create an input stream that spans the next 'size' bytes from the connection
- InputStream in = new SizeConstrainedInputStream(connection.getInputStream(), size, true /*discardOnClose*/);
- // setup progress monitoring
- in = new ProgressMonitorInputStream(in, size, TRANSFER_PROGRESS_INCREMENT, monitor) {
- protected void updateMonitor(long bytesRead, long bytesTotal, IProgressMonitor monitor) {
- if (bytesRead == 0) return;
- monitor.subTask(Policy.bind("Session.transfer", //$NON-NLS-1$
- new Object[] { title, Long.toString(bytesRead >> 10), Long.toString(bytesTotal >> 10) }));
- }
- };
- // if compression enabled, decompress on the fly
- if (compressed) {
- try {
- in = new GZIPInputStream(in);
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- }
- // if not binary, translate line delimiters on the fly
- if (! isBinary) {
- // always auto-correct for CRLF line-ends that come from the server
- in = new CRLFtoLFInputStream(in);
- // switch from LF to CRLF if appropriate
- if (IS_CRLF_PLATFORM) in = new LFtoCRLFInputStream(in);
- }
- // write the file locally
- file.setContents(in, responseType, true, new NullProgressMonitor());
- }
-
- /**
- * Stores the value of the last Mod-time response encountered.
- * Valid only for the duration of a single CVS command.
- */
- void setModTime(Date modTime) {
- this.modTime = modTime;
- }
-
- /**
- * Returns the stored value of the last Mod-time response,
- * or null if there was none while processing the current command.
- */
- Date getModTime() {
- return modTime;
- }
-
- /**
- * Stores true if the -n global option was specified for the current command.
- * Valid only for the duration of a single CVS command.
- */
- void setNoLocalChanges(boolean noLocalChanges) {
- this.noLocalChanges = noLocalChanges;
- }
-
- /**
- * Returns true if the -n global option was specified for the current command,
- * false otherwise.
- */
- boolean isNoLocalChanges() {
- return noLocalChanges;
- }
-
- /**
- * Callback hook for the ValidRequestsHandler to specify the set of valid
- * requests for this session.
- */
- void setValidRequests(String validRequests) {
- this.validRequests = " " + validRequests + " "; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- boolean isOutputToConsole() {
- return outputToConsole;
- }
-
- /**
- * Stores a flag as to whether .# files will be created. (Default is true)
- * @param createBackups if true, creates .# files at the server's request
- */
- void setCreateBackups(boolean createBackups) {
- this.createBackups = createBackups;
- }
-
- /**
- * Returns a flag as to whether .# files will be created.
- */
- boolean isCreateBackups() {
- return createBackups;
- }
-
- /**
- * Gets the sendFileTitleKey.
- * @return Returns a String
- */
- String getSendFileTitleKey() {
- if (sendFileTitleKey == null)
- return "Session.sending"; //$NON-NLS-1$
- return sendFileTitleKey;
- }
-
- /**
- * Sets the sendFileTitleKey.
- * @param sendFileTitleKey The sendFileTitleKey to set
- */
- public void setSendFileTitleKey(String sendFileTitleKey) {
- this.sendFileTitleKey = sendFileTitleKey;
- }
-
- /**
- * Remembers a set of files that must be transferred as 'text'
- * regardless of what the isBinary parameter to sendFile() is.
- *
- * @param textTransferOverrideSet the set of ICVSFiles to override, or null if none
- */
- public void setTextTransferOverride(Collection textTransferOverrideSet) {
- this.textTransferOverrideSet = textTransferOverrideSet;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java
deleted file mode 100644
index a4c4cb9d5..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-
-/**
- * Handles any "Set-static-directory" and "Clear-static-directory" responses
- * from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Set-static-directory myproject/ \n
- * /u/cvsroot/myproject/ \n
- * [...]
- * </pre>
- * Then we set or clear the static flag of the folder "myproject",
- * automatically creating it if it does not exist locally,
- * </p>
- */
-class StaticHandler extends ResponseHandler {
- private final boolean setStaticDirectory;
-
- public StaticHandler(boolean setStaticDirectory) {
- this.setStaticDirectory = setStaticDirectory;
- }
-
- public String getResponseID() {
- if (setStaticDirectory) {
- return "Set-static-directory"; //$NON-NLS-1$
- } else {
- return "Clear-static-directory"; //$NON-NLS-1$
- }
- }
-
- public void handle(Session session, String localDir,
- IProgressMonitor monitor) throws CVSException {
- // read additional data for the response
- String repositoryDir = session.readLine();
-
- // create the directory then set or clear the static flag
- Assert.isTrue(repositoryDir.endsWith("/")); //$NON-NLS-1$
- repositoryDir = repositoryDir.substring(0, repositoryDir.length() - 1);
- ICVSFolder folder = createFolder(session, localDir, repositoryDir);
- FolderSyncInfo syncInfo = folder.getFolderSyncInfo();
- folder.setFolderSyncInfo(new FolderSyncInfo(syncInfo.getRepository(),
- syncInfo.getRoot(), syncInfo.getTag(), setStaticDirectory));
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Status.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Status.java
deleted file mode 100644
index ba1f0f05d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Status.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-public class Status extends AbstractMessageCommand {
- /*** Local options: specific to status ***/
-
- protected Status() { }
- protected String getRequestId() {
- return "status"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java
deleted file mode 100644
index 5765a0729..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-
-/**
- * Handles any "Set-sticky" and "Clear-stick" responses from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Set-sticky myproject/ \n
- * /u/cvsroot/myproject/ \n
- * Tsometag \n
- * [...]
- * </pre>
- * Then we set or clear the sticky tag property of the folder "myproject",
- * automatically creating it if it does not exist locally,
- * </p>
- */
-class StickyHandler extends ResponseHandler {
- private final boolean setSticky;
-
- public StickyHandler(boolean setSticky) {
- this.setSticky = setSticky;
- }
-
- public String getResponseID() {
- if (setSticky) {
- return "Set-sticky"; //$NON-NLS-1$
- } else {
- return "Clear-sticky"; //$NON-NLS-1$
- }
- }
-
- public void handle(Session session, String localDir,
- IProgressMonitor monitor) throws CVSException {
- // read additional data for the response
- String repositoryDir = session.readLine();
- String tag = null;
- if (setSticky) {
- tag = session.readLine();
- if (tag.length() == 0) tag = null; // FIXME: is this correct
- }
-
- // create the directory then set or clear the sticky tag
- Assert.isTrue(repositoryDir.endsWith("/")); //$NON-NLS-1$
- repositoryDir = repositoryDir.substring(0, repositoryDir.length() - 1);
- ICVSFolder folder = createFolder(session, localDir, repositoryDir);
- FolderSyncInfo syncInfo = folder.getFolderSyncInfo();
- folder.setFolderSyncInfo(new FolderSyncInfo(syncInfo.getRepository(),
- syncInfo.getRoot(), tag != null ? new CVSEntryLineTag(tag) : null,
- syncInfo.getIsStatic()));
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java
deleted file mode 100644
index af39226c7..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-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.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.TagListener;
-
-public class Tag extends Command {
- /*** Local options: specific to tag ***/
- public static final LocalOption CREATE_BRANCH = new LocalOption("-b", null); //$NON-NLS-1$
-
- /*** Default command output listener ***/
- private static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new TagListener();
-
- // handle added and removed resources in a special way
- private boolean customBehaviorEnabled;
-
- protected Tag(boolean customBehaviorEnabled) {
- this.customBehaviorEnabled = customBehaviorEnabled;
- }
-
- protected Tag() {
- this(false);
- }
-
- protected String getRequestId() {
- return "tag"; //$NON-NLS-1$
- }
-
- protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions,
- String[] arguments) throws CVSException {
-
- if (arguments.length < 1) throw new IllegalArgumentException();
- String[] allButFirst = new String[arguments.length - 1];
- System.arraycopy(arguments, 1, allButFirst, 0, arguments.length - 1);
- return super.computeWorkResources(session, localOptions, allButFirst);
- }
-
- public IStatus execute(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, CVSTag tag, String[] arguments, ICommandOutputListener listener,
- IProgressMonitor monitor) throws CVSException {
-
- if(tag.getType() != CVSTag.VERSION && tag.getType() != CVSTag.BRANCH) {
- throw new CVSException(new CVSStatus(IStatus.ERROR, Policy.bind("Tag.notVersionOrBranchError"))); //$NON-NLS-1$
- }
-
- // Add the CREATE_BRANCH option for a branch tag
- if (tag.getType() == tag.BRANCH) {
- if ( ! CREATE_BRANCH.isElementOf(localOptions)) {
- LocalOption[] newLocalOptions = new LocalOption[localOptions.length + 1];
- System.arraycopy(localOptions, 0, newLocalOptions, 0, localOptions.length);
- newLocalOptions[newLocalOptions.length - 1] = CREATE_BRANCH;
- localOptions = newLocalOptions;
- }
- }
-
- // Add the tag name to the start of the arguments
- String[] newArguments = new String[arguments.length + 1];
- newArguments[0] = tag.getName();
- System.arraycopy(arguments, 0, newArguments, 1, arguments.length);
-
- return execute(session, globalOptions, localOptions, newArguments, listener, monitor);
- }
-
- protected ICommandOutputListener getDefaultCommandOutputListener() {
- return DEFAULT_OUTPUT_LISTENER;
- }
-
- protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // Send all folders that are already managed to the server
- if (customBehaviorEnabled) {
- new TagFileSender(session, monitor).visit(session, resources);
- } else {
- new FileStructureVisitor(session, false, false, monitor).visit(session, resources);
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java
deleted file mode 100644
index de1861827..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * Special visitor which handles added and removed files in a special way.
- * Added resources are skipped. Deleted resources are sent as if they were not deleted.
- */
-class TagFileSender extends FileStructureVisitor {
-
- public TagFileSender(Session session, IProgressMonitor monitor) {
- super(session, false, false, monitor);
- }
-
- /**
- * Override sendFile to provide custom handling of added and deleted resources.
- * Added resources are skipped. Deleted resources are sent as if they were not deleted.
- */
- protected void sendFile(ICVSFile mFile) throws CVSException {
- Policy.checkCanceled(monitor);
- if (mFile.isManaged()) {
- // Send the parent folder if it hasn't been sent already
- sendFolder(mFile.getParent());
- // Send the file if appropriate
- ResourceSyncInfo info = mFile.getSyncInfo();
- if (info.isDeleted()) {
- // makes this resource sync undeleted
- MutableResourceSyncInfo undeletedInfo = info.cloneMutable();
- undeletedInfo.setDeleted(false);
- info = undeletedInfo;
- }
- if (!info.isAdded()) {
- session.sendEntry(info.getServerEntryLine(mFile.getTimeStamp()));
- boolean binary = info != null && info.getKeywordMode().isBinary();
- session.sendIsModified(mFile, binary, monitor);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java
deleted file mode 100644
index 2a4f87c2a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-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.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.UpdateListener;
-
-public class Update extends Command {
- /*** Local options: specific to update ***/
- public static final LocalOption CLEAR_STICKY = new LocalOption("-A"); //$NON-NLS-1$
- public static final LocalOption IGNORE_LOCAL_CHANGES = new LocalOption("-C"); //$NON-NLS-1$
- public static final LocalOption RETRIEVE_ABSENT_DIRECTORIES = new LocalOption("-d"); //$NON-NLS-1$
- public static final LocalOption JOIN = new LocalOption("-j"); //$NON-NLS-1$
-
- /*** Default command output listener ***/
- private static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new UpdateListener(null);
-
- /*** File information status returned from update ***/
- public static final int STATE_NONE = 0; // no state information available
- public static final int STATE_ADDED_LOCAL = 1; // new file locally that was added but not comitted to server yet
- public static final int STATE_UNKOWN = 2; // new file locally but not added to server
- public static final int STATE_REMOTE_CHANGES = 3; // remote changes to an unmodified local file
- public static final int STATE_DELETED = 4; // removed locally but still exists on the server
- public static final int STATE_MODIFIED = 5; // modified locally
- public static final int STATE_CONFLICT = 6; // modified locally and on the server but cannot be auto-merged
- public static final int STATE_MERGEABLE_CONFLICT = 7; // modified locally and on the server but can be auto-merged
-
- /**
- * Makes a -r or -D or -A option for a tag.
- * Valid for: checkout export history rdiff update
- */
- public static LocalOption makeTagOption(CVSTag tag) {
- int type = tag.getType();
- switch (type) {
- case CVSTag.HEAD:
- return CLEAR_STICKY;
- default:
- return Command.makeTagOption(tag);
- }
- }
-
- protected Update() { }
- protected String getRequestId() {
- return "update"; //$NON-NLS-1$
- }
-
- protected ICommandOutputListener getDefaultCommandOutputListener() {
- return DEFAULT_OUTPUT_LISTENER;
- }
-
- protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // Send all folders that are already managed to the server
- // even folders that are empty
- sendFileStructure(session, resources, true, monitor);
- }
-
- /**
- * Convenience method that allows the creation of .# files to be disabled.
- * @param createBackups if true, creates .# files
- * @see Command.execute
- */
- public final IStatus execute(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener,
- IProgressMonitor pm, boolean createBackups) throws CVSException {
- session.setCreateBackups(createBackups);
- try {
- return super.execute(session, globalOptions, localOptions, arguments, listener, pm);
- } finally {
- session.setCreateBackups(true);
- }
- }
-
- /**
- * On successful finish, prune empty directories if the -P or -D option was specified.
- */
- protected void commandFinished(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor,
- boolean succeeded) throws CVSException {
- // If we didn't succeed, don't do any post processing
- if (! succeeded) return;
-
- // If we are pruning (-P) or getting a sticky copy using -D, then prune empty directories
- if (PRUNE_EMPTY_DIRECTORIES.isElementOf(localOptions) ||
- findOption(localOptions, "-D") != null) { //$NON-NLS-1$
- // Delete empty directories
- new PruneFolderVisitor().visit(session, resources);
-
- }
- session.handleCaseCollisions();
- }
-
- protected LocalOption[] filterLocalOptions(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions) {
- List newOptions = new ArrayList(Arrays.asList(localOptions));
-
- // Look for absent directories if enabled and the option is not already included
- if (CVSProviderPlugin.getPlugin().getFetchAbsentDirectories() && ! RETRIEVE_ABSENT_DIRECTORIES.isElementOf(localOptions)) {
- newOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
- }
-
- // Prune empty directories if pruning is enabled and the command in not being run in non-update mode
- if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories() && ! PRUNE_EMPTY_DIRECTORIES.isElementOf(localOptions)) {
- if (! DO_NOT_CHANGE.isElementOf(globalOptions)) {
- newOptions.add(Update.PRUNE_EMPTY_DIRECTORIES);
- }
- }
- localOptions = (LocalOption[]) newOptions.toArray(new LocalOption[newOptions.size()]);
- return super.filterLocalOptions(session, globalOptions, localOptions);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java
deleted file mode 100644
index a5c2a8695..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.Date;
-
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-
-/**
- * Handles any "Updated" and "Merged" responses
- * from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Updated ???\n
- * [...]
- * </pre>
- * Then
- * </p>
- */
-
-/**
- * Does get information about the file that is updated
- * and the file-content itself and puts it on the fileSystem.
- *
- * The difference beetween the "Updated" and the "Merged" is, that
- * an "Merged" file is not going to be up-to-date after the operation.
- *
- * Requiers a exisiting parent-folder.
- */
-class UpdatedHandler extends ResponseHandler {
-
- private int handlerType;
-
- protected static final int HANDLE_UPDATED = ICVSFile.UPDATED;
- protected static final int HANDLE_MERGED = ICVSFile.MERGED;
- protected static final int HANDLE_UPDATE_EXISTING = ICVSFile.UPDATE_EXISTING;
- protected static final int HANDLE_CREATED = ICVSFile.CREATED;
-
- private static final String READ_ONLY_FLAG = "u=rw"; //$NON-NLS-1$
-
- public UpdatedHandler(int handlerType) {
- this.handlerType = handlerType;
- }
-
- public String getResponseID() {
- switch (handlerType) {
- case HANDLE_UPDATED: return "Updated"; //$NON-NLS-1$
- case HANDLE_MERGED: return "Merged"; //$NON-NLS-1$
- case HANDLE_UPDATE_EXISTING: return "Update-existing"; //$NON-NLS-1$
- case HANDLE_CREATED: return "Created"; //$NON-NLS-1$
- }
- return null;
- }
-
- public void handle(Session session, String localDir,
- IProgressMonitor monitor) throws CVSException {
- // read additional data for the response
- String repositoryFile = session.readLine();
- String entryLine = session.readLine();
- String permissionsLine = session.readLine();
- // temporary sync info for parsing the line received from the server
- ResourceSyncInfo info = new ResourceSyncInfo(entryLine, permissionsLine, null);
-
- // clear file update modifiers
- Date modTime = session.getModTime();
- session.setModTime(null);
-
- // Get the local file
- String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$
- ICVSFolder mParent = session.getLocalRoot().getFolder(localDir);
- if (! mParent.exists()) {
- // It is possible that we have a case invarient problem.
- localDir = session.getUniquePathForCaseSensitivePath(localDir, false);
- mParent = session.getLocalRoot().getFolder(localDir);
- Assert.isTrue(mParent.exists());
- }
- ICVSFile mFile = mParent.getFile(fileName);
-
- boolean binary = info.getKeywordMode().isBinary();
- boolean readOnly = info.getPermissions().indexOf(READ_ONLY_FLAG) == -1;
-
- // The file may have been set as read-only by a previous checkout/update
- if (mFile.isReadOnly()) mFile.setReadOnly(false);
- try {
- session.receiveFile(mFile, binary, handlerType, monitor);
- } catch (CVSException e) {
- if (e.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
- // Record that we have a case collision and continue;
- session.addCaseCollision(new Path(localDir).append(fileName).toString(), Path.EMPTY.toString());
- return;
- } else {
- throw e;
- }
- }
- if (readOnly) mFile.setReadOnly(true);
-
- // Set the timestamp in the file and get it again so that we use the *real* timestamp
- // in the sync info. The os may not actually set the time we provided :)
- mFile.setTimeStamp(modTime);
- modTime = mFile.getTimeStamp();
- MutableResourceSyncInfo newInfoWithTimestamp = info.cloneMutable();
- newInfoWithTimestamp.setTimeStamp(modTime);
- if(handlerType==HANDLE_MERGED) {
- newInfoWithTimestamp.setMerged();
- }
- mFile.setSyncInfo(newInfoWithTimestamp);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java
deleted file mode 100644
index e90c9b9fe..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * 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.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-class ValidRequests extends Request {
- protected ValidRequests() { }
- protected String getRequestId() {
- return "valid-requests"; //$NON-NLS-1$
- }
-
- public IStatus execute(Session session, IProgressMonitor monitor) throws CVSException {
- return executeRequest(session, null, monitor);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequestsHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequestsHandler.java
deleted file mode 100644
index 071dd2877..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequestsHandler.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-
-/**
- * Handles a "Valid-requests" response from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Valid-requests ci co update Root Directory Valid-responses Argument ...\n
- * [...]
- * </pre>
- * Then we remember the set of valid requests for this session in
- * preparation for isValidRequests queries.
- * </p>
- */
-class ValidRequestsHandler extends ResponseHandler {
- public String getResponseID() {
- return "Valid-requests"; //$NON-NLS-1$
- }
-
- public void handle(Session session, String validRequests,
- IProgressMonitor monitor) throws CVSException {
- // remember the set of valid requests for this session
- session.setValidRequests(validRequests);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java
deleted file mode 100644
index c0e25833b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * 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.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.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-
-/**
- * Here are some of the output formats we know about:
- *
- * Concurrent Versions System (CVS) 1.11.1p1 (client/server)
- * Concurrent Versions System (CVS) NT 1.11.1.1 (Build 27)
- * Concurrent Versions System (CVSNT) 1.11.1.3 (Build 57a) (client/server)
- */
-public class Version extends RemoteCommand {
-
- private static final String CVS_NT_PREFIX_1 = "Concurrent Versions System (CVS) NT "; //$NON-NLS-1$
- private static final String CVS_NT_PREFIX_2 = "Concurrent Versions System (CVSNT) "; //$NON-NLS-1$
- private static final String CVS_PREFIX = "Concurrent Versions System (CVS) "; //$NON-NLS-1$
- /**
- * @see Request#getRequestId()
- */
- protected String getRequestId() {
- return "version"; //$NON-NLS-1$
- }
-
- public IStatus execute(Session session, final ICVSRepositoryLocation location, IProgressMonitor monitor) throws CVSException {
-
- // The server may not support the version request
- if (session == null) {
- session = getOpenSession(null);
- }
- if ( ! session.isValidRequest(getRequestId())) {
- IStatus status = new CVSStatus(IStatus.WARNING, CVSStatus.SERVER_IS_UNKNOWN, Policy.bind("Version.versionNotValidRequest", location.getHost()));//$NON-NLS-1$
- ((CVSRepositoryLocation)location).setServerPlaform(status);
- CVSProviderPlugin.log(status);
- return status;
- }
-
- ICommandOutputListener listener = new ICommandOutputListener() {
- public IStatus messageLine(String line, ICVSFolder commandRoot, IProgressMonitor monitor) {
- String knownPrefix = null;
- boolean isCVSNT = false;
- if (line.startsWith(CVS_NT_PREFIX_1)) {
- isCVSNT = true;
- knownPrefix = CVS_NT_PREFIX_1;
- } else if (line.startsWith(CVS_NT_PREFIX_2)) {
- isCVSNT = true;
- knownPrefix = CVS_NT_PREFIX_2;
- } else if (line.startsWith(CVS_PREFIX)) {
- knownPrefix = CVS_PREFIX;
- }
- IStatus status = OK;
- if (knownPrefix != null) {
- String versionNumber = line.substring(knownPrefix.length(), line.indexOf(' ', knownPrefix.length() + 1));
- if (versionNumber.startsWith("1.10") || versionNumber.equals("1.11") || versionNumber.equals("1.11.1")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- status = new CVSStatus(IStatus.ERROR, CVSStatus.UNSUPPORTED_SERVER_VERSION, Policy.bind("Version.unsupportedVersion", location.getHost(), versionNumber));//$NON-NLS-1$
- } else if (isCVSNT) {
- status = new CVSStatus(IStatus.WARNING, CVSStatus.SERVER_IS_CVSNT, Policy.bind("Version.unsupportedCVSNT", location.getHost(), versionNumber));//$NON-NLS-1$
- }
- } else {
- status = new CVSStatus(IStatus.INFO, CVSStatus.SERVER_IS_UNKNOWN, Policy.bind("Version.unknownVersionFormat", location.getHost(), line));//$NON-NLS-1$
- }
- ((CVSRepositoryLocation)location).setServerPlaform(status);
- return status;
- }
- public IStatus errorLine(String line, ICVSFolder commandRoot, IProgressMonitor monitor) {
- return new CVSStatus(IStatus.ERROR, CVSStatus.ERROR_LINE, line);
- }
- };
-
- return execute(session, NO_GLOBAL_OPTIONS, NO_LOCAL_OPTIONS, new String[] {}, listener, monitor);
- }
-}
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 a8d24b0fa..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-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.Policy;
-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.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * 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
- */
-public class AdminKSubstListener implements ICommandOutputListener {
- private KSubstOption ksubstMode;
-
- public AdminKSubstListener(KSubstOption ksubstMode) {
- this.ksubstMode = ksubstMode;
- }
-
- public IStatus messageLine(String line, 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(CVSStatus.ERROR,
- Policy.bind("AdminKSubstListener.expectedRCSFile", rcsFile)); //$NON-NLS-1$
- }
- String remoteRootLocation = null;
- try {
- FolderSyncInfo info = commandRoot.getFolderSyncInfo();
- remoteRootLocation = info.getRemoteLocation();
- } catch (CVSException e) {
- // XXX bad eating of exception
- }
- if (remoteRootLocation == null) {
- return new CVSStatus(CVSStatus.ERROR,
- Policy.bind("AdminKSubstListener.commandRootNotManaged")); //$NON-NLS-1$
- }
- IPath rcsFilePath = new Path(rcsFile.substring(0, rcsFile.length() - 2));
- IPath remoteRootPath = new Path(remoteRootLocation);
- if (! remoteRootPath.isPrefixOf(rcsFilePath)) {
- return new CVSStatus(CVSStatus.ERROR,
- Policy.bind("AdminKSubstListener.expectedChildOfCommandRoot", //$NON-NLS-1$
- rcsFilePath.toString(), remoteRootPath.toString()));
- }
- rcsFilePath = rcsFilePath.removeFirstSegments(remoteRootPath.segmentCount());
- try {
- ICVSFile file = commandRoot.getFile(rcsFilePath.toString());
- ResourceSyncInfo info = file.getSyncInfo();
- if (info != null) {
- // only update sync info if we have it locally
- MutableResourceSyncInfo newInfo = info.cloneMutable();
- newInfo.setKeywordMode(ksubstMode);
- file.setSyncInfo(newInfo);
- }
- } catch (CVSException e) {
- return new CVSStatus(CVSStatus.ERROR,
- Policy.bind("AdminKSubstListener.couldNotSetResourceSyncInfo", //$NON-NLS-1$
- rcsFilePath.toString(), e.toString()));
- }
- }
- return OK;
- }
-
- public IStatus errorLine(String line, ICVSFolder commandRoot,
- IProgressMonitor monitor) {
- // we don't expect to see anything on stderr if the command succeeds
- // possible errors include:
- // cvs server: cannot open /repo/a.txt,v: Permission denied
- // cvs server: failed to create lock directory for `/repo/folder' (/repo/folder/#cvs.lock): Permission denied
- // cvs server: failed to remove lock /repo/folder/#cvs.wfl.fiji.4442: Permission denied
- // cvs server: lock failed - giving up
- // cvs [server aborted]: lock failed - giving up
- return new CVSStatus(CVSStatus.ERROR, CVSStatus.ERROR_LINE, line);
- }
-}
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 adc54af55..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.io.PrintStream;
-
-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;
-
-public class DiffListener implements ICommandOutputListener {
- PrintStream patchStream;
-
- public DiffListener(PrintStream patchStream) {
- this.patchStream = patchStream;
- }
-
- public IStatus messageLine(String line, ICVSFolder commandRoot,
- IProgressMonitor monitor) {
- if (! line.startsWith("cvs server:")) { //$NON-NLS-1$
- patchStream.println(line);
- }
- return OK;
- }
-
- public IStatus errorLine(String line, ICVSFolder commandRoot,
- IProgressMonitor monitor) {
- // ignore these errors for now - this is used only with the diff
- // request and the errors can be safely ignored.
- if(! line.startsWith("cvs server:")) {//$NON-NLS-1$
- return new CVSStatus(CVSStatus.ERROR, CVSStatus.ERROR_LINE, line);
- }
- return OK;
- }
-}
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 78dc32c0d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-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.Policy;
-
-public interface ICommandOutputListener {
-
- /*** Status to be returned when no error or warning occured ***/
- public static final IStatus OK = new CVSStatus(CVSStatus.OK,Policy.bind("ok")); //$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, 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, 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 a2ff86e1d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * 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.listeners;
-
-import org.eclipse.core.runtime.IStatus;
-
-public interface IConsoleListener {
- /**
- * Called when a command is invoked.
- * @param line the command invocation string
- */
- public void commandInvoked(String line);
-
- /**
- * Called when a line of message text has been received.
- * @param line the line of text
- */
- public void messageLineReceived(String line);
-
- /**
- * Called when a line of error text has been received.
- * @param line the line of text
- */
- public void errorLineReceived(String line);
-
- /**
- * Called when a command has been completed.
- * @param status the status code, or null if not applicable
- * @param exception an exception, or null if not applicable
- */
- public void commandCompleted(IStatus status, Exception exception);
-}
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 f36162143..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.listeners;
-
-import org.eclipse.core.runtime.IPath;
-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, IPath 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 c3583baa0..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.listeners;
-
-import org.eclipse.core.runtime.IPath;
-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, IPath 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, IPath 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 3cce54017..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.Date;
-
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
-import org.eclipse.team.internal.ccvs.core.ILogEntry;
-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;
-
- 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;
- }
-
- /**
- * @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$
- }
-
-}
-
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 fada2df4e..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.DateUtil;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-
-public class LogListener implements ICommandOutputListener {
- private List entries;
- private RemoteFile file;
-
- // state
- private final int BEGIN = 0, SYMBOLIC_NAMES = 1, REVISION = 2, COMMENT = 3, DONE = 4;
- private List tagNames = new ArrayList(5);
- private List tagRevisions = new ArrayList(5);
- private int state = BEGIN; // current state
- private String creationDate;
- private String author;
- private String revision; // revision number
- private String fileState; //
- private StringBuffer comment; // comment
-
- public LogListener(RemoteFile file, List entries) {
- this.file = file;
- this.entries = entries;
- }
-
- public IStatus messageLine(String line, 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("symbolic names:")) { //$NON-NLS-1$
- state = SYMBOLIC_NAMES;
- } else if (line.startsWith("revision ")) { //$NON-NLS-1$
- revision = line.substring(9);
- state = REVISION;
- }
- break;
- case SYMBOLIC_NAMES:
- if (line.startsWith("keyword substitution:")) { //$NON-NLS-1$
- state = BEGIN;
- } else {
- int firstColon = line.indexOf(':');
- String tagName = line.substring(1, firstColon);
- String tagRevision = line.substring(firstColon + 2);
- tagNames.add(tagName);
- tagRevisions.add(tagRevision);
- }
- 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 = line.substring(6, endOfDateIndex) + " GMT"; //$NON-NLS-1$
-
- // get the author name
- int endOfAuthorIndex = line.indexOf(';', endOfDateIndex + 1);
- author = line.substring(endOfDateIndex + 11, endOfAuthorIndex);
-
- // get the file state (because this revision might be "dead")
- fileState = 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;
- }
- 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 = new ArrayList(3);
- for (int i = 0; i < tagNames.size(); i++) {
- String tagName = (String) tagNames.get(i);
- String tagRevision = (String) tagRevisions.get(i);
- // If this is a branch tag then only include this tag with the revision
- // that is the root of this branch (e.g. 1.1 is root of branch 1.1.2).
- boolean isBranch = isBranchTag(tagRevision);
- if (isBranch) {
- int lastDot = tagRevision.lastIndexOf('.');
- if (tagRevision.charAt(lastDot - 1) == '0' && tagRevision.charAt(lastDot - 2) == '.') {
- lastDot = lastDot - 2;
- }
- tagRevision = tagRevision.substring(0, lastDot);
- }
- if (tagRevision.equals(revision)) {
- int type = isBranch ? CVSTag.BRANCH : CVSTag.VERSION;
- thisRevisionTags.add(new CVSTag(tagName, type));
- }
- }
- Date date = DateUtil.convertFromLogTime(creationDate);
- LogEntry entry = new LogEntry(file, revision, author, date,
- comment.toString(), fileState, (CVSTag[]) thisRevisionTags.toArray(new CVSTag[0]));
- entries.add(entry);
- state = BEGIN;
- // XXX should we reset the tagNames and tagRevisions stuff?
- }
- return OK;
- }
-
- public IStatus errorLine(String line, ICVSFolder commandRoot,
- IProgressMonitor monitor) {
- return OK;
- }
-
- /** 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 */
- protected 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 128140c33..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-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.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-
-/*
- * 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 implements ICommandOutputListener {
-
- // 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,
- 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;
- }
-
- /*
- * @see ICommandOutputListener#errorLine(String, ICVSFolder, IProgressMonitor)
- */
- public IStatus errorLine(String line, ICVSFolder commandRoot, IProgressMonitor monitor) {
- return new CVSStatus(CVSStatus.ERROR, CVSStatus.ERROR_LINE, line);
- }
-
- 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/ModuleExpansion.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleExpansion.java
deleted file mode 100644
index ac88c6972..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleExpansion.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-
-/**
- *
- */
-public class ModuleExpansion {
-
- /** Name of the CVS module as found in the CVSROOT/modules file */
- private String moduleName;
-
- /** Expansion of the module name returned by the CVS server */
- private String[] expansions;
-
- private LocalOption[] options;
-
- ModuleExpansion(String moduleName, String[] expansions, LocalOption[] options) {
- this.moduleName = moduleName;
- this.expansions = expansions;
- this.options = options;
- }
-
- /**
- * @see IModuleExpansion#getModuleName()
- */
- public String getModuleName() {
- return moduleName;
- }
-
- /**
- * @see IModuleExpansion#getModuleExpansionString()
- */
- public String getModuleExpansionString() {
- String result = expansions[0];
- for (int i=1;i<expansions.length; i++)
- result = result + ", " + expansions[i]; //$NON-NLS-1$
- return result;
- }
-
- /**
- * @see IModuleExpansion#getExpansions()
- */
- public String[] getExpansions() {
- return expansions;
- }
-
- public LocalOption[] getOptions() {
- return options;
- }
-
- /**
- * Translate an array of module names to their expansions.
- * The resulting List of Strings may be bigger than the original
- */
- private List getExpansionsFor(String[] possibleModules, Map moduleMappings, int depth) throws CVSException {
- List result = new ArrayList();
- for (int i=0;i<possibleModules.length;i++) {
- // Is it a module?
- if (possibleModules[i].charAt(0) == '&')
- result.addAll(getExpansionsFor(possibleModules[i].substring(1), moduleMappings, depth));
- else
- result.add(possibleModules[i]);
- }
- return result;
- }
-
- /**
- * Translate a module name to its expansion.
- * The resulting List may contain one or more Strings
- */
- private List getExpansionsFor(String module, Map moduleMappings, int depth) throws CVSException {
- if (depth > moduleMappings.size()) {
- // Indicate that a circular reference exists
- throw new CVSException(Policy.bind("ModuleExpansion.circular", module));//$NON-NLS-1$
- }
- Object mappings = moduleMappings.get(module);
- if (mappings == null) {
- // If there's no mapping assume it is a project name
- List result = new ArrayList();
- result.add(module);
- return result;
- } else {
- // Follow any expansion chains
- return getExpansionsFor(((ModuleExpansion)mappings).expansions, moduleMappings, depth + 1);
- }
- }
-
- /**
- * Resolve the module mappings using moduleMappings which maps
- * module names to their ModuleExpansion
- */
- public void resolveModuleReferencesUsing(Map moduleMappings) {
- try {
- List result = getExpansionsFor(expansions, moduleMappings, 0);
- expansions = (String[])result.toArray(new String[result.size()]);
- } catch (CVSException e) {
- // Is this the best way to show the circular reference problem?
- // Or should we just leave the expansions untouched?
- List result = new ArrayList();
- result.add(e.getStatus().getMessage());
- result.addAll(Arrays.asList(expansions));
- expansions = (String[])result.toArray(new String[result.size()]);
- }
- }
-}
-
-
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 cdf501883..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.listeners;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-
-public class StatusListener implements ICommandOutputListener {
- private static boolean isFolder = false;
- private IStatusListener statusListener;
-
- public StatusListener(IStatusListener statusListener) {
- this.statusListener = statusListener;
- }
-
- public IStatus messageLine(String line, 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);
-
- // This is the absolute remote pathincluding the repository root directory
- IPath fullPath = new Path(fileLocation);
-
- // 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 update
- // to put them in the correct location.
- // (e.g. /project/Attic/file.txt -> /project/file.txt)
- if ((fullPath.segmentCount() >= 2) && (fullPath.segment(fullPath.segmentCount() - 2).equals("Attic"))) { //$NON-NLS-1$
- String filename = fullPath.lastSegment();
- fullPath = fullPath.removeLastSegments(2);
- fullPath = fullPath.append(filename);
- }
-
- // Inform the listener about the file revision
- statusListener.fileStatus(commandRoot, fullPath, remoteRevision);
- }
- }
- return OK;
- }
-
- public IStatus errorLine(String line, ICVSFolder commandRoot, IProgressMonitor monitor) {
- if (line.startsWith("cvs server: 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(CVSStatus.WARNING, CVSStatus.CONFLICT, line);
- }
- if (line.startsWith("cvs server: Examining")) {//$NON-NLS-1$
- isFolder = true;
- return OK;
- }
- if (isFolder && line.startsWith("cvs [server aborted]: could not chdir to")) {//$NON-NLS-1$
- String folderPath = line.substring(41, line.indexOf(':', 42));
- // Pass null to listener indicating that the resource exists but does not have a revision number
- // (i.e. the resource is a folder)
- if (statusListener != null)
- // XXX We should be using that path relative to the root of the command (mRoot)!!!
- statusListener.fileStatus(commandRoot, new Path(folderPath).removeFirstSegments(1), IStatusListener.FOLDER_REVISION);
- isFolder = false;
- return OK;
- }
- return new CVSStatus(CVSStatus.ERROR, CVSStatus.ERROR_LINE, line);
- }
-}
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 062890109..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-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;
-
-public class TagListener implements ICommandOutputListener {
-
- /*
- * @see ICommandOutputListener#messageLine(String, ICVSFolder, IProgressMonitor)
- */
- public IStatus messageLine(
- String line,
- 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
- if( line.charAt(0) == 'W' ) {
- return new CVSStatus(CVSStatus.WARNING, CVSStatus.TAG_ALREADY_EXISTS, line.substring(2));
- }
-
- return OK;
- }
-
- /*
- * @see ICommandOutputListener#errorLine(String, ICVSFolder, IProgressMonitor)
- */
- public IStatus errorLine(
- String line,
- ICVSFolder commandRoot,
- IProgressMonitor monitor) {
-
- // Ignore the lines: Tagging folder1/folder2
- if( line.startsWith("cvs server: Tagging") ) { //$NON-NLS-1$
- return OK;
- }
-
- return new CVSStatus(CVSStatus.ERROR, CVSStatus.ERROR_LINE, line);
- }
-
-}
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 c723969c8..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.listeners;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-
-public class UpdateListener implements ICommandOutputListener {
- static final String SERVER_PREFIX = "cvs server: "; //$NON-NLS-1$
- static final String SERVER_ABORTED_PREFIX = "cvs [server aborted]: "; //$NON-NLS-1$
-
- IUpdateMessageListener updateMessageListener;
- boolean merging = false;
-
- public UpdateListener(IUpdateMessageListener updateMessageListener) {
- this.updateMessageListener = updateMessageListener;
- }
-
- public IStatus messageLine(String line, ICVSFolder commandRoot,
- IProgressMonitor monitor) {
- 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
- */
- public IStatus errorLine(String line, ICVSFolder commandRoot,
- IProgressMonitor monitor) {
-
- if (line.startsWith(SERVER_PREFIX)) {
- // Strip the prefix from the line
- String message = line.substring(SERVER_PREFIX.length());
- if (message.startsWith("Updating")) { //$NON-NLS-1$
- if (updateMessageListener != null) {
- IPath path = new Path(message.substring(9));
- updateMessageListener.directoryInformation(commandRoot, path, false);
- }
- return OK;
- } else if (message.startsWith("skipping directory")) { //$NON-NLS-1$
- if (updateMessageListener != null) {
- IPath path = new Path(message.substring(18).trim());
- updateMessageListener.directoryDoesNotExist(commandRoot, path);
- }
- return OK;
- } else if (message.startsWith("New directory")) { //$NON-NLS-1$
- if (updateMessageListener != null) {
- IPath path = new Path(message.substring(15, message.indexOf('\'', 15)));
- 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);
- 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);
- updateMessageListener.fileDoesNotExist(commandRoot, filename);
- }
- }
- return new CVSStatus(CVSStatus.WARNING, CVSStatus.CONFLICT, line);
- } 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(CVSStatus.WARNING, CVSStatus.CONFLICT, line);
- } 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);
- } else if (!message.startsWith("cannot open directory") //$NON-NLS-1$
- && !message.startsWith("nothing known about")) { //$NON-NLS-1$
- return new CVSStatus(CVSStatus.ERROR, CVSStatus.ERROR_LINE, line);
- }
- } else if (line.startsWith(SERVER_ABORTED_PREFIX)) {
- // Strip the prefix from the line
- String message = line.substring(SERVER_ABORTED_PREFIX.length());
- 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(CVSStatus.WARNING, CVSStatus.NO_SUCH_TAG, line);
- } else {
- return new CVSStatus(CVSStatus.ERROR, CVSStatus.ERROR_LINE, line);
- }
- }
- return new CVSStatus(CVSStatus.ERROR, CVSStatus.ERROR_LINE, line);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException.java
deleted file mode 100644
index 4041d185c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.connection;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.Policy;
-
-public class CVSAuthenticationException extends CVSException {
-
- /**
- * Creates a new <code>CVSAuthenticationException</code>
- *
- * @param detail a message that describes the exception in detail.
- */
- public CVSAuthenticationException(String detail) {
- super(
- Policy.bind("CVSAuthenticationException.detail", new Object[] { detail }), //$NON-NLS-1$
- null,
- null);
- }
- /**
- * Creates a new <code>CVSAuthenticationException</code>
- *
- * @param cvsroot the cvs server.
- * @param detail a message that describes the exception in detail.
- */
- public CVSAuthenticationException(String cvsroot, String detail) {
- this(detail);
- }
- /**
- * Creates a new <code>CVSAuthenticationException</code>
- *
- * @param status the status result describing this exception.
- */
- public CVSAuthenticationException(IStatus status) {
- super(status);
- }
- /**
- * Creates a new <code>CVSAuthenticationException</code>
- *
- * @param cvsroot the cvs server.
- * @param throwable the exception that has caused the authentication
- * failure.
- */
- public CVSAuthenticationException(String cvsroot, Throwable throwable) {
- super(
- Policy.bind("CVSAuthenticationException.normal", new Object[] { cvsroot }),//$NON-NLS-1$
- null,
- null);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException.java
deleted file mode 100644
index 55f616d31..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.connection;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.Policy;
-
-public class CVSCommunicationException extends CVSException {
-
- /**
- * Create a new <code>CVSCommunicationException with the
- * given message.
- */
- public CVSCommunicationException(String message) {
- super(message, null, null);
- }
- /**
- * Create a new <code>CVSCommunicationException.
- *
- * @param message a message describing the exception in detail.
- * @param the caught exception that has caused the communication
- * exception.
- */
- public CVSCommunicationException(String message, Throwable throwable) {
- super(message, null, throwable);
- }
- /**
- * Create a new <code>CVSCommunicationException.
- *
- * @param the caught exception that has caused the communication
- * exception.
- */
- public CVSCommunicationException(Throwable throwable) {
- this(getMessageFor(throwable), throwable);
- }
-
- public static String getMessageFor(Throwable throwable) {
- String message = Policy.bind(throwable.getClass().getName(), new Object[] {throwable.getMessage()});
- if (message.equals(throwable.getClass().getName()))
- message = Policy.bind("CVSCommunicationException.io", new Object[] {throwable.toString()}); //$NON-NLS-1$
- return message;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSFileException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSFileException.java
deleted file mode 100644
index 186308124..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSFileException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.connection;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.Policy;
-
-// NIK: this class is nerver used (once in a catch statment)
-
-public class CVSFileException extends CVSException {
-
- /**
- * Creates a new <code>CVSFileException</code>.
- *
- * @param message a message describing the exception in detail.
- * @param path the file's path that has caused the exception.
- */
- public CVSFileException(String message, IPath path) {
- super(message, path, null);
- }
- /**
- * Creates a new <code>CVSFileException</code>.
- *
- * @param path the file's path that has caused the exception.
- * @param throwable the caught exception that has caused the communication
- * exception.
- */
- public CVSFileException(IPath path, Throwable throwable) {
- super(Policy.bind("CVSFileException.io"), path, throwable);//$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java
deleted file mode 100644
index 293c55ec0..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java
+++ /dev/null
@@ -1,805 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.connection;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProvider;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.IConnectionMethod;
-import org.eclipse.team.internal.ccvs.core.IUserAuthenticator;
-import org.eclipse.team.internal.ccvs.core.IUserInfo;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteModule;
-
-/**
- * This class manages a CVS repository location.
- *
- * It provides the mapping between connection method name and the
- * plugged in ICunnectionMethod.
- *
- * It parses location strings into instances.
- *
- * It provides a method to open a connection to the server along
- * with a method to validate that connections can be made.
- *
- * It manages its user info using the plugged in IUserAuthenticator
- * (unless a username and password are provided as part of the creation
- * string, in which case, no authenticator is used).
- *
- * Instances must be disposed of when no longer needed in order to
- * notify the authenticator so cached properties can be cleared
- *
- */
-public class CVSRepositoryLocation extends PlatformObject implements ICVSRepositoryLocation, IUserInfo {
-
- // server platform constants
- public static final int UNDETERMINED_PLATFORM = 0;
- public static final int CVS_SERVER = 1;
- public static final int CVSNT_SERVER = 2;
- public static final int UNSUPPORTED_SERVER = 3;
- public static final int UNKNOWN_SERVER = 4;
-
- // static variables for extension points
- private static IUserAuthenticator authenticator;
- private static IConnectionMethod[] pluggedInConnectionMethods = null;
-
- private IConnectionMethod method;
- private String user;
- private String password;
- private String host;
- private int port;
- private String root;
- private boolean userFixed;
- private boolean passwordFixed;
- private int serverPlatform = UNDETERMINED_PLATFORM;
-
- public static final char COLON = ':';
- public static final char HOST_SEPARATOR = '@';
- public static final char PORT_SEPARATOR = '#';
- public static final boolean STANDALONE_MODE = (System.getProperty("eclipse.cvs.standalone")==null) ? //$NON-NLS-1$
- false :(new Boolean(System.getProperty("eclipse.cvs.standalone")).booleanValue()); //$NON-NLS-1$
-
- // fields needed for caching the password
- public static final String INFO_PASSWORD = "org.eclipse.team.cvs.core.password";//$NON-NLS-1$
- public static final String INFO_USERNAME = "org.eclipse.team.cvs.core.username";//$NON-NLS-1$
- public static final String AUTH_SCHEME = "";//$NON-NLS-1$
- public static final URL FAKE_URL;
-
- static {
- URL temp = null;
- try {
- temp = new URL("http://org.eclipse.team.cvs.core");//$NON-NLS-1$
- } catch (MalformedURLException e) {
- }
- FAKE_URL = temp;
- }
-
- /*
- * Create a CVSRepositoryLocation from its composite parts.
- */
- private CVSRepositoryLocation(IConnectionMethod method, String user, String password, String host, int port, String root, boolean userFixed, boolean passwordFixed) {
- this.method = method;
- this.user = user;
- this.password = password;
- this.host = host;
- this.port = port;
- this.root = root;
- // The username can be fixed only if one is provided
- if (userFixed && (user != null))
- this.userFixed = true;
- // The password can only be fixed if the username is and a password is provided
- if (userFixed && passwordFixed && (password != null))
- this.passwordFixed = true;
- }
-
- /*
- * Create the connection to the remote server.
- * If anything fails, an exception will be thrown and must
- * be handled by the caller.
- */
- private Connection createConnection(String password, IProgressMonitor monitor) throws CVSException {
- // FIXME Should the open() of Connection be done in the constructor?
- // The only reason it should is if connections can be reused (they aren't reused now).
- // FIXME! monitor is unused
- Connection connection = new Connection(this, method.createConnection(this, password));
- connection.open(monitor);
- return connection;
- }
-
- /*
- * Dispose of the receiver by clearing any cached authorization information.
- * This method shold only be invoked when the corresponding adapter is shut
- * down or a connection is being validated.
- */
- public void dispose() throws CVSException {
- flushCache();
- }
-
- /*
- * Flush the keyring entry associated with the receiver
- */
- private void flushCache() throws CVSException {
- try {
- Platform.flushAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME);
- } catch (CoreException e) {
- // We should probably wrap the CoreException here!
- CVSProviderPlugin.log(e.getStatus());
- throw new CVSException(IStatus.ERROR, IStatus.ERROR, Policy.bind("CVSRepositoryLocation.errorFlushing", getLocation()), e);//$NON-NLS-1$
- }
- }
-
- /*
- * @see ICVSRepositoryLocation#getHost()
- */
- public String getHost() {
- return host;
- }
-
- /*
- * @see IRepositoryLocation#getLocation()
- *
- * The username is included if it is fixed.
- * The password is never included even if it is fixed.
- * The port is included if it is not the default port.
- */
- public String getLocation() {
- return COLON + method.getName() + COLON +
- (userFixed?(user +
- (passwordFixed?(COLON + password):"")//$NON-NLS-1$
- + HOST_SEPARATOR):"") +//$NON-NLS-1$
- host +
- ((port == USE_DEFAULT_PORT)?"":(PORT_SEPARATOR + new Integer(port).toString())) +//$NON-NLS-1$
- COLON + root;
- }
-
- /*
- * @see ICVSRepositoryLocation#getMethod()
- */
- public IConnectionMethod getMethod() {
- return method;
- }
-
- public boolean setMethod(String methodName) {
- IConnectionMethod newMethod = getPluggedInConnectionMethod(methodName);
- if (newMethod == null)
- return false;
- method = newMethod;
- return true;
- }
-
- /*
- * @see ICVSRepositoryLocation#getPort()
- */
- public int getPort() {
- return port;
- }
-
- /*
- * @see ICVSRepositoryLocation#members(CVSTag, boolean, IProgressMonitor)
- */
- public ICVSRemoteResource[] members(CVSTag tag, boolean modules, IProgressMonitor progress) throws CVSException {
- try {
- if (modules) {
- return RemoteModule.getRemoteModules(this, tag, progress);
- } else {
- RemoteFolder root = new RemoteFolder(null, this, Path.EMPTY, tag);
- ICVSRemoteResource[] resources = (ICVSRemoteResource[])root.members(progress);
- // There is the off chance that there is a file in the root of the repository.
- // This is not supported by cvs so we need to make sure there are no files
- List folders = new ArrayList(resources.length);
- for (int i = 0; i < resources.length; i++) {
- ICVSRemoteResource remoteResource = resources[i];
- if (remoteResource.isContainer()) {
- folders.add(remoteResource);
- }
- }
- return (ICVSRemoteResource[]) folders.toArray(new ICVSRemoteResource[folders.size()]);
- }
- } catch(TeamException e) {
- throw new CVSException(e.getStatus());
- }
- }
-
- /*
- * @see ICVSRepositoryLocation#getRemoteFolder(String, CVSTag)
- */
- public ICVSRemoteFolder getRemoteFolder(String remotePath, CVSTag tag) {
- return new RemoteFolder(null, this, new Path(remotePath), tag);
- }
-
- /*
- * @see ICVSRepositoryLocation#getRootDirectory()
- */
- public String getRootDirectory() {
- return root;
- }
-
- /*
- * @see ICVSRepositoryLocation#getTimeout()
- *
- * For the time being, the timeout value is a system wide value
- * associated with the CVSPlugin singleton.
- */
- public int getTimeout() {
- return CVSProviderPlugin.getPlugin().getTimeout();
- }
-
- /*
- * @see ICVSRepositoryLocation#getUserInfo()
- */
- public IUserInfo getUserInfo(boolean makeUsernameMutable) {
- return new UserInfo(user, password, makeUsernameMutable ? true : isUsernameMutable());
- }
-
- /*
- * @see ICVSRepositoryLocation#getUsername()
- * @see IUserInfo#getUsername()
- */
- public String getUsername() {
- return user;
- }
-
- /*
- * @see IUserInfo#isUsernameMutable()
- */
- public boolean isUsernameMutable() {
- return !userFixed;
- }
-
- /*
- * Open a connection to the repository represented by the receiver.
- * If the username or password are not fixed, openConnection will
- * use the plugged-in authenticator to prompt for the username and/or
- * password if one has not previously been provided or if the previously
- * supplied username and password are invalid.
- */
- public Connection openConnection(IProgressMonitor monitor) throws CVSException {
-
- try {
- // Allow two ticks in case of a retry
- monitor.beginTask(Policy.bind("CVSRepositoryLocation.openingConnection", getLocation()), 2);//$NON-NLS-1$
-
- // If we have a username and password, use them to attempt a connection
- if ((user != null) && (password != null)) {
- return createConnection(password, monitor);
- }
-
- // Get the repository in order to ensure that the location is known by CVS.
- // (The get will record the location if it's not already recorded.
- CVSProvider.getInstance().getRepository(getLocation());
-
- while (true) {
- try {
- // The following will throw an exception if authentication fails
- String password = retrievePassword();
- if (user == null) {
- // This is possible if the cache was cleared somehow for a location with a mutable username
- throw new CVSAuthenticationException(new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSRepositoryLocation.usernameRequired"))); //$NON-NLS-1$
- }
- if (password == null)
- password = "";//$NON-NLS-1$
- return createConnection(password, monitor);
- } catch (CVSAuthenticationException ex) {
- String message = ex.getMessage();
- try {
- IUserAuthenticator authenticator = getAuthenticator();
- if (authenticator == null) {
- throw new CVSAuthenticationException(getLocation(), Policy.bind("Client.noAuthenticator"));//$NON-NLS-1$
- }
- authenticator.promptForUserInfo(this, this, message);
- updateCache();
- } catch (OperationCanceledException e) {
- throw new CVSAuthenticationException(new CVSStatus(CVSStatus.ERROR, message));
- }
- }
- }
- } finally {
- monitor.done();
- }
- }
-
- /*
- * Implementation of inherited toString()
- */
- public String toString() {
- return getLocation();
- }
-
- public boolean equals(Object o) {
- if (!(o instanceof CVSRepositoryLocation)) return false;
- return getLocation().equals(((CVSRepositoryLocation)o).getLocation());
- }
- public int hashCode() {
- return getLocation().hashCode();
- }
-
- /*
- * Return the cached password from the keyring.
- * Also, set the username of the receiver if the username is mutable
- */
- private String retrievePassword() throws CVSException {
- Map map = Platform.getAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME);
- if (map != null) {
- String username = (String) map.get(INFO_USERNAME);
- if (username != null && isUsernameMutable())
- setUsername(username);
- String password = (String) map.get(INFO_PASSWORD);
- if (password != null) {
- return password;
- }
- }
- return null;
- }
- /*
- * @see IUserInfo#setPassword(String)
- */
- public void setPassword(String password) {
- if (passwordFixed)
- throw new UnsupportedOperationException();
- this.password = password;
- // XXX The cache needs to get the new password somehow but not before we are validated!
- }
-
- public void setUserInfo(IUserInfo userinfo) {
- user = userinfo.getUsername();
- password = ((UserInfo)userinfo).getPassword();
- }
- /*
- * @see IUserInfo#setUsername(String)
- */
- public void setUsername(String user) {
- if (userFixed)
- throw new UnsupportedOperationException();
- this.user = user;
- // XXX The cache needs to get the new username somehow but not before we are validated!
- }
-
- public void setUserMuteable(boolean muteable) {
- userFixed = !muteable;
- }
-
- public void updateCache() throws CVSException {
- if (passwordFixed)
- return;
- updateCache(user, password, true);
- password = null;
- // Ensure that the receiver is known by the CVS provider
- CVSProvider.getInstance().getRepository(getLocation());
- }
-
- /*
- * Cache the user info in the keyring
- */
- private void updateCache(String username, String password, boolean createIfAbsent) throws CVSException {
- // put the password into the Platform map
- Map map = Platform.getAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME);
- if (map == null) {
- if ( ! createIfAbsent) return;
- map = new java.util.HashMap(10);
- }
- if (username != null)
- map.put(INFO_USERNAME, username);
- if (password != null)
- map.put(INFO_PASSWORD, password);
- try {
- Platform.addAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME, map);
- } catch (CoreException e) {
- // We should probably wrap the CoreException here!
- CVSProviderPlugin.log(e.getStatus());
- throw new CVSException(IStatus.ERROR, IStatus.ERROR, Policy.bind("CVSRepositoryLocation.errorCaching", getLocation()), e);//$NON-NLS-1$
- }
- }
-
- /*
- * Validate that the receiver contains valid information for
- * making a connection. If the receiver contains valid
- * information, the method returns. Otherwise, an exception
- * indicating the problem is throw.
- */
- public void validateConnection(IProgressMonitor monitor) throws CVSException {
- try {
- ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot());
- Session.run(this, root, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- IStatus status = Command.VERSION.execute(null, CVSRepositoryLocation.this, monitor);
- // Log any non-ok status
- if (! status.isOK()) {
- if (status.isMultiStatus()) {
- IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- CVSProviderPlugin.log(children[i]);
- }
- } else {
- CVSProviderPlugin.log(status);
- }
- }
- }
- }, monitor);
- } catch (CVSException e) {
- // If the validation failed, dispose of any cached info
- dispose();
- throw e;
- }
- }
-
- /**
- * Return the server platform type. It will be one of the following:
- * UNDETERMINED_PLATFORM: The platform has not been determined
- * CVS_SERVER: The platform is regular CVS server
- * CVSNT_SERVER: The platform in CVSNT
- * If UNDETERMINED_PLATFORM is returned, the platform can be determined
- * using the Command.VERSION command.
- */
- public int getServerPlatform() {
- return serverPlatform;
- }
-
- /**
- * This method is called from Command.VERSION to set the platform type.
- */
- public void setServerPlaform(IStatus status) {
- // OK means that its a regular cvs server
- if (status.isOK()) {
- serverPlatform = CVS_SERVER;
- return;
- }
- // Find the status that reports the CVS platform
- if (status.isMultiStatus()) {
- IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- IStatus iStatus = children[i];
- if (iStatus.getCode() == CVSStatus.SERVER_IS_CVSNT
- || iStatus.getCode() == CVSStatus.UNSUPPORTED_SERVER_VERSION
- || iStatus.getCode() == CVSStatus.SERVER_IS_UNKNOWN) {
- status = iStatus;
- break;
- }
- }
- }
- // Second, check the code of the status itself to see if it is NT
- switch (status.getCode()) {
- case CVSStatus.SERVER_IS_CVSNT:
- serverPlatform = CVSNT_SERVER;
- break;
- case CVSStatus.UNSUPPORTED_SERVER_VERSION:
- serverPlatform = UNSUPPORTED_SERVER;
- break;
- case CVSStatus.SERVER_IS_UNKNOWN:
- serverPlatform = UNKNOWN_SERVER;
- break;
- default:
- // We had an error status with no info about the server.
- // Mark it as undetermined.
- serverPlatform = UNDETERMINED_PLATFORM;
- }
- }
-
- public static boolean validateConnectionMethod(String methodName) {
- String[] methods = CVSProviderPlugin.getProvider().getSupportedConnectionMethods();
- for (int i=0;i<methods.length;i++) {
- if (methodName.equals(methods[i]))
- return true;
- }
- return false;
- }
-
- /*
- * Create a repository location instance from the given properties.
- * The supported properties are:
- *
- * connection The connection method to be used
- * user The username for the connection (optional)
- * password The password used for the connection (optional)
- * host The host where the repository resides
- * port The port to connect to (optional)
- * root The server directory where the repository is located
- */
- public static CVSRepositoryLocation fromProperties(Properties configuration) throws CVSException {
- // We build a string to allow validation of the components that are provided to us
- String connection = configuration.getProperty("connection");//$NON-NLS-1$
- if (connection == null)
- connection = "pserver";//$NON-NLS-1$
- IConnectionMethod method = getPluggedInConnectionMethod(connection);
- if (method == null)
- throw new CVSException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, Policy.bind("CVSRepositoryLocation.methods", new Object[] {getPluggedInConnectionMethodNames()}), null));//$NON-NLS-1$
- String user = configuration.getProperty("user");//$NON-NLS-1$
- if (user.length() == 0)
- user = null;
- String password = configuration.getProperty("password");//$NON-NLS-1$
- if (user == null)
- password = null;
- String host = configuration.getProperty("host");//$NON-NLS-1$
- if (host == null)
- throw new CVSException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, Policy.bind("CVSRepositoryLocation.hostRequired"), null));//$NON-NLS-1$
- String portString = configuration.getProperty("port");//$NON-NLS-1$
- int port;
- if (portString == null)
- port = ICVSRepositoryLocation.USE_DEFAULT_PORT;
- else
- port = Integer.parseInt(portString);
- String root = configuration.getProperty("root");//$NON-NLS-1$
- if (root == null)
- throw new CVSException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, Policy.bind("CVSRepositoryLocation.rootRequired"), null));//$NON-NLS-1$
- root = root.replace('\\', '/');
-
- return new CVSRepositoryLocation(method, user, password, host, port, root, user != null, false);
- }
-
- /*
- * Parse a location string and return a CVSRepositoryLocation.
- *
- * On failure, the status of the exception will be a MultiStatus
- * that includes the original parsing error and a general status
- * displaying the passed location and proper form. This form is
- * better for logging, etc.
- */
- public static CVSRepositoryLocation fromString(String location) throws CVSException {
- try {
- return fromString(location, false);
- } catch (CVSException e) {
- // Parsing failed. Include a status that
- // shows the passed location and the proper form
- MultiStatus error = new MultiStatus(CVSProviderPlugin.ID, CVSStatus.ERROR, Policy.bind("CVSRepositoryLocation.invalidFormat", new Object[] {location}), null);//$NON-NLS-1$
- error.merge(new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSRepositoryLocation.locationForm")));//$NON-NLS-1$
- error.merge(e.getStatus());
- throw new CVSException(error);
- }
- }
-
- /*
- * Parse a location string and return a CVSRepositoryLocation.
- *
- * The valid format (from the cederqvist) is:
- *
- * :method:[[user][:password]@]hostname[:[port]]/path/to/repository
- *
- * However, this does not work with CVS on NT so we use the format
- *
- * :method:[user[:password]@]hostname[#port]:/path/to/repository
- *
- * Some differences to note:
- * The : after the host/port is not optional because of NT naming including device
- * e.g. :pserver:username:password@hostname#port:D:\cvsroot
- *
- * If validateOnly is true, this method will always throw an exception.
- * The status of the exception indicates success or failure. The status
- * of the exception contains a specific message suitable for displaying
- * to a user who has knowledge of the provided location string.
- * @see CVSRepositoryLocation.fromString(String)
- */
- public static CVSRepositoryLocation fromString(String location, boolean validateOnly) throws CVSException {
- String partId = null;
- try {
- // Get the connection method
- partId = "CVSRepositoryLocation.parsingMethod";//$NON-NLS-1$
- int start = location.indexOf(COLON);
- if (start != 0)
- throw new CVSException(Policy.bind("CVSRepositoryLocation.startOfLocation"));//$NON-NLS-1$
- int end = location.indexOf(COLON, start + 1);
- String methodName = location.substring(start + 1, end);
- IConnectionMethod method = getPluggedInConnectionMethod(methodName);
- if (method == null)
- throw new CVSException(new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSRepositoryLocation.methods", new Object[] {getPluggedInConnectionMethodNames()})));//$NON-NLS-1$
-
- // Get the user name and password (if provided)
- partId = "CVSRepositoryLocation.parsingUser";//$NON-NLS-1$
- start = end + 1;
- end = location.indexOf(HOST_SEPARATOR, start);
- String user = null;;
- String password = null;
- // if end is -1 then there is no host separator meaning that the username is not present
- if (end != -1) {
- // Get the optional user and password
- user = location.substring(start, end);
- // Separate the user and password (if there is a password)
- start = user.indexOf(COLON);
- if (start != -1) {
- partId = "CVSRepositoryLocation.parsingPassword";//$NON-NLS-1$
- password = user.substring(start+1);
- user = user.substring(0, start);
- }
- // Set start to point after the host separator
- start = end + 1;
- }
-
- // Get the host (and port)
- partId = "CVSRepositoryLocation.parsingHost";//$NON-NLS-1$
- end= location.indexOf(COLON, start);
- String host = location.substring(start, end);
- int port = USE_DEFAULT_PORT;
- // Separate the port and host if there is a port
- start = host.indexOf(PORT_SEPARATOR);
- if (start != -1) {
- partId = "CVSRepositoryLocation.parsingPort";//$NON-NLS-1$
- port = Integer.parseInt(host.substring(start+1));
- host = host.substring(0, start);
- }
-
- // Get the repository path (translating backslashes to slashes)
- partId = "CVSRepositoryLocation.parsingRoot";//$NON-NLS-1$
- start = end + 1;
- String root = location.substring(start).replace('\\', '/');
-
- if (validateOnly)
- throw new CVSException(new CVSStatus(CVSStatus.OK, Policy.bind("ok")));//$NON-NLS-1$
-
- return new CVSRepositoryLocation(method, user, password, host, port, root, (user != null), (password != null));
- }
- catch (IndexOutOfBoundsException e) {
- // We'll get here if anything funny happened while extracting substrings
- throw new CVSException(Policy.bind(partId));
- }
- catch (NumberFormatException e) {
- // We'll get here if we couldn't parse a number
- throw new CVSException(Policy.bind(partId));
- }
- }
-
- public static IUserAuthenticator getAuthenticator() {
- if (authenticator == null) {
- authenticator = getPluggedInAuthenticator();
- }
- return authenticator;
- }
-
- /*
- * Return the connection method registered for the given name or null if none
- * are registered
- */
- private static IConnectionMethod getPluggedInConnectionMethod(String methodName) {
- IConnectionMethod[] methods = getPluggedInConnectionMethods();
- for(int i=0; i<methods.length; i++) {
- if(methodName.equals(methods[i].getName()))
- return methods[i];
- }
- return null;
- }
-
- /*
- * Return a string containing a list of all connection methods
- */
- private static String getPluggedInConnectionMethodNames() {
- IConnectionMethod[] methods = getPluggedInConnectionMethods();
- StringBuffer methodNames = new StringBuffer();
- for(int i=0; i<methods.length; i++) {
- String name = methods[i].getName();
- if (i>0)
- methodNames.append(", ");//$NON-NLS-1$
- methodNames.append(name);
- }
- return methodNames.toString();
- }
-
- public static IConnectionMethod[] getPluggedInConnectionMethods() {
- if(pluggedInConnectionMethods==null) {
- List connectionMethods = new ArrayList();
-
- if (STANDALONE_MODE) {
- connectionMethods.add(new PServerConnectionMethod());
- } else {
- IExtension[] extensions = Platform.getPluginRegistry().getExtensionPoint(CVSProviderPlugin.ID, CVSProviderPlugin.PT_CONNECTIONMETHODS).getExtensions();
- for(int i=0; i<extensions.length; i++) {
- IExtension extension = extensions[i];
- IConfigurationElement[] configs = extension.getConfigurationElements();
- if (configs.length == 0) {
- CVSProviderPlugin.log(new Status(IStatus.ERROR, CVSProviderPlugin.ID, 0, Policy.bind("CVSProviderPlugin.execProblem"), null));//$NON-NLS-1$
- continue;
- }
- try {
- IConfigurationElement config = configs[0];
- connectionMethods.add(config.createExecutableExtension("run"));//$NON-NLS-1$
- } catch (CoreException ex) {
- CVSProviderPlugin.log(new Status(IStatus.ERROR, CVSProviderPlugin.ID, 0, Policy.bind("CVSProviderPlugin.execProblem"), ex));//$NON-NLS-1$
- }
- }
- }
- pluggedInConnectionMethods = (IConnectionMethod[])connectionMethods.toArray(new IConnectionMethod[0]);
- }
- return pluggedInConnectionMethods;
- }
-
- private static IUserAuthenticator getPluggedInAuthenticator() {
- IExtension[] extensions = Platform.getPluginRegistry().getExtensionPoint(CVSProviderPlugin.ID, CVSProviderPlugin.PT_AUTHENTICATOR).getExtensions();
- if (extensions.length == 0)
- return null;
- IExtension extension = extensions[0];
- IConfigurationElement[] configs = extension.getConfigurationElements();
- if (configs.length == 0) {
- CVSProviderPlugin.log(new Status(IStatus.ERROR, CVSProviderPlugin.ID, 0, Policy.bind("CVSAdapter.noConfigurationElement", new Object[] {extension.getUniqueIdentifier()}), null));//$NON-NLS-1$
- return null;
- }
- try {
- IConfigurationElement config = configs[0];
- return (IUserAuthenticator) config.createExecutableExtension("run");//$NON-NLS-1$
- } catch (CoreException ex) {
- CVSProviderPlugin.log(new Status(IStatus.ERROR, CVSProviderPlugin.ID, 0, Policy.bind("CVSAdapter.unableToInstantiate", new Object[] {extension.getUniqueIdentifier()}), ex));//$NON-NLS-1$
- return null;
- }
- }
-
- /*
- * Validate that the given string could ne used to succesfully create
- * an instance of the receiver.
- *
- * This method performs some initial checks to provide displayable
- * feedback and also tries a more in-depth parse using fromString(String, boolean).
- */
- public static IStatus validate(String location) {
-
- // Check some simple things that are not checked in creation
- if (location == null)
- return new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSRepositoryLocation.nullLocation"));//$NON-NLS-1$
- if (location.equals(""))//$NON-NLS-1$
- return new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSRepositoryLocation.emptyLocation"));//$NON-NLS-1$
- if (location.endsWith(" ") || location.endsWith("\t"))//$NON-NLS-1$ //$NON-NLS-2$
- return new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSRepositoryLocation.endWhitespace"));//$NON-NLS-1$
- if (!location.startsWith(":") || location.indexOf(COLON, 1) == -1)//$NON-NLS-1$
- return new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSRepositoryLocation.startOfLocation"));//$NON-NLS-1$
-
- // Do some quick checks to provide geberal feedback
- String formatError = Policy.bind("CVSRepositoryLocation.locationForm");//$NON-NLS-1$
- int secondColon = location.indexOf(COLON, 1);
- int at = location.indexOf(HOST_SEPARATOR);
- if (at != -1) {
- String user = location.substring(secondColon + 1, at);
- if (user.equals(""))//$NON-NLS-1$
- return new CVSStatus(CVSStatus.ERROR, formatError);
- } else
- at = secondColon;
- int colon = location.indexOf(COLON, at + 1);
- if (colon == -1)
- return new CVSStatus(CVSStatus.ERROR, formatError);
- String host = location.substring(at + 1, colon);
- if (host.equals(""))//$NON-NLS-1$
- return new CVSStatus(CVSStatus.ERROR, formatError);
- String path = location.substring(colon + 1, location.length());
- if (path.equals(""))//$NON-NLS-1$
- return new CVSStatus(CVSStatus.ERROR, formatError);
-
- // Do a full parse and see if it passes
- try {
- fromString(location, true);
- } catch (CVSException e) {
- // An exception is always throw. Return the status
- return e.getStatus();
- }
-
- // Looks ok (we'll actually never get here because above
- // fromString(String, boolean) will always throw an exception).
- return new CVSStatus(IStatus.OK, Policy.bind("ok"));//$NON-NLS-1$
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java
deleted file mode 100644
index bf2c6e474..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.connection;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-
-/**
- * Client has received an error response from the server.
- */
-public class CVSServerException extends CVSException {
-
- /**
- * Return true if the exception from the cvs server is the no tag error, and false
- * otherwise.
- */
- public boolean isNoTagException() {
- IStatus status = getStatus();
- if ( ! status.isMultiStatus())
- return false;
- IStatus[] children = ((MultiStatus)status).getChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i].getCode() == CVSStatus.NO_SUCH_TAG) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return true if the exceptions status contains any error status messages
- */
- public boolean containsErrors() {
- IStatus status = getStatus();
- if ( ! status.isMultiStatus())
- return status.getSeverity() == IStatus.ERROR;
- IStatus[] children = ((MultiStatus)status).getChildren();
- for (int i=0;i<children.length;i++) {
- if (children[i].getSeverity() == IStatus.ERROR)
- return true;
- }
- return false;
- }
-
- /**
- * Return the CVSServerException for the given error message and error list
- *
- * This is public due to packaging and should not be used by clients.
- */
- public static CVSServerException forError(String message, IStatus[] children) {
- if (children.length > 0) {
- return new CVSServerException(message, children);
- } else {
- return new CVSServerException(new CVSStatus(IStatus.ERROR, CVSStatus.SERVER_ERROR, message, null));
- }
- }
-
- public CVSServerException(IStatus status) {
- super(status);
- }
-
- private CVSServerException(String message, IStatus[] children) {
- super(new MultiStatus(CVSProviderPlugin.ID, CVSStatus.SERVER_ERROR, children, message, null));
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java
deleted file mode 100644
index 3e68d7ce0..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java
+++ /dev/null
@@ -1,202 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.connection;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.IServerConnection;
-import org.eclipse.team.internal.ccvs.core.Policy;
-
-/**
- * A connection to talk to a cvs server. The life cycle of a connection is
- * as follows:
- * <ul>
- * <li> constructor: creates a new connection object that wraps the given
- * repository location and connection method.
- * <li> open: opens a connection.
- * <li> send a request: use write* method or use the request stream directly.
- * <code>GetRequestStream</code> returns an output stream to directly
- * talk to the server.
- * <li> read responses: use read* methods or use the response stream directly.
- * <code>GetResponseStream</code> returns an input stream to directly
- * read output from the server.
- * <li> close: closes the connection. A closed connection can be reopened by
- * calling open again.
- * </ul>
- */
-public class Connection {
- private static final byte NEWLINE= 0xA;
-
- private IServerConnection serverConnection;
- private ICVSRepositoryLocation fCVSRoot;
- private String fCVSRootDirectory;
- private boolean fIsEstablished;
- private InputStream fResponseStream;
- private byte[] readLineBuffer = new byte[256];
-
- public Connection(ICVSRepositoryLocation cvsroot, IServerConnection serverConnection) {
- fCVSRoot = cvsroot;
- this.serverConnection = serverConnection;
- }
-
- private static byte[] append(byte[] buffer, int index, byte b) {
- if (index >= buffer.length) {
- byte[] newBuffer= new byte[index * 2];
- System.arraycopy(buffer, 0, newBuffer, 0, buffer.length);
- buffer= newBuffer;
- }
- buffer[index]= b;
- return buffer;
- }
- /**
- * Closes the connection.
- */
- public void close() throws CVSException {
- if (!isEstablished())
- return;
- try {
- serverConnection.close();
- } catch (IOException ex) {
- throw new CVSCommunicationException(Policy.bind("Connection.cannotClose"), ex);//$NON-NLS-1$
- } finally {
- fResponseStream = null;
- fIsEstablished = false;
- }
- }
- /**
- * Flushes the request stream.
- */
- public void flush() throws CVSException {
- if (!isEstablished())
- return;
- try {
- getOutputStream().flush();
- } catch(IOException e) {
- throw new CVSCommunicationException(e);
- }
- }
-
- /**
- * Returns the <code>OutputStream</code> used to send requests
- * to the server.
- */
- public OutputStream getOutputStream() throws CVSException {
- if (!isEstablished())
- return null;
- return serverConnection.getOutputStream();
- }
- /**
- * Returns the <code>InputStream</code> used to read responses from
- * the server.
- */
- public InputStream getInputStream() throws CVSException {
- if (!isEstablished())
- return null;
- if (fResponseStream == null)
- fResponseStream = serverConnection.getInputStream();
- return fResponseStream;
- }
-
- /**
- * Returns <code>true</code> if the connection is established;
- * otherwise <code>false</code>.
- */
- public boolean isEstablished() {
- return fIsEstablished;
- }
-
- /**
- * Opens the connection.
- */
- public void open(IProgressMonitor monitor) throws CVSException {
- if (isEstablished())
- return;
- try {
- serverConnection.open(monitor);
- } catch (IOException e) {
- throw new CVSCommunicationException(e);
- }
- fIsEstablished= true;
- }
- /**
- * Reads a line from the response stream.
- */
- public String readLine() throws CVSException {
- if (!isEstablished())
- throw new CVSCommunicationException(Policy.bind("Connection.readUnestablishedConnection"));//$NON-NLS-1$
- try {
- InputStream in = getInputStream();
- int index = 0;
- int r;
- while ((r = in.read()) != -1) {
- if (r == NEWLINE) break;
- readLineBuffer = append(readLineBuffer, index++, (byte) r);
- }
- String result = new String(readLineBuffer, 0, index);
- if (Policy.DEBUG_CVS_PROTOCOL) System.out.println(result);
- return result;
- } catch (IOException e) {
- throw new CVSCommunicationException(e);
- }
- }
-
- static String readLine(InputStream in) throws IOException {
- byte[] buffer = new byte[256];
- int index = 0;
- int r;
- while ((r = in.read()) != -1) {
- if (r == NEWLINE)
- break;
- buffer = append(buffer, index++, (byte) r);
- }
- String result = new String(buffer, 0, index);
- if (Policy.DEBUG_CVS_PROTOCOL)
- System.out.println(result);
- return result;
- }
-
- //---- Helper to send strings to the server ----------------------------
-
- /**
- * Sends the given string to the server.
- */
- public void write(String s) throws CVSException {
- write(s, false);
- }
- /**
- * Sends the given string and a newline to the server.
- */
- public void writeLine(String s) throws CVSException {
- write(s, true);
- }
- /**
- * Low level method to write a string to the server. All write* methods are
- * funneled through this method.
- */
- void write(String s, boolean newline) throws CVSException {
- if (!isEstablished())
- throw new CVSCommunicationException(Policy.bind("Connection.writeUnestablishedConnection"));//$NON-NLS-1$
-
- if (Policy.DEBUG_CVS_PROTOCOL)
- System.out.print(s + (newline ? "\n" : ""));//$NON-NLS-1$ //$NON-NLS-2$
-
- try {
- OutputStream out= getOutputStream();
- out.write(s.getBytes());
- if (newline)
- out.write(NEWLINE);
- out.flush();
-
- } catch (IOException e) {
- throw new CVSCommunicationException(e);
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java
deleted file mode 100644
index 5637e54ca..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.connection;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.IServerConnection;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.streams.*;
-
-/**
- * Implements a connection method which invokes an external tool to
- * establish the connection to the cvs server. Authentication and starting
- * of the cvs server are the responsibility of the external connection
- * tool.
- */
-public class ExtConnection implements IServerConnection {
-
- // command to start remote cvs in server mode
- private static final String INVOKE_SVR_CMD = "server"; //$NON-NLS-1$
-
- // The default port for rsh
- private static final int DEFAULT_PORT = 9999;
-
- // cvs format for the repository (e.g. :extssh:user@host:/home/cvs/repo)
- private ICVSRepositoryLocation location;
-
- // incoming from remote host
- InputStream inputStream;
-
- // outgoing to remote host
- OutputStream outputStream;
-
- // Process spawn to run the command
- Process process;
-
- protected ExtConnection(ICVSRepositoryLocation location, String password) {
- this.location = location;
- // passwork not needed, authentication performed by external tool
- }
-
- /**
- * Closes the connection.
- */
- public void close() throws IOException {
- try {
- if (inputStream != null) inputStream.close();
- } finally {
- inputStream = null;
- try {
- if (outputStream != null) outputStream.close();
- } finally {
- outputStream = null;
- process.destroy();
- }
- }
- }
-
- /**
- * Returns the <code>InputStream</code> used to read data from the
- * server.
- */
- public InputStream getInputStream() {
- return inputStream;
- }
-
- /**
- * Returns the <code>OutputStream</code> used to send data to the
- * server.
- */
- public OutputStream getOutputStream() {
- return outputStream;
- }
-
- /**
- * Opens the connection and invokes cvs in server mode.
- *
- * @see Connection.open()
- */
- public void open(IProgressMonitor monitor) throws IOException {
- String hostname = location.getHost();
- String username = location.getUsername();
-
- String CVS_RSH = CVSProviderPlugin.getPlugin().getCvsRshCommand();
- String CVS_SERVER = CVSProviderPlugin.getPlugin().getCvsServer();
- String[] command = new String[] {CVS_RSH, hostname, "-l", username, CVS_SERVER, INVOKE_SVR_CMD}; //$NON-NLS-1$
-
- int port = location.getPort();
- if (port == location.USE_DEFAULT_PORT)
- port = DEFAULT_PORT;
-
- // The command line doesn't support the use of a port
- if (port != DEFAULT_PORT)
- throw new IOException(Policy.bind("EXTServerConnection.invalidPort")); //$NON-NLS-1$
-
- if(CVS_RSH == null || CVS_SERVER == null) {
- throw new IOException(Policy.bind("EXTServerConnection.varsNotSet")); //$NON-NLS-1$
- }
-
- boolean connected = false;
- try {
- process = Runtime.getRuntime().exec(command);
-
- inputStream = new PollingInputStream(new TimeoutInputStream(process.getInputStream(),
- 8192 /*bufferSize*/, 1000 /*readTimeout*/, -1 /*closeTimeout*/), location.getTimeout(), monitor);
- outputStream = new PollingOutputStream(new TimeoutOutputStream(process.getOutputStream(),
- 8192 /*buffersize*/, 1000 /*writeTimeout*/, 1000 /*closeTimeout*/), location.getTimeout(), monitor);
-
- // XXX need to do something more useful with stderr
- // discard the input to prevent the process from hanging due to a full pipe
- Thread thread = new DiscardInputThread(process.getErrorStream());
- connected = true;
- } finally {
- if (! connected) {
- try {
- close();
- } finally {
- throw new IOException(Policy.bind("EXTServerConnection.ioError", CVS_RSH)); //$NON-NLS-1$
- }
- }
- }
- }
-
- private static class DiscardInputThread extends Thread {
- private InputStream in;
- public DiscardInputThread(InputStream in) {
- this.in = in;
- }
- public void run() {
- try {
- try {
- while (in.read() != -1);
- } finally {
- in.close();
- }
- } catch (IOException e) {
- }
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java
deleted file mode 100644
index 1b97fc84b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.connection;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.IConnectionMethod;
-import org.eclipse.team.internal.ccvs.core.IServerConnection;
-
-public class ExtConnectionMethod implements IConnectionMethod {
- /**
- * @see IConnectionMethod#getName
- */
- public String getName() {
- return "ext"; //$NON-NLS-1$
- }
-
- /**
- * @see IConnectionMethod#createConnection
- */
- public IServerConnection createConnection(ICVSRepositoryLocation repositoryRoot, String password) {
- return new ExtConnection(repositoryRoot, password);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java
deleted file mode 100644
index 3c2f92549..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java
+++ /dev/null
@@ -1,272 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.connection;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InterruptedIOException;
-import java.io.OutputStream;
-import java.net.Socket;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.IServerConnection;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.streams.*;
-
-/**
- * A connection used to talk to an cvs pserver.
- */
-public class PServerConnection implements IServerConnection {
-
- protected static final String SLEEP_PROPERTY = "cvs.pserver.wait";//$NON-NLS-1$
- protected static final String milliseconds = System.getProperty(SLEEP_PROPERTY);
-
- public static final char NEWLINE= 0xA;
-
- /** default CVS pserver port */
- private static final int DEFAULT_PORT= 2401;
-
- /** error line indicators */
- private static final char ERROR_CHAR = 'E';
- private static final String ERROR_MESSAGE = "error 0";//$NON-NLS-1$
- private static final String NO_SUCH_USER = "no such user";//$NON-NLS-1$
-
- private static final char[] SCRAMBLING_TABLE=new char[] {
- 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
- 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
- 114,120,53,79,96,109,72,108,70,64,76,67,116,74,68,87,
- 111,52,75,119,49,34,82,81,95,65,112,86,118,110,122,105,
- 41,57,83,43,46,102,40,89,38,103,45,50,42,123,91,35,
- 125,55,54,66,124,126,59,47,92,71,115,78,88,107,106,56,
- 36,121,117,104,101,100,69,73,99,63,94,93,39,37,61,48,
- 58,113,32,90,44,98,60,51,33,97,62,77,84,80,85,223,
- 225,216,187,166,229,189,222,188,141,249,148,200,184,136,248,190,
- 199,170,181,204,138,232,218,183,255,234,220,247,213,203,226,193,
- 174,172,228,252,217,201,131,230,197,211,145,238,161,179,160,212,
- 207,221,254,173,202,146,224,151,140,196,205,130,135,133,143,246,
- 192,159,244,239,185,168,215,144,139,165,180,157,147,186,214,176,
- 227,231,219,169,175,156,206,198,129,164,150,210,154,177,134,127,
- 182,128,158,208,162,132,167,209,149,241,153,251,237,236,171,195,
- 243,233,253,240,194,250,191,155,142,137,245,235,163,242,178,152
- };
-
- /** Communication strings */
- private static final String BEGIN= "BEGIN AUTH REQUEST";//$NON-NLS-1$
- private static final String END= "END AUTH REQUEST";//$NON-NLS-1$
- private static final String LOGIN_OK= "I LOVE YOU";//$NON-NLS-1$
- private static final String LOGIN_FAILED= "I HATE YOU";//$NON-NLS-1$
-
- private String password;
- private ICVSRepositoryLocation cvsroot;
-
- private Socket fSocket;
-
- private InputStream inputStream;
- private OutputStream outputStream;
-
- /**
- * @see Connection#doClose()
- */
- public void close() throws IOException {
- try {
- if (inputStream != null) inputStream.close();
- } finally {
- inputStream = null;
- try {
- if (outputStream != null) outputStream.close();
- } finally {
- outputStream = null;
- try {
- if (fSocket != null) fSocket.close();
- } finally {
- fSocket = null;
- }
- }
- }
- }
-
- /**
- * @see Connection#doOpen()
- */
- public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException {
-
- // XXX see sleepIfPropertyIsSet() for comments.
- // This should be removed once we have corrected the
- // CVS plugin's bad behavior with connections.
- sleepIfPropertyIsSet();
-
- monitor.subTask(Policy.bind("PServerConnection.authenticating"));//$NON-NLS-1$
- monitor.worked(1);
-
- fSocket = createSocket();
- boolean connected = false;
- try {
- this.inputStream = new BufferedInputStream(new PollingInputStream(fSocket.getInputStream(),
- cvsroot.getTimeout(), monitor));
- this.outputStream = new PollingOutputStream(new TimeoutOutputStream(
- fSocket.getOutputStream(), 8192 /*bufferSize*/, 1000 /*writeTimeout*/, 1000 /*closeTimeout*/),
- cvsroot.getTimeout(), monitor);
- authenticate();
- connected = true;
- } finally {
- if (! connected) cleanUpAfterFailedConnection();
- }
- }
-
- /**
- * @see Connection#getInputStream()
- */
- public InputStream getInputStream() {
- return inputStream;
- }
- /**
- * @see Connection#getOutputStream()
- */
- public OutputStream getOutputStream() {
- return outputStream;
- }
-
- /**
- * Creates a new <code>PServerConnection</code> for the given
- * cvs root.
- */
- PServerConnection(ICVSRepositoryLocation cvsroot, String password) {
- this.cvsroot = cvsroot;
- this.password = password;
- }
- /**
- * Does the actual authentification.
- */
- private void authenticate() throws IOException, CVSAuthenticationException {
- String scrambledPassword = scramblePassword(password);
-
- String user = cvsroot.getUsername();
- OutputStream out = getOutputStream();
-
- StringBuffer request = new StringBuffer();
- request.append(BEGIN);
- request.append(NEWLINE);
- request.append(cvsroot.getRootDirectory());
- request.append(NEWLINE);
- request.append(user);
- request.append(NEWLINE);
- request.append(scrambledPassword);
- request.append(NEWLINE);
- request.append(END);
- request.append(NEWLINE);
- out.write(request.toString().getBytes());
- out.flush();
- String line = Connection.readLine(getInputStream());
-
- // Return if we succeeded
- if (LOGIN_OK.equals(line))
- return;
-
- // Otherwise, determine the type of error
- if (line.length() == 0)
- throw new IOException(Policy.bind("PServerConnection.noResponse"));//$NON-NLS-1$
- if (LOGIN_FAILED.equals(line))
- throw new CVSAuthenticationException(cvsroot.getLocation(), Policy.bind("PServerConnection.loginRefused"));//$NON-NLS-1$
- String message = "";//$NON-NLS-1$
- // Skip any E messages for now
- while (line.charAt(0) == ERROR_CHAR) {
- // message += line.substring(1) + " ";
- line = Connection.readLine(getInputStream());
- }
- // Remove leading "error 0"
- if (line.startsWith(ERROR_MESSAGE))
- message += line.substring(ERROR_MESSAGE.length() + 1);
- else
- message += line;
- if (message.indexOf(NO_SUCH_USER) != -1)
- throw new CVSAuthenticationException(cvsroot.getLocation(), Policy.bind("PServerConnection.invalidUser", new Object[] {message}));//$NON-NLS-1$
- throw new IOException(Policy.bind("PServerConnection.connectionRefused", new Object[] { message }));//$NON-NLS-1$
- }
- /*
- * Called if there are exceptions when connecting.
- * This method makes sure that all connections are closed.
- */
- private void cleanUpAfterFailedConnection() throws IOException {
- try {
- if (inputStream != null)
- inputStream.close();
- } finally {
- try {
- if (outputStream != null)
- outputStream.close();
- } finally {
- try {
- if (fSocket != null)
- fSocket.close();
- } finally {
- fSocket = null;
- }
- }
- }
-
- }
- /**
- * Creates the actual socket
- */
- protected Socket createSocket() throws IOException {
- // Determine what port to use
- int port = cvsroot.getPort();
- if (port == cvsroot.USE_DEFAULT_PORT)
- port = DEFAULT_PORT;
- // Make the connection
- Socket result;
- try {
- result= new Socket(cvsroot.getHost(), port);
- } catch (InterruptedIOException e) {
- // If we get this exception, chances are the host is not responding
- throw new InterruptedIOException(Policy.bind("PServerConnection.socket", new Object[] {cvsroot.getHost()}));//$NON-NLS-1$
- }
- result.setSoTimeout(1000); // 1 second between timeouts
- return result;
- }
-
- private String scramblePassword(String password) throws CVSAuthenticationException {
- int length = password.length();
- char[] out= new char[length];
- for (int i= 0; i < length; i++) {
- char value = password.charAt(i);
- if( value < 0 || value > 255 )
- throwInValidCharacter();
- out[i]= SCRAMBLING_TABLE[value];
- }
- return "A" + new String(out);//$NON-NLS-1$
- }
-
- private void throwInValidCharacter() throws CVSAuthenticationException {
- throw new CVSAuthenticationException(cvsroot.getLocation(),
- Policy.bind("PServerConnection.invalidChars"));//$NON-NLS-1$
- }
-
- /**
- * XXX This is provided to allow slowing down of pserver connections in cases
- * where the inetd connections per second setting is not set high enough. The
- * CVS plugin has a known problem of creating too many unnecessary connections.
- */
- private void sleepIfPropertyIsSet()
- {
- try {
- if( milliseconds == null )
- return;
-
- long sleepMilli = new Long(milliseconds).longValue();
-
- if( sleepMilli > 0 )
- Thread.currentThread().sleep(sleepMilli);
- } catch( InterruptedException e ) {
- // keep going
- } catch( NumberFormatException e ) {
- // don't sleep if number format is wrong
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnectionMethod.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnectionMethod.java
deleted file mode 100644
index 264ba8091..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnectionMethod.java
+++ /dev/null
@@ -1 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.connection; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; import org.eclipse.team.internal.ccvs.core.IConnectionMethod; import org.eclipse.team.internal.ccvs.core.IServerConnection; public class PServerConnectionMethod implements IConnectionMethod { /** * @see IConnectionMethod#createConnection(ICVSRepositoryLocation, String) */ public IServerConnection createConnection(ICVSRepositoryLocation location, String password) { return new PServerConnection(location, password); } /** * @see IConnectionMethod#getName() */ public String getName() { return "pserver";//$NON-NLS-1$ } } \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/UserInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/UserInfo.java
deleted file mode 100644
index 7b5ace98c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/UserInfo.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.connection;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.team.internal.ccvs.core.IUserInfo;
-
-/**
- * @version 1.0
- * @author
- */
-public class UserInfo implements IUserInfo {
-
- private String username;
- private String password;
- private boolean isUsernameMutable;
-
- protected UserInfo(String username, String password, boolean isUsernameMutable) {
- this.username = username;
- this.password = password;
- this.isUsernameMutable = isUsernameMutable;
- }
-
- /*
- * @see IUserInfo#getUsername()
- */
- public String getUsername() {
- return username;
- }
-
- protected String getPassword() {
- return password;
- }
-
- /*
- * @see IUserInfo#isUsernameMutable()
- */
- public boolean isUsernameMutable() {
- return false;
- }
-
- /*
- * @see IUserInfo#setPassword(String)
- */
- public void setPassword(String password) {
- this.password = password;
- }
-
- /*
- * @see IUserInfo#setUsername(String)
- */
- public void setUsername(String username) {
- this.username = username;
- }
-
-}
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
deleted file mode 100644
index 3820c3789..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
+++ /dev/null
@@ -1,265 +0,0 @@
-org.eclipse.team.internal.provider.cvs.CVSException=CVS Error: {0}
-
-ok=ok
-
-AbstractStructureVisitor.sendingFolder=Processing {0}
-AbstractStructureVisitor.sendingFile=Processing {0}
-AbstractStructureVisitor.noRemote=Unable to determine remote location for resource
-
-AddDeleteMoveListener.deletedResource={0} has been deleted locally
-AddDeleteMoveListener.Error_creating_deletion_marker_1=Error creating deletion marker
-AddDeleteMoveListener.Local_addition_not_under_CVS_control_2=Local addition not under CVS control
-AddDeleteMoveListener.Error_creating_addition_marker_3=Error creating addition marker
-AddDeleteMoveListener.Error_updating_marker_state_4=Error updating marker state
-
-CVSAuthenticationException.normal=Authentication error connecting to {0}
-CVSAuthenticationException.detail=Authentication error: {0}
-
-CVSCommunicationException.io=CVS communication error: {0}
-CVSFileException.io=Error accessing CVS file
-CVSDiffException.message=The compared files are different
-
-CVSTag.nullName=Name must not be null
-CVSTag.emptyName=Name must not be empty
-CVSTag.beginName=Name must start with a letter
-CVSTag.badCharName=Name must not contain spaces or the characters `$,.:;@|'
-
-CVSWorkspaceRoot.notCVSFolder=The CVS synchronization information for {0} has become corrupt or does not exist
-
-java.io.IOException={0}
-java.io.EOFException=End of file encountered: {0}
-java.io.FileNotFoundException=File not found: {0}
-java.io.InterruptedIOException=Interrupted IO: {0}
-java.net.UnknownHostException=Cannot locate host: {0}
-java.net.ConnectException=Cannot connect to host: {0}
-java.net.SocketException=Socket Exception: {0}
-
-Connection.cannotClose=Cannot close connection
-Connection.readUnestablishedConnection=Failure due to attempt to read from an unestablished connection
-Connection.writeUnestablishedConnection=Failure due to attempt to write to an unestablished connection
-
-PServerConnection.invalidChars=Invalid characters in password
-PServerConnection.hostInvalid=Invalid host
-PServerConnection.loginRefused=Incorrect user name or password
-PServerConnection.invalidUser={0}
-PServerConnection.socket=Cannot connect to host: {0}
-PServerConnection.connectionRefused=Connection refused: {0}
-PServerConnection.stream=Error opening socket connection
-PServerConnection.noResponse=No response from server
-PServerConnection.authenticating=Authenticating using pserver
-
-CVSProviderPlugin.cannotUpdateDescription=Error updating project description
-CVSProviderPlugin.errorDeletingCache=Error occured deleting cache: {0}
-CVSProviderPlugin.errorCreatingCache=Error occured creating cache: {0}
-
-CVSProvider.exception=Internal error occured.
-CVSProvider.invalidResource=Resource {0} is not a CVS resource
-CVSProvider.initialImport=Initial import
-CVSProvider.alreadyExists=The specified repository location already exists.
-CVSProvider.rename=An IO Exception occurred while renaming the state file {0}
-CVSProvider.save=An IO Exception occurred while saving the state file {0}
-CVSProvider.ioException=IO Exception occured on the state file
-CVSProvider.errorSaving=Error saving state
-CVSProvider=errorLoading=Error Locading state
-CVSProvider.infoMismatch=Provided CVS information does not match that on disk for project {0}
-
-CVSTeamProvider.noFolderInfo=Project {0} does not contain CVS folder meta-information
-CVSTeamProvider.deconfigureProblem=Error while deconfiguring CVS project {0}
-CVSTeamProvider.initializationFailed=Initialization of CVS for project {0} failed
-CVSTeamProvider.visitError=An error occurred while visiting resource {0}
-CVSTeamProvider.invalidResource=Resource {0} is not a child of project {1}
-CVSTeamProvider.checkinProblems=Problems occured committing resources to server
-CVSTeamProvider.invalidProjectState=CVS sharing information is missing from project {0}
-CVSTeamProvider.unmanagedParent=Error retrieving remote resource tree for {0}. Parent is not managed by CVS.
-CVSTeamProvider.typesDiffer=Error retrieving remote resource tree. Local and remote resource types differ for {0}
-CVSTeamProvider.connectionInfo=Updating connection information for project {0}
-CVSTeamProvider.folderInfo=Updating folder synchronization information for project {0}
-CVSTeamProvider.updatingFolder=Updating {0}
-CVSTeamProvider.scrubbingResource=Scrubbing {0}
-CVSTeamProvider.updatingFile=Updating {0}
-CVSTeamProvider.makeBranch=Creating branch
-CVSTeamProvider.preparingToSetKSubst=Preparing to set keyword substitution mode
-CVSTeamProvider.settingKSubst=Setting keyword substitution mode
-CVSTeamProvider.cleanLineDelimitersException=Exception occurred while cleaning line delimiters
-
-ProjectDescriptionManager.unableToSetDescription=An error occured setting the project description
-ProjectDescriptionManager.unableToReadDescription=An error occured reading the project description
-ProjectDescriptionManager.ioDescription=An IO error occured while writing the project description
-ProjectDescriptionManager.coreDescription=A Core error occured while writing the project description
-ProjectDescriptionManager.vcmmetaIgnored=.vcm_meta file ignored for project {0}
-ProjectDescriptionManager.cannotUpdateDesc=Cannot update project description
-ProjectDescriptionManager.markerError=Error creating marker for .vcm_meta file.
-ProjectDescriptionManager.vcmmetaMarker=The file {0} exists in {1} but is no longer being read; its usage has been replaced with .project.
-
-ResourceDeltaVisitor.visitError=Error while processing resource deltas
-
-ResponseDispatcher.serverError=The CVS server responded with an error (see the CVS console)
-ResponseDispatcher.problemsReported= Errors occured during the CVS operation
-ResponseDispatcher.receiving=Receiving reponse
-
-FileProperties.invalidEntryLine=Invalid entry line: {0}
-
-EclipseResource.invalidResourceClass=Two different implementations of ICVSResource used
-
-RemoteResource.invalidResourceClass=Two different implementations of ICVSResource used
-RemoteResource.invalidOperation=Invalid operation performed on remote resource
-RemoteFolder.errorFetchingRevisions=Error fetching file revision numbers
-RemoteFolder.invalidChild=Resource {0} is not a child of folder {1}
-RemoteFolder.errorFetchingRevisions=Error fetching file revisions
-RemoteFolder.errorFetchingMembers=One or more error occured fetching the members of a remote folder
-RemoteFolder.doesNotExist=Folder {0} does not exist remotely
-
-RemoteFile.noContentsReceived=No contents received from server for {0}
-RemoteFile.errorRetrievingFromCache=Error occured retrieving cached contents: {0}
-
-RemoteFolderTreeBuilder.buildingBase=Collecting local synchronization information
-RemoteFolderTreeBuilder.receivingDelta=Receiving delta for {0}
-RemoteFolderTreeBuilder.receivingRevision=Receiving revision for {0}
-RemoteFolderTreeBuilder.missingParent=An error has occurred processing file ''{0} {1}''
-
-ReplaceWithBaseVisitor.replacing=Replacing ''{0}''
-
-Session.badInt="Malformed file transmission received"
-Session.receiving=Receiving file: {0}
-Session.sending=Sending file: {0}
-Session.transfer={0} ({1}K of {2}K bytes)
-Session.transferNoSize={0}
-
-Command.receivingResponses=Receiving server response
-Command.warnings=Warnings occured during CVS operation: {0}
-Command.serverError=Error occured during CVS operation: {0}
-Command.noMoreInfoAvailable=The server did not provide any additional information.
-Command.add=add
-Command.admin=admin
-Command.co=checkout
-Command.ci=commit
-Command.diff=diff
-Command.import=import
-Command.log=log
-Command.remove=remove
-Command.status=status
-Command.tag=tag
-Command.update=update
-Command.version=version
-Command.valid-requests=valid-requests
-Command.unsupportedResponse=Unknown response received from cvs server: {0} {1}
-Command.argumentNotManaged=Argument {0} is not managed
-Command.invalidTag=HEAD is not a valid tag
-Command.noOpenSession=The CVS command cannot be issued because there is no connection available
-
-Tag.notVersionOrBranchError=Error applying tag: the tag provided is not a version or branch tag.
-
-DefaultHandler.connectionClosed=The connection to the server has been closed
-ModTimeHandler.invalidFormat=The server modification time {0} is in an unknown format
-Updated.numberFormat=Server did not send length of the file
-UnsupportedHandler.message=Unsupported response received from server
-RemovedHandler.invalid=Invalid removed response received from CVS server for {0}
-
-KSubstOption.-kb.short=Binary
-KSubstOption.-kb.long=Binary (-kb)
-KSubstOption.-ko.short=Text
-KSubstOption.-ko.long=Text without keyword substitution (-ko)
-KSubstOption.-kkv.short=Text -kkv
-KSubstOption.-kkv.long=Text with keyword expansion (-kkv)
-KSubstOption.-kkvl.short=Text -kkvl
-KSubstOption.-kkvl.long=Text with keyword expansion and locker (-kkvl)
-KSubstOption.-kv.short=Text -kv
-KSubstOption.-kv.long=Text with keyword replacement (-kv)
-KSubstOption.-kk.short=Text -kk
-KSubstOption.-kk.long=Text with keyword compression (-kk)
-KSubstOption.unknown.short=Unknown {0}
-KSubstOption.unknown.long=Unknown ({0})
-
-AdminKSubstListener.expectedRCSFile=Expected RCS file {0} to end in ',v'
-AdminKSubstListener.commandRootNotManaged=Local root for this command is not managed
-AdminKSubstListener.expectedChildOfCommandRoot=Expected RCS file {0} to be a child of remote root for this command {1}
-AdminKSubstListener.couldNotSetResourceSyncInfo=Could not set resource sync info for {0}: {1}
-
-CVSRepositoryLocation.nullLocation=Location must not be null
-CVSRepositoryLocation.emptyLocation=Location must not be empty
-CVSRepositoryLocation.endWhitespace=Location must not end with whitespace
-CVSRepositoryLocation.locationForm=Location must have form ':methodname:[user[:password]@]host[#port]:/path/to/cvsroot'
-CVSRepositoryLocation.startOfLocation=Location must start with a connection method name enclosed in colons
-CVSRepositoryLocation.methods=Only the following methods are supported: {0}
-CVSRepositoryLocation.parsingMethod=Error in connection method specification
-CVSRepositoryLocation.parsingUser=Error in user name specification
-CVSRepositoryLocation.parsingPassword=Error in password specification
-CVSRepositoryLocation.parsingHost=Error in host specification
-CVSRepositoryLocation.parsingPort=Error in port specification
-CVSRepositoryLocation.parsingRoot=Error in repository root directory specification
-CVSRepositoryLocation.invalidFormat=Invalid CVS repository location format: {0}
-CVSRepositoryLocation.authenticationCanceled=Authentication canceled by user
-CVSRepositoryLocation.errorCaching=Error occurred while saving password for {0}
-CVSRepositoryLocation.errorFlushing=Error occurred while flushing password for {0}
-CVSRepositoryLocation.openingConnection=Opening connection to {0}
-CVSRepositoryLocation.usernameRequired=A username is required to make a connection
-
-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...
-FileSystemSynchronizer_Error_loading_from_CVS/Entries_file_1=Error loading from CVS/Entries file
-FileSystemSynchronizer_Error_loading_from_.cvsignore_file_2=Error loading from .cvsignore file
-FileSystemSynchronizer_Error_loading_from_CVS/Root,Repository_files_3=Error loading from CVS/Root,Repository files
-FileSystemSynchronizer_Error_reloading_sync_information_5=Error reloading sync information
-Malformed_entry_line___11=Malformed entry line:
-Malformed_entry_line,_missing_name___12=Malformed entry line, missing name:
-Malformed_entry_line,_missing_revision___13=Malformed entry line, missing revision:
-FolderSyncInfo_Maleformed_root_4=Maleformed root
-SyncFileUtil_Error_writing_to_Entries.log_48=Error writing to Entries.log
-SyncFileUtil_Cannot_close_Entries.log_49=Cannot close Entries.log
-SyncFileUtil_Error_reloading_sync_information_58=Error reloading sync information
-SyncFileUtil_Error_writing_to_.cvsignore_61=Error writing to .cvsignore
-SyncFileUtil_Cannot_close_.cvsignore_62=Cannot close .cvsignore
-
-FileModificationValidator.isReadOnly=File is Read Only.
-
-EXTServerConnection.invalidPort=A port cannot be specified for the ext connection method.
-EXTServerConnection.varsNotSet=Cannot run external ext program because CVS_RSH and CVS_SERVER variables are not initialized.
-EXTServerConnection.ioError=Error starting external connection program: {0}. Ensure that the path is correct and that you can connect manually using this program.
-
-CVSRemoteSyncElement.rootDiffers=Error mapping local folder {0} to repository {1}. It is already managed by repository {2}.
-CVSRemoteSyncElement.repositoryDiffers=Error mapping local folder {0} to remote folder {1}. It is already mapped to {2}.
-Util.Internal_error,_resource_does_not_start_with_root_3=Internal error, resource does not start with root
-
-
-CVSProvider.Scrubbing_local_project_1=Scrubbing local project
-CVSProvider.Scrubbing_projects_1=Scrubbing projects
-CVSProvider.Creating_projects_2=Creating projects
-
-EclipseFile_Problem_deleting_resource=Problem deleting resource: {1}
-EclipseFile_Problem_accessing_resource=Problem accessing resource: {1} Perform a Refresh.
-EclipseFile_Problem_creating_resource=Problem creating resource: {1}
-EclipseFile_Problem_writing_resource=Problem writing resource: {1}
-EclipseFolder_problem_creating=Problem creating folder: {1}
-
-EclipseSynchronizer.UpdatingSyncEndOperation=Saving CVS synchronization information...
-EclipseSynchronizer.UpdatingSyncEndOperationCancelled=Operation cancelled: saving CVS synchronization information...
-EclipseSynchronizer.ErrorSettingFolderSync=Cannot set folder sync info on {0}
-EclipseSynchronizer.ErrorSettingResourceSync=Cannot set resource sync info on {0}
-EclipseSynchronizer.ErrorSettingIgnorePattern=Cannot set ignored pattern on {0}
-EclipseSynchronizer.ErrorCommitting=Errors saving CVS synchronization information to disk. Please fix the problems listed below and then update the affected resources from the CVS repository.
-
-SyncFileChangeListener.errorSettingTeamPrivateFlag=Error setting team-private flag on resource
-
-PollingInputStream.readTimeout=Timeout while reading from input stream
-PollingInputStream.closeTimeout=Timeout while closing input stream
-PollingOutputStream.writeTimeout=Timeout while writing to output stream
-PollingOutputStream.closeTimeout=Timeout while closing output stream
-TimeoutOutputStream.cannotWriteToStream=Cannot write to output stream
-
-RemoteFile.getContents=Retrieving remote file contents
-RemoteFile.getLogEntries=Retrieving log entries
-RemoteFolder.exists=Checking if resource exists remotely
-RemoteFolder.getMembers=Retrieving children of remote folder
-RemoteModule.getRemoteModules=Retrieving remote modules
-
-PruneFolderVisitor.caseVariantsExist=The following resources could not be created.
-PruneFolderVisitor.caseVariantExists=Resource ''{0}'' could not be created because a case variant exists.
-
-Version.unsupportedVersion=Host ''{0}'' is running unsupported CVS version {1}. Although most functionality works, use version 1.11.1p1 or later for full support.
-Version.unsupportedCVSNT=Host ''{0}'' is running CVS NT (version {1}) which is not fully supported. However, most functionality is available.
-Version.unknownVersionFormat=Host ''{0}'' is running ''{1}'' which is an unknown version to the workbench. Although most functionality may work, use version 1.11.1p1 or later for full support.
-Version.versionNotValidRequest=Unable to determine server version. Host ''{0}'' does not support the ''cvs version'' command. Although most functionality works, use version 1.11.1p1 or later for full support. \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSEntryLineTag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSEntryLineTag.java
deleted file mode 100644
index ac60cf365..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSEntryLineTag.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-
-public class CVSEntryLineTag extends CVSTag {
-
- /*
- * The parameter tag must not be null.
- */
- public CVSEntryLineTag(CVSTag tag) {
- super(tag.getName(), tag.getType());
- }
-
- public CVSEntryLineTag(String entryLineTag) {
- switch (entryLineTag.charAt(0)) {
- case 'T' : type = BRANCH; break;
- case 'N' : type = VERSION; break;
- case 'D' : type = DATE; break;
- default: type = HEAD;
- }
- name = entryLineTag.substring(1);
- }
- /*
- * Returns the tag name
- */
- public String getName() {
- return name;
- }
- /*
- * Returns the tag type
- */
- public int getType() {
- return type;
- }
-
- public String toEntryLineFormat(boolean useSamePrefixForBranchAndTag) {
- if (type == BRANCH || (type == VERSION && useSamePrefixForBranchAndTag))
- return "T" + name;//$NON-NLS-1$
- else if (type == VERSION)
- return "N" + name;//$NON-NLS-1$
- else if (type == DATE)
- return "D" + name;//$NON-NLS-1$
- return "";//$NON-NLS-1$
- }
-
- /*
- * For debugging purposes.
- */
- public String toString() {
- return toEntryLineFormat(false);
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java
deleted file mode 100644
index 416b19a9f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.team.core.sync.ILocalSyncElement;
-import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.core.sync.LocalSyncElement;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-public class CVSLocalSyncElement extends LocalSyncElement {
-
- protected IRemoteResource base;
- protected IResource local;
-
- public CVSLocalSyncElement(IResource local, IRemoteResource base) {
- this.local = local;
- this.base = base;
- }
-
- /*
- * @see RemoteSyncElement#create(IResource, IRemoteResource, IRemoteResource)
- */
- public ILocalSyncElement create(IResource local, IRemoteResource base, Object data) {
- return new CVSLocalSyncElement(local, base);
- }
-
- /*
- * @see ILocalSyncElement#getLocal()
- */
- public IResource getLocal() {
- return local;
- }
-
- /*
- * @see ILocalSyncElement#getBase()
- */
- public IRemoteResource getBase() {
- return base;
- }
-
- /*
- * @see ILocalSyncElement#isCheckedOut()
- */
- public boolean isCheckedOut() {
- return getLocal() != null;
- }
-
- /*
- * @see ILocalSyncElement#hasRemote()
- */
- public boolean hasRemote() {
- return getLocal() != null;
- }
-
- /*
- * @see RemoteSyncElement#getData()
- */
- protected Object getData() {
- return null;
- }
-
- /*
- * Answers the CVS resource for this sync element
- */
- public ICVSResource getCVSResource() {
- return getCVSResourceFor(getLocal());
- }
-
- /*
- * @see LocalSyncElement#isIgnored(IResource)
- */
- protected boolean isIgnored(IResource child) {
- ICVSResource cvsResource = getCVSResourceFor(getLocal());
- if(cvsResource==null || !cvsResource.isFolder() ) {
- return false;
- } else {
- try {
- ICVSResource managedChild = ((ICVSFolder)cvsResource).getChild(child.getName());
- return managedChild.isIgnored();
- } catch(CVSException e) {
- return false;
- }
- }
- }
-
- private ICVSResource getCVSResourceFor(IResource resource) {
- if(resource.getType() != IResource.FILE) {
- return new EclipseFolder((IContainer)resource);
- } else {
- return new EclipseFile((IFile)resource);
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java
deleted file mode 100644
index 45ae627e4..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java
+++ /dev/null
@@ -1,392 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.ILocalSyncElement;
-import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.core.sync.IRemoteSyncElement;
-import org.eclipse.team.core.sync.RemoteSyncElement;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-
-public class CVSRemoteSyncElement extends RemoteSyncElement {
-
- CVSLocalSyncElement localSync;
- IRemoteResource remote;
- boolean isThreeWay = true;
-
- public CVSRemoteSyncElement(boolean isThreeWay, IResource local, IRemoteResource base, IRemoteResource remote) {
- localSync = new CVSLocalSyncElement(local, base);
- this.remote = remote;
- this.isThreeWay = isThreeWay;
- }
-
- /*
- * @see RemoteSyncElement#create(IResource, IRemoteResource, IRemoteResource)
- */
- public IRemoteSyncElement create(boolean isThreeWay, IResource local, IRemoteResource base, IRemoteResource remote, Object data) {
- return new CVSRemoteSyncElement(isThreeWay, local, base, remote);
- }
-
- /*
- * @see IRemoteSyncElement#getRemote()
- */
- public IRemoteResource getRemote() {
- return remote;
- }
-
- /*
- * @see LocalSyncElement#getData()
- */
- protected Object getData() {
- return localSync.getData();
- }
-
- /*
- * @see ILocalSyncElement#getLocal()
- */
- public IResource getLocal() {
- return localSync.getLocal();
- }
-
- /*
- * @see ILocalSyncElement#getBase()
- */
- public IRemoteResource getBase() {
- return localSync.getBase();
- }
-
- /*
- * @see ILocalSyncElement#isCheckedOut()
- */
- public boolean isCheckedOut() {
- return localSync.isCheckedOut();
- }
-
- /*
- * Local helper to indicate if the corresponding local resource has a base
- *
- * XXX Should this be part of the interface?
- */
- public boolean hasBase() {
- return getBase() != null;
- }
-
- /*
- * @see ILocalSyncElement#hasRemote()
- */
- public boolean hasRemote() {
- return remote != null;
- }
-
- /*
- * @see LocalSyncElement#create(IResource, IRemoteResource, Object)
- */
- public ILocalSyncElement create(IResource local, IRemoteResource base, Object data) {
- return localSync.create(local, base, data);
- }
- /*
- * @see LocalSyncElement#isIgnored(IResource)
- */
- protected boolean isIgnored(IResource resource) {
- return localSync.isIgnored(resource);
- }
- /*
- * @see IRemoteSyncElement#ignoreBaseTree()
- */
- public boolean isThreeWay() {
- return isThreeWay;
- }
-
- /*
- * Update the sync info of the local resource in such a way that the local changes can be committed.
- */
- public void makeOutgoing(IProgressMonitor monitor) throws TeamException {
-
- int syncKind = getSyncKind(GRANULARITY_TIMESTAMP, monitor);
- boolean incoming = (syncKind & DIRECTION_MASK) == INCOMING;
- boolean outgoing = (syncKind & DIRECTION_MASK) == OUTGOING;
-
- ICVSResource local = localSync.getCVSResource();
- RemoteResource remote = (RemoteResource)getRemote();
- ResourceSyncInfo origInfo = local.getSyncInfo();
- MutableResourceSyncInfo info = null;
- if(origInfo!=null) {
- info = origInfo.cloneMutable();
- }
-
- if (outgoing) {
- // The sync info is alright, it's already outgoing!
- return;
- } else if (incoming) {
- // We have an incoming change, addition, or deletion that we want to ignore
- if (local.exists()) {
- // We could have an incoming change or deletion
- if (remote == null) {
- info.setAdded();
- } else {
- // Otherwise change the revision to the remote revision and dirty the file
- info.setRevision(remote.getSyncInfo().getRevision());
- info.setTimeStamp(null);
- }
- } else {
- // We have an incoming add, turn it around as an outgoing delete
- info = remote.getSyncInfo().cloneMutable();
- info.setDeleted(true);
- }
- } else if (local.exists()) {
- // We have a conflict and a local resource!
- if (hasRemote()) {
- if (hasBase()) {
- // We have a conflicting change, Update the local revision
- info.setRevision(remote.getSyncInfo().getRevision());
- } else {
- // We have conflictin additions.
- // We need to fetch the contents of the remote to get all the relevant information (timestamp, permissions)
- remote.getContents(Policy.monitorFor(monitor));
- info = remote.getSyncInfo().cloneMutable();
- }
- } else if (hasBase()) {
- // We have a remote deletion. Make the local an addition
- info.setAdded();
- } else {
- // There's a local, no base and no remote. We can't possible have a conflict!
- Assert.isTrue(false);
- }
- } else {
- // We have a conflict and there is no local!
- if (hasRemote()) {
- // We have a local deletion that conflicts with remote changes.
- info.setRevision(remote.getSyncInfo().getRevision());
- info.setDeleted(true);
- } else {
- // We have conflicting deletions. Clear the sync info
- info = null;
- return;
- }
- }
- if(info!=null) {
- info.setTag(local.getParent().getFolderSyncInfo().getTag());
- }
- local.setSyncInfo(info);
- }
-
- /*
- * Update the sync info of the local resource in such a way that the remote resource can be loaded
- * ignore any local changes.
- */
- public void makeIncoming(IProgressMonitor monitor) throws TeamException {
- // To make outgoing deletions incoming, the local will not exist but
- // it is still important to unmanage (e.g. delete all meta info) for the
- // deletion.
- CVSWorkspaceRoot.getCVSResourceFor(getLocal()).unmanage(null);
- }
-
- /*
- * Load the resource and folder sync info into the local from the remote
- *
- * This method can be used on incoming folder additions to set the folder sync info properly
- * without hitting the server again. It also applies to conflicts that involves unmanaged
- * local resources.
- *
- * If the local folder is already managed and is a cvs folder, this operation
- * will throw an exception if the mapping does not match that of the remote.
- */
- public void makeInSync(IProgressMonitor monitor) throws TeamException {
-
- // Only work on folders
- if (! isContainer()) return;
-
- int syncKind = getSyncKind(GRANULARITY_TIMESTAMP, monitor);
- boolean outgoing = (syncKind & DIRECTION_MASK) == OUTGOING;
- if (outgoing) return;
-
- ICVSFolder local = (ICVSFolder)localSync.getCVSResource();
- RemoteFolder remote = (RemoteFolder)getRemote();
-
- // The parent must be managed
- if (! local.getParent().isCVSFolder())
- return;
-
- // If the folder already has CVS info, check that the remote and local match
- if(local.isManaged() && local.isCVSFolder()) {
- // Verify that the root and repository are the same
- FolderSyncInfo remoteInfo = remote.getFolderSyncInfo();
- FolderSyncInfo localInfo = local.getFolderSyncInfo();
- if ( ! localInfo.getRoot().equals(remoteInfo.getRoot())) {
- throw new CVSException(Policy.bind("CVSRemoteSyncElement.rootDiffers", new Object[] {local.getName(), remoteInfo.getRoot(), localInfo.getRoot()}));//$NON-NLS-1$
- } else if ( ! localInfo.getRepository().equals(remoteInfo.getRepository())) {
- throw new CVSException(Policy.bind("CVSRemoteSyncElement.repositoryDiffers", new Object[] {local.getName(), remoteInfo.getRepository(), localInfo.getRepository()}));//$NON-NLS-1$
- }
- // The folders are in sync so just return
- return;
- }
-
- // Ensure that the folder exists locally
- if (! local.exists()) {
- local.mkdir();
- }
-
- // Since the parent is managed, this will also set the resource sync info. It is
- // impossible for an incoming folder addition to map to another location in the
- // repo, so we assume that using the parent's folder sync as a basis is safe.
- // It is also impossible for an incomming folder to be static.
- FolderSyncInfo remoteInfo = remote.getFolderSyncInfo();
- FolderSyncInfo localInfo = local.getParent().getFolderSyncInfo();
- local.setFolderSyncInfo(new FolderSyncInfo(remoteInfo.getRepository(), remoteInfo.getRoot(), localInfo.getTag(), false));
- }
- /*
- * @see ILocalSyncElement#getSyncKind(int, IProgressMonitor)
- */
- public int getSyncKind(int granularity, IProgressMonitor progress) {
-
- // special handling for folders, the generic sync algorithm doesn't work well
- // with CVS because folders are not in namespaces (e.g. they exist in all versions
- // and branches).
- if(isContainer() && isThreeWay()) {
- int folderKind = IRemoteSyncElement.IN_SYNC;
- IResource local = getLocal();
- ICVSRemoteFolder remote = (ICVSRemoteFolder)getRemote();
- ICVSFolder cvsFolder = (ICVSFolder)localSync.getCVSResource();
- if(!local.exists()) {
- if ( cvsFolder.isCVSFolder()) {
- // We have local information for the folder but it doesn't exist
- if (remote == null) {
- // Conflicting deletion. Purge local information
- try {
- cvsFolder.unmanage(null);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e.getStatus());
- }
- } else {
- // The folder exists remotely and has been deleted locally
- folderKind = IRemoteSyncElement.OUTGOING | IRemoteSyncElement.DELETION;
- }
- } else if(remote != null) {
- folderKind = IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION;
- } else {
- // conflicting deletion ignore
- }
- } else {
- if(remote == null) {
- if(cvsFolder.isCVSFolder()) {
- folderKind = IRemoteSyncElement.INCOMING | IRemoteSyncElement.DELETION;
- } else {
- folderKind = IRemoteSyncElement.OUTGOING | IRemoteSyncElement.ADDITION;
- }
- } else if(!cvsFolder.isCVSFolder()) {
- folderKind = IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.ADDITION;
- } else {
- // folder exists both locally and remotely and are considered in sync, however
- // we aren't checking the folder mappings to ensure that they are the same.
- }
- }
- return folderKind;
- }
-
- // 1. Run the generic sync calculation algorithm, then handle CVS specific
- // sync cases.
- int kind = super.getSyncKind(granularity, progress);
-
- // 2. Set the CVS specific sync type based on the workspace sync state provided
- // by the CVS server.
- if(remote!=null && (kind & IRemoteSyncElement.PSEUDO_CONFLICT) == 0) {
- int type = ((RemoteResource)remote).getWorkspaceSyncState();
- switch(type) {
- // the server compared both text files and decided that it cannot merge
- // them without line conflicts.
- case Update.STATE_CONFLICT:
- return kind | ILocalSyncElement.MANUAL_CONFLICT;
-
- // the server compared both text files and decided that it can safely merge
- // them without line conflicts.
- case Update.STATE_MERGEABLE_CONFLICT:
- return kind | ILocalSyncElement.AUTOMERGE_CONFLICT;
- }
- }
-
- // 3. unmanage delete/delete conflicts and return that they are in sync
- kind = handleDeletionConflicts(kind);
-
- return kind;
- }
-
- /*
- * If the resource has a delete/delete conflict then ensure that the local is unmanaged so that the
- * sync info can be properly flushed.
- */
- private int handleDeletionConflicts(int kind) {
- if(kind == (IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.DELETION | IRemoteSyncElement.PSEUDO_CONFLICT)) {
- try {
- ICVSResource cvsResource = localSync.getCVSResource();
- if(!isContainer() && cvsResource.isManaged()) {
- cvsResource.unmanage(null);
- }
- return IRemoteSyncElement.IN_SYNC;
- } catch(CVSException e) {
- CVSProviderPlugin.log(e.getStatus());
- return IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.DELETION;
- }
- }
- return kind;
- }
-
- /**
- * @see RemoteSyncElement#timestampEquals(IRemoteResource, IRemoteResource)
- */
- protected boolean timestampEquals(IRemoteResource e1, IRemoteResource e2) {
- if(e1.isContainer()) {
- if(e2.isContainer()) {
- return true;
- }
- return false;
- }
- return e1.equals(e2);
- }
-
- /**
- * @see RemoteSyncElement#timestampEquals(IResource, IRemoteResource)
- */
- protected boolean timestampEquals(IResource e1, IRemoteResource e2) {
- if(e1.getType() != IResource.FILE) {
- if(e2.isContainer()) {
- return true;
- }
- return false;
- }
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)e1);
- try {
- ResourceSyncInfo info1 = cvsFile.getSyncInfo();
- ResourceSyncInfo info2 = ((ICVSRemoteResource)e2).getSyncInfo();
-
- if(info1 != null) {
- if(info1.isDeleted() || info1.isMerged() || cvsFile.isModified()) {
- return false;
- }
- return info1.getRevision().equals(info2.getRevision());
- }
- return false;
- } catch(CVSException e) {
- CVSProviderPlugin.log(e.getStatus());
- return false;
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java
deleted file mode 100644
index 5730407a5..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.TeamPlugin;
-import org.eclipse.team.core.sync.IRemoteSyncElement;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProvider;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-
-public class CVSWorkspaceRoot {
-
- private ICVSFolder localRoot;
-
- public CVSWorkspaceRoot(IContainer resource){
- this.localRoot = getCVSFolderFor(resource);
- }
-
- public static ICVSFolder getCVSFolderFor(IContainer resource) {
- return new EclipseFolder(resource);
- }
-
-
- public static ICVSFile getCVSFileFor(IFile resource) {
- return new EclipseFile(resource);
- }
-
-
- public static ICVSResource getCVSResourceFor(IResource resource) {
- if (resource.getType() == IResource.FILE)
- return getCVSFileFor((IFile) resource);
- else
- return getCVSFolderFor((IContainer) resource);
- }
-
- public static ICVSRemoteResource getRemoteResourceFor(IResource resource) throws CVSException {
- ICVSResource managed = getCVSResourceFor(resource);
- return getRemoteResourceFor(managed);
- }
-
- public static ICVSRemoteResource getRemoteResourceFor(ICVSResource resource) throws CVSException {
- if (resource.isFolder()) {
- ICVSFolder folder = (ICVSFolder)resource;
- FolderSyncInfo syncInfo = folder.getFolderSyncInfo();
- if (syncInfo != null) {
- return new RemoteFolder(null, CVSProvider.getInstance().getRepository(syncInfo.getRoot()), new Path(syncInfo.getRepository()), syncInfo.getTag());
- }
- } else {
- if (resource.isManaged())
- return RemoteFile.getBase((RemoteFolder)getRemoteResourceFor(resource.getParent()), (ICVSFile)resource);
- }
- return null;
- }
-
- /*
- * Helper method that uses the parent of a local resource that has no base to ensure that the resource
- * wasn't added remotely by a third party
- */
- private static ICVSRemoteResource getRemoteTreeFromParent(IResource resource, ICVSResource managed, CVSTag tag, IProgressMonitor progress) throws TeamException {
- // If the parent isn't mapped to CVS, there's nothing we can do
- ICVSFolder parent = managed.getParent();
- FolderSyncInfo syncInfo = parent.getFolderSyncInfo();
- if (syncInfo == null) {
- throw new CVSException(new CVSStatus(CVSStatus.ERROR, resource.getFullPath(), Policy.bind("CVSTeamProvider.unmanagedParent", resource.getFullPath().toString()), null)); //$NON-NLS-1$
- }
- ICVSRepositoryLocation location = CVSProvider.getInstance().getRepository(parent.getFolderSyncInfo().getRoot());
- // XXX We build and fetch the whole tree from the parent. We could restrict the search to just the desired child
- RemoteFolder remoteParent = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, parent, tag, progress);
- ICVSRemoteResource remote = null;
- if (remoteParent != null) {
- try {
- remote = (ICVSRemoteResource)remoteParent.getChild(resource.getName());
- } catch (CVSException e) {
- remote = null;
- }
- // The types need to match or we're in trouble
- if (remote != null && !(remote.isContainer() == managed.isFolder()))
- throw new CVSException(new CVSStatus(CVSStatus.ERROR, resource.getFullPath(), Policy.bind("CVSTeamProvider.typesDiffer", resource.getFullPath().toString()), null)); //$NON-NLS-1$
- }
- return remote;
- }
-
- public static IRemoteSyncElement getRemoteSyncTree(IResource resource, CVSTag tag, IProgressMonitor progress) throws TeamException {
- ICVSResource managed = CVSWorkspaceRoot.getCVSResourceFor(resource);
- ICVSRemoteResource remote = CVSWorkspaceRoot.getRemoteResourceFor(resource);
- ICVSRemoteResource baseTree = null;
-
- // The resource doesn't have a remote base.
- // However, we still need to check to see if its been created remotely by a third party.
- if (remote == null) {
- remote = getRemoteTreeFromParent(resource, managed, tag, progress);
- } else if(resource.getType() == IResource.FILE) {
- baseTree = remote;
- ICVSRepositoryLocation location = remote.getRepository();
- remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFile)managed, tag, progress);
- } else {
- ICVSRepositoryLocation location = remote.getRepository();
- baseTree = RemoteFolderTreeBuilder.buildBaseTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress);
- remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress);
- }
- return new CVSRemoteSyncElement(true /*three way*/, resource, baseTree, remote);
- }
-
- public static ICVSRemoteResource getRemoteTree(IResource resource, CVSTag tag, IProgressMonitor progress) throws TeamException {
- ICVSResource managed = CVSWorkspaceRoot.getCVSResourceFor(resource);
- ICVSRemoteResource remote = CVSWorkspaceRoot.getRemoteResourceFor(resource);
- if (remote == null) {
- remote = getRemoteTreeFromParent(resource, managed, tag, progress);
- } else if(resource.getType() == IResource.FILE) {
- ICVSRepositoryLocation location = remote.getRepository();
- remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFile)managed, tag, progress);
- } else {
- ICVSRepositoryLocation location = remote.getRepository();
- remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress);
- }
- return remote;
- }
-
- public ICVSRepositoryLocation getRemoteLocation() throws CVSException {
- FolderSyncInfo info = localRoot.getFolderSyncInfo();
- if (info == null) {
- throw new CVSException(Policy.bind("CVSWorkspaceRoot.notCVSFolder", localRoot.getName())); //$NON-NLS-1$
- }
- return CVSProvider.getInstance().getRepository(info.getRoot());
- }
-
- public ICVSFolder getLocalRoot() {
- return localRoot;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
deleted file mode 100644
index 5c0cab35f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * 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.resources;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.Date;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.ILogEntry;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * Represents handles to CVS resource on the local file system. Synchronization
- * information is taken from the CVS subdirectories.
- */
-public class EclipseFile extends EclipseResource implements ICVSFile {
-
- private static final String TEMP_FILE_EXTENSION = ".tmp";//$NON-NLS-1$
- private static final IPath PROJECT_META_DATA_PATH = new Path(".project");//$NON-NLS-1$
-
- /**
- * Create a handle based on the given local resource.
- */
- protected EclipseFile(IFile file) {
- super(file);
- }
-
- /*
- * @see ICVSResource#delete()
- */
- public void delete() throws CVSException {
- try {
- ((IFile)resource).delete(false /*force*/, true /*keepHistory*/, null);
- } catch(CoreException e) {
- throw CVSException.wrapException(resource, Policy.bind("EclipseFile_Problem_deleting_resource", resource.getFullPath().toString(), e.getStatus().getMessage()), e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public long getSize() {
- return getIOFile().length();
- }
-
- public InputStream getContents() throws CVSException {
- try {
- return getIFile().getContents();
- } catch (CoreException e) {
- throw CVSException.wrapException(resource, Policy.bind("EclipseFile_Problem_accessing_resource", resource.getFullPath().toString(), e.getStatus().getMessage()), e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /*
- * @see ICVSFile#getTimeStamp()
- */
- public Date getTimeStamp() {
- return new Date((getIOFile().lastModified()/1000)*1000);
- }
-
- /*
- * @see ICVSFile#setTimeStamp(String)
- */
- public void setTimeStamp(Date date) throws CVSException {
- long time;
- if (date == null) {
- time = System.currentTimeMillis();
- } else {
- time = date.getTime();
- }
- getIOFile().setLastModified(time);
- try {
- // Needed for workaround to Platform Core Bug #
- resource.refreshLocal(IResource.DEPTH_ZERO, null);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /*
- * @see ICVSResource#isFolder()
- */
- public boolean isFolder() {
- return false;
- }
-
- /*
- * @see ICVSFile#isModified()
- */
- public boolean isModified() throws CVSException {
- if (!exists() || !isManaged()) {
- return true;
- } else {
- ResourceSyncInfo info = getSyncInfo();
- // consider a merged file as always modified.
- if(info.isMerged()) return true;
- return !getTimeStamp().equals(info.getTimeStamp());
- }
- }
-
- /*
- * @see ICVSResource#accept(ICVSResourceVisitor)
- */
- public void accept(ICVSResourceVisitor visitor) throws CVSException {
- visitor.visitFile(this);
- }
-
- /*
- * This is to be used by the Copy handler. The filename of the form .#filename
- */
- public void copyTo(String filename) throws CVSException {
- try {
- getIFile().copy(new Path(filename), true /*force*/, null);
- } catch(CoreException e) {
- throw new CVSException(e.getStatus());
- }
- }
-
- /*
- * @see ICVSResource#getRemoteLocation()
- */
- public String getRemoteLocation(ICVSFolder stopSearching) throws CVSException {
- return getParent().getRemoteLocation(stopSearching) + SEPARATOR + getName();
- }
-
- /*
- * @see ICVSFile#setReadOnly()
- */
- public void setContents(InputStream stream, int responseType, boolean keepLocalHistory, IProgressMonitor monitor) throws CVSException {
- try {
- IFile file = getIFile();
- if (PROJECT_META_DATA_PATH.equals(file.getFullPath().removeFirstSegments(1))) {
- responseType = UPDATED;
- }
- switch (responseType) {
- case UPDATED:
- if (resource.exists()) {
- file.setContents(stream, true /*force*/, true /*keep history*/, monitor);
- break;
- }
- case CREATED: // creating a new file so it should not exist locally
- file.create(stream, false /*force*/, monitor);
- break;
- case MERGED: // merging contents into a file that exists locally
- // Ensure we don't leave the file in a partially written state
- IFile tempFile = file.getParent().getFile(new Path(file.getName() + TEMP_FILE_EXTENSION));
- tempFile.create(stream, true /*force*/, monitor);
- file.delete(false, true, monitor);
- tempFile.move(new Path(file.getName()), true /*force*/, false /*history*/, monitor);
- break;
- case UPDATE_EXISTING: // creating a new file so it should exist locally
- file.setContents(stream, true /*force*/, true /*keep history*/, monitor);
- break;
- }
- } catch(CoreException e) {
- throw CVSException.wrapException(resource, Policy.bind("EclipseFile_Problem_writing_resource", e.getMessage(), e.getStatus().getMessage()), e); //$NON-NLS-1$
- }
- }
-
- /*
- * @see ICVSFile#setReadOnly()
- */
- public void setReadOnly(boolean readOnly) throws CVSException {
- getIFile().setReadOnly(readOnly);
- }
-
- /*
- * @see ICVSFile#isReadOnly()
- */
- public boolean isReadOnly() throws CVSException {
- return getIFile().isReadOnly();
- }
-
- /*
- * Typecasting helper
- */
- public IFile getIFile() {
- return (IFile)resource;
- }
-
- /*
- * To allow accessing size and timestamp for the underlying java.io.File
- */
- private File getIOFile() {
- IPath location = resource.getLocation();
- if(location!=null) {
- return location.toFile();
- }
- return null;
- }
- /**
- * @see ICVSFile#getLogEntries(IProgressMonitor)
- */
- public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws TeamException {
- if(isManaged() && !getSyncInfo().isAdded()) {
- ICVSRemoteResource remoteFile = CVSWorkspaceRoot.getRemoteResourceFor(resource);
- return ((ICVSRemoteFile)remoteFile).getLogEntries(monitor);
- }
- return new ILogEntry[0];
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java
deleted file mode 100644
index c1c3984c8..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*******************************************************************************
- * 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.resources;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.resources.team.IMoveDeleteHook;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * Implements the ICVSFolder interface on top of an
- * instance of the ICVSFolder interface
- *
- * @see ICVSFolder
- */
-class EclipseFolder extends EclipseResource implements ICVSFolder {
-
- protected EclipseFolder(IContainer container) {
- super(container);
- }
-
- /**
- * @see ICVSFolder#members(int)
- */
- public ICVSResource[] members(int flags) throws CVSException {
- final List result = new ArrayList();
- IResource[] resources = EclipseSynchronizer.getInstance().members((IContainer)resource);
- boolean includeFiles = (((flags & FILE_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
- boolean includeFolders = (((flags & FOLDER_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
- boolean includeManaged = (((flags & MANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0));
- boolean includeUnmanaged = (((flags & UNMANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0));
- boolean includeIgnored = ((flags & IGNORED_MEMBERS) != 0);
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- if ((includeFiles && (resource.getType()==IResource.FILE))
- || (includeFolders && (resource.getType()==IResource.FOLDER))) {
- boolean isManaged = cvsResource.isManaged();
- boolean isIgnored = cvsResource.isIgnored();
- if ((isManaged && includeManaged)|| (isIgnored && includeIgnored)
- || ( ! isManaged && ! isIgnored && includeUnmanaged)) {
- result.add(cvsResource);
- }
-
- }
- }
- return (ICVSResource[]) result.toArray(new ICVSResource[result.size()]);
- }
-
- /**
- * @see ICVSFolder#createFolder(String)
- */
- public ICVSFolder getFolder(String name) throws CVSException {
- if ((CURRENT_LOCAL_FOLDER.equals(name)) || ((CURRENT_LOCAL_FOLDER + SEPARATOR).equals(name)))
- return this;
- IPath path = new Path(name);
- if(resource.getType()==IResource.ROOT && path.segmentCount()==1) {
- return new EclipseFolder(((IWorkspaceRoot)resource).getProject(name));
- } else {
- return new EclipseFolder(((IContainer)resource).getFolder(new Path(name)));
- }
- }
-
- /**
- * @see ICVSFolder#createFile(String)
- */
- public ICVSFile getFile(String name) throws CVSException {
- return new EclipseFile(((IContainer)resource).getFile(new Path(name)));
- }
-
- /**
- * @see ICVSFolder#mkdir()
- */
- public void mkdir() throws CVSException {
- try {
- if(resource.getType()==IResource.PROJECT) {
- IProject project = (IProject)resource;
- project.create(null);
- project.open(null);
- } else {
- ((IFolder)resource).create(false /*don't force*/, true /*make local*/, null);
- EclipseSynchronizer.getInstance().folderCreated((IFolder)resource);
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(resource, Policy.bind("EclipseFolder_problem_creating", resource.getFullPath().toString(), e.getStatus().getMessage()), e); //$NON-NLS-1$
- }
- }
-
- /**
- * @see ICVSResource#isFolder()
- */
- public boolean isFolder() {
- return true;
- }
-
- /**
- * @see ICVSFolder#acceptChildren(ICVSResourceVisitor)
- */
- public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException {
-
- // Visit files and then folders
- ICVSResource[] subFiles = members(FILE_MEMBERS);
- for (int i=0; i<subFiles.length; i++) {
- subFiles[i].accept(visitor);
- }
- ICVSResource[] subFolders = members(FOLDER_MEMBERS);
- for (int i=0; i<subFolders.length; i++) {
- subFolders[i].accept(visitor);
- }
- }
-
- /**
- * @see ICVSResource#accept(ICVSResourceVisitor)
- */
- public void accept(ICVSResourceVisitor visitor) throws CVSException {
- visitor.visitFolder(this);
- }
-
- /**
- * @see ICVSResource#getRemoteLocation(ICVSFolder)
- */
- public String getRemoteLocation(ICVSFolder stopSearching) throws CVSException {
-
- if (getFolderSyncInfo() != null) {
- return getFolderSyncInfo().getRemoteLocation();
- }
-
- ICVSFolder parent = getParent();
- if(parent!=null && !equals(stopSearching)) {
- String parentLocation;
- parentLocation = parent.getRemoteLocation(stopSearching);
- if (parentLocation!=null) {
- return parentLocation + SEPARATOR + getName();
- }
- }
- return null;
- }
-
- /*
- * @see ICVSFolder#getFolderInfo()
- */
- public FolderSyncInfo getFolderSyncInfo() throws CVSException {
- return EclipseSynchronizer.getInstance().getFolderSync((IContainer)resource);
- }
-
- /*
- * @see ICVSFolder#setFolderInfo(FolderSyncInfo)
- */
- public void setFolderSyncInfo(FolderSyncInfo folderInfo) throws CVSException {
- EclipseSynchronizer.getInstance().setFolderSync((IContainer)resource, folderInfo);
- // the server won't add directories as sync info, therefore it must be done when
- // a directory is shared with the repository.
- setSyncInfo(new ResourceSyncInfo(getName()));
- }
-
- /*
- * @see ICVSFolder#isCVSFolder()
- */
- public boolean isCVSFolder() {
- try {
- return EclipseSynchronizer.getInstance().getFolderSync((IContainer)resource) != null;
- } catch(CVSException e) {
- return false;
- }
- }
-
- /*
- * @see ICVSResource#unmanage()
- */
- public void unmanage(IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- try {
- monitor.beginTask("", 100); //$NON-NLS-1$
- run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- recursiveUnmanage((IContainer) resource, monitor);
- }
- }, Policy.subMonitorFor(monitor, 99));
- // unmanaged from parent
- super.unmanage(Policy.subMonitorFor(monitor, 1));
- } finally {
- monitor.done();
- }
- }
-
- private static void recursiveUnmanage(IContainer container, IProgressMonitor monitor) throws CVSException {
- try {
- monitor.beginTask("", 10); //$NON-NLS-1$
- monitor.subTask(container.getFullPath().toOSString());
- EclipseSynchronizer.getInstance().deleteFolderSync(container);
- IResource[] members = container.members();
- for (int i = 0; i < members.length; i++) {
- monitor.worked(1);
- IResource resource = members[i];
- if (members[i].getType() != IResource.FILE) {
- recursiveUnmanage((IContainer) resource, monitor);
- }
- }
- } catch (CoreException e) {
- } finally {
- monitor.done();
- }
- }
-
- /*
- * @see ICVSResource#isIgnored()
- */
- public boolean isIgnored() {
- if(isCVSFolder()) {
- return false;
- }
- return super.isIgnored();
- }
-
- /*
- * @see ICVSFolder#getChild(String)
- */
- public ICVSResource getChild(String namedPath) throws CVSException {
- IPath path = new Path(namedPath);
- if(path.segmentCount()==0) {
- return this;
- }
- IResource child = ((IContainer)resource).findMember(path, true /* include phantoms */);
- if(child!=null) {
- if(child.getType()==IResource.FILE) {
- return new EclipseFile((IFile)child);
- } else {
- return new EclipseFolder((IContainer)child);
- }
- }
- return null;
- }
-
- /*
- * @see ICVSFolder#run(ICVSRunnable, IProgressMonitor)
- */
- public void run(final ICVSRunnable job, IProgressMonitor monitor) throws CVSException {
- final CVSException[] error = new CVSException[1];
- // Remove the registered Move/Delete hook, assuming that the cvs runnable will keep sync info up-to-date
- final IMoveDeleteHook oldHook = CVSTeamProvider.getRegisteredMoveDeleteHook();
- CVSTeamProvider.setMoveDeleteHook(null);
- try {
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- monitor = Policy.monitorFor(monitor);
- try {
- monitor.beginTask(null, 100);
- try {
- EclipseSynchronizer.getInstance().beginOperation(Policy.subMonitorFor(monitor, 5));
- job.run(Policy.subMonitorFor(monitor, 60));
- } finally {
- EclipseSynchronizer.getInstance().endOperation(Policy.subMonitorFor(monitor, 35));
- }
- } catch(CVSException e) {
- error[0] = e;
- } finally {
- monitor.done();
- }
- }
- }, monitor);
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- CVSTeamProvider.setMoveDeleteHook(oldHook);
- }
- if(error[0]!=null) {
- throw error[0];
- }
- }
- /**
- * @see ICVSFolder#fetchChildren(IProgressMonitor)
- */
- public ICVSResource[] fetchChildren(IProgressMonitor monitor) throws CVSException {
- return members(FILE_MEMBERS | FOLDER_MEMBERS);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipsePhantomSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipsePhantomSynchronizer.java
deleted file mode 100644
index bb365cb9c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipsePhantomSynchronizer.java
+++ /dev/null
@@ -1,450 +0,0 @@
-/*******************************************************************************
- * 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.resources;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ISynchronizer;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.QualifiedName;
-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.ICVSResource;
-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.SyncFileWriter;
-
-/**
- * Wraps the CVS EclipseSynchronizer with phantoms for folder deletions.
- */
-public class EclipsePhantomSynchronizer extends EclipseSynchronizer {
-
- private static final QualifiedName FOLDER_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-sync"); //$NON-NLS-1$
- private static final QualifiedName RESOURCE_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "resource-sync"); //$NON-NLS-1$
-
- private Set changedResources = new HashSet();
-
- EclipsePhantomSynchronizer() {
- // Add the sync keys to the workspace synchronizer which is used to handle folder deletions
- getWorkspaceSynchronizer().add(FOLDER_SYNC_KEY);
- getWorkspaceSynchronizer().add(RESOURCE_SYNC_KEY);
- }
-
- /**
- * Gets the folder sync info for the specified folder.
- *
- * @param folder the folder
- * @return the folder sync info associated with the folder, or null if none.
- * @see #setFolderSync, #deleteFolderSync
- */
- public FolderSyncInfo getFolderSync(IContainer container) throws CVSException{
- if (container.isPhantom()) {
- return getPhantomFolderSyncInfo(container);
- }
- return super.getFolderSync(container);
- }
-
- /**
- * @see EclipseSynchronizer#setFolderSync(IContainer, FolderSyncInfo)
- */
- public void setFolderSync(IContainer container, FolderSyncInfo info) throws CVSException {
- if (container.isPhantom()) {
- try {
- beginOperation(null);
- changedResources.add(container);
- try {
- getWorkspaceSynchronizer().setSyncInfo(FOLDER_SYNC_KEY, container, getBytes(info));
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- } finally {
- endOperation(null);
- }
- } else {
- super.setFolderSync(container, info);
- }
- }
-
- /**
- * Deletes the folder sync for the specified folder and the resource sync
- * for all of its children. Does not recurse.
- *
- * @param folder the folder
- * @see #getFolderSync, #setFolderSync
- */
- public void deleteFolderSync(IContainer container) throws CVSException {
- if (container.isPhantom()) {
- try {
- beginOperation(null);
- changedResources.add(container);
- flushPhantomInfo(container);
- } finally {
- endOperation(null);
- }
- } else {
- super.deleteFolderSync(container);
- }
- }
-
- /**
- * Gets the resource sync info for the specified folder.
- *
- * @param resource the resource
- * @return the resource sync info associated with the resource, or null if none.
- * @see #setResourceSync, #deleteResourceSync
- */
- public ResourceSyncInfo getResourceSync(IResource resource) throws CVSException {
- IContainer parent = resource.getParent();
- if (parent != null && parent.isPhantom()) {
- Map map = getPhantomResourceSyncInfoMap(parent);
- return (ResourceSyncInfo)map.get(resource.getName());
- }
- return super.getResourceSync(resource);
- }
-
- /**
- * @see EclipseSynchronizer#setResourceSync(IResource, ResourceSyncInfo)
- */
- public void setResourceSync(IResource resource, ResourceSyncInfo info) throws CVSException {
- IContainer parent = resource.getParent();
- if (parent != null && parent.isPhantom()) {
- // Look for the sync info in the workspace synchronizer
- try {
- beginOperation(null);
- Map map = getPhantomResourceSyncInfoMap(parent);
- map.put(resource.getName(), info);
- getWorkspaceSynchronizer().setSyncInfo(RESOURCE_SYNC_KEY, parent, getBytes(map));
- changedResources.add(resource);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- endOperation(null);
- }
- } else {
- super.setResourceSync(resource, info);
- }
- }
-
- /**
- * Deletes the resource sync info for the specified resource, if it exists.
- *
- * @param resource the resource
- * @see #getResourceSync, #setResourceSync
- */
- public void deleteResourceSync(IResource resource) throws CVSException {
- IContainer parent = resource.getParent();
- if (parent != null && parent.isPhantom()) {
- // Look for the sync info in the workspace synchronizer
- try {
- beginOperation(null);
- Map map = getPhantomResourceSyncInfoMap(parent);
- map.remove(resource.getName());
- if (map.isEmpty()) {
- flushEmptyFolder(parent);
- } else {
- getWorkspaceSynchronizer().setSyncInfo(RESOURCE_SYNC_KEY, parent, getBytes(map));
- }
- changedResources.add(resource);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- endOperation(null);
- }
- } else {
- super.deleteResourceSync(resource);
- }
- }
-
- /**
- * Flush the folder sync and resource sync for a phantom folder that has no childen
- * @param folder an empty phantom folder
- */
- private void flushEmptyFolder(IContainer folder) throws CVSException {
- deleteFolderSync(folder);
- deleteResourceSync(folder);
- }
-
- /**
- * Returns the members of this folder which are either phantom folder
- * or file deletions
- *
- * @param folder the container to list
- * @return the array of members
- */
- public IResource[] members(IContainer container) throws CVSException {
- if (container.isPhantom()) {
- Map map = getPhantomResourceSyncInfoMap(container);
- Set childResources = new HashSet();
- for (Iterator it = map.values().iterator(); it.hasNext();) {
- ResourceSyncInfo info = (ResourceSyncInfo) it.next();
- IPath path = new Path(info.getName());
- if(info.isDirectory()) {
- childResources.add(container.getFolder(path));
- } else {
- childResources.add(container.getFile(path));
- }
- }
- return (IResource[])childResources.toArray(new IResource[childResources.size()]);
- } else {
- return super.members(container);
- }
- }
-
- /**
- * Notify the receiver that a folder has been created.
- * Any existing phantom sync info will be moved
- *
- * @param folder the folder that has been created
- */
- public void folderCreated(IFolder folder) throws CVSException {
- FolderSyncInfo folderInfo = getPhantomFolderSyncInfo(folder);
- if (folderInfo != null) {
- if (folder.getFolder(SyncFileWriter.CVS_DIRNAME).exists()) {
- // There is already a CVS subdirectory which indicates that the folder
- // was recreated by an external tool.
- // Therefore, just forget what we had and use the info from disk.
- flushPhantomInfo(folder);
- return;
- }
- try {
- beginOperation(null);
- setFolderSync(folder, folderInfo);
- Map map = getPhantomResourceSyncInfoMap(folder);
- for (Iterator it = map.values().iterator(); it.hasNext();) {
- ResourceSyncInfo info = (ResourceSyncInfo) it.next();
- IPath path = new Path(info.getName());
- IResource childResource;
- if(info.isDirectory()) {
- childResource = folder.getFolder(path);
- } else {
- childResource = folder.getFile(path);
- }
- setResourceSync(childResource, info);
- }
- } finally {
- endOperation(null);
- flushPhantomInfo(folder);
- }
- }
- }
-
- /**
- * Return the cached folder sync info for the given container or null
- * if there is none.
- */
- private FolderSyncInfo getPhantomFolderSyncInfo(IContainer container) throws CVSException {
- try {
- byte[] bytes = getWorkspaceSynchronizer().getSyncInfo(FOLDER_SYNC_KEY, container);
- if (bytes == null) return null;
- return getFolderSyncInfo(bytes);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- private Map getPhantomResourceSyncInfoMap(IContainer container) throws CVSException {
- try {
- byte[] bytes = getWorkspaceSynchronizer().getSyncInfo(RESOURCE_SYNC_KEY, container);
- if (bytes == null) return new HashMap();
- return getResourceSyncInfoMap(bytes);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Flush any info cahced for the folder
- */
- private void flushPhantomInfo(IContainer container) throws CVSException {
- try {
- if (container.isPhantom()) {
- getWorkspaceSynchronizer().flushSyncInfo(FOLDER_SYNC_KEY, container, IResource.DEPTH_ZERO);
- }
- if (container.isPhantom()) {
- getWorkspaceSynchronizer().flushSyncInfo(RESOURCE_SYNC_KEY, container, IResource.DEPTH_ZERO);
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Return the Eclipse Workspace Synchronizer (from org.eclipse.core.resources)
- */
- private ISynchronizer getWorkspaceSynchronizer() {
- return ResourcesPlugin.getWorkspace().getSynchronizer();
- }
-
- /**
- * The folder is about to be deleted so move the folder's CVS information
- * to the workspace synchronizer so it will survive the deletion
- */
- public void prepareForDeletion(IContainer container) throws CVSException {
- try {
- beginOperation(null);
- if (container.getType() == IResource.PROJECT) {
- getWorkspaceSynchronizer().flushSyncInfo(FOLDER_SYNC_KEY, container, IResource.DEPTH_INFINITE);
- getWorkspaceSynchronizer().flushSyncInfo(RESOURCE_SYNC_KEY, container, IResource.DEPTH_INFINITE);
- } else {
- FolderSyncInfo info = getFolderSync(container);
- if (info == null) return;
- getWorkspaceSynchronizer().setSyncInfo(FOLDER_SYNC_KEY, container, getBytes(info));
- getWorkspaceSynchronizer().setSyncInfo(RESOURCE_SYNC_KEY, container, getBytes(getResourceSyncInfosForChildren(container)));
- changedResources.add(container);
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- endOperation(null);
- }
- }
-
- /**
- * Return a map of resource name to ResourceSyncInfo
- *
- * This should only be used on folders that exist in the workspace
- */
- private Map getResourceSyncInfosForChildren(IContainer parent) throws CVSException {
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(parent);
- ICVSResource[] files = folder.members(ICVSFolder.FILE_MEMBERS | ICVSFolder.FOLDER_MEMBERS | ICVSFolder.MANAGED_MEMBERS);
- Map result = new HashMap();
- for (int i = 0; i < files.length; i++) {
- ICVSResource resource = files[i];
- result.put(resource.getName(), resource.getSyncInfo());
- }
- return result;
- }
-
- /**
- * Convert a byte array that was created using getBytes(FolderSyncInfo)
- * into a FolderSyncInfo
- */
- private static FolderSyncInfo getFolderSyncInfo(byte[] bytes) throws CVSException {
- ByteArrayInputStream in = new ByteArrayInputStream(bytes);
- DataInputStream dis = new DataInputStream(in);
- String root;
- String repository;
- CVSEntryLineTag tag;
- boolean isStatic;
- try {
- root = dis.readUTF();
- repository = dis.readUTF();
- String tagName = dis.readUTF();
- if (tagName.length() == 0) {
- tag = null;
- } else {
- tag = new CVSEntryLineTag(tagName);
- }
- isStatic = dis.readBoolean();
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- return new FolderSyncInfo(repository, root, tag, isStatic);
- }
-
- /**
- * Convert a FolderSyncInfo into a byte array that can be stored
- * in the workspace synchronizer
- */
- private static byte[] getBytes(FolderSyncInfo info) throws CVSException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- DataOutputStream dos = new DataOutputStream(out);
- try {
- dos.writeUTF(info.getRoot());
- dos.writeUTF(info.getRepository());
- CVSEntryLineTag tag = info.getTag();
- if (tag == null) {
- dos.writeUTF(""); // $NON-NLS-1$
- } else {
- dos.writeUTF(tag.toString());
- }
- dos.writeBoolean(info.getIsStatic());
- dos.close();
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- return out.toByteArray();
- }
-
- /**
- * Convert a Map of ResourceSyncInfo into a byte array that can be stored
- * in the workspace synchronizer
- */
- private static byte[] getBytes(Map infos) throws CVSException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- DataOutputStream dos = new DataOutputStream(out);
- try {
- dos.writeInt(infos.size());
- Iterator iter = infos.values().iterator();
- while (iter.hasNext()) {
- ResourceSyncInfo info = (ResourceSyncInfo)iter.next();
- dos.writeUTF(info.getEntryLine());
- }
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- return out.toByteArray();
- }
-
- /**
- * Convert a byte array that was created using getBytes(Map)
- * into a Map of ResourceSyncInfo
- */
- private static Map getResourceSyncInfoMap(byte[] bytes) throws CVSException {
- ByteArrayInputStream in = new ByteArrayInputStream(bytes);
- DataInputStream dis = new DataInputStream(in);
- Map result = new HashMap();
- try {
- int size = dis.readInt();
- for (int i = 0; i < size; i++) {
- ResourceSyncInfo info = new ResourceSyncInfo(dis.readUTF(), null, null);
- result.put(info.getName(), info);
- }
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- return result;
- }
-
- /**
- * @see EclipseSynchronizer#broadcastResourceStateChanges(IResource[])
- */
- void broadcastResourceStateChanges(IResource[] resources) {
- // Add the changedResources to the list of broadcasted resources
- if (changedResources.size() > 0) {
- ArrayList allResources = new ArrayList();
- allResources.addAll(Arrays.asList(resources));
- allResources.addAll(changedResources);
- resources = (IResource[]) allResources.toArray(new IResource[allResources.size()]);
- changedResources.clear();
- }
- super.broadcastResourceStateChanges(resources);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java
deleted file mode 100644
index 7e5a318bb..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java
+++ /dev/null
@@ -1,247 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.IIgnoreInfo;
-import org.eclipse.team.core.Team;
-import org.eclipse.team.core.TeamPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-import org.eclipse.team.internal.ccvs.core.util.FileNameMatcher;
-import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * Represents handles to CVS resource on the local file system. Synchronization
- * information is taken from the CVS subdirectories.
- *
- * @see LocalFolder
- * @see LocalFile
- */
-abstract class EclipseResource implements ICVSResource {
-
- // The seperator that must be used when creating CVS resource paths. Never use
- // the platform default seperator since it is not compatible with CVS resources.
- protected static final String SEPARATOR = Session.SERVER_SEPARATOR;
- protected static final String CURRENT_LOCAL_FOLDER = Session.CURRENT_LOCAL_FOLDER;
-
- /*
- * The local resource represented by this handle
- */
- IResource resource;
-
- /*
- * Creates a CVS handle to the provided resource
- */
- protected EclipseResource(IResource resource) {
- Assert.isNotNull(resource);
- this.resource = resource;
- }
-
- /*
- * Get the extention of the path of resource relative to the path of root
- *
- * @throws CVSException if root is not a root-folder of resource
- */
- public String getRelativePath(ICVSFolder root) throws CVSException {
- try {
- EclipseResource rootFolder;
- String result;
- rootFolder = (EclipseResource)root;
- result = Util.getRelativePath(rootFolder.getPath(), getPath());
- return result;
- } catch (ClassCastException e) {
- throw new CVSException(Policy.bind("EclipseResource.invalidResourceClass"), e); //$NON-NLS-1$
- }
- }
-
- /*
- * @see ICVSResource#delete()
- */
- public void delete() throws CVSException {
- try {
- resource.delete(false /*force*/, null);
- } catch(CoreException e) {
- throw new CVSException(e.getStatus());
- }
- }
-
- /*
- * @see ICVSResource#exists()
- */
- public boolean exists() {
- return resource.exists();
- }
-
- /*
- * Returns the parent folder of this resource of <code>null</code> if resource
- * the resource.
- *
- * @see ICVSResource#getParent()
- */
- public ICVSFolder getParent() {
- IContainer parent = resource.getParent();
- if (parent==null) {
- return null;
- }
- return new EclipseFolder(parent);
- }
-
- /*
- * @see ICVSResource#getName()
- */
- public String getName() {
- return resource.getName();
- }
-
- /*
- * @see ICVSResource#isIgnored()
- */
- public boolean isIgnored() {
- // a managed resource is never ignored
- if(isManaged() || resource.getType()==IResource.ROOT || resource.getType()==IResource.PROJECT) {
- return false;
- }
-
- // If the resource is a derived resource, it is ignored
- if (resource.isDerived()) {
- return true;
- }
-
- // initialize matcher with global ignores, basic CVS ignore patterns, and ignore patterns
- // from the .cvsignore file.
- FileNameMatcher matcher = new FileNameMatcher(SyncFileWriter.BASIC_IGNORE_PATTERNS);
- String[] cvsIgnorePatterns;;
- try {
- cvsIgnorePatterns = EclipseSynchronizer.getInstance().getIgnored(resource.getParent());
- } catch(CVSException e) {
- cvsIgnorePatterns = null;
- }
- IIgnoreInfo[] ignorePatterns = Team.getAllIgnores();
- for (int i = 0; i < ignorePatterns.length; i++) {
- IIgnoreInfo info = ignorePatterns[i];
- if(info.getEnabled()) {
- matcher.register(info.getPattern(), "true"); //$NON-NLS-1$
- }
- }
- if(cvsIgnorePatterns!=null) {
- for (int i = 0; i < cvsIgnorePatterns.length; i++) {
- matcher.register(cvsIgnorePatterns[i], "true"); //$NON-NLS-1$
- }
- }
-
- // check against all the registered patterns
- boolean ignored = matcher.match(getName());
-
- // check the parent, if the parent is ignored then this resource
- // is ignored also
- if(!ignored) {
- ICVSFolder parent = getParent();
- if(parent==null) return false;
- return parent.isIgnored();
- } else {
- return ignored;
- }
- }
-
- /*
- * @see ICVSResource#setIgnored()
- */
- public void setIgnored() throws CVSException {
- EclipseSynchronizer.getInstance().addIgnored(resource.getParent(), resource.getName());
- }
-
- /*
- * @see ICVSResource#setIgnoredAs(String)
- */
- public void setIgnoredAs(String pattern) throws CVSException {
- EclipseSynchronizer.getInstance().addIgnored(resource.getParent(), pattern);
- }
-
- /*
- * @see ICVSResource#isManaged()
- */
- public boolean isManaged() {
- try {
- return getSyncInfo() != null;
- } catch(CVSException e) {
- return false;
- }
- }
-
- /**
- * Two ManagedResources are equal, if there cvsResources are
- * equal (and that is, if the point to the same file)
- */
- public boolean equals(Object obj) {
-
- if (!(obj instanceof EclipseResource)) {
- return false;
- } else {
- return getPath().equals(((EclipseResource) obj).getPath());
- }
- }
-
- /*
- * @see ICVSResource#getPath()
- */
- public String getPath() {
- return resource.getFullPath().toString();
- }
-
- /*
- * @see ICVSResource#isFolder()
- */
- public boolean isFolder() {
- return false;
- }
-
- /*
- * @see ICVSResource#getSyncInfo()
- */
- public ResourceSyncInfo getSyncInfo() throws CVSException {
- return EclipseSynchronizer.getInstance().getResourceSync(resource);
- }
-
- /*
- * @see ICVSResource#setSyncInfo(ResourceSyncInfo)
- */
- public void setSyncInfo(ResourceSyncInfo info) throws CVSException {
- if (getParent().isCVSFolder()) {
- EclipseSynchronizer.getInstance().setResourceSync(resource, info);
- }
- }
-
- /*
- * Implement the hashcode on the underlying strings, like it is done in the equals.
- */
- public int hashCode() {
- return getPath().hashCode();
- }
-
- /*
- * Give the pathname back
- */
- public String toString() {
- return getPath();
- }
-
- /*
- * @see ICVSResource#unmanage()
- */
- public void unmanage(IProgressMonitor monitor) throws CVSException {
- EclipseSynchronizer.getInstance().deleteResourceSync(resource);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java
deleted file mode 100644
index 457df03be..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java
+++ /dev/null
@@ -1,820 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.Status;
-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.Policy;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ReentrantLock;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter;
-
-/**
- * A synchronizer is responsible for managing synchronization information for local
- * CVS resources.
- *
- * @see ResourceSyncInfo
- * @see FolderSyncInfo
- */
-public class EclipseSynchronizer {
- // the resources plugin synchronizer is used to cache and possibly persist. These
- // are keys for storing the sync info.
- private static final QualifiedName FOLDER_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-sync"); //$NON-NLS-1$
- private static final QualifiedName RESOURCE_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "resource-sync"); //$NON-NLS-1$
- private static final QualifiedName IGNORE_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-ignore"); //$NON-NLS-1$
-
- private static final String[] NULL_IGNORES = new String[0];
- private static final FolderSyncInfo NULL_FOLDER_SYNC_INFO = new FolderSyncInfo("", "", null, false); //$NON-NLS-1$ //$NON-NLS-2$
-
- private static final IStatus STATUS_OK = new Status(IStatus.OK, CVSProviderPlugin.ID, 0, Policy.bind("ok"), null); //$NON-NLS-1$
-
- // the cvs eclipse synchronizer is a singleton
- private static EclipseSynchronizer instance;
-
- // track resources that have changed in a given operation
- private ReentrantLock lock = new ReentrantLock();
-
- private Set changedResources = new HashSet();
- private Set changedFolders = new HashSet();
-
- /*
- * Package private contructor to allow specialized subclass for handling folder deletions
- */
- EclipseSynchronizer() {
- }
-
- /**
- * Returns the singleton instance of the synchronizer.
- */
- public static EclipseSynchronizer getInstance() {
- if(instance==null) {
- instance = new EclipsePhantomSynchronizer();
- }
- return instance;
- }
-
- /**
- * Sets the folder sync info for the specified folder.
- * The folder must exist and must not be the workspace root.
- *
- * @param folder the folder
- * @param info the folder sync info, must not be null
- * @see #getFolderSync, #deleteFolderSync
- */
- public void setFolderSync(IContainer folder, FolderSyncInfo info) throws CVSException {
- Assert.isNotNull(info); // enforce the use of deleteFolderSync
- if (folder.getType() == IResource.ROOT || ! folder.exists()) {
- throw new CVSException(IStatus.ERROR, CVSException.UNABLE,
- Policy.bind("EclipseSynchronizer.ErrorSettingFolderSync", folder.getFullPath().toString())); //$NON-NLS-1$
- }
- try {
- beginOperation(null);
- // set folder sync and notify
- setCachedFolderSync(folder, info);
- changedFolders.add(folder);
- } finally {
- endOperation(null);
- }
- }
-
- /**
- * Gets the folder sync info for the specified folder.
- *
- * @param folder the folder
- * @return the folder sync info associated with the folder, or null if none.
- * @see #setFolderSync, #deleteFolderSync
- */
- public FolderSyncInfo getFolderSync(IContainer folder) throws CVSException {
- if (folder.getType() == IResource.ROOT || ! folder.exists()) return null;
- try {
- beginOperation(null);
- // cache folder sync and return it
- return cacheFolderSync(folder);
- } finally {
- endOperation(null);
- }
- }
-
- /**
- * Deletes the folder sync for the specified folder and the resource sync
- * for all of its children. Does not recurse.
- *
- * @param folder the folder
- * @see #getFolderSync, #setFolderSync
- */
- public void deleteFolderSync(IContainer folder) throws CVSException {
- if (folder.getType() == IResource.ROOT || ! folder.exists()) return;
- try {
- beginOperation(null);
- // delete folder sync
- setCachedFolderSync(folder, null);
- changedFolders.add(folder);
- // iterate over all children with sync info and prepare notifications
- cacheResourceSyncForChildren(folder);
- Collection infos = getCachedResourceSyncForChildren(folder);
- for (Iterator it = infos.iterator(); it.hasNext();) {
- ResourceSyncInfo info = (ResourceSyncInfo) it.next();
- IPath path = new Path(info.getName());
- if(info.isDirectory()) {
- changedResources.add(folder.getFolder(path));
- } else {
- changedResources.add(folder.getFile(path));
- }
- }
- // delete resource sync for all children
- deleteCachedResourceSyncForChildren(folder);
- } finally {
- endOperation(null);
- }
- }
-
- /**
- * Sets the resource sync info for the specified resource.
- * The parent folder must exist and must not be the workspace root.
- *
- * @param resource the resource
- * @param info the resource sync info, must not be null
- * @see #getResourceSync, #deleteResourceSync
- */
- public void setResourceSync(IResource resource, ResourceSyncInfo info) throws CVSException {
- Assert.isNotNull(info); // enforce the use of deleteResourceSync
- IContainer parent = resource.getParent();
- if (parent == null || ! parent.exists() || parent.getType() == IResource.ROOT) {
- throw new CVSException(IStatus.ERROR, CVSException.UNABLE,
- Policy.bind("EclipseSynchronizer.ErrorSettingResourceSync", resource.getFullPath().toString())); //$NON-NLS-1$
- }
- try {
- beginOperation(null);
- // cache resource sync for siblings, set for self, then notify
- cacheResourceSyncForChildren(parent);
- setCachedResourceSync(resource, info);
- changedResources.add(resource);
- } finally {
- endOperation(null);
- }
- }
-
- /**
- * Gets the resource sync info for the specified folder.
- *
- * @param resource the resource
- * @return the resource sync info associated with the resource, or null if none.
- * @see #setResourceSync, #deleteResourceSync
- */
- public ResourceSyncInfo getResourceSync(IResource resource) throws CVSException {
- IContainer parent = resource.getParent();
- if (parent == null || ! parent.exists() || parent.getType() == IResource.ROOT) return null;
- try {
- beginOperation(null);
- // cache resource sync for siblings, then return for self
- cacheResourceSyncForChildren(parent);
- return getCachedResourceSync(resource);
- } finally {
- endOperation(null);
- }
- }
-
- /**
- * Deletes the resource sync info for the specified resource, if it exists.
- *
- * @param resource the resource
- * @see #getResourceSync, #setResourceSync
- */
- public void deleteResourceSync(IResource resource) throws CVSException {
- IContainer parent = resource.getParent();
- if (parent == null || ! parent.exists() || parent.getType() == IResource.ROOT) return;
- try {
- beginOperation(null);
- // cache resource sync for siblings, delete for self, then notify
- cacheResourceSyncForChildren(resource.getParent());
- if (getCachedResourceSync(resource) != null) { // avoid redundant notifications
- setCachedResourceSync(resource, null);
- changedResources.add(resource);
- }
- } finally {
- endOperation(null);
- }
- }
-
- /**
- * Gets the array of ignore patterns for the specified folder.
- *
- * @param folder the folder
- * @return the patterns, or an empty array if none
- * @see #addIgnored
- */
- public String[] getIgnored(IContainer folder) throws CVSException {
- if (folder.getType() == IResource.ROOT || ! folder.exists()) return NULL_IGNORES;
- try {
- beginOperation(null);
- return cacheFolderIgnores(folder);
- } finally {
- endOperation(null);
- }
- }
-
- /**
- * Adds a pattern to the set of ignores for the specified folder.
- *
- * @param folder the folder
- * @param pattern the pattern
- */
- public void addIgnored(IContainer folder, String pattern) throws CVSException {
- if (folder.getType() == IResource.ROOT || ! folder.exists()) {
- throw new CVSException(IStatus.ERROR, CVSException.UNABLE,
- Policy.bind("EclipseSynchronizer.ErrorSettingIgnorePattern", folder.getFullPath().toString())); //$NON-NLS-1$
- }
- try {
- beginOperation(null);
- String[] ignores = cacheFolderIgnores(folder);
- if (ignores != null) {
- String[] oldIgnores = ignores;
- ignores = new String[oldIgnores.length + 1];
- System.arraycopy(oldIgnores, 0, ignores, 0, oldIgnores.length);
- ignores[oldIgnores.length] = pattern;
- } else {
- ignores = new String[] { pattern };
- }
- setCachedFolderIgnores(folder, ignores);
- SyncFileWriter.addCVSIgnoreEntries(folder, ignores);
- // broadcast changes to unmanaged children - they are the only candidates for being ignored
- List possibleIgnores = new ArrayList();
- accumulateNonManagedChildren(folder, possibleIgnores);
- CVSProviderPlugin.broadcastResourceStateChanges((IResource[])possibleIgnores.toArray(new IResource[possibleIgnores.size()]));
- } finally {
- endOperation(null);
- }
- }
-
- /**
- * Returns the members of this folder including deleted resources with sync info,
- * but excluding special resources such as CVS subdirectories.
- *
- * @param folder the container to list
- * @return the array of members
- */
- public IResource[] members(IContainer folder) throws CVSException {
- if (! folder.exists()) return new IResource[0];
- try {
- beginOperation(null);
- if (folder.getType() == IResource.ROOT) return folder.members();
- cacheResourceSyncForChildren(folder);
- Collection infos = getCachedResourceSyncForChildren(folder);
- // add all children with or without sync info
- Set childResources = new HashSet();
- for (Iterator it = infos.iterator(); it.hasNext();) {
- ResourceSyncInfo info = (ResourceSyncInfo) it.next();
- IPath path = new Path(info.getName());
- if(info.isDirectory()) {
- childResources.add(folder.getFolder(path));
- } else {
- childResources.add(folder.getFile(path));
- }
- }
- childResources.addAll(Arrays.asList(folder.members()));
- return (IResource[])childResources.toArray(new IResource[childResources.size()]);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- endOperation(null);
- }
- }
-
- /**
- * Begins a batch of operations.
- *
- * @param monitor the progress monitor, may be null
- */
- public void beginOperation(IProgressMonitor monitor) throws CVSException {
- lock.acquire();
-
- if (lock.getNestingCount() == 1) {
- prepareCache(monitor);
- }
- }
-
- /**
- * Ends a batch of operations. Pending changes are committed only when
- * the number of calls to endOperation() balances those to beginOperation().
- * <p>
- * Progress cancellation is ignored while writting the cache to disk. This
- * is to ensure cache to disk consistency.
- * </p>
- *
- * @param monitor the progress monitor, may be null
- * @exception CVSException with a status with code <code>COMMITTING_SYNC_INFO_FAILED</code>
- * if all the CVS sync information could not be written to disk.
- */
- public void endOperation(IProgressMonitor monitor) throws CVSException {
- try {
- IStatus status = STATUS_OK;
- if (lock.getNestingCount() == 1) {
- status = commitCache(monitor);
- }
- if (status != STATUS_OK) {
- throw new CVSException(status);
- }
- } finally {
- lock.release();
- }
- }
-
- /**
- * Flushes unwritten sync information to disk.
- * <p>
- * Recursively commits unwritten sync information for all resources
- * below the root, and optionally purges the cached data from memory
- * so that the next time it is accessed it will be retrieved from disk.
- * May flush more sync information than strictly needed, but never less.
- * </p>
- * <p>
- * Will throw a CVS Exception with a status with code = CVSStatus.DELETION_FAILED
- * if the flush could not perform CVS folder deletions. In this case, all other
- * aspects of the operation succeeded.
- * </p>
- *
- * @param root the root of the subtree to flush
- * @param purgeCache if true, purges the cache from memory as well
- * @param deep purge sync from child folders
- * @param monitor the progress monitor, may be null
- */
- public void flush(IContainer root, boolean purgeCache, boolean deep, IProgressMonitor monitor) throws CVSException {
- // flush unwritten sync info to disk
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 10);
- try {
- beginOperation(Policy.subMonitorFor(monitor, 1));
-
- IStatus status = commitCache(Policy.subMonitorFor(monitor, 7));
-
- // purge from memory too if we were asked to
- if (purgeCache) purgeCache(root, deep);
-
- // prepare for the operation again if we cut the last one short
- prepareCache(Policy.subMonitorFor(monitor, 1));
-
- if (status != STATUS_OK) {
- throw new CVSException(status);
- }
- } finally {
- endOperation(Policy.subMonitorFor(monitor, 1));
- monitor.done();
- }
- }
-
- /**
- * Called to notify the synchronizer that meta files have changed on disk, outside
- * of the workbench. The cache will be flushed for this folder and it's immediate
- * children and appropriate state change events are broadcasts to state change
- * listeners.
- */
- public void syncFilesChanged(IContainer[] roots) throws CVSException {
- try {
- for (int i = 0; i < roots.length; i++) {
- IContainer root = roots[i];
- flush(root, true, false /*don't flush children*/, null);
- List changedPeers = new ArrayList();
- changedPeers.add(root);
- changedPeers.addAll(Arrays.asList(root.members()));
- CVSProviderPlugin.broadcastResourceStateChanges((IResource[]) changedPeers.toArray(new IResource[changedPeers.size()]));
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * The folder is about to be deleted (including its CVS subfolder).
- * Take any appropriate action to remember the CVS information.
- */
- public void prepareForDeletion(IContainer container) throws CVSException {
- }
-
- /**
- * Signal to the synchronizer that a folder has been created
- *
- * @param folder the folder to be created
- */
- public void folderCreated(IFolder folder) throws CVSException {
- }
-
- /**
- * Prepares the cache for a series of operations.
- *
- * @param monitor the progress monitor, may be null
- */
- private void prepareCache(IProgressMonitor monitor) throws CVSException {
- }
-
- /**
- * Commits the cache after a series of operations.
- *
- * Will return STATUS_OK unless there were problems writting sync
- * information to disk. If an error occurs a multistatus is returned
- * with the list of reasons for the failures. Failures are recovered,
- * and all changed resources are given a chance to be written to disk.
- *
- * @param monitor the progress monitor, may be null
- */
- private IStatus commitCache(IProgressMonitor monitor) {
- if (changedFolders.isEmpty() && changedResources.isEmpty()) {
- broadcastResourceStateChanges(new IResource[0]);
- return STATUS_OK;
- }
- List errors = new ArrayList();
- try {
- /*** prepare operation ***/
- // find parents of changed resources
- Set dirtyParents = new HashSet();
- for(Iterator it = changedResources.iterator(); it.hasNext();) {
- IResource resource = (IResource) it.next();
- IContainer folder = resource.getParent();
- dirtyParents.add(folder);
- }
-
- monitor = Policy.monitorFor(monitor);
- int numDirty = dirtyParents.size();
- int numResources = changedFolders.size() + numDirty;
- monitor.beginTask(null, numResources);
- if(monitor.isCanceled()) {
- monitor.subTask(Policy.bind("EclipseSynchronizer.UpdatingSyncEndOperationCancelled")); //$NON-NLS-1$
- } else {
- monitor.subTask(Policy.bind("EclipseSynchronizer.UpdatingSyncEndOperation")); //$NON-NLS-1$
- }
-
- /*** write sync info to disk ***/
- // folder sync info changes
- for(Iterator it = changedFolders.iterator(); it.hasNext();) {
- IContainer folder = (IContainer) it.next();
- if (folder.exists() && folder.getType() != IResource.ROOT) {
- try {
- FolderSyncInfo info = getCachedFolderSync(folder);
- if (info == null) {
- // deleted folder sync info since we loaded it
- SyncFileWriter.deleteFolderSync(folder);
- dirtyParents.remove(folder);
- } else {
- // modified or created new folder sync info since we loaded it
- SyncFileWriter.writeFolderSync(folder, info);
- }
- } catch(CVSException e) {
- try {
- purgeCache(folder, true /* deep */);
- } catch(CVSException pe) {
- errors.add(pe.getStatus());
- }
- errors.add(e.getStatus());
- }
- }
- monitor.worked(1);
- }
-
- // update progress for parents we will skip because they were deleted
- monitor.worked(numDirty - dirtyParents.size());
-
- // resource sync info changes
- for (Iterator it = dirtyParents.iterator(); it.hasNext();) {
- IContainer folder = (IContainer) it.next();
- if (folder.exists() && folder.getType() != IResource.ROOT) {
- // write sync info for all children in one go
- try {
- Collection infos = getCachedResourceSyncForChildren(folder);
- SyncFileWriter.writeAllResourceSync(folder,
- (ResourceSyncInfo[]) infos.toArray(new ResourceSyncInfo[infos.size()]));
- } catch(CVSException e) {
- try {
- purgeCache(folder, false /* depth 1 */);
- } catch(CVSException pe) {
- errors.add(pe.getStatus());
- }
- errors.add(e.getStatus());
- }
- }
- monitor.worked(1);
- }
-
- /*** broadcast events ***/
- changedResources.addAll(changedFolders);
- IResource[] resources = (IResource[]) changedResources.toArray(
- new IResource[changedResources.size()]);
- broadcastResourceStateChanges(resources);
- changedResources.clear();
- changedFolders.clear();
- if ( ! errors.isEmpty()) {
- MultiStatus status = new MultiStatus(CVSProviderPlugin.ID,
- CVSStatus.COMMITTING_SYNC_INFO_FAILED,
- Policy.bind("EclipseSynchronizer.ErrorCommitting"), //$NON-NLS-1$
- null);
- for (int i = 0; i < errors.size(); i++) {
- status.merge((IStatus)errors.get(i));
- }
- return status;
- }
- return STATUS_OK;
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Broadcasts the resource state changes for the given resources to CVS Provider Plugin
- */
- void broadcastResourceStateChanges(IResource[] resources) {
- if (resources.length > 0) {
- CVSProviderPlugin.broadcastResourceStateChanges(resources);
- }
- }
-
- /**
- * Purges the cache recursively for all resources beneath the container.
- * There must not be any pending uncommitted changes.
- */
- private static void purgeCache(IContainer container, boolean deep) throws CVSException {
- if (! container.exists()) return;
- try {
- if (container.getType() != IResource.ROOT) {
- container.setSessionProperty(RESOURCE_SYNC_KEY, null);
- container.setSessionProperty(IGNORE_SYNC_KEY, null);
- container.setSessionProperty(FOLDER_SYNC_KEY, null);
- }
- if(deep) {
- IResource[] members = container.members();
- for (int i = 0; i < members.length; i++) {
- IResource resource = members[i];
- if (resource.getType() != IResource.FILE) {
- purgeCache((IContainer) resource, deep);
- }
- }
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * If not already cached, loads and caches the resource sync for the children of the container.
- * Folder must exist and must not be the workspace root.
- *
- * @param container the container
- */
- private static void cacheResourceSyncForChildren(IContainer container) throws CVSException {
- try {
- // don't try to load if the information is already cached
- HashMap children = (HashMap)container.getSessionProperty(RESOURCE_SYNC_KEY);
- if (children == null) {
- // load the sync info from disk
- ResourceSyncInfo[] infos = SyncFileWriter.readAllResourceSync(container);
- if (infos != null) {
- children = new HashMap(infos.length);
- for (int i = 0; i < infos.length; i++) {
- ResourceSyncInfo syncInfo = infos[i];
- children.put(syncInfo.getName(), syncInfo);
- }
- } else {
- children = new HashMap(0);
- }
- container.setSessionProperty(RESOURCE_SYNC_KEY, children);
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Returns the resource sync info for the resource; null if none.
- * Parent must exist and must not be the workspace root.
- * The resource sync info for the children of the parent container MUST ALREADY BE CACHED.
- *
- * @param resource the resource
- * @return the resource sync info for the resource, or null
- * @see #cacheResourceSyncForChildren
- */
- private static ResourceSyncInfo getCachedResourceSync(IResource resource) throws CVSException {
- try {
- IContainer parent = resource.getParent();
- HashMap children = (HashMap)resource.getParent().getSessionProperty(RESOURCE_SYNC_KEY);
- Assert.isNotNull(children);
- return (ResourceSyncInfo) children.get(resource.getName());
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Sets the resource sync info for the resource; if null, deletes it.
- * Parent must exist and must not be the workspace root.
- * The resource sync info for the children of the parent container MUST ALREADY BE CACHED.
- *
- * @param resource the resource
- * @param info the new resource sync info
- * @see #cacheResourceSyncForChildren
- */
- private static void setCachedResourceSync(IResource resource, ResourceSyncInfo info) throws CVSException {
- try {
- IContainer parent = resource.getParent();
- HashMap children = (HashMap)parent.getSessionProperty(RESOURCE_SYNC_KEY);
- Assert.isNotNull(children);
- if (info == null) {
- children.remove(resource.getName());
- } else {
- children.put(resource.getName(), info);
- }
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Returns the resource sync info for all children of the container.
- * Container must exist and must not be the workspace root.
- * The resource sync info for the children of the container MUST ALREADY BE CACHED.
- *
- * @param container the container
- * @return a collection of the resource sync info's for all children
- * @see #cacheResourceSyncForChildren
- */
- private static Collection /* of ResourceSyncInfo */ getCachedResourceSyncForChildren(IContainer container) throws CVSException {
- try {
- HashMap children = (HashMap)container.getSessionProperty(RESOURCE_SYNC_KEY);
- Assert.isNotNull(children);
- return children.values();
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Deletes the resource sync info for all children of the container.
- * Container must exist and must not be the workspace root.
- * The resource sync info for the children of the container need not have previously been cached.
- *
- * @param container the container
- */
- private static void deleteCachedResourceSyncForChildren(IContainer container) throws CVSException {
- try {
- HashMap children = (HashMap)container.getSessionProperty(RESOURCE_SYNC_KEY);
- if (children != null) {
- children.clear();
- } else {
- children = new HashMap(0);
- container.setSessionProperty(RESOURCE_SYNC_KEY, children);
- }
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * If not already cached, loads and caches the folder sync for the container.
- * Folder must exist and must not be the workspace root.
- *
- * @param container the container
- * @return the folder sync info for the folder, or null if none.
- */
- private static FolderSyncInfo cacheFolderSync(IContainer container) throws CVSException {
- try {
- // don't try to load if the information is already cached
- FolderSyncInfo info = (FolderSyncInfo)container.getSessionProperty(FOLDER_SYNC_KEY);
- if (info == null) {
- // read folder sync info and remember it
- info = SyncFileWriter.readFolderSync(container);
- if (info == null) {
- container.setSessionProperty(FOLDER_SYNC_KEY, NULL_FOLDER_SYNC_INFO);
- } else {
- container.setSessionProperty(FOLDER_SYNC_KEY, info);
- }
- } else if (info == NULL_FOLDER_SYNC_INFO) {
- info = null;
- }
- return info;
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Returns the folder sync info for the container; null if none.
- * Folder must exist and must not be the workspace root.
- * The folder sync info for the container MUST ALREADY BE CACHED.
- *
- * @param container the container
- * @return the folder sync info for the folder, or null if none.
- * @see #cacheFolderSync
- */
- private static FolderSyncInfo getCachedFolderSync(IContainer container) throws CVSException {
- try {
- FolderSyncInfo info = (FolderSyncInfo)container.getSessionProperty(FOLDER_SYNC_KEY);
- Assert.isNotNull(info);
- if (info == NULL_FOLDER_SYNC_INFO) return null;
- return info;
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Sets the folder sync info for the container; if null, deletes it.
- * Folder must exist and must not be the workspace root.
- * The folder sync info for the container need not have previously been cached.
- *
- * @param container the container
- * @param info the new folder sync info
- */
- private static void setCachedFolderSync(IContainer container, FolderSyncInfo info) throws CVSException {
- try {
- if (info == null) info = NULL_FOLDER_SYNC_INFO;
- container.setSessionProperty(FOLDER_SYNC_KEY, info);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * If not already cached, loads and caches the folder ignores sync for the container.
- * Folder must exist and must not be the workspace root.
- *
- * @param container the container
- * @return the folder ignore patterns, or an empty array if none
- */
- private static String[] cacheFolderIgnores(IContainer container) throws CVSException {
- try {
- // don't try to load if the information is already cached
- String[] ignores = (String[])container.getSessionProperty(IGNORE_SYNC_KEY);
- if (ignores == null) {
- // read folder ignores and remember it
- ignores = SyncFileWriter.readCVSIgnoreEntries(container);
- if (ignores == null) ignores = NULL_IGNORES;
- container.setSessionProperty(IGNORE_SYNC_KEY, ignores);
- }
- return ignores;
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Sets the array of folder ignore patterns for the container, must not be null.
- * Folder must exist and must not be the workspace root.
- *
- * @param container the container
- * @param ignores the array of ignore patterns
- */
- private static void setCachedFolderIgnores(IContainer container, String[] ignores) throws CVSException {
- try {
- container.setSessionProperty(IGNORE_SYNC_KEY, ignores);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Recursively adds to the possibleIgnores list all children of the given
- * folder that can be ignored.
- *
- * @param folder the folder to be searched
- * @param possibleIgnores the list of IResources that can be ignored
- */
- private void accumulateNonManagedChildren(IContainer folder, List possibleIgnores) throws CVSException {
- try {
- cacheResourceSyncForChildren(folder);
- IResource[] children = folder.members();
- for (int i = 0; i < children.length; i++) {
- IResource child = children[i];
- if(getCachedResourceSync(child)==null) {
- possibleIgnores.add(child);
- }
- if(child.getType()!=IResource.FILE) {
- accumulateNonManagedChildren((IContainer)child, possibleIgnores);
- }
- }
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-} \ No newline at end of file
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
deleted file mode 100644
index da91c272d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
+++ /dev/null
@@ -1,509 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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.resources;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteResource;
-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.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.ILogEntry;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption;
-import org.eclipse.team.internal.ccvs.core.client.listeners.LogListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * This class provides the implementation of ICVSRemoteFile and IManagedFile for
- * use by the repository and sync view.
- */
-public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
-
- // Contents will be cached to disk when this thrshold is exceeded
- private static final int CACHING_THRESHOLD = 32768;
-
- // buffer for file contents received from the server
- private byte[] contents;
- // cach the log entry for the remote file
- private ILogEntry entry;
-
- /**
- * Static method which creates a file as a single child of its parent.
- * This should only be used when one is only interested in the file alone.
- *
- * The returned RemoteFile represents the base of the local resource.
- * If the local resource does not have a base, then null is returned
- * even if the resource does exists remotely (e.g. created by another party).
- */
- public static RemoteFile getBase(RemoteFolder parent, ICVSFile managed) throws CVSException {
- ResourceSyncInfo info = managed.getSyncInfo();
- if ((info == null) || info.isAdded()) {
- // Either the file is unmanaged or has just been added (i.e. doesn't necessarily have a remote)
- return null;
- }
- RemoteFile file = new RemoteFile(parent, managed.getSyncInfo());
- parent.setChildren(new ICVSRemoteResource[] {file});
- return file;
- }
-
- /**
- * Constructor for RemoteFile that should be used when nothing is know about the
- * file ahead of time.
- */
- // XXX do we need the first two constructors?
- public RemoteFile(RemoteFolder parent, int workspaceSyncState, String name, CVSTag tag) {
- this(parent, workspaceSyncState, name, "", tag); //$NON-NLS-1$
- MutableResourceSyncInfo newInfo = info.cloneMutable();
- newInfo.setAdded();
- }
-
- public RemoteFile(RemoteFolder parent, int workspaceSyncState, String name, String revision, CVSTag tag) {
- this(parent, workspaceSyncState, null);
- MutableResourceSyncInfo newInfo = new MutableResourceSyncInfo(name, revision);
- newInfo.setKeywordMode(Command.KSUBST_TEXT_EXPAND);
- newInfo.setTag(tag);
- info = newInfo;
- }
-
- public RemoteFile(RemoteFolder parent, ResourceSyncInfo info) {
- this(parent, Update.STATE_NONE, info);
- }
-
- public RemoteFile(RemoteFolder parent, int workspaceSyncState, ResourceSyncInfo newInfo) {
- this.parent = parent;
- info = newInfo;
- setWorkspaceSyncState(workspaceSyncState);
- }
-
- /**
- * @see ICVSResource#accept(IManagedVisitor)
- */
- public void accept(ICVSResourceVisitor visitor) throws CVSException {
- visitor.visitFile(this);
- }
-
- /**
- * @see ICVSRemoteFile#getContents()
- */
- public InputStream getContents(IProgressMonitor monitor) throws CVSException {
- if (contents == null) {
- // First, check to see if there's a cached contents for the file
- InputStream cached = getCachedContents();
- if (cached != null) {
- return cached;
- }
-
- // We need to fetch the contents from the server
- monitor.beginTask(Policy.bind("RemoteFile.getContents"), 100);//$NON-NLS-1$
- Session.run(getRepository(), parent, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- IStatus status = Command.UPDATE.execute(
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] {
- Update.makeTagOption(new CVSTag(info.getRevision(), CVSTag.VERSION)),
- Update.IGNORE_LOCAL_CHANGES },
- new ICVSResource[] { RemoteFile.this },
- null,
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- }
- }, Policy.subMonitorFor(monitor, 100));
-
- // If the update succeeded but no contents were retreived from the server
- // than we can assume that the remote file has no contents.
- if (contents == null) {
- // The above is true unless there is a cache file
- cached = getCachedContents();
- if (cached != null) {
- return cached;
- } else {
- contents = new byte[0];
- }
- }
- }
- return new ByteArrayInputStream(contents);
- }
-
- /*
- * @see ICVSRemoteFile#getLogEntry(IProgressMonitor)
- */
- public ILogEntry getLogEntry(IProgressMonitor monitor) throws CVSException {
- if (entry == null) {
- Session.run(getRepository(), parent, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100); //$NON-NLS-1$
- try {
- final List entries = new ArrayList();
- IStatus status = Command.LOG.execute(
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] {
- Command.LOG.makeRevisionOption(info.getRevision())},
- new ICVSResource[] { RemoteFile.this },
- new LogListener(RemoteFile.this, entries),
- Policy.subMonitorFor(monitor, 100));
- if (entries.size() == 1) {
- entry = (ILogEntry)entries.get(0);
- }
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- monitor.done();
- }
- }
- }, monitor);
- }
- return entry;
- }
-
- /**
- * @see ICVSRemoteFile#getLogEntries()
- */
- public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws CVSException {
- final List entries = new ArrayList();
- Session.run(getRepository(), parent, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100); //$NON-NLS-1$
- QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
- try {
- CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
- IStatus status = Command.LOG.execute(Command.NO_GLOBAL_OPTIONS, Command.NO_LOCAL_OPTIONS,
- new ICVSResource[] { RemoteFile.this }, new LogListener(RemoteFile.this, entries),
- Policy.subMonitorFor(monitor, 100));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- CVSProviderPlugin.getPlugin().setQuietness(quietness);
- monitor.done();
- }
- }
- }, monitor);
- return (ILogEntry[])entries.toArray(new ILogEntry[entries.size()]);
- }
-
- /**
- * @see ICVSRemoteFile#getRevision()
- */
- public String getRevision() {
- return info.getRevision();
- }
-
- /*
- * Get a different revision of the remote file.
- *
- * We must also create a new parent since the child is accessed through the parent from within CVS commands.
- * Therefore, we need a new parent so that we can fecth the contents of the remote file revision
- */
- public RemoteFile toRevision(String revision) {
- RemoteFolder newParent = new RemoteFolder(null, parent.getRepository(), new Path(parent.getRepositoryRelativePath()), parent.getTag());
- RemoteFile file = new RemoteFile(newParent, getWorkspaceSyncState(), getName(), revision, CVSTag.DEFAULT);
- newParent.setChildren(new ICVSRemoteResource[] {file});
- return file;
- }
-
- /**
- * @see ICVSFile#getSize()
- */
- public long getSize() {
- if (contents == null) {
- try {
- File ioFile = getCacheFile();
- if (ioFile.exists()) {
- return ioFile.length();
- }
- } catch (IOException e) {
- // Try to purge the cache and continue
- try {
- clearCachedContents();
- } catch (IOException e2) {
- }
- CVSProviderPlugin.log(CVSException.wrapException(e).getStatus());
- }
- }
- return contents == null ? 0 : contents.length;
- }
-
- /**
- * @see ICVSFile#getSyncInfo()
- */
- public ResourceSyncInfo getSyncInfo() {
- return info;
- }
-
- /**
- * @see ICVSResource#getRemoteLocation(ICVSFolder)
- */
- public String getRemoteLocation(ICVSFolder stopSearching) throws CVSException {
- return parent.getRemoteLocation(stopSearching) + Session.SERVER_SEPARATOR + getName();
- }
-
- /**
- * Get the remote path for the receiver relative to the repository location path
- */
- public String getRepositoryRelativePath() {
- String parentPath = parent.getRepositoryRelativePath();
- return parentPath + Session.SERVER_SEPARATOR + getName();
- }
-
- /**
- * Return the server root directory for the repository
- */
- public ICVSRepositoryLocation getRepository() {
- return parent.getRepository();
- }
-
- /**
- * @see IManagedFile#setFileInfo(FileProperties)
- */
- public void setSyncInfo(ResourceSyncInfo fileInfo) {
- info = fileInfo;
- }
-
- /**
- * Set the revision for this remote file.
- *
- * @param revision to associated with this remote file
- */
- public void setRevision(String revision) {
- MutableResourceSyncInfo newInfo = getSyncInfo().cloneMutable();
- newInfo.setRevision(revision);
- info = newInfo;
- }
-
- public InputStream getContents() throws CVSException {
- if (contents == null) {
- // Check for cached contents for the file
- InputStream cached = getCachedContents();
- if (cached != null) {
- return cached;
- }
- }
- return new ByteArrayInputStream(contents == null ? new byte[0] : contents);
- }
-
- public void setContents(InputStream stream, int responseType, boolean keepLocalHistory, IProgressMonitor monitor) throws CVSException {
- try {
- try {
- byte[] buffer = new byte[1024];
- ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
- OutputStream out = byteStream;
- int read;
- try {
- try {
- while ((read = stream.read(buffer)) >= 0) {
- Policy.checkCanceled(monitor);
- out.write(buffer, 0, read);
- // Detect when the file is getting too big to keep in memory
- // and switch to a caching strategy for the contents of the file
- if (out == byteStream && byteStream.size() > CACHING_THRESHOLD) {
- // Switch streams
- byteStream.close();
- out = switchToCacheOutputStream(byteStream);
- // Continue looping until the whole file is read
- }
- }
- } finally {
- out.close();
- }
- } catch (IOException e) {
- // Make sure we don't leave the cache file around as it may not have the right contents
- if (byteStream != out) {
- clearCachedContents();
- }
- throw e;
- }
-
- // Set the contents if we didn't cache them to disk
- if (out == byteStream) {
- contents = byteStream.toByteArray();
- } else {
- contents = null;
- }
- } finally {
- stream.close();
- }
- } catch(IOException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /*
- * @see ICVSFile#setReadOnly(boolean)
- */
- public void setReadOnly(boolean readOnly) throws CVSException {
- }
-
- /*
- * @see ICVSFile#isReadOnly()
- */
- public boolean isReadOnly() throws CVSException {
- return true;
- }
-
- /*
- * @see ICVSFile#getTimeStamp()
- */
- public Date getTimeStamp() {
- return info.getTimeStamp();
- }
-
- /*
- * @see ICVSFile#setTimeStamp(Date)
- */
- public void setTimeStamp(Date date) throws CVSException {
- }
-
- public boolean isModified() throws CVSException {
- // it is safe to always consider a remote file handle as modified. This will cause any
- // CVS command to fetch new contents from the server.
- return true;
- }
-
- /**
- * @see IManagedFile#moveTo(IManagedFile)
- */
- public void copyTo(String mFile) throws CVSException, ClassCastException {
- // Do nothing
- }
-
- /*
- * @see IRemoteResource#members(IProgressMonitor)
- */
- public IRemoteResource[] members(IProgressMonitor progress) throws TeamException {
- return new IRemoteResource[0];
- }
-
- /*
- * @see IRemoteResource#isContainer()
- */
- public boolean isContainer() {
- return false;
- }
-
- /*
- * @see ICVSResource#isFolder()
- */
- public boolean isFolder() {
- return false;
- }
-
- public boolean updateRevision(CVSTag tag, IProgressMonitor monitor) throws CVSException {
- return parent.updateRevision(this, tag, monitor);
- }
-
- public boolean equals(Object target) {
- if (this == target)
- return true;
- if (!(target instanceof RemoteFile))
- return false;
- RemoteFile remote = (RemoteFile) target;
- return super.equals(target) && remote.getRevision().equals(getRevision());
- }
-
- /*
- * Return the cache relative path for the receiver as
- * host/cvs/root/module/path/.#filename revision
- */
- private String getCacheRelativePath() {
- ICVSRepositoryLocation location = getRepository();
- IPath path = new Path(location.getHost());
- path = path.append(location.getRootDirectory());
- path = path.append(parent.getRepositoryRelativePath());
- path = path.append(getName() + ' ' + getRevision());
- return path.toString();
- }
-
- private File getCacheFile() throws IOException {
- return CVSProviderPlugin.getPlugin().getCacheFileFor(getCacheRelativePath());
- }
-
- private void clearCachedContents() throws IOException {
- try {
- File ioFile = getCacheFile();
- if (ioFile.exists()) {
- ioFile.delete();
- }
- } catch (IOException e) {
- CVSProviderPlugin.log(CVSException.wrapException(e).getStatus());
- }
- }
-
- private InputStream getCachedContents() throws CVSException {
- try {
- try {
- File ioFile = getCacheFile();
- if (ioFile.exists()) {
- return new BufferedInputStream(new FileInputStream(ioFile));
- }
- } catch (IOException e) {
- // Try to purge the cache and continue
- clearCachedContents();
- throw e;
- }
- } catch (IOException e) {
- // We will end up here if we couldn't read or delete the cache file
- throw new CVSException(new CVSStatus(IStatus.ERROR, 0, Policy.bind("RemoteFile.errorRetrievingFromCache", e.getMessage()), e));//$NON-NLS-1$
- }
- return null;
- }
-
- private OutputStream switchToCacheOutputStream(ByteArrayOutputStream byteStream) throws IOException {
- // Get the cache file and make sure it's parent exists
- File ioFile = getCacheFile();
- if ( ! ioFile.getParentFile().exists()) {
- ioFile.getParentFile().mkdirs();
- }
- // Switch streams
- OutputStream out = new BufferedOutputStream(new FileOutputStream(ioFile));
- // Write what we've read so far
- out.write(byteStream.toByteArray());
- return out;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java
deleted file mode 100644
index 3b17cd2d8..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java
+++ /dev/null
@@ -1,750 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteResource;
-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.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption;
-import org.eclipse.team.internal.ccvs.core.client.listeners.IStatusListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.IUpdateMessageListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.StatusListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.UpdateListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-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.Assert;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * This class provides the implementation of ICVSRemoteFolder
- *
- * The parent of the RemoteFolder represents the folders parent in a local configuration.
- * For instance, the parent may correspond to the remote parent or may be a folder in the
- * same repository that has no physical relationship to the RemoteFolder (resulting from the use
- * of a module definition, for instance). A RemoteFolder may not have a parent, indicating that it is
- * the root of the local configuration it represents.
- *
- * A RemoteFolder has the following:
- * A name in the folder's local configuration
- *
- */
-public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, ICVSFolder {
-
- protected FolderSyncInfo folderInfo;
- private ICVSRemoteResource[] children;
- private ICVSRepositoryLocation repository;
-
- /**
- * Constructor for RemoteFolder.
- */
- public RemoteFolder(RemoteFolder parent, ICVSRepositoryLocation repository, IPath repositoryRelativePath, CVSTag tag) {
- this(parent,
- repositoryRelativePath.lastSegment() == null ? "" : repositoryRelativePath.lastSegment(), //$NON-NLS-1$
- repository,
- repositoryRelativePath,
- tag,
- false);
- }
-
- public RemoteFolder(RemoteFolder parent, String name, ICVSRepositoryLocation repository, IPath repositoryRelativePath, CVSTag tag, boolean isStatic) {
- this.info = new ResourceSyncInfo(name);
- this.parent = parent;
- this.folderInfo = new FolderSyncInfo(repositoryRelativePath.toString(), repository.getLocation(), tag, isStatic);
- this.repository = repository;
- }
-
- // Get the file revisions for the given filenames
- protected void updateFileRevisions(final ICVSFile[] files, IProgressMonitor monitor) throws CVSException {
-
- final int[] count = new int[] {0};
-
- // Create a listener for receiving the revision info
- final IStatusListener listener = new IStatusListener() {
- public void fileStatus(ICVSFolder parent, IPath path, String remoteRevision) {
- if (remoteRevision == IStatusListener.FOLDER_REVISION)
- // Ignore any folders
- return;
- try {
- ((RemoteFile)getChild(path.lastSegment())).setRevision(remoteRevision);
- count[0]++;
- } catch (CVSException e) {
- // The count will be off to indicate an error
- }
- }
- };
-
- // Perform a "cvs status..." with a listener
- QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
- try {
- CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
- Session.run(getRepository(), this, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- IStatus status = Command.STATUS.execute(
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- files,
- new StatusListener(listener),
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- }
- }, monitor);
- } finally {
- CVSProviderPlugin.getPlugin().setQuietness(quietness);
- }
-
- if (count[0] != files.length)
- throw new CVSException(Policy.bind("RemoteFolder.errorFetchingRevisions")); //$NON-NLS-1$
- }
-
- /**
- * @see IManagedResource#accept(IManagedVisitor)
- */
- public void accept(ICVSResourceVisitor visitor) throws CVSException {
- visitor.visitFolder(this);
- }
-
- /*
- * @see ICVSRemoteResource#exists(IProgressMonitor)
- */
- public boolean exists(IProgressMonitor monitor) throws TeamException {
- try {
- members(monitor);
- return true;
- } catch (CVSException e) {
- if (e.getStatus().getCode() == CVSStatus.DOES_NOT_EXIST) {
- return false;
- } else {
- throw e;
- }
- }
- }
-
- /*
- * Check whether the given resource is a child of the receiver remotely
- */
- protected boolean exists(ICVSRemoteResource child, IProgressMonitor monitor) throws CVSException {
- return exists(child, getTag(), monitor);
- }
-
- /*
- * Check whether the child exists for the given tag. This additional method is required because
- * CVS will signal an error if a folder only contains subfolders when a tag is used. If we get this
- * error and we're looking for a folder, we need to reissue the command without a tag.
- */
- protected boolean exists(final ICVSRemoteResource child, CVSTag tag, IProgressMonitor monitor) throws CVSException {
- final IProgressMonitor progress = Policy.monitorFor(monitor);
- progress.beginTask(Policy.bind("RemoteFolder.exists"), 100); //$NON-NLS-1$
- try {
- // Create the listener for remote files and folders
- final boolean[] exists = new boolean[] {true};
- final IUpdateMessageListener listener = new IUpdateMessageListener() {
- public void directoryInformation(ICVSFolder parent, IPath path, boolean newDirectory) {
- exists[0] = true;
- }
- public void directoryDoesNotExist(ICVSFolder parent, IPath path) {
- exists[0] = false;
- }
- public void fileInformation(int type, ICVSFolder parent, String filename) {
- // We can't set exists true here as we may get a conflict on a deleted file.
- // i.e. remote files are always communicated to the server as modified.
- }
- public void fileDoesNotExist(ICVSFolder parent, String filename) {
- exists[0] = false;
- }
- };
-
- // Build the local options
- final List localOptions = new ArrayList();
- localOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
- if (tag != null && tag.getType() != CVSTag.HEAD)
- localOptions.add(Update.makeTagOption(tag));
-
- // Retrieve the children and any file revision numbers in a single connection
- // Perform a "cvs -n update -d -r tagName folderName" with custom message and error handlers
- final boolean[] retry = new boolean[] {false};
- Session.run(getRepository(), this, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- IStatus status = Command.UPDATE.execute(
- new GlobalOption[] { Command.DO_NOT_CHANGE },
- (LocalOption[]) localOptions.toArray(new LocalOption[localOptions.size()]),
- new ICVSResource[] { child }, new UpdateListener(listener),
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- CVSServerException e = new CVSServerException(status);
- if (e.isNoTagException() && child.isContainer()) {
- retry[0] = true;
- } else {
- if (e.containsErrors()) {
- throw e;
- }
- }
- }
- }
- }, Policy.subMonitorFor(progress, 80));
-
- // We now know that this is an exception caused by a cvs bug.
- // If the folder has no files in it (just subfolders) CVS does not respond with the subfolders...
- // Workaround: Retry the request with no tag to get the directory names (if any)
- if (retry[0]) {
- Policy.checkCanceled(progress);
- return exists(child, null, Policy.subMonitorFor(progress, 20));
- }
- return exists[0];
- } finally {
- progress.done();
- }
- }
-
- /**
- * @see ICVSRemoteFolder#getMembers()
- */
- public ICVSRemoteResource[] getMembers(IProgressMonitor monitor) throws TeamException {
- return getMembers(getTag(), monitor);
- }
-
- /**
- * This method gets the members for a given tag and returns them.
- * During the execution of this method, the instance variable children
- * will be used to contain the children. However, the variable is reset
- * and the result returned. Thus, instances of RemoteFolder do not
- * persist the children. Subclasses (namely RemoteFolderTree) may
- * persist the children.
- */
- protected ICVSRemoteResource[] getMembers(final CVSTag tag, IProgressMonitor monitor) throws CVSException {
- final IProgressMonitor progress = Policy.monitorFor(monitor);
- progress.beginTask(Policy.bind("RemoteFolder.getMembers"), 100); //$NON-NLS-1$
- try {
- // Forget about any children we used to know about children
- children = null;
-
- // Create the listener for remote files and folders
- final List newRemoteDirectories = new ArrayList();
- final List newRemoteFiles = new ArrayList();
- final boolean[] exists = new boolean[] {true};
- final List exceptions = new ArrayList();
- final IUpdateMessageListener listener = new IUpdateMessageListener() {
- public void directoryInformation(ICVSFolder commandRoot, IPath path, boolean newDirectory) {
- try {
- path = getRelativePathFromRootRelativePath(commandRoot, path);
- if (newDirectory && path.segmentCount() == 1) {
- newRemoteDirectories.add(path.lastSegment());
- progress.subTask(path.lastSegment().toString());
- progress.worked(1);
- }
- } catch (CVSException e) {
- exceptions.add(e);
- }
- }
- public void directoryDoesNotExist(ICVSFolder parent, IPath path) {
- try {
- path = getRelativePathFromRootRelativePath(parent, path);
- if (path.isEmpty()) {
- // the remote folder doesn't exist
- exists[0] = false;
- }
- } catch (CVSException e) {
- exceptions.add(e);
- }
- }
- public void fileInformation(int type, ICVSFolder parent, String filename) {
- try {
- IPath filePath = new Path(filename);
- filePath = getRelativePathFromRootRelativePath(parent, filePath);
- if( filePath.segmentCount() == 1 ) {
- String properFilename = filePath.lastSegment();
- newRemoteFiles.add(properFilename);
- progress.subTask(properFilename);
- progress.worked(1);
- }
- } catch (CVSException e) {
- exceptions.add(e);
- }
- }
- public void fileDoesNotExist(ICVSFolder parent, String filename) {
- }
- };
-
- // Build the local options
- final List localOptions = new ArrayList();
- localOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
- if (tag != null) localOptions.add(Update.makeTagOption(tag));
-
- // Retrieve the children and any file revision numbers in a single connection
- try {
- Session.run(getRepository(), this, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- // Perform a "cvs -n update -d -r tagName folderName"
- monitor.beginTask(null, 100); //$NON-NLS-1$
- IStatus status = Command.UPDATE.execute(
- new GlobalOption[] { Command.DO_NOT_CHANGE },
- (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]),
- new ICVSResource[] { RemoteFolder.this },
- new UpdateListener(listener),
- Policy.subMonitorFor(monitor, 60));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- // Only throw the exception if no files or folders were found
- if (newRemoteDirectories.size() + newRemoteFiles.size() == 0) {
- throw new CVSServerException(status);
- } else {
- CVSProviderPlugin.log(status);
- }
-
- }
- if (! exists[0]) {
- throw new CVSException(new CVSStatus(CVSStatus.ERROR, CVSStatus.DOES_NOT_EXIST, Policy.bind("RemoteFolder.doesNotExist", getRepositoryRelativePath()))); //$NON-NLS-1$
- }
- // Report any internal exceptions that occured fetching the members
- if ( ! exceptions.isEmpty()) {
- if (exceptions.size() == 1) {
- throw (CVSException)exceptions.get(0);
- } else {
- MultiStatus multi = new MultiStatus(CVSProviderPlugin.ID, 0, Policy.bind("RemoteFolder.errorFetchingMembers"), null); //$NON-NLS-1$
- for (int i = 0; i < exceptions.size(); i++) {
- multi.merge(((CVSException)exceptions.get(i)).getStatus());
- }
- throw new CVSException(multi);
- }
- }
- // Convert the file names to remote resources
- Policy.checkCanceled(monitor);
- List result = new ArrayList();
- List remoteFiles = new ArrayList();
- for (int i=0;i<newRemoteFiles.size();i++) {
- RemoteFile newFile = new RemoteFile(RemoteFolder.this, Update.STATE_NONE, (String)newRemoteFiles.get(i), tag);
- result.add(newFile);
- remoteFiles.add(newFile);
- }
- // Convert the folder names to remote resources
- for (int i=0;i<newRemoteDirectories.size();i++)
- result.add(new RemoteFolder(RemoteFolder.this, getRepository(), new Path(getRepositoryRelativePath()).append((String)newRemoteDirectories.get(i)), tag));
- children = (ICVSRemoteResource[])result.toArray(new ICVSRemoteResource[0]);
- // Get the revision numbers for the files
- if (remoteFiles.size() > 0) {
- updateFileRevisions((ICVSFile[])remoteFiles.toArray(new ICVSFile[remoteFiles.size()]),
- Policy.subMonitorFor(monitor, 40));
- } else {
- monitor.worked(40);
- }
- }
- }, Policy.subMonitorFor(progress, 80));
- } catch (CVSServerException e) {
- if ( ! e.isNoTagException() && e.containsErrors())
- throw e;
- if (tag == null)
- throw e;
- // we now know that this is an exception caused by a cvs bug.
- // if the folder has no files in it (just subfolders) cvs does not respond with the subfolders...
- // workaround: retry the request with no tag to get the directory names (if any)
- Policy.checkCanceled(progress);
- children = getMembers(null, Policy.subMonitorFor(progress, 20));
- // the returned children must be given the original tag
- for (int i = 0; i < children.length; i++) {
- ICVSRemoteResource remoteResource = children[i];
- if(remoteResource.isContainer()) {
- ((RemoteFolder)remoteResource).setTag(tag);
- }
- }
- }
-
- // We need to remember the children that were fetched in order to support file
- // operations that depend on the parent knowing about the child (i.e. RemoteFile#getContents)
- return children;
- } finally {
- progress.done();
- }
- }
-
- /**
- * @see ICVSFolder#members(int)
- */
- public ICVSResource[] members(int flags) throws CVSException {
- final List result = new ArrayList();
- ICVSRemoteResource[] resources = getChildren();
- if (children == null) {
- return new ICVSResource[0];
- }
- boolean includeFiles = (((flags & FILE_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
- boolean includeFolders = (((flags & FOLDER_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
- boolean includeManaged = (((flags & MANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0));
- boolean includeUnmanaged = (((flags & UNMANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0));
- boolean includeIgnored = ((flags & IGNORED_MEMBERS) != 0);
- for (int i = 0; i < resources.length; i++) {
- ICVSResource cvsResource = resources[i];
- if ((includeFiles && ( ! cvsResource.isFolder()))
- || (includeFolders && (cvsResource.isFolder()))) {
- boolean isManaged = cvsResource.isManaged();
- boolean isIgnored = cvsResource.isIgnored();
- if ((isManaged && includeManaged)|| (isIgnored && includeIgnored)
- || ( ! isManaged && ! isIgnored && includeUnmanaged)) {
- result.add(cvsResource);
- }
-
- }
- }
- return (ICVSResource[]) result.toArray(new ICVSResource[result.size()]);
- }
-
- /**
- * @see ICVSFolder#getFolder(String)
- */
- public ICVSFolder getFolder(String name) throws CVSException {
- if (name.equals(Session.CURRENT_LOCAL_FOLDER) || name.equals(Session.CURRENT_LOCAL_FOLDER + Session.SERVER_SEPARATOR))
- return this;
- ICVSResource child = getChild(name);
- if (child.isFolder())
- return (ICVSFolder)child;
- throw new CVSException(Policy.bind("RemoteFolder.invalidChild", name, getName())); //$NON-NLS-1$
- }
-
- /**
- * @see ICVSFolder#getFile(String)
- */
- public ICVSFile getFile(String name) throws CVSException {
- ICVSResource child = getChild(name);
- if (!child.isFolder())
- return (ICVSFile)child;
- throw new CVSException(Policy.bind("RemoteFolder.invalidChild", name, getName())); //$NON-NLS-1$
-
- }
-
- public LocalOption[] getLocalOptions() {
- return Command.NO_LOCAL_OPTIONS;
- }
-
- public String getRepositoryRelativePath() {
- // The REPOSITORY property of the folder info is the repository relative path
- return getFolderSyncInfo().getRepository();
- }
-
- /**
- * @see ICVSResource#getRelativePath(ICVSFolder)
- */
- public String getRelativePath(ICVSFolder ancestor) throws CVSException {
- // Check to see if the receiver is the ancestor
- if (ancestor == this) return Session.CURRENT_LOCAL_FOLDER;
- // Otherwise, we need a parent to continue
- if (parent == null) {
- throw new CVSException(Policy.bind("RemoteFolder.invalidChild", getName(), ancestor.getName())); //$NON-NLS-1$
- }
- return super.getRelativePath(ancestor);
- }
-
- public ICVSRepositoryLocation getRepository() {
- return repository;
- }
-
- /**
- * @see ICVSRemoteFolder#isExpandable()
- */
- public boolean isExpandable() {
- return true;
- }
-
- /**
- * @see ICVSResource#isFolder()
- */
- public boolean isFolder() {
- return true;
- }
-
- /**
- * @see ICVSFolder#childExists(String)
- */
- public boolean childExists(String path) {
- try {
- return getChild(path) != null;
- } catch (CVSException e) {
- return false;
- }
- }
-
- /**
- * @see ICVSFolder#getChild(String)
- *
- * XXX: shouldn't this consider the case where children is null. Maybe
- * by running the update + status with only one member?
- *
- * XXX: The only problem with the above is that this is not supposed to be a long
- * running method. Also, path could be a file or folder and can be more than one level.
- *
- * This getChild is geared to work with the Command hierarchy. Therefore it only returns
- * children that were previously fetched by a call to getMembers(). If the request child
- * does not exist, an exception is thrown.
- */
- public ICVSResource getChild(String path) throws CVSException {
- if (path.equals(Session.CURRENT_LOCAL_FOLDER) || path.length() == 0)
- return this;
- ICVSRemoteResource[] children = getChildren();
- if (children == null)
- throw new CVSException(Policy.bind("RemoteFolder.invalidChild", path, getName()));//$NON-NLS-1$
- if (path.indexOf(Session.SERVER_SEPARATOR) == -1) {
- for (int i=0;i<children.length;i++) {
- if (children[i].getName().equals(path))
- return (ICVSResource)children[i];
- }
- } else {
- IPath p = new Path(path);
- try {
- return ((RemoteFolder)getChild(p.segment(0))).getChild(p.removeFirstSegments(1).toString());
- } catch (CVSException e) {
- // regenerate the exception to give as much info as possible
- throw new CVSException(Policy.bind("RemoteFolder.invalidChild", path, getName()));//$NON-NLS-1$
- }
- }
- throw new CVSException(Policy.bind("RemoteFolder.invalidChild", path, getName()));//$NON-NLS-1$
- }
-
- /**
- * @see ICVSFolder#mkdir()
- */
- public void mkdir() throws CVSException {
- throw new CVSException(Policy.bind("RemoteResource.invalidOperation"));//$NON-NLS-1$
- }
-
- /**
- * @see ICVSFolder#flush(boolean)
- */
- public void flush(boolean deep) {
- }
-
- /**
- * @see ICVSFolder#getFolderInfo()
- */
- public FolderSyncInfo getFolderSyncInfo() {
- return folderInfo;
- }
-
- /**
- * @see ICVSResource#getRemoteLocation(ICVSFolder)
- */
- public String getRemoteLocation(ICVSFolder stopSearching) throws CVSException {
- return folderInfo.getRemoteLocation();
- }
-
- /**
- * @see ICVSFolder#isCVSFolder()
- */
- public boolean isCVSFolder() {
- return true;
- }
-
- /**
- * @see ICVSFolder#acceptChildren(ICVSResourceVisitor)
- */
- public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException {
- throw new CVSException(Policy.bind("RemoteResource.invalidOperation"));//$NON-NLS-1$
- }
-
- /*
- * @see IRemoteResource#isContainer()
- */
- public boolean isContainer() {
- return true;
- }
-
- /*
- * @see IRemoteResource#members(IProgressMonitor)
- */
- public IRemoteResource[] members(IProgressMonitor progress) throws TeamException {
- return getMembers(progress);
- }
-
- /*
- * @see IRemoteResource#getContents(IProgressMonitor)
- */
- public InputStream getContents(IProgressMonitor progress) throws TeamException {
- return null;
- }
-
- /*
- * Answers the immediate cached children of this remote folder or null if the remote folder
- * handle has not yet queried the server for the its children.
- */
- public ICVSRemoteResource[] getChildren() {
- return children;
- }
- /*
- * This allows subclass to set the children
- */
- protected void setChildren(ICVSRemoteResource[] children) {
- this.children = children;
- }
- /*
- * @see ICVSRemoteFolder#setTag(String)
- */
- public void setTag(CVSTag tag) {
- this.folderInfo = new FolderSyncInfo(folderInfo.getRepository(), folderInfo.getRoot(), tag, folderInfo.getIsStatic());
- }
-
- /*
- * @see ICVSRemoteFolder#getTag()
- */
- public CVSTag getTag() {
- return folderInfo.getTag();
- }
- /*
- * @see ICVSFolder#setFolderInfo(FolderSyncInfo)
- */
- public void setFolderSyncInfo(FolderSyncInfo folderInfo) throws CVSException {
- this.folderInfo = folderInfo;
- // XXX temporary to see if this ever occurs
- throw new CVSException(Policy.bind("RemoteResource.invalidOperation"));//$NON-NLS-1$
- }
-
- /**
- * Update the file revision for the given child such that the revision is the one in the given branch.
- * Return true if the file exists and false otherwise
- */
- protected boolean updateRevision(final ICVSRemoteFile child, CVSTag tag, IProgressMonitor monitor) throws CVSException {
- final IProgressMonitor progress = Policy.monitorFor(monitor);
- progress.beginTask(null, 100); //$NON-NLS-1$
- ICVSRemoteResource[] oldChildren = children;
- try {
- children = new ICVSRemoteResource[] {child};
-
- // Create the listener for remote files and folders
- final boolean[] exists = new boolean[] {true};
- final IUpdateMessageListener listener = new IUpdateMessageListener() {
- public void directoryInformation(ICVSFolder parent, IPath path, boolean newDirectory) {
- }
- public void directoryDoesNotExist(ICVSFolder parent, IPath path) {
- // If we get this, we can assume that the parent directory no longer exists
- exists[0] = false;
- }
- public void fileInformation(int type, ICVSFolder parent, String filename) {
- // The file was found and has a different revision
- try {
- ((RemoteFile)parent.getChild(filename)).setWorkspaceSyncState(type);
- } catch(CVSException e) {
- exists[0] = false;
- }
- exists[0] = true;
- }
- public void fileDoesNotExist(ICVSFolder parent, String filename) {
- exists[0] = false;
- }
- };
-
- // Build the local options
- final List localOptions = new ArrayList();
- if (tag != null && tag.getType() != CVSTag.HEAD)
- localOptions.add(Update.makeTagOption(tag));
-
- // Retrieve the children and any file revision numbers in a single connection
- Session.run(getRepository(), this, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- // Perform a "cvs -n update -d -r tagName fileName" with custom message and error handlers
- Command.UPDATE.execute(
- new GlobalOption[] { Command.DO_NOT_CHANGE },
- (LocalOption[]) localOptions.toArray(new LocalOption[localOptions.size()]),
- new ICVSResource[] { child },
- new UpdateListener(listener),
- monitor);
- }
- }, Policy.subMonitorFor(progress, 70));
-
- if (!exists[0]) return false;
- updateFileRevisions(new ICVSFile[] {child}, Policy.subMonitorFor(progress, 30));
- return true;
- } finally {
- children = oldChildren;
- }
- }
-
- /*
- * @see ICVSFolder#run(ICVSRunnable, IProgressMonitor)
- */
- public void run(ICVSRunnable job, IProgressMonitor monitor) throws CVSException {
- job.run(monitor);
- }
-
- /*
- * @see ICVSFolder#tag(CVSTag, LocalOption[], IProgressMonitor)
- */
- public IStatus tag(CVSTag tag, LocalOption[] localOptions, IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(null, 100);
- Session s = new Session(getRepository(), this, false);
- s.open(Policy.subMonitorFor(monitor, 10));
- try {
- return Command.RTAG.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- localOptions,
- folderInfo.getTag(),
- tag,
- new String[] { folderInfo.getRepository() },
- Policy.subMonitorFor(monitor, 90));
-
- } finally {
- s.close();
- monitor.done();
- }
- }
-
- /**
- * @see ICVSFolder#fetchChildren(IProgressMonitor)
- */
- public ICVSResource[] fetchChildren(IProgressMonitor monitor) throws CVSException {
- try {
- return getMembers(monitor);
- } catch(TeamException e) {
- throw new CVSException(e.getStatus());
- }
- }
-
- public boolean equals(Object target) {
- if ( ! super.equals(target)) return false;
- RemoteFolder folder = (RemoteFolder)target;
- CVSTag tag1 = getTag();
- CVSTag tag2 = folder.getTag();
- if (tag1 == null) tag1 = CVSTag.DEFAULT;
- if (tag2 == null) tag2 = CVSTag.DEFAULT;
- return tag1.equals(tag2);
- }
-
- /*
- * The given root must be an ancestor of the receiver (or the receiver)
- * and the path of the receiver must be a prefix of the provided path.
- */
- protected IPath getRelativePathFromRootRelativePath(ICVSFolder root, IPath path) throws CVSException {
- // If the root is the receiver, then the path is already relative to the receiver
- if (root == this) {
- return path;
- }
- Assert.isTrue( ! path.isEmpty());
- return getRelativePathFromRootRelativePath((ICVSFolder)root.getChild(path.segment(0)), path.removeFirstSegments(1));
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java
deleted file mode 100644
index e784c3e3e..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * Whereas the RemoteFolder class provides access to a remote hierarchy using
- * lazy retrieval via <code>getMembers()</code>, the RemoteFolderTree will force
- * a recursive retrieval of the remote hierarchy in one round trip.
- */
-public class RemoteFolderTree extends RemoteFolder {
-
- public RemoteFolderTree(RemoteFolder parent, ICVSRepositoryLocation repository, IPath repositoryRelativePath, CVSTag tag) {
- super(parent, repository, repositoryRelativePath, tag);
- }
-
- public RemoteFolderTree(RemoteFolder parent, String name, ICVSRepositoryLocation repository, IPath repositoryRelativePath, CVSTag tag) {
- super(parent, name, repository, repositoryRelativePath, tag, false);
- }
-
- /*
- * Override of inherited method which persists the children
- */
- public ICVSRemoteResource[] getMembers(CVSTag tagName, IProgressMonitor monitor) throws CVSException {
- if (getChildren() == null)
- setChildren(super.getMembers(tagName, monitor));
- return getChildren();
- }
-
- /*
- * This method is public to allow access by the RemoteFolderTreeBuilder utility class.
- * No other external classes should use this method.
- */
- public void setChildren(ICVSRemoteResource[] children) {
- super.setChildren(children);
- }
-
- /*
- * @see ICVSFolder#acceptChildren(ICVSResourceVisitor)
- */
- public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException {
- ICVSRemoteResource[] children = getChildren();
- if (children == null) return;
- for (int i=0; i<children.length; i++) {
- ((ICVSResource)children[i]).accept(visitor);
- }
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java
deleted file mode 100644
index 2ff1dc2f0..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java
+++ /dev/null
@@ -1,704 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption;
-import org.eclipse.team.internal.ccvs.core.client.listeners.IStatusListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.IUpdateMessageListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.StatusListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.UpdateListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/*
- * This class is responsible for building a remote tree that shows the repository
- * state of a locally loaded folder tree.
- *
- * It is used as follows
- *
- * RemoteFolderTreeBuilder.buildRemoteTree(CVSRepositoryLocation, IManagedFolder, String, IProgressMonitor);
- *
- * The provider IManagedFolder can be a local resource or a RemoteFolderTree that
- * that was previously built.
- */
-public class RemoteFolderTreeBuilder {
-
- private static final int MAX_REVISION_FETCHES_PER_CONNECTION = 1024;
-
- private Map fileDeltas;
- private List changedFiles;
- private Map remoteFolderTable;
-
- private ICVSFolder root;
- private RemoteFolderTree remoteRoot;
- private CVSRepositoryLocation repository;
-
- private CVSTag tag;
-
- private LocalOption[] updateLocalOptions;
-
- private boolean projectDoesNotExist = false;
-
- private static String UNKNOWN = ""; //$NON-NLS-1$
- private static String DELETED = "DELETED"; //$NON-NLS-1$
- private static String ADDED = "ADDED"; //$NON-NLS-1$
- private static String FOLDER = "FOLDER"; //$NON-NLS-1$
-
- private static Map EMPTY_MAP = new HashMap();
-
- static class DeltaNode {
- int syncState = Update.STATE_NONE;
- String name;
- String revision;
-
- DeltaNode(String name, String revision, int syncState) {
- this.name = name;
- this.revision = revision;
- this.syncState = syncState;
- }
-
- String getName() {
- return name;
- }
-
- String getRevision() {
- return revision;
- }
-
- int getSyncState() {
- return syncState;
- }
- }
-
-
- private RemoteFolderTreeBuilder(CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag) {
- this.repository = repository;
- this.root = root;
- this.tag = tag;
- this.fileDeltas = new HashMap();
- this.changedFiles = new ArrayList();
- this.remoteFolderTable = new HashMap();
-
- // Build the local options
- List localOptions = new ArrayList();
- localOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
- if (tag != null) {
- if (tag.getType() == CVSTag.HEAD) {
- localOptions.add(Update.CLEAR_STICKY);
- } else {
- localOptions.add(Update.makeTagOption(tag));
- }
- }
- updateLocalOptions = (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]);
- }
-
- private LocalOption[] getOptionsWithoutTag() {
- // Build the local options
- List localOptions = new ArrayList();
- localOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
- return (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]);
- }
-
- public static RemoteFolderTree buildBaseTree(CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag, IProgressMonitor progress) throws CVSException {
- try {
- RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, root, tag);
- progress.beginTask(null, 100);
- IProgressMonitor subProgress = Policy.infiniteSubMonitorFor(progress, 100);
- subProgress.beginTask(null, 512); //$NON-NLS-1$
- subProgress.subTask(Policy.bind("RemoteFolderTreeBuilder.buildingBase", root.getName())); //$NON-NLS-1$
- return builder.buildBaseTree(null, root, subProgress);
- } finally {
- progress.done();
- }
- }
-
- public static RemoteFolderTree buildRemoteTree(CVSRepositoryLocation repository, IContainer root, CVSTag tag, IProgressMonitor monitor) throws CVSException {
- return buildRemoteTree(repository, CVSWorkspaceRoot.getCVSFolderFor(root), tag, monitor);
- }
-
- public static RemoteFolderTree buildRemoteTree(CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag, IProgressMonitor monitor) throws CVSException {
- RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, root, tag);
- return builder.buildTree(monitor);
- }
-
- public static RemoteFile buildRemoteTree(CVSRepositoryLocation repository, ICVSFile file, CVSTag tag, IProgressMonitor monitor) throws CVSException {
- RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, file.getParent(), tag);
- return builder.buildTree(file, monitor);
- }
-
- private RemoteFolderTree buildTree(IProgressMonitor monitor) throws CVSException {
-
- // Make sure that the cvs commands are not quiet during this operations
- QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
- try {
- CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
-
- monitor.beginTask(null, 100);
-
- Policy.checkCanceled(monitor);
- Session session = new Session(repository, root, false);
- session.open(Policy.subMonitorFor(monitor, 10));
- try {
- Policy.checkCanceled(monitor);
- fetchDelta(session, Session.CURRENT_LOCAL_FOLDER, Policy.subMonitorFor(monitor, 50));
- if (projectDoesNotExist) {
- return null;
- }
- } finally {
- session.close();
- }
- // We need a second session because of the use of a different handle on the same remote resource
- // Perhaps we could support the changing of a sessions root as long as
- // the folder sync info is the same
- remoteRoot =
- new RemoteFolderTree(null, root.getName(), repository,
- new Path(root.getFolderSyncInfo().getRepository()),
- tagForRemoteFolder(root, tag));
- session = new Session(repository, remoteRoot, false);
- session.open(Policy.subMonitorFor(monitor, 10));
- try {
- // Set up an infinite progress monitor for the recursive build
- IProgressMonitor subProgress = Policy.infiniteSubMonitorFor(monitor, 30);
- subProgress.beginTask(null, 512);
- // Build the remote tree
- buildRemoteTree(session, root, remoteRoot, Path.EMPTY, subProgress);
- // we can only fecth the status for up to 1024 files in a single connection due to
- // the server which has a limit on the number of "open" files.
- if (!changedFiles.isEmpty() && changedFiles.size() <= MAX_REVISION_FETCHES_PER_CONNECTION) {
- fetchFileRevisions(session, (String[])changedFiles.toArray(new String[changedFiles.size()]), Policy.subMonitorFor(monitor, 20));
- }
- } finally {
- session.close();
- }
-
- // If there were more than 1024 changed files, we need a connection per each 1024
- if (!changedFiles.isEmpty() && changedFiles.size() > MAX_REVISION_FETCHES_PER_CONNECTION) {
- String[] allChangedFiles = (String[])changedFiles.toArray(new String[changedFiles.size()]);
- int iterations = (allChangedFiles.length / MAX_REVISION_FETCHES_PER_CONNECTION)
- + (allChangedFiles.length % MAX_REVISION_FETCHES_PER_CONNECTION == 0 ? 0 : 1);
- for (int i = 0; i < iterations ; i++) {
- int length = Math.min(MAX_REVISION_FETCHES_PER_CONNECTION,
- allChangedFiles.length - (MAX_REVISION_FETCHES_PER_CONNECTION * i));
- String buffer[] = new String[length];
- System.arraycopy(allChangedFiles, i * MAX_REVISION_FETCHES_PER_CONNECTION, buffer, 0, length);
- session = new Session(repository, remoteRoot, false);
- session.open(Policy.subMonitorFor(monitor, 1));
- try {
- fetchFileRevisions(session, buffer, Policy.subMonitorFor(monitor, 2));
- } finally {
- session.close();
- }
- }
- }
-
- return remoteRoot;
-
- } finally {
- CVSProviderPlugin.getPlugin().setQuietness(quietness);
- monitor.done();
- }
- }
-
- private RemoteFile buildTree(ICVSFile file, IProgressMonitor monitor) throws CVSException {
- QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
- try {
- CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
-
- monitor.beginTask(null, 100);
-
- // Query the server to see if there is a delta available
- Policy.checkCanceled(monitor);
- Session session = new Session(repository, root, false);
- session.open(Policy.subMonitorFor(monitor, 10));
- try {
- Policy.checkCanceled(monitor);
- fetchDelta(session, file.getName(), Policy.subMonitorFor(monitor, 50));
- if (projectDoesNotExist) {
- return null;
- }
- } finally {
- session.close();
- }
- // Create a parent for the remote resource
- remoteRoot =
- new RemoteFolderTree(null, root.getName(), repository,
- new Path(root.getFolderSyncInfo().getRepository()),
- tagForRemoteFolder(root, tag));
- // Create the remote resource (using the delta if there is one)
- RemoteFile remoteFile;
- Map deltas = (Map)fileDeltas.get(Path.EMPTY);
- if (deltas == null || deltas.isEmpty()) {
- remoteFile = new RemoteFile(remoteRoot, file.getSyncInfo());
- } else {
- DeltaNode d = (DeltaNode)deltas.get(file.getName());
- remoteFile = new RemoteFile(remoteRoot, d.getSyncState(), file.getName(), tagForRemoteFolder(remoteRoot, tag));
- }
- // Add the resource to its parent
- remoteRoot.setChildren(new ICVSRemoteResource[] {remoteFile});
- // If there was a delta, ftech the new revision
- if (!changedFiles.isEmpty()) {
- // Add the remote folder to the remote folder lookup table (used to update file revisions)
- remoteFolderTable.put(new Path(remoteRoot.getFolderSyncInfo().getRemoteLocation()), remoteRoot);
- session = new Session(repository, remoteRoot, false);
- session.open(Policy.subMonitorFor(monitor, 10));
- try {
- fetchFileRevisions(session, (String[])changedFiles.toArray(new String[changedFiles.size()]), Policy.subMonitorFor(monitor, 20));
- } finally {
- session.close();
- }
- }
- return remoteFile;
-
- } finally {
- CVSProviderPlugin.getPlugin().setQuietness(quietness);
- monitor.done();
- }
- }
-
- /*
- * Build the base remote tree from the local tree.
- *
- * The localPath is used to retrieve deltas from the recorded deltas
- *
- * Does 1 work for each managed file and folder
- */
- private RemoteFolderTree buildBaseTree(RemoteFolderTree parent, ICVSFolder local, IProgressMonitor monitor) throws CVSException {
-
- Policy.checkCanceled(monitor);
-
- // Create a remote folder tree corresponding to the local resource
- RemoteFolderTree remote = new RemoteFolderTree(parent, local.getName(), repository, new Path(local.getFolderSyncInfo().getRepository()), local.getFolderSyncInfo().getTag());
-
- // Create a List to contain the created children
- List children = new ArrayList();
-
- // Build the child folders corresponding to local folders base
- ICVSResource[] folders = local.members(ICVSFolder.FOLDER_MEMBERS);
- for (int i=0;i<folders.length;i++) {
- ICVSFolder folder = (ICVSFolder)folders[i];
- if (folder.isManaged() && folder.isCVSFolder()) {
- monitor.worked(1);
- children.add(buildBaseTree(remote, folder, monitor));
- }
- }
-
- // Build the child files corresponding to local files base
- ICVSResource[] files = local.members(ICVSFolder.FILE_MEMBERS);
- for (int i=0;i<files.length;i++) {
- ICVSFile file = (ICVSFile)files[i];
- ResourceSyncInfo info = file.getSyncInfo();
- // if there is no sync info then there is no base
- if (info==null)
- continue;
- // There is no remote if the file was added
- if (info.isAdded())
- continue;
- // If the file was deleted locally, we need to generate a new sync info without the delete flag
- if (info.isDeleted()) {
- MutableResourceSyncInfo undeletedInfo = info.cloneMutable();
- undeletedInfo.setDeleted(false);
- info = undeletedInfo;
- }
- children.add(new RemoteFile(remote, info));
- monitor.worked(1);
- }
-
- // Add the children to the remote folder tree
- remote.setChildren((ICVSRemoteResource[])children.toArray(new ICVSRemoteResource[children.size()]));
-
- return remote;
- }
-
- /*
- * Build the remote tree from the local tree and the recorded deltas.
- *
- * The localPath is used to retrieve deltas from the recorded deltas
- *
- * Does 1 work for each file and folder delta processed
- */
- private void buildRemoteTree(Session session, ICVSFolder local, RemoteFolderTree remote, IPath localPath, IProgressMonitor monitor) throws CVSException {
-
- Policy.checkCanceled(monitor);
-
- // Add the remote folder to the remote folder lookup table (used to update file revisions)
- remoteFolderTable.put(new Path(remote.getFolderSyncInfo().getRemoteLocation()), remote);
-
- // Create a map to contain the created children
- Map children = new HashMap();
-
- // If there's no corresponding local resource then we need to fetch its contents in order to populate the deltas
- if (local == null) {
- fetchNewDirectory(session, remote, localPath, monitor);
- }
-
- // Fetch the delta's for the folder
- Map deltas = (Map)fileDeltas.get(localPath);
- if (deltas == null)
- deltas = EMPTY_MAP;
-
- // If there is a local, use the local children to start buidling the remote children
- if (local != null) {
- // Build the child folders corresponding to local folders
- ICVSResource[] folders = local.members(ICVSFolder.FOLDER_MEMBERS);
- for (int i=0;i<folders.length;i++) {
- ICVSFolder folder = (ICVSFolder)folders[i];
- DeltaNode d = (DeltaNode)deltas.get(folder.getName());
- if (folder.isCVSFolder() && ! isOrphanedSubtree(session, folder) && (d==null || d.getRevision() != DELETED)) {
- children.put(folders[i].getName(),
- new RemoteFolderTree(remote, folders[i].getName(), repository,
- new Path(folder.getFolderSyncInfo().getRepository()),
- tagForRemoteFolder(folder,tag)));
- }
- }
- // Build the child files corresponding to local files
- ICVSResource[] files = local.members(ICVSFolder.FILE_MEMBERS);
- for (int i=0;i<files.length;i++) {
- ICVSFile file = (ICVSFile)files[i];
-
- DeltaNode d = (DeltaNode)deltas.get(file.getName());
- ResourceSyncInfo info = file.getSyncInfo();
- // if there is no sync info then there isn't a remote file for this local file on the
- // server.
- if (info==null)
- continue;
- // There is no remote if the file was added and we didn't get a conflict (C) indicator from the server
- if (info.isAdded() && d==null)
- continue;
- // There is no remote if the file was deleted and we didn;t get a remove (R) indicator from the server
- if (info.isDeleted() && d==null)
- continue;
-
- int type = d==null ? Update.STATE_NONE : d.getSyncState();
- children.put(file.getName(), new RemoteFile(remote, type, info));
- }
- }
-
- // Build the children for new or out-of-date resources from the deltas
- Iterator i = deltas.keySet().iterator();
- while (i.hasNext()) {
- String name = (String)i.next();
- DeltaNode d = (DeltaNode)deltas.get(name);
- String revision = d.getRevision();
- if (revision == FOLDER) {
- // XXX should getRemotePath() return an IPath instead of a String?
- children.put(name, new RemoteFolderTree(remote, repository,
- new Path(remote.getRepositoryRelativePath()).append(name),
- tagForRemoteFolder(remote, tag)));
- } else if (revision == ADDED) {
- children.put(name, new RemoteFile(remote, d.getSyncState(), name, tagForRemoteFolder(remote, tag)));
- } else if (revision == UNKNOWN) {
- // The local resource is out of sync with the remote.
- // Create a RemoteFile associated with the tag so we are assured of getting the proper revision
- // (Note: this will replace the RemoteFile added from the local base)
- children.put(name, new RemoteFile(remote, d.getSyncState(), name, tagForRemoteFolder(remote, tag)));
- } else if (revision == DELETED) {
- // This should have been deleted while creating from the local resources.
- // If it wasn't, delete it now.
- if (children.containsKey(name))
- children.remove(name);
- } else {
- // We should never get here
- }
- monitor.worked(1);
- }
-
- // Add the children to the remote folder tree
- remote.setChildren((ICVSRemoteResource[])children.values().toArray(new ICVSRemoteResource[children.size()]));
-
- // We have to delay building the child folders to support the proper fetching of new directories
- // due to the fact that the same CVS home directory (i.e. the same root directory) must
- // be used for all requests sent over the same connection
- Iterator childIterator = children.entrySet().iterator();
- List emptyChildren = new ArrayList();
- while (childIterator.hasNext()) {
- Map.Entry entry = (Map.Entry)childIterator.next();
- if (((RemoteResource)entry.getValue()).isFolder()) {
- RemoteFolderTree remoteFolder = (RemoteFolderTree)entry.getValue();
- String name = (String)entry.getKey();
- ICVSFolder localFolder;
- DeltaNode d = (DeltaNode)deltas.get(name);
- // for directories that are new on the server
- if (d!=null && d.getRevision() == FOLDER)
- localFolder = null;
- else
- localFolder = local.getFolder(name);
- buildRemoteTree(session, localFolder, remoteFolder, localPath.append(name), monitor);
- // Record any children that are empty
- if (pruneEmptyDirectories() && remoteFolder.getChildren().length == 0) {
- // Prune if the local folder is also empty.
- if (localFolder == null || (localFolder.members(ICVSFolder.ALL_MEMBERS).length == 0))
- emptyChildren.add(remoteFolder);
- else {
- // Also prune if the tag we are fetching is not HEAD and differs from the tag of the local folder
- FolderSyncInfo info = localFolder.getFolderSyncInfo();
- if (tag != null && info != null && ! tag.equals(CVSTag.DEFAULT) && ! tag.equals(info.getTag()))
- emptyChildren.add(remoteFolder);
- }
- }
- }
- }
-
- // Prune any empty child folders
- if (pruneEmptyDirectories() && !emptyChildren.isEmpty()) {
- List newChildren = new ArrayList();
- newChildren.addAll(Arrays.asList(remote.getChildren()));
- newChildren.removeAll(emptyChildren);
- remote.setChildren((ICVSRemoteResource[])newChildren.toArray(new ICVSRemoteResource[newChildren.size()]));
-
- }
- }
-
- /*
- * This method fetches the delta between the local state and the remote state of the resource tree
- * and records the deltas in the fileDeltas instance variable
- *
- * Returns the list of changed files
- */
- private List fetchDelta(Session session, String argument, final IProgressMonitor monitor) throws CVSException {
-
- // Create an listener that will accumulate new and removed files and folders
- final List newChildDirectories = new ArrayList();
- IUpdateMessageListener listener = new IUpdateMessageListener() {
- public void directoryInformation(ICVSFolder root, IPath path, boolean newDirectory) {
- if (newDirectory) {
- // Record new directory with parent so it can be retrieved when building the parent
- recordDelta(path, FOLDER, Update.STATE_NONE);
- monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", path.toString())); //$NON-NLS-1$
- // Record new directory to be used as a parameter to fetch its contents
- newChildDirectories.add(path.toString());
- }
- }
- public void directoryDoesNotExist(ICVSFolder root, IPath path) {
- // Record removed directory with parent so it can be removed when building the parent
- if (path.isEmpty()) {
- projectDoesNotExist = true;
- } else {
- recordDelta(path, DELETED, Update.STATE_NONE);
- monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", path.toString())); //$NON-NLS-1$
- }
- }
- public void fileInformation(int type, ICVSFolder root, String filename) {
- // Cases that do not require action are:
- // case 'A' : = A locally added file that does not exists remotely
- // case '?' : = A local file that has not been added and does not exists remotely
- // case 'M' : = A locally modified file that has not been modified remotely
- switch(type) {
- case Update.STATE_MERGEABLE_CONFLICT :
- case Update.STATE_CONFLICT :
- // We have an remote change to a modified local file
- // The change could be a local change conflicting with a remote deletion.
- // If so, the deltas may already have a DELETED for the file.
- // We shouldn't override this DELETED
- IPath filePath = new Path(filename);
- Map deltas = deltas = (Map)fileDeltas.get(filePath.removeLastSegments(1));
- DeltaNode d = deltas != null ? (DeltaNode)deltas.get(filePath.lastSegment()) : null;
- if ((d!=null) && (d.getRevision() == DELETED))
- break;
- case Update.STATE_DELETED : // We have a locally removed file that still exists remotely
- case Update.STATE_REMOTE_CHANGES : // We have an remote change to an unmodified local file
- changedFiles.add(filename);
- recordDelta(new Path(filename), UNKNOWN, type);
- monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", filename)); //$NON-NLS-1$
- break;
- }
- }
- public void fileDoesNotExist(ICVSFolder root, String filename) {
- recordDelta(new Path(filename), DELETED, Update.STATE_NONE);
- monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", filename)); //$NON-NLS-1$
- }
- };
-
- // Perform a "cvs -n update -d [-r tag] ." in order to get the
- // messages from the server that will indicate what has changed on the
- // server.
- IStatus status = Command.UPDATE.execute(session,
- new GlobalOption[] { Command.DO_NOT_CHANGE },
- updateLocalOptions,
- new String[] { argument },
- new UpdateListener(listener),
- monitor);
- return changedFiles;
- }
- /*
- * Fetch the children of a previously unknown directory.
- *
- * The fetch may do up to 2 units of work in the provided monitor.
- */
- private void fetchNewDirectory(Session session, RemoteFolderTree newFolder, IPath localPath, final IProgressMonitor monitor) throws CVSException {
-
- // Create an listener that will accumulate new files and folders
- IUpdateMessageListener listener = new IUpdateMessageListener() {
- public void directoryInformation(ICVSFolder root, IPath path, boolean newDirectory) {
- if (newDirectory) {
- // Record new directory with parent so it can be retrieved when building the parent
- // NOTE: Check path prefix
- recordDelta(path, FOLDER, Update.STATE_NONE);
- monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", path.toString())); //$NON-NLS-1$
- }
- }
- public void directoryDoesNotExist(ICVSFolder root, IPath path) {
- }
- public void fileInformation(int type, ICVSFolder root, String filename) {
- // NOTE: Check path prefix
- changedFiles.add(filename);
- recordDelta(new Path(filename), ADDED, type);
- monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", filename)); //$NON-NLS-1$
- }
- public void fileDoesNotExist(ICVSFolder root, String filename) {
- }
- };
-
- // NOTE: Should use the path relative to the remoteRoot
- IPath path = new Path(newFolder.getRepositoryRelativePath());
- IStatus status = Command.UPDATE.execute(session,
- new GlobalOption[] { Command.DO_NOT_CHANGE },
- updateLocalOptions,
- new String[] { localPath.toString() },
- new UpdateListener(listener),
- Policy.subMonitorFor(monitor, 1));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- // FIXME: This should be refactored (maybe static methods on CVSException?)
- CVSServerException e = new CVSServerException(status);
- if ( ! e.isNoTagException() && e.containsErrors())
- throw e;
- // we now know that this is an exception caused by a cvs bug.
- // if the folder has no files in it (just subfolders) cvs does not respond with the subfolders...
- // workaround: retry the request with no tag to get the directory names (if any)
- Policy.checkCanceled(monitor);
- status = Command.UPDATE.execute(session,
- new GlobalOption[] { Command.DO_NOT_CHANGE },
- getOptionsWithoutTag(),
- new String[] { localPath.toString() },
- new UpdateListener(listener),
- Policy.subMonitorFor(monitor, 1));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- }
- }
-
- // Get the file revisions for the given filenames
- private void fetchFileRevisions(Session session, String[] fileNames, final IProgressMonitor monitor) throws CVSException {
-
- // Create a listener for receiving the revision info
- final Map revisions = new HashMap();
- final List exceptions = new ArrayList();
- IStatusListener listener = new IStatusListener() {
- public void fileStatus(ICVSFolder root, IPath path, String remoteRevision) {
- try {
- updateRevision(path, remoteRevision);
- monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingRevision", path.toString())); //$NON-NLS-1$
- } catch (CVSException e) {
- exceptions.add(e);
- }
- }
- };
-
- // Perform a "cvs status..." with a custom message handler
- IStatus status = Command.STATUS.execute(session,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- fileNames,
- new StatusListener(listener),
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
-
- // Report any exceptions that occured fecthing the revisions
- if ( ! exceptions.isEmpty()) {
- if (exceptions.size() == 1) {
- throw (CVSException)exceptions.get(0);
- } else {
- MultiStatus multi = new MultiStatus(CVSProviderPlugin.ID, 0, Policy.bind("RemoteFolder.errorFetchingRevisions"), null); //$NON-NLS-1$
- for (int i = 0; i < exceptions.size(); i++) {
- multi.merge(((CVSException)exceptions.get(i)).getStatus());
- }
- throw new CVSException(multi);
- }
- }
- }
-
- private boolean pruneEmptyDirectories() {
- return CVSProviderPlugin.getPlugin().getPruneEmptyDirectories();
- }
- /*
- * Record the deltas in a double map where the outer key is the parent directory
- * and the inner key is the file name. The value is the revision of the file or
- * DELETED (file or folder). New folders have a revision of FOLDER.
- *
- * A revison of UNKNOWN indicates that the revision has not been fetched
- * from the repository yet.
- */
- private void recordDelta(IPath path, String revision, int syncState) {
- IPath parent = path.removeLastSegments(1);
- Map deltas = (Map)fileDeltas.get(parent);
- if (deltas == null) {
- deltas = new HashMap();
- fileDeltas.put(parent, deltas);
- }
- String name = path.lastSegment();
- deltas.put(name, new DeltaNode(name, revision, syncState));
- }
-
- private void updateRevision(IPath path, String revision) throws CVSException {
- RemoteFolderTree folder = (RemoteFolderTree)remoteFolderTable.get(path.removeLastSegments(1));
- if (folder == null) {
- throw new CVSException(Policy.bind("RemoteFolderTreeBuilder.missingParent", path.toString(), revision));//$NON-NLS-1$
- }
- ((RemoteFile)folder.getFile(path.lastSegment())).setRevision(revision);
- }
-
- /*
- * Return the tag that should be associated with a remote folder.
- *
- * This method is used to ensure that new directories contain the tag
- * derived from the parant local folder when appropriate. For instance,
- *
- * The tag should be the provided tag. However, if tag is null, the
- * tag for the folder should be derived from the provided reference folder
- * which could be the local resource corresponding to the remote or the parent
- * of the remote.
- */
- private CVSTag tagForRemoteFolder(ICVSFolder folder, CVSTag tag) throws CVSException {
- return tag == null ? folder.getFolderSyncInfo().getTag() : tag;
- }
-
- private boolean isOrphanedSubtree(Session session, ICVSFolder mFolder) {
- return mFolder.isCVSFolder() && ! mFolder.isManaged() && ! mFolder.equals(session.getLocalRoot()) && mFolder.getParent().isCVSFolder();
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java
deleted file mode 100644
index 3da3e7811..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java
+++ /dev/null
@@ -1,311 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Checkout;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-
-public class RemoteModule extends RemoteFolder {
-
- private String label;
- private ICVSRemoteResource[] referencedModules;
- private LocalOption[] localOptions;
- private boolean expandable;
-
- public static RemoteModule[] getRemoteModules(ICVSRepositoryLocation repository, CVSTag tag, IProgressMonitor monitor) throws TeamException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(Policy.bind("RemoteModule.getRemoteModules"), 100); //$NON-NLS-1$
- try {
- RemoteModule[] modules;
- Session s = new Session(repository, (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(ResourcesPlugin.getWorkspace().getRoot()), false);
- s.open(Policy.subMonitorFor(monitor, 10));
- try {
- modules = Command.CHECKOUT.getRemoteModules(s, tag, Policy.subMonitorFor(monitor, 90));
- } finally {
- s.close();
- }
- return modules;
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Create a set of RemoteModules from the provided module definition strings returned from the server
- *
- * At the moment, we are very restrictive on the types of modules we support.
- */
- public static RemoteModule[] createRemoteModules(String[] moduleDefinitionStrings, ICVSRepositoryLocation repository, CVSTag tag) {
-
- Map modules = new HashMap();
- Map referencedModulesTable = new HashMap();
- Map moduleAliases = new HashMap();
- List acceptableModules = new ArrayList();
-
- // First pass: Create the remote module instances based on remote mapping
- for (int i = 0; i < moduleDefinitionStrings.length; i++) {
-
- // Read the module name
- StringTokenizer tokenizer = new StringTokenizer(moduleDefinitionStrings[i]);
- String moduleName = tokenizer.nextToken();
-
- // Read the options associated with the module
- List localOptionsList = new ArrayList();
- String next = tokenizer.nextToken();
- while (next.charAt(0) == '-') {
- switch (next.charAt(1)) {
- case 'a': // alias
- localOptionsList.add(Checkout.ALIAS);
- break;
- case 'l': // don't recurse
- localOptionsList.add(Checkout.DO_NOT_RECURSE);
- break;
- case 'd': // directory
- localOptionsList.add(Checkout.makeDirectoryNameOption(tokenizer.nextToken()));
- break;
- case 'e':
- case 'i':
- case 'o':
- case 't':
- case 'u': // Ignore any programs
- tokenizer.nextToken();
- break;
- case 's': // status
- localOptionsList.add(Checkout.makeStatusOption(tokenizer.nextToken()));
- break;
- default: // unanticipated option. Ignore it and go on
- }
- next = tokenizer.nextToken();
- }
- LocalOption[] localOptions = (LocalOption[]) localOptionsList.toArray(new LocalOption[localOptionsList.size()]);
-
- if (Checkout.ALIAS.isElementOf(localOptions)) {
-
- if (localOptions.length > 1) {
- // XXX This is an error condition that needs to be reported
- }
-
- // An alias expands to one or more modules or paths
- List expansions = new ArrayList(10);
- expansions.add(next);
- while (tokenizer.hasMoreTokens())
- expansions.add(tokenizer.nextToken());
-
- moduleAliases.put(moduleName, (String[]) expansions.toArray(new String[expansions.size()]));
- modules.put(moduleName, new RemoteModule(moduleName, null, repository, null, localOptions, tag, true));
-
- } else {
-
- // The module definition may have a leading directory which can be followed by some files
- if (!(next.charAt(0) == '&')) {
- String directory = next;
- List files = new ArrayList();
- while (tokenizer.hasMoreTokens() && (next.charAt(0) != '&')) {
- next = tokenizer.nextToken() ;
- if ((next.charAt(0) != '&'))
- files.add(next);
- }
- RemoteModule remoteModule = new RemoteModule(moduleName, null, repository, new Path(directory), localOptions, tag, ! files.isEmpty());
- modules.put(moduleName, remoteModule);
- if ( ! files.isEmpty()) {
- ICVSRemoteResource[] children = new ICVSRemoteResource[files.size()];
- for (int j = 0; j < children.length; j++) {
- children[j] = new RemoteFile(remoteModule, Update.STATE_NONE, (String)files.get(j), tag);
- remoteModule.setChildren(children);
- }
- }
- } else {
- modules.put(moduleName, new RemoteModule(moduleName, null, repository, null, localOptions, tag, true));
- }
-
- // Record any referenced modules so that can be cross-referenced below
- if (next.charAt(0) == '&') {
- List children = new ArrayList(10);
- children.add(next);
- while (tokenizer.hasMoreTokens())
- children.add(tokenizer.nextToken());
- referencedModulesTable.put(moduleName, (String[])children.toArray(new String[children.size()]));
- }
- }
- }
-
- // Second pass: Cross reference aliases to modules
- // XXX Aliases can reference other aliases which confuses the expansion!
- Iterator iter = moduleAliases.keySet().iterator();
- while (iter.hasNext()) {
- String moduleName = (String)iter.next();
- RemoteModule module = (RemoteModule)modules.get(moduleName);
- String[] expansion = (String[])moduleAliases.get(moduleName);
- List referencedFolders = new ArrayList();
- boolean expandable = true;
- for (int i = 0; i < expansion.length; i++) {
- if (expansion[i].charAt(0) == '!') {
- // XXX Unsupported for now
- expandable = false;
- } else {
- IPath path = new Path(expansion[i]);
- if (path.segmentCount() > 1) {
- // XXX Unsupported for now
- expandable = false;
- } else {
- RemoteModule child = (RemoteModule)modules.get(expansion[i]);
- if (child == null) {
- referencedFolders.add(new RemoteFolder(null, repository, path, tag));
- } else {
- // Need to check if the child is a module alias
- if (child.isAlias()) {
- // XXX Unsupported for now
- expandable = false;
- } else {
- referencedFolders.add(child);
- }
- }
- }
- }
- }
- if (expandable) {
- module.setChildren((ICVSRemoteResource[]) referencedFolders.toArray(new ICVSRemoteResource[referencedFolders.size()]));
- } else {
- module.setExpandable(false);
- }
- }
-
- // Third pass: Cross reference remote modules where necessary
- iter = modules.keySet().iterator();
- while (iter.hasNext()) {
- String moduleName = (String)iter.next();
- String[] children = (String[])referencedModulesTable.get(moduleName);
- if (children != null) {
- RemoteModule module = (RemoteModule)modules.get(moduleName);
- List referencedFolders = new ArrayList();
- boolean expandable = true;
- for (int i = 0; i < children.length; i++) {
- RemoteModule child = (RemoteModule)modules.get(children[i].substring(1));
- if (child.isAlias()) {
- // Include alias children in-line
- expandable = false;
-// referencedFolders.addAll(Arrays.asList(child.getChildren()));
- } else {
- // XXX not expandable if child has local directory option (-d)
- if (Command.findOption(child.getLocalOptions(), "-d") != null) { //$NON-NLS-1$
- expandable = false;
- } else {
- referencedFolders.add(child);
- }
- }
- }
- if (expandable) {
- module.setReferencedModules((ICVSRemoteResource[]) referencedFolders.toArray(new ICVSRemoteResource[referencedFolders.size()]));
- } else {
- module.setExpandable(false);
- }
- }
- }
-
- return (RemoteModule[])modules.values().toArray(new RemoteModule[modules.size()]);
- }
-
- public RemoteModule(String label, RemoteFolder parent, ICVSRepositoryLocation repository, IPath repositoryRelativePath, LocalOption[] localOptions, CVSTag tag, boolean isStatic) {
- super(parent,
- label,
- repository,
- repositoryRelativePath == null ? new Path(FolderSyncInfo.VIRTUAL_DIRECTORY) : repositoryRelativePath,
- tag,
- isStatic);
- this.localOptions = localOptions;
- this.label = label;
- this.expandable = true;
- }
-
- public LocalOption[] getLocalOptions() {
- return localOptions;
- }
- /*
- * Override of inherited getMembers in order to combine the physical members with any referenced modules
- */
- public ICVSRemoteResource[] getMembers(CVSTag tagName, IProgressMonitor monitor) throws CVSException {
-
- if ( ! expandable) return new ICVSRemoteResource[0];
-
- ICVSRemoteResource[] physicalChildren;
- if ( folderInfo.getIsStatic()) {
- physicalChildren = getChildren();
- } else {
- physicalChildren = super.getMembers(tagName, monitor);
- }
- ICVSRemoteResource[] allChildren;
- if (referencedModules != null && referencedModules.length > 0) {
- if (physicalChildren == null) {
- allChildren = referencedModules;
- } else {
- // Combine two sets of children
- allChildren = new ICVSRemoteResource[physicalChildren.length + referencedModules.length];
- for (int i = 0; i < physicalChildren.length; i++) {
- allChildren[i] = physicalChildren[i];
- }
- for (int i = 0; i < referencedModules.length; i++) {
- allChildren[i + physicalChildren.length] = referencedModules[i];
- }
- }
- } else if (physicalChildren != null) {
- allChildren = physicalChildren;
- } else {
- allChildren = new ICVSRemoteResource[0];
- }
- return allChildren;
- }
-
- /*
- * Set the children to a static set of children
- */
- protected void setChildren(ICVSRemoteResource[] children) {
- super.setChildren(children);
- if ( ! folderInfo.getIsStatic())
- this.folderInfo = new FolderSyncInfo(folderInfo.getRepository(), folderInfo.getRoot(), folderInfo.getTag(), true);
- }
-
- private void setReferencedModules(ICVSRemoteResource[] referencedModules) {
- this.referencedModules = referencedModules;
- }
-
- public boolean isAlias() {
- return Checkout.ALIAS.isElementOf(localOptions);
- }
-
- /**
- * @see ICVSRemoteFolder#isExpandable()
- */
- public boolean isExpandable() {
- return expandable;
- }
-
- private void setExpandable(boolean expandable) {
- this.expandable = expandable;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java
deleted file mode 100644
index fee58046f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * The purpose of this class and its subclasses is to implement the corresponding
- * ICVSRemoteResource interfaces for the purpose of communicating information about
- * resources that reside in a CVS repository but have not necessarily been loaded
- * locally.
- */
-public abstract class RemoteResource extends PlatformObject implements ICVSRemoteResource {
-
- protected ResourceSyncInfo info;
- protected RemoteFolder parent;
-
- // relative synchronization state calculated by server of this remote file compare to the current local
- // workspace copy.
- private int workspaceSyncState = Update.STATE_NONE;
-
- /*
- * @see ICVSRemoteResource#getName()
- */
- public String getName() {
- return info.getName();
- }
-
- /*
- * @see ICVSResource#getRelativePath(ICVSFolder)
- */
- public String getRelativePath(ICVSFolder ancestor) throws CVSException {
- return Util.appendPath(parent.getRelativePath(ancestor), getName());
- }
-
- /*
- * @see ICVSRemoteResource#getParent()
- */
- public ICVSRemoteResource getRemoteParent() {
- return parent;
- }
-
- public abstract String getRepositoryRelativePath();
-
- public abstract ICVSRepositoryLocation getRepository();
-
- public int getWorkspaceSyncState() {
- return workspaceSyncState;
- }
-
- public void setWorkspaceSyncState(int workspaceSyncState) {
- this.workspaceSyncState = workspaceSyncState;
- }
-
- /*
- * @see ICVSResource#delete()
- */
- public void delete() {
- // XXX we should know how to delete a remote?
- }
-
- /*
- * @see ICVSResource#exists()
- *
- * This method is used by the Command framework so it must return true so that
- * the proper information gets sent to the server. (i.e. it is used to fake that
- * the file exists locally so cvs commands can be used to retrieve information about
- * the remote resource from the server)
- */
- public boolean exists() {
- return true;
- }
-
- /*
- * @see ICVSRemoteResource#exists(IProgressMonitor)
- */
- public boolean exists(IProgressMonitor monitor) throws TeamException {
- return parent.exists(this, monitor);
- }
-
- /*
- * @see ICVSResource#getParent()
- */
- public ICVSFolder getParent() {
- return parent;
- }
-
- /*
- * @see ICVSResource#isIgnored()
- */
- public boolean isIgnored() {
- return false;
- }
-
- /*
- * @see ICVSResource#isManaged()
- */
- public boolean isManaged() {
- return parent != null;
- }
-
- /*
- * @see ICVSResource#unmanage()
- */
- public void unmanage(IProgressMonitor monitor) throws CVSException {
- // do nothing
- }
-
- /*
- * @see ICVSResource#getSyncInfo()
- */
- public ResourceSyncInfo getSyncInfo() {
- return info;
- }
- /*
- * @see ICVSResource#setSyncInfo(ResourceSyncInfo)
- */
- public void setSyncInfo(ResourceSyncInfo info) {
- // ensure that clients are not trying to set sync info on remote handles.
- Assert.isTrue(false);
- }
-
- public boolean equals(Object target) {
- if (this == target)
- return true;
- if (!(target instanceof RemoteResource))
- return false;
- RemoteResource remote = (RemoteResource) target;
- return remote.isContainer() == isContainer() && remote.getRepositoryRelativePath().equals(getRepositoryRelativePath());
- }
- /*
- * @see ICVSResource#setIgnored()
- */
- public void setIgnored() throws CVSException {
- // ensure that clients are not trying to set sync info on remote handles.
- Assert.isTrue(false);
- }
-
- /*
- * @see ICVSResource#setIgnoredAs(String)
- */
- public void setIgnoredAs(String pattern) throws CVSException {
- // ensure that clients are not trying to set sync info on remote handles.
- Assert.isTrue(false);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/CRLFtoLFInputStream.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/CRLFtoLFInputStream.java
deleted file mode 100644
index a5db44884..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/CRLFtoLFInputStream.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * 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.streams;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InterruptedIOException;
-
-/**
- * Converts CR/LFs in the underlying input stream to LF.
- *
- * Supports resuming partially completed operations after an InterruptedIOException
- * if the underlying stream does. Check the bytesTransferred field to determine how
- * much of the operation completed; conversely, at what point to resume.
- */
-public class CRLFtoLFInputStream extends FilterInputStream {
- private boolean pendingByte = false;
- private int lastByte = -1;
-
- /**
- * Creates a new filtered input stream.
- * @param in the underlying input stream
- */
- public CRLFtoLFInputStream(InputStream in) {
- super(in);
- }
-
- /**
- * Wraps the underlying stream's method.
- * Translates CR/LF sequences to LFs transparently.
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred will be zero
- * @throws IOException if an i/o error occurs
- */
- public int read() throws IOException {
- if (! pendingByte) {
- lastByte = in.read(); // ok if this throws
- pendingByte = true; // remember the byte in case we throw an exception later on
- }
- if (lastByte == '\r') {
- lastByte = in.read(); // ok if this throws
- if (lastByte != '\n') {
- if (lastByte == -1) pendingByte = false;
- return '\r'; // leaves the byte pending for later
- }
- }
- pendingByte = false;
- return lastByte;
- }
-
- /**
- * Wraps the underlying stream's method.
- * Translates CR/LF sequences to LFs transparently.
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred may be non-zero
- * @throws IOException if an i/o error occurs
- */
- public int read(byte[] buffer, int off, int len) throws IOException {
- // handle boundary cases cleanly
- if (len == 0) {
- return 0;
- } else if (len == 1) {
- int b = read();
- if (b == -1) return -1;
- buffer[off] = (byte) b;
- return 1;
- }
- // read some bytes from the stream
- // prefix with pending byte from last read if any
- int count = 0;
- if (pendingByte) {
- buffer[off] = (byte) lastByte;
- pendingByte = false;
- count = 1;
- }
- InterruptedIOException iioe = null;
- try {
- len = in.read(buffer, off + count, len - count);
- if (len == -1) {
- return (count == 0) ? -1 : count;
- }
- } catch (InterruptedIOException e) {
- len = e.bytesTransferred;
- iioe = e;
- }
- count += len;
- // strip out CR's in CR/LF pairs
- // pendingByte will be true iff previous byte was a CR
- int j = off;
- for (int i = off; i < off + count; ++i) { // invariant: j <= i
- lastByte = buffer[i];
- if (lastByte == '\r') {
- if (pendingByte) {
- buffer[j++] = '\r'; // write out orphan CR
- } else {
- pendingByte = true;
- }
- } else {
- if (pendingByte) {
- if (lastByte != '\n') buffer[j++] = '\r'; // if LF, don't write the CR
- pendingByte = false;
- }
- buffer[j++] = (byte) lastByte;
- }
- }
- if (iioe != null) {
- iioe.bytesTransferred = j - off;
- throw iioe;
- }
- return j - off;
- }
-
- /**
- * Calls read() to skip the specified number of bytes
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred may be non-zero
- * @throws IOException if an i/o error occurs
- */
- public long skip(long count) throws IOException {
- int actualCount = 0; // assumes count < Integer.MAX_INT
- try {
- while (count-- > 0 && read() != -1) actualCount++; // skip the specified number of bytes
- return actualCount;
- } catch (InterruptedIOException e) {
- e.bytesTransferred = actualCount;
- throw e;
- }
- }
-
- /**
- * Wraps the underlying stream's method.
- * Returns the number of bytes that can be read without blocking; accounts for
- * possible translation of CR/LF sequences to LFs in these bytes.
- * @throws IOException if an i/o error occurs
- */
- public int available() throws IOException {
- return in.available() / 2; // we can guarantee at least this amount after contraction
- }
-
- /**
- * Mark is not supported by the wrapper even if the underlying stream does, returns false.
- */
- public boolean markSupported() {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/LFtoCRLFInputStream.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/LFtoCRLFInputStream.java
deleted file mode 100644
index 6c4d20e4a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/LFtoCRLFInputStream.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * 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.streams;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InterruptedIOException;
-
-/**
- * Converts LFs in the underlying input stream to CR/LF.
- *
- * Supports resuming partially completed operations after an InterruptedIOException
- * if the underlying stream does. Check the bytesTransferred field to determine how
- * much of the operation completed; conversely, at what point to resume.
- */
-public class LFtoCRLFInputStream extends FilterInputStream {
- private boolean mustReturnLF = false;
-
- /**
- * Creates a new filtered input stream.
- * @param in the underlying input stream
- */
- public LFtoCRLFInputStream(InputStream in) {
- super(in);
- }
-
- /**
- * Wraps the underlying stream's method.
- * Translates LFs to CR/LF sequences transparently.
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred will be zero
- * @throws IOException if an i/o error occurs
- */
- public int read() throws IOException {
- if (mustReturnLF) {
- mustReturnLF = false;
- return '\n';
- }
- int b = in.read(); // ok if this throws
- if (b == '\n') {
- mustReturnLF = true;
- b = '\r';
- }
- return b;
- }
-
- /**
- * Wraps the underlying stream's method.
- * Translates LFs to CR/LF sequences transparently.
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred may be non-zero
- * @throws IOException if an i/o error occurs
- */
- public int read(byte[] buffer, int off, int len) throws IOException {
- // handle boundary cases cleanly
- if (len == 0) {
- return 0;
- } else if (len == 1) {
- int b = read();
- if (b == -1) return -1;
- buffer[off] = (byte) b;
- return 1;
- }
- // prefix with remembered \n from last read, but don't expand it a second time
- int count = 0;
- if (mustReturnLF) {
- mustReturnLF = false;
- buffer[off++] = '\n';
- --len;
- count = 1;
- if (len < 2) return count; // is there still enough room to expand more?
- }
- // read some bytes from the stream into the back half of the buffer
- // this guarantees that there is always room to expand
- len /= 2;
- int j = off + len;
- InterruptedIOException iioe = null;
- try {
- len = in.read(buffer, j, len);
- if (len == -1) {
- return (count == 0) ? -1 : count;
- }
- } catch (InterruptedIOException e) {
- len = e.bytesTransferred;
- iioe = e;
- }
- count += len;
- // copy bytes from the middle to the front of the array, expanding LF->CR/LF
- while (len-- > 0) {
- byte b = buffer[j++];
- if (b == '\n') {
- buffer[off++] = '\r';
- count++;
- }
- buffer[off++] = b;
- }
- if (iioe != null) {
- iioe.bytesTransferred = count;
- throw iioe;
- }
- return count;
- }
-
- /**
- * Calls read() to skip the specified number of bytes
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred may be non-zero
- * @throws IOException if an i/o error occurs
- */
- public long skip(long count) throws IOException {
- int actualCount = 0; // assumes count < Integer.MAX_INT
- try {
- while (count-- > 0 && read() != -1) actualCount++; // skip the specified number of bytes
- return actualCount;
- } catch (InterruptedIOException e) {
- e.bytesTransferred = actualCount;
- throw e;
- }
- }
-
- /**
- * Wraps the underlying stream's method.
- * Returns the number of bytes that can be read without blocking; accounts for
- * possible translation of LFs to CR/LF sequences in these bytes.
- * @throws IOException if an i/o error occurs
- */
- public int available() throws IOException {
- return in.available(); // we can guarantee at least this amount after expansion
- }
-
- /**
- * Mark is not supported by the wrapper even if the underlying stream does, returns false.
- */
- public boolean markSupported() {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/PollingInputStream.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/PollingInputStream.java
deleted file mode 100644
index 3ba903905..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/PollingInputStream.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * 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.streams;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InterruptedIOException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.Policy;
-
-/**
- * Polls a progress monitor periodically and handles timeouts over extended durations.
- * For this class to be effective, a high numAttempts should be specified, and the
- * underlying stream should time out frequently on reads (every second or so).
- *
- * Supports resuming partially completed operations after an InterruptedIOException
- * if the underlying stream does. Check the bytesTransferred field to determine how
- * much of the operation completed; conversely, at what point to resume.
- */
-public class PollingInputStream extends FilterInputStream {
- private static final boolean DEBUG = Policy.DEBUG_STREAMS;
- private int numAttempts;
- private IProgressMonitor monitor;
-
- /**
- * Creates a new polling input stream.
- * @param in the underlying input stream
- * @param numAttempts the number of attempts before issuing an InterruptedIOException,
- * if 0, retries indefinitely until canceled
- * @param monitor the progress monitor to be polled for cancellation
- */
- public PollingInputStream(InputStream in, int numAttempts, IProgressMonitor monitor) {
- super(in);
- this.numAttempts = numAttempts;
- this.monitor = monitor;
- }
-
- /**
- * Wraps the underlying stream's method.
- * It may be important to wait for an input stream to be closed because it
- * holds an implicit lock on a system resoure (such as a file) while it is
- * open. Closing a stream may take time if the underlying stream is still
- * servicing a previous request.
- * @throws OperationCanceledException if the progress monitor is canceled
- * @throws InterruptedIOException if the underlying operation times out numAttempts times
- * @throws IOException if an i/o error occurs
- */
- public void close() throws IOException {
- int attempts = 0;
- try {
- readPendingInput();
- } catch (IOException e) {
- // We shouldn't get an exception when we're getting the available input.
- // If we do, just log it so we can close.
- CVSProviderPlugin.log(CVSException.wrapException(e).getStatus());
- } finally {
- for (;;) {
- try {
- in.close();
- return;
- } catch (InterruptedIOException e) {
- if (monitor.isCanceled()) throw new OperationCanceledException();
- if (++attempts == numAttempts)
- throw new InterruptedIOException(Policy.bind("PollingInputStream.closeTimeout")); //$NON-NLS-1$
- if (DEBUG) System.out.println("close retry=" + attempts); //$NON-NLS-1$
- }
- }
- }
- }
-
- /**
- * Wraps the underlying stream's method.
- * @throws OperationCanceledException if the progress monitor is canceled
- * @throws InterruptedIOException if the underlying operation times out numAttempts times
- * and no data was received, bytesTransferred will be zero
- * @throws IOException if an i/o error occurs
- */
- public int read() throws IOException {
- int attempts = 0;
- for (;;) {
- if (monitor.isCanceled()) throw new OperationCanceledException();
- try {
- return in.read();
- } catch (InterruptedIOException e) {
- if (++attempts == numAttempts)
- throw new InterruptedIOException(Policy.bind("PollingInputStream.readTimeout")); //$NON-NLS-1$
- if (DEBUG) System.out.println("read retry=" + attempts); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Wraps the underlying stream's method.
- * @throws OperationCanceledException if the progress monitor is canceled
- * @throws InterruptedIOException if the underlying operation times out numAttempts times
- * and no data was received, bytesTransferred will be zero
- * @throws IOException if an i/o error occurs
- */
- public int read(byte[] buffer, int off, int len) throws IOException {
- int attempts = 0;
- for (;;) {
- if (monitor.isCanceled()) throw new OperationCanceledException();
- try {
- return in.read(buffer, off, len);
- } catch (InterruptedIOException e) {
- if (e.bytesTransferred != 0) return e.bytesTransferred; // keep partial transfer
- if (++attempts == numAttempts)
- throw new InterruptedIOException(Policy.bind("PollingInputStream.readTimeout")); //$NON-NLS-1$
- if (DEBUG) System.out.println("read retry=" + attempts); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Wraps the underlying stream's method.
- * @throws OperationCanceledException if the progress monitor is canceled
- * @throws InterruptedIOException if the underlying operation times out numAttempts times
- * and no data was received, bytesTransferred will be zero
- * @throws IOException if an i/o error occurs
- */
- public long skip(long count) throws IOException {
- int attempts = 0;
- for (;;) {
- if (monitor.isCanceled()) throw new OperationCanceledException();
- try {
- return in.skip(count);
- } catch (InterruptedIOException e) {
- if (e.bytesTransferred != 0) return e.bytesTransferred; // keep partial transfer
- if (++attempts == numAttempts)
- throw new InterruptedIOException(Policy.bind("PollingInputStream.readTimeout")); //$NON-NLS-1$
- if (DEBUG) System.out.println("read retry=" + attempts); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Reads any pending input from the input stream so that
- * the stream can savely be closed.
- */
- protected void readPendingInput() throws IOException {
- byte[] buffer= new byte[2048];
- while (true) {
- int available = in.available();
- if (available < 1) break;
- if (available > buffer.length) available = buffer.length;
- if (in.read(buffer, 0, available) < 1) break;
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/PollingOutputStream.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/PollingOutputStream.java
deleted file mode 100644
index a486d4bd2..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/PollingOutputStream.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * 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.streams;
-
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.io.OutputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.team.internal.ccvs.core.Policy;
-
-/**
- * Polls a progress monitor periodically and handles timeouts over extended durations.
- * For this class to be effective, a high numAttempts should be specified, and the
- * underlying stream should time out frequently on writes (every second or so).
- *
- * Supports resuming partially completed operations after an InterruptedIOException
- * if the underlying stream does. Check the bytesTransferred field to determine how
- * much of the operation completed; conversely, at what point to resume.
- */
-public class PollingOutputStream extends FilterOutputStream {
- private static final boolean DEBUG = Policy.DEBUG_STREAMS;
- private int numAttempts;
- private IProgressMonitor monitor;
-
- /**
- * Creates a new polling output stream.
- * @param in the underlying output stream
- * @param numAttempts the number of attempts before issuing an InterruptedIOException,
- * if 0, retries indefinitely until canceled
- * @param monitor the progress monitor to be polled for cancellation
- */
- public PollingOutputStream(OutputStream out, int numAttempts, IProgressMonitor monitor) {
- super(out);
- this.numAttempts = numAttempts;
- this.monitor = monitor;
- }
-
- /**
- * Wraps the underlying stream's method.
- * @throws OperationCanceledException if the progress monitor is canceled
- * @throws InterruptedIOException if the underlying operation times out numAttempts times
- * and no data was sent, bytesTransferred will be zero
- * @throws IOException if an i/o error occurs
- */
- public void write(int b) throws IOException {
- int attempts = 0;
- for (;;) {
- if (monitor.isCanceled()) throw new OperationCanceledException();
- try {
- out.write(b);
- return;
- } catch (InterruptedIOException e) {
- if (++attempts == numAttempts)
- throw new InterruptedIOException(Policy.bind("PollingOutputStream.writeTimeout")); //$NON-NLS-1$
- if (DEBUG) System.out.println("write retry=" + attempts); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Wraps the underlying stream's method.
- * @throws OperationCanceledException if the progress monitor is canceled
- * @throws InterruptedIOException if the underlying operation times out numAttempts times,
- * bytesTransferred will reflect the number of bytes sent
- * @throws IOException if an i/o error occurs
- */
- public void write(byte[] buffer, int off, int len) throws IOException {
- int count = 0;
- int attempts = 0;
- for (;;) {
- if (monitor.isCanceled()) throw new OperationCanceledException();
- try {
- out.write(buffer, off, len);
- return;
- } catch (InterruptedIOException e) {
- int amount = e.bytesTransferred;
- if (amount != 0) { // keep partial transfer
- len -= amount;
- if (len <= 0) return;
- off += amount;
- count += amount;
- attempts = 0; // made some progress, don't time out quite yet
- }
- if (++attempts == numAttempts) {
- e = new InterruptedIOException(Policy.bind("PollingOutputStream.writeTimeout")); //$NON-NLS-1$
- e.bytesTransferred = count;
- throw e;
- }
- if (DEBUG) System.out.println("write retry=" + attempts); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Wraps the underlying stream's method.
- * @throws OperationCanceledException if the progress monitor is canceled
- * @throws InterruptedIOException if the underlying operation times out numAttempts times,
- * bytesTransferred will reflect the number of bytes sent
- * @throws IOException if an i/o error occurs
- */
- public void flush() throws IOException {
- int count = 0;
- int attempts = 0;
- for (;;) {
- if (monitor.isCanceled()) throw new OperationCanceledException();
- try {
- out.flush();
- return;
- } catch (InterruptedIOException e) {
- int amount = e.bytesTransferred;
- if (amount != 0) { // keep partial transfer
- count += amount;
- attempts = 0; // made some progress, don't time out quite yet
- }
- if (++attempts == numAttempts) {
- e = new InterruptedIOException(Policy.bind("PollingOutputStream.writeTimeout")); //$NON-NLS-1$
- e.bytesTransferred = count;
- throw e;
- }
- if (DEBUG) System.out.println("write retry=" + attempts); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Calls flush() then close() on the underlying stream.
- * @throws OperationCanceledException if the progress monitor is canceled
- * @throws InterruptedIOException if the underlying operation times out numAttempts times,
- * bytesTransferred will reflect the number of bytes sent during the flush()
- * @throws IOException if an i/o error occurs
- */
- public void close() throws IOException {
- int attempts = numAttempts - 1; // fail fast if flush() does times out
- try {
- out.flush();
- attempts = 0;
- } finally {
- for (;;) {
- try {
- out.close();
- return;
- } catch (InterruptedIOException e) {
- if (monitor.isCanceled()) throw new OperationCanceledException();
- if (++attempts == numAttempts)
- throw new InterruptedIOException(Policy.bind("PollingOutputStream.closeTimeout")); //$NON-NLS-1$
- if (DEBUG) System.out.println("close retry=" + attempts); //$NON-NLS-1$
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/ProgressMonitorInputStream.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/ProgressMonitorInputStream.java
deleted file mode 100644
index 9ee8e93cb..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/ProgressMonitorInputStream.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * 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 implementation
- ******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.streams;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InterruptedIOException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-
-/**
- * Updates a progress monitor as bytes are read from the input stream.
- * Also starts a background thread to provide responsive cancellation on read().
- *
- * Supports resuming partially completed operations after an InterruptedIOException
- * if the underlying stream does. Check the bytesTransferred field to determine how
- * much of the operation completed; conversely, at what point to resume.
- */
-public abstract class ProgressMonitorInputStream extends FilterInputStream {
- private IProgressMonitor monitor;
- private int updateIncrement;
- private long bytesTotal;
- private long bytesRead = 0;
- private long lastUpdate = -1;
- private long nextUpdate = 0;
-
- /**
- * Creates a progress monitoring input stream.
- * @param in the underlying input stream
- * @param bytesTotal the number of bytes to read in total (passed to updateMonitor())
- * @param updateIncrement the number of bytes read between updates
- * @param monitor the progress monitor
- */
- public ProgressMonitorInputStream(InputStream in, long bytesTotal, int updateIncrement, IProgressMonitor monitor) {
- super(in);
- this.bytesTotal = bytesTotal;
- this.updateIncrement = updateIncrement;
- this.monitor = monitor;
- update(true);
- }
-
- protected abstract void updateMonitor(long bytesRead, long size, IProgressMonitor monitor);
-
- /**
- * Wraps the underlying stream's method.
- * Updates the progress monitor to the final number of bytes read.
- * @throws IOException if an i/o error occurs
- */
- public void close() throws IOException {
- try {
- in.close();
- } finally {
- update(true);
- }
- }
-
- /**
- * Wraps the underlying stream's method.
- * Updates the progress monitor if the next update increment has been reached.
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred will be zero
- * @throws IOException if an i/o error occurs
- */
- public int read() throws IOException {
- int b = in.read();
- if (b != -1) {
- bytesRead += 1;
- update(false);
- }
- return b;
- }
-
- /**
- * Wraps the underlying stream's method.
- * Updates the progress monitor if the next update increment has been reached.
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred may be non-zero
- * @throws IOException if an i/o error occurs
- */
- public int read(byte[] buffer, int offset, int length) throws IOException {
- try {
- int count = in.read(buffer, offset, length);
- if (count != -1) {
- bytesRead += count;
- update(false);
- }
- return count;
- } catch (InterruptedIOException e) {
- bytesRead += e.bytesTransferred;
- update(false);
- throw e;
- }
- }
-
- /**
- * Wraps the underlying stream's method.
- * Updates the progress monitor if the next update increment has been reached.
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred may be non-zero
- * @throws IOException if an i/o error occurs
- */
- public long skip(long amount) throws IOException {
- try {
- long count = in.skip(amount);
- bytesRead += count;
- update(false);
- return count;
- } catch (InterruptedIOException e) {
- bytesRead += e.bytesTransferred;
- update(false);
- throw e;
- }
- }
-
- /**
- * Mark is not supported by the wrapper even if the underlying stream does, returns false.
- */
- public boolean markSupported() {
- return false;
- }
-
- private void update(boolean now) {
- if (bytesRead >= nextUpdate || now) {
- nextUpdate = bytesRead - (bytesRead % updateIncrement);
- if (nextUpdate != lastUpdate) updateMonitor(nextUpdate, bytesTotal, monitor);
- lastUpdate = nextUpdate;
- nextUpdate += updateIncrement;
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/SizeConstrainedInputStream.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/SizeConstrainedInputStream.java
deleted file mode 100644
index 5cafd3047..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/SizeConstrainedInputStream.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * 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 implementation
- ******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.streams;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InterruptedIOException;
-
-import org.eclipse.core.runtime.OperationCanceledException;
-
-/**
- * Simulates a stream that represents only a portion of the underlying stream.
- * Will report EOF when this portion has been fully read and prevent further reads.
- * The underlying stream is not closed on close(), but the remaining unread input
- * may optionally be skip()'d.
- *
- * Supports resuming partially completed operations after an InterruptedIOException
- * if the underlying stream does. Check the bytesTransferred field to determine how
- * much of the operation completed; conversely, at what point to resume.
- */
-public class SizeConstrainedInputStream extends FilterInputStream {
- private boolean discardOnClose;
- private long bytesRemaining;
-
- /**
- * Creates a size contrained input stream.
- * @param in the underlying input stream, never actually closed by this filter
- * @param size the maximum number of bytes of the underlying input stream that
- * can be read through this filter
- * @param discardOnClose if true, discards remaining unread bytes on close()
- */
- public SizeConstrainedInputStream(InputStream in, long size, boolean discardOnClose) {
- super(in);
- this.bytesRemaining = size;
- this.discardOnClose = discardOnClose;
- }
-
- /**
- * Prevents further reading from the stream but does not close the underlying stream.
- * If discardOnClose, skip()'s over any remaining unread bytes in the constrained region.
- * @throws IOException if an i/o error occurs
- */
- public void close() throws IOException {
- try {
- if (discardOnClose) {
- while (bytesRemaining != 0 && skip(bytesRemaining) != 0);
- }
- } catch (OperationCanceledException e) {
- // The receiver is likely wrapping a PollingInputStream which could throw
- // an OperationCanceledException on a skip.
- // Since we're closing, just ignore the cancel and let the caller check the monitor
- } finally {
- bytesRemaining = 0;
- }
- }
-
- /**
- * Wraps the underlying stream's method.
- * Simulates an end-of-file condition if the end of the constrained region has been reached.
- * @throws IOException if an i/o error occurs
- */
- public int available() throws IOException {
- int amount = in.available();
- if (amount > bytesRemaining) amount = (int) bytesRemaining;
- return amount;
- }
-
- /**
- * Wraps the underlying stream's method.
- * Simulates an end-of-file condition if the end of the constrained region has been reached.
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred will be zero
- * @throws IOException if an i/o error occurs
- */
- public int read() throws IOException {
- if (bytesRemaining == 0) return -1;
- int b = in.read();
- if (b != -1) bytesRemaining -= 1;
- return b;
- }
-
- /**
- * Wraps the underlying stream's method.
- * Simulates an end-of-file condition if the end of the constrained region has been reached.
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred may be non-zero
- * @throws IOException if an i/o error occurs
- */
- public int read(byte[] buffer, int offset, int length) throws IOException {
- if (length > bytesRemaining) {
- if (bytesRemaining == 0) return -1;
- length = (int) bytesRemaining;
- }
- try {
- int count = in.read(buffer, offset, length);
- if (count != -1) bytesRemaining -= count;
- return count;
- } catch (InterruptedIOException e) {
- bytesRemaining -= e.bytesTransferred;
- throw e;
- }
- }
-
- /**
- * Wraps the underlying stream's method.
- * Simulates an end-of-file condition if the end of the constrained region has been reached.
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred may be non-zero
- * @throws IOException if an i/o error occurs
- */
- public long skip(long amount) throws IOException {
- if (amount > bytesRemaining) amount = bytesRemaining;
- try {
- long count = in.skip(amount);
- bytesRemaining -= count;
- return count;
- } catch (InterruptedIOException e) {
- bytesRemaining -= e.bytesTransferred;
- throw e;
- }
- }
-
- /**
- * Mark is not supported by the wrapper even if the underlying stream does, returns false.
- */
- public boolean markSupported() {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/TimeoutInputStream.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/TimeoutInputStream.java
deleted file mode 100644
index 744e50249..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/TimeoutInputStream.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * 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.streams;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InterruptedIOException;
-
-/**
- * Wraps an input stream that blocks indefinitely to simulate timeouts on read(),
- * skip(), and close(). The resulting input stream is buffered and supports
- * retrying operations that failed due to an InterruptedIOException.
- *
- * Supports resuming partially completed operations after an InterruptedIOException
- * REGARDLESS of whether the underlying stream does unless the underlying stream itself
- * generates InterruptedIOExceptions in which case it must also support resuming.
- * Check the bytesTransferred field to determine how much of the operation completed;
- * conversely, at what point to resume.
- */
-public class TimeoutInputStream extends FilterInputStream {
- private byte[] iobuffer; // circular buffer
- private int head = 0; // points to first unread byte
- private int length = 0; // number of remaining unread bytes
- private boolean eof = false; // if true, EOF encountered
- private boolean closeRequested = false; // if true, close requested
- private IOException ioe = null;
- private RuntimeException re = null;
-
- private long readTimeout; // read() timeout in millis
- private long closeTimeout; // close() timeout in millis, or -1
- private Thread thread;
-
- /**
- * Creates a timeout wrapper for an input stream.
- * @param in the underlying input stream
- * @param bufferSize the buffer size in bytes; should be large enough to mitigate
- * Thread synchronization and context switching overhead
- * @param readTimeout the number of milliseconds to block for a read() or skip() before
- * throwing an InterruptedIOException; 0 blocks indefinitely
- * @param closeTimeout the number of milliseconds to block for a close() before throwing
- * an InterruptedIOException; 0 blocks indefinitely, -1 closes the stream in the background
- */
- public TimeoutInputStream(InputStream in, int bufferSize, long readTimeout, long closeTimeout) {
- super(in);
- this.iobuffer = new byte[bufferSize];
- this.readTimeout = readTimeout;
- this.closeTimeout = closeTimeout;
- thread = new Thread(new FillBufferRunnable(), "TimeoutInputStream");//$NON-NLS-1$
- thread.setDaemon(true);
- thread.start();
- }
-
- /**
- * Wraps the underlying stream's method.
- * It may be important to wait for a stream to actually be closed because it
- * holds an implicit lock on a system resoure (such as a file) while it is
- * open. Closing a stream may take time if the underlying stream is still
- * servicing a previous request.
- * @throws InterruptedIOException if the timeout expired
- * @throws IOException if an i/o error occurs
- */
- public void close() throws IOException {
- Thread oldThread;
- synchronized (this) {
- if (thread == null) return;
- oldThread = thread;
- closeRequested = true;
- thread.interrupt();
- checkError();
- }
- if (closeTimeout == -1) return;
- try {
- oldThread.join(closeTimeout);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt(); // we weren't expecting to be interrupted
- }
- synchronized (this) {
- checkError();
- if (thread != null) throw new InterruptedIOException();
- }
- }
-
- /**
- * Returns the number of unread bytes in the buffer.
- * @throws IOException if an i/o error occurs
- */
- public synchronized int available() throws IOException {
- if (length == 0) checkError();
- return length > 0 ? length : 0;
- }
-
- /**
- * Reads a byte from the stream.
- * @throws InterruptedIOException if the timeout expired and no data was received,
- * bytesTransferred will be zero
- * @throws IOException if an i/o error occurs
- */
- public synchronized int read() throws IOException {
- if (length == 0) checkError();
- syncFill();
- if (length == 0) {
- checkError();
- if (eof) return -1;
- throw new InterruptedIOException();
- }
- int b = iobuffer[head++] & 255;
- if (head == iobuffer.length) head = 0;
- length--;
- asyncFill();
- return b;
- }
-
- /**
- * Reads multiple bytes from the stream.
- * @throws InterruptedIOException if the timeout expired and no data was received,
- * bytesTransferred will be zero
- * @throws IOException if an i/o error occurs
- */
- public synchronized int read(byte[] buffer, int off, int len) throws IOException {
- if (length == 0) checkError();
- syncFill();
- if (length == 0) {
- checkError();
- if (eof) return -1;
- throw new InterruptedIOException();
- }
- int pos = off;
- if (len > length) len = length;
- while (len-- > 0) {
- buffer[pos++] = iobuffer[head++];
- if (head == iobuffer.length) head = 0;
- length--;
- }
- asyncFill();
- return pos - off;
- }
-
- /**
- * Skips multiple bytes in the stream.
- * @throws InterruptedIOException if the timeout expired before all of the
- * bytes specified have been skipped, bytesTransferred may be non-zero
- * @throws IOException if an i/o error occurs
- */
- public synchronized long skip(long count) throws IOException {
- if (length == 0) checkError();
- long amount = 0;
- try {
- while (count != 0) {
- int skip = (count > length) ? length : (int) count;
- head = (head + skip) % iobuffer.length;
- length -= skip;
- amount += skip;
- count -= skip;
- syncFill();
- if (length == 0) {
- checkError();
- if (eof) break;
- throw new InterruptedIOException();
- }
- }
- asyncFill();
- return amount;
- } catch (InterruptedIOException e) {
- e.bytesTransferred = (int) amount; // assumes amount < Integer.MAX_INT
- throw e;
- }
- }
-
- /**
- * Mark is not supported by the wrapper even if the underlying stream does, returns false.
- */
- public boolean markSupported() {
- return false;
- }
-
- /*
- * Waits for the buffer to fill if it is empty and the stream has not reached EOF.
- * The buffer might still be empty when this method returns if the operation timed out
- * or EOF was encountered.
- */
- private void syncFill() throws IOException {
- if (length != 0 || eof) return;
- notify();
- try {
- wait(readTimeout);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt(); // we weren't expecting to be interrupted
- }
- }
-
- /*
- * Notifies the background thread that some bytes were read so that it can fill the buffer
- * asynchronously in the background.
- */
- private void asyncFill() {
- if ((length != iobuffer.length && ! eof) || closeRequested) notify();
- }
-
- /*
- * Checks if exceptions are pending and throws the next one, if any.
- */
- private void checkError() throws IOException {
- if (ioe != null) {
- IOException e = ioe;
- ioe = null;
- throw e;
- }
- if (re != null) {
- RuntimeException e = re;
- re = null;
- throw e;
- }
- }
-
- private class FillBufferRunnable implements Runnable {
- private final Object lock = TimeoutInputStream.this;
-
- public void run() {
- try {
- readUntilDone();
- waitUntilClosed();
- } catch (IOException e) {
- synchronized (lock) { ioe = e; }
- waitUntilClosed();
- } catch (RuntimeException e) {
- synchronized (lock) { re = e; }
- waitUntilClosed();
- } finally {
- /*** Closes the stream and sets thread to null when done ***/
- try {
- in.close();
- } catch (IOException e) {
- synchronized (lock) { ioe = e; }
- } catch (RuntimeException e) {
- synchronized (lock) { re = e; }
- } finally {
- synchronized (lock) {
- eof = true;
- thread = null;
- lock.notify();
- }
- }
- }
- }
-
- /**
- * Reads bytes into the buffer until EOF, closed, or error.
- */
- private void readUntilDone() throws IOException {
- boolean pause = false;
- for (;;) {
- int off, len;
- synchronized (lock) {
- for (;;) {
- if (closeRequested || eof) return; // quit signal
- if (length != iobuffer.length && ! pause) break;
- pause = false;
- try {
- lock.wait();
- } catch (InterruptedException e) {
- closeRequested = true; // alternate quit signal
- }
- }
- off = (head + length) % iobuffer.length;
- len = ((head > off) ? head : iobuffer.length) - off;
- }
- int count;
- try {
- // the i/o operation might block without releasing the lock,
- // so we do this outside of the synchronized block
- count = in.read(iobuffer, off, len);
- } catch (InterruptedIOException e) {
- // keep partial transfer
- count = e.bytesTransferred;
- e.bytesTransferred = 0;
- synchronized (lock) { ioe = e; }
- }
- synchronized (lock) {
- if (count == -1) return;
- if (count == 0) pause = true;
- length += count;
- lock.notify();
- }
- }
- }
-
- /**
- * Waits until we have been requested to close the stream.
- */
- private void waitUntilClosed() {
- synchronized (lock) {
- eof = true;
- lock.notify();
- while (! closeRequested) {
- try {
- lock.wait();
- } catch (InterruptedException e) {
- closeRequested = true; // alternate quit signal
- }
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/TimeoutOutputStream.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/TimeoutOutputStream.java
deleted file mode 100644
index cb749d4c6..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/streams/TimeoutOutputStream.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * 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.streams;
-
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.io.OutputStream;
-
-import org.eclipse.team.internal.ccvs.core.Policy;
-
-/**
- * Wraps an output stream that blocks indefinitely to simulate timeouts on write(),
- * flush(), and close(). The resulting output stream is buffered and supports
- * retrying operations that failed due to an InterruptedIOException.
- *
- * Supports resuming partially completed operations after an InterruptedIOException
- * REGARDLESS of whether the underlying stream does unless the underlying stream itself
- * generates InterruptedIOExceptions in which case it must also support resuming.
- * Check the bytesTransferred field to determine how much of the operation completed;
- * conversely, at what point to resume.
- */
-public class TimeoutOutputStream extends FilterOutputStream {
- private byte[] iobuffer; // circular buffer
- private int head = 0; // points to first unwritten byte
- private int length = 0; // number of remaining unwritten bytes
- private boolean cannotWrite = false; // if true, writes will not be honoured
- private boolean closeRequested = false; // if true, close requested
- private boolean flushRequested = false; // if true, flush requested
- private IOException ioe = null;
- private RuntimeException re = null;
-
- private long writeTimeout; // write() timeout in millis
- private long closeTimeout; // close() timeout in millis, or -1
- private Thread thread;
-
- /**
- * Creates a timeout wrapper for an output stream.
- * @param out the underlying input stream
- * @param bufferSize the buffer size in bytes; should be large enough to mitigate
- * Thread synchronization and context switching overhead
- * @param writeTimeout the number of milliseconds to block for a write() or flush() before
- * throwing an InterruptedIOException; 0 blocks indefinitely
- * @param closeTimeout the number of milliseconds to block for a close() before throwing
- * an InterruptedIOException; 0 blocks indefinitely, -1 closes the stream in the background
- */
- public TimeoutOutputStream(OutputStream out, int bufferSize, long writeTimeout, long closeTimeout) {
- super(out);
- this.iobuffer = new byte[bufferSize];
- this.writeTimeout = writeTimeout;
- this.closeTimeout = closeTimeout;
- thread = new Thread(new CommitBufferRunnable(), "TimeoutOutputStream");//$NON-NLS-1$
- thread.setDaemon(true);
- thread.start();
- }
-
- /**
- * Wraps the underlying stream's method.
- * It may be important to wait for a stream to actually be closed because it
- * holds an implicit lock on a system resoure (such as a file) while it is
- * open. Closing a stream may take time if the underlying stream is still
- * servicing a previous request.
- * @throws InterruptedIOException if the timeout expired, bytesTransferred will
- * reflect the number of bytes flushed from the buffer
- * @throws IOException if an i/o error occurs
- */
- public void close() throws IOException {
- Thread oldThread;
- synchronized (this) {
- if (thread == null) return;
- oldThread = thread;
- closeRequested = true;
- flushRequested = true;
- thread.interrupt();
- checkError();
- }
- if (closeTimeout == -1) return;
- try {
- oldThread.join(closeTimeout);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt(); // we weren't expecting to be interrupted
- }
- synchronized (this) {
- checkError();
- if (thread != null) throw new InterruptedIOException();
- }
- }
-
- /**
- * Writes a byte to the stream.
- * @throws InterruptedIOException if the timeout expired and no data was sent,
- * bytesTransferred will be zero
- * @throws IOException if an i/o error occurs
- */
- public synchronized void write(int b) throws IOException {
- if (cannotWrite) throw new IOException(Policy.bind("TimeoutOutputStream.cannotWriteToStream")); //$NON-NLS-1$
- checkError();
- if (length == iobuffer.length) {
- syncCommit();
- if (length == iobuffer.length) throw new InterruptedIOException();
- }
- iobuffer[(head + length) % iobuffer.length] = (byte) b;
- length++;
- asyncCommit();
- }
-
- /**
- * Writes multiple bytes to the stream.
- * @throws InterruptedIOException if the timeout expired, bytesTransferred will
- * reflect the number of bytes sent
- * @throws IOException if an i/o error occurs
- */
- public synchronized void write(byte[] buffer, int off, int len) throws IOException {
- if (cannotWrite) throw new IOException(Policy.bind("TimeoutOutputStream.cannotWriteToStream")); //$NON-NLS-1$
- checkError();
- int amount = 0;
- try {
- while (len-- > 0) {
- if (length == iobuffer.length) {
- syncCommit();
- if (length == iobuffer.length) throw new InterruptedIOException();
- }
- iobuffer[(head + length) % iobuffer.length] = buffer[off++];
- length++;
- amount++;
- }
- } catch (InterruptedIOException e) {
- e.bytesTransferred = amount;
- throw e;
- }
- asyncCommit();
- }
-
- /**
- * Flushes the stream.
- * @throws InterruptedIOException if the timeout expired, bytesTransferred will
- * reflect the number of bytes flushed from the buffer
- * @throws IOException if an i/o error occurs
- */
- public synchronized void flush() throws IOException {
- if (cannotWrite) throw new IOException(Policy.bind("TimeoutOutputStream.cannotWriteToStream")); //$NON-NLS-1$
- checkError();
- flushRequested = true;
- int amount = 0;
- try {
- while (flushRequested && length != 0) {
- int oldLength = length;
- syncCommit();
- amount += oldLength - length;
- if (length == oldLength) throw new InterruptedIOException();
- }
- } catch (InterruptedIOException e) {
- e.bytesTransferred = amount;
- throw e;
- }
- asyncCommit();
- }
-
- /*
- * Waits for the buffer to drain.
- * The buffer might still be at the same level when this method returns if the operation timed out.
- */
- private void syncCommit() throws IOException {
- notify();
- try {
- wait(writeTimeout);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt(); // we weren't expecting to be interrupted
- }
- checkError();
- if (cannotWrite) throw new IOException(Policy.bind("TimeoutOutputStream.cannotWriteToStream")); //$NON-NLS-1$
- }
-
- /*
- * Notifies the background thread that some bytes were written so that it can drain the buffer
- * asynchronously in the background.
- */
- private void asyncCommit() throws IOException {
- if (length != 0 || flushRequested || closeRequested) notify();
- }
-
- /*
- * Checks if exceptions are pending and throws the next one, if any.
- */
- private void checkError() throws IOException {
- if (ioe != null) {
- IOException e = ioe;
- ioe = null;
- throw e;
- }
- if (re != null) {
- RuntimeException e = re;
- re = null;
- throw e;
- }
- }
-
- private class CommitBufferRunnable implements Runnable {
- private final Object lock = TimeoutOutputStream.this;
-
- public void run() {
- try {
- writeUntilDone();
- waitUntilClosed();
- } catch (IOException e) {
- synchronized (lock) { ioe = e; }
- waitUntilClosed();
- } catch (RuntimeException e) {
- synchronized (lock) { re = e; }
- waitUntilClosed();
- } finally {
- /*** Closes the stream and sets thread to null when done ***/
- try {
- out.close();
- } catch (IOException e) {
- synchronized (lock) { ioe = e; }
- } catch (RuntimeException e) {
- synchronized (lock) { re = e; }
- } finally {
- synchronized (lock) {
- cannotWrite = true;
- thread = null;
- lock.notify();
- }
- }
- }
- }
-
- /**
- * Writes bytes from the buffer until closed and buffer is empty
- */
- private void writeUntilDone() throws IOException {
- boolean pause = false;
- boolean mustFlush = false;
- for (;;) {
- int off, len;
- synchronized (lock) {
- for (;;) {
- if (closeRequested && length == 0) return; // quit signal
- if ((mustFlush || flushRequested || length != 0) && ! pause) break;
- pause = false;
- try {
- lock.wait();
- } catch (InterruptedException e) {
- closeRequested = true; // alternate quit signal
- }
- }
- off = head;
- len = iobuffer.length - head;
- if (len > length) len = length;
- if (flushRequested) {
- mustFlush = true;
- flushRequested = false;
- }
- }
- if (len != 0) {
- try {
- // the i/o operation might block without releasing the lock,
- // so we do this outside of the synchronized block
- out.write(iobuffer, off, len);
- } catch (InterruptedIOException e) {
- len = e.bytesTransferred;
- e.bytesTransferred = 0;
- if (len == 0) pause = true;
- synchronized (lock) { ioe = e; }
- }
- synchronized (lock) {
- head = (head + len) % iobuffer.length;
- length -= len;
- lock.notify();
- }
- } else {
- try {
- out.flush();
- mustFlush = false;
- } catch (InterruptedIOException e) {
- if (e.bytesTransferred == 0) pause = true;
- e.bytesTransferred = 0;
- synchronized (lock) { ioe = e; }
- }
- synchronized (lock) {
- lock.notify();
- }
- }
- }
- }
-
- /**
- * Waits until we have been requested to close the stream.
- */
- private void waitUntilClosed() {
- synchronized (lock) {
- cannotWrite = true;
- lock.notify();
- while (! closeRequested) {
- try {
- lock.wait();
- } catch (InterruptedException e) {
- closeRequested = true; // alternate quit signal
- }
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java
deleted file mode 100644
index f5a1199db..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java
+++ /dev/null
@@ -1,184 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.resources.*;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-import org.eclipse.team.internal.ccvs.core.Policy;
-
-/**
- * Value (immutable) object that represents workspace state information about the contents of a
- * folder that was retreived from a CVS repository. It is a specialized representation of the files from
- * the CVS sub-directory that contain folder specific connection information (e.g. Root, Repository, Tag).
- *
- * @see ICVSFolder#getFolderSyncInfo()
- */
-public class FolderSyncInfo {
-
- // The Repository value for virtual directories (i.e. local with no corresponding remote)
- public static final String VIRTUAL_DIRECTORY = "CVSROOT/Emptydir"; //$NON-NLS-1$
-
- // relative path of this folder in the repository, project1/folder1/folder2
- private String repository;
-
- // :pserver:user@host:/home/user/repo
- private String root;
-
- // sticky tag (e.g. version, date, or branch tag applied to folder)
- private CVSEntryLineTag tag;
-
- // if true then it means only part of the folder was fetched from the repository, and CVS will not create
- // additional files in that folder.
- private boolean isStatic;
-
- /**
- * Construct a folder sync object.
- *
- * @param repo the relative path of this folder in the repository, cannot be <code>null</code>.
- * @param root the location of the repository, cannot be <code>null</code>.
- * @param tag the tag set for the folder or <code>null</code> if there is no tag applied.
- * @param isStatic to indicate is only part of the folder was fetched from the server.
- */
- public FolderSyncInfo(String repo, String root, CVSTag tag, boolean isStatic) {
- Assert.isNotNull(repo);
- Assert.isNotNull(root);
- this.repository = repo;
- this.root = root;
- this.isStatic = isStatic;
- if(tag != null) {
- this.tag = new CVSEntryLineTag(tag);
- }
- }
-
- public boolean equals(Object other) {
- if(other == this) return true;
- if (!(other instanceof FolderSyncInfo)) return false;
-
- FolderSyncInfo syncInfo = ((FolderSyncInfo)other);
- if (!getRoot().equals(syncInfo.getRoot())) return false;
- if (!getRepository().equals(syncInfo.getRepository())) return false;
- if (getIsStatic() != syncInfo.getIsStatic()) return false;
- if ((getTag() == null) || (syncInfo.getTag() == null)) {
- if ((getTag() == null) && (syncInfo.getTag() != null) && (syncInfo.getTag().getType() != CVSTag.HEAD)) {
- return false;
- } else if ((syncInfo.getTag() == null) && (getTag() != null) && (getTag().getType() != CVSTag.HEAD)) {
- return false;
- }
- } else if (!getTag().equals(syncInfo.getTag())) {
- return false;
- }
- return true;
- }
- /**
- * Gets the root, cannot be <code>null.
- *
- * @return Returns a String
- */
- public String getRoot() {
- return root;
- }
-
- /**
- * Gets the tag, may be <code>null</code>.
- *
- * @return Returns a String
- */
- public CVSEntryLineTag getTag() {
- return tag;
- }
-
- /**
- * Gets the repository, may be <code>null</code>.
- *
- * @return Returns a String
- */
- public String getRepository() {
- return repository;
- }
-
- /**
- * Gets the isStatic.
- *
- * @return Returns a boolean
- */
- public boolean getIsStatic() {
- return isStatic;
- }
-
- /**
- * Answers a full path to the folder on the remote server. This by appending the repository to the
- * repository location speficied in the root.
- *
- * Example:
- * root = :pserver:user@host:/home/user/repo
- * repository = folder1/folder2
- *
- * Returns:
- * /home/users/repo/folder1/folder2
- *
- * Note: CVS supports repository root directories that end in a slash (/).
- * For these directories, the remote location must contain two slashes (//)
- * between the root directory and the rest of the path. For example:
- * root = :pserver:user@host:/home/user/repo/
- * repository = folder1/folder2
- * must return:
- * /home/users/repo//folder1/folder2
- *
- * @return the full path of this folder on the server.
- * @throws a CVSException if the root or repository is malformed.
- */
- public String getRemoteLocation() throws CVSException {
-
- String result;
-
- try {
- String root = getRoot();
- int index = root.indexOf('@');
- if (index == -1) {
- // If the username is mising, we have to find the third ':' instead.
- index = root.indexOf(':');
- index = root.indexOf(':', index + 1);
- index = root.indexOf(':', index + 1);
- }
- result = getRoot().substring(index+1);
- result = result.substring(result.indexOf(":")+1); //$NON-NLS-1$
- result = result + "/" + getRepository(); //$NON-NLS-1$
- } catch (IndexOutOfBoundsException e) {
- throw new CVSException(Policy.bind("FolderSyncInfo_Maleformed_root_4")); //$NON-NLS-1$
- }
-
- return result;
- }
-
- /*
- * Provide a hashCode() method that gaurentees that equal object will have the
- * same hashCode
- */
- public int hashCode() {
- return getRoot().hashCode() | getRepository().hashCode();
- }
-
- /**
- * Sets the tag for the folder.
- *
- * @param tag The tag to set
- */
- private void setTag(CVSTag tag) {
- if (tag == null) {
- this.tag = null;
- } else {
- this.tag = new CVSEntryLineTag(tag);
- }
- }
- /*
- * @see Object#toString()
- */
- public String toString() {
- return getRoot() + "/" + getRepository() + "/" + getTag(); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableResourceSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableResourceSyncInfo.java
deleted file mode 100644
index fb47bdbb5..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableResourceSyncInfo.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * 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.syncinfo;
-
-import java.util.Date;
-
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-
-/**
- * Mutable version of ResourceSyncInfo. Can be used when either creating a resource sync
- * object from scratch (e.g. without an entry line) or want to modify an existing
- * <code>ResourceSyncInfo</code> instance. Example usage:
- * <pre>
- * ResourceSyncInfo info = resource.getSyncInfo();
- * if(info!=null) {
- * MutableResourceSyncInfo newInfo = info.cloneMutable();
- * newInfo.setRevision("1.22");
- * resource.setSyncInfo(newInfo);
- * }
- * </pre>
- * @see ResourceSyncInfo
- */
-public class MutableResourceSyncInfo extends ResourceSyncInfo {
-
- protected MutableResourceSyncInfo(ResourceSyncInfo info) {
- this.name = info.getName();
- setRevision(info.getRevision());
- setTag(info.getTag());
- this.permissions = info.getPermissions();
- this.timeStamp = info.getTimeStamp();
- this.isDirectory = info.isDirectory();
- this.keywordMode = info.getKeywordMode();
- this.isDeleted = info.isDeleted();
- if(info.isMergedWithConflicts()) {
- setSyncType(TYPE_MERGED_WITH_CONFLICTS);
- } else if(info.isMerged()) {
- setSyncType(TYPE_MERGED);
- } else {
- setSyncType(TYPE_REGULAR);
- }
- }
-
- /**
- * Creates a default sync info, if revision is <code>null</code> then
- * the sync info will be considered in the newly added state.
- */
- public MutableResourceSyncInfo(String name, String revision) {
- Assert.isNotNull(name);
- this.name = name;
- setRevision(revision);
- }
-
- void setResourceInfoType(int type) {
- this.syncType = type;
- }
-
- /**
- * Sets the revision.
- * @param revision The revision to set
- */
- public void setRevision(String revision) {
- super.setRevision(revision);
- }
-
- /**
- * Sets the timeStamp.
- * @param timeStamp The timeStamp to set
- */
- public void setTimeStamp(Date timeStamp) {
- this.timeStamp = timeStamp;
- }
-
- /**
- * Sets the keywordMode.
- * @param keywordMode The keywordMode to set
- */
- public void setKeywordMode(KSubstOption keywordMode) {
- this.keywordMode = keywordMode;
- }
-
- /**
- * Sets the tag.
- * @param tag The tag to set
- */
- public void setTag(CVSTag tag) {
- super.setTag(tag);
- }
-
- /**
- * Sets the permissions.
- * @param permissions The permissions to set
- */
- public void setPermissions(String permissions) {
- this.permissions = permissions;
- }
-
- /**
- * Sets the deleted state.
- * @param isDeleted The deleted state of this resource sync
- */
- public void setDeleted(boolean isDeleted) {
- this.isDeleted = isDeleted;
- }
-
- /**
- * Sets to the added state. The timestamp and other are cleared.
- */
- public void setAdded() {
- setRevision(ADDED_REVISION);
- }
-
- /**
- * Sets that this resource sync is a result of a non-conflicting merge
- */
- public void setMerged() {
- // if already merged state then ignore
- if(syncType==TYPE_REGULAR) {
- this.syncType = TYPE_MERGED;
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ReentrantLock.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ReentrantLock.java
deleted file mode 100644
index 7e33d893f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ReentrantLock.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * 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 implementation
- ******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-
-/**
- * Provides a per-thread nested locking mechanism. A thread can acquire a
- * lock and then call acquire() multiple times. Other threads that try
- * and acquire the lock will be blocked until the first thread releases all
- * it's nested locks.
- */
-public class ReentrantLock {
-
- private final static boolean DEBUG = Policy.DEBUG_THREADING;
- private Thread thread;
- private int nestingCount;
-
- public ReentrantLock() {
- this.thread = null;
- this.nestingCount = 0;
- }
-
- public synchronized void acquire() {
- // stop early if we've been interrupted -- don't enter the lock anew
- Thread thisThread = Thread.currentThread();
-
- // race for access to the lock -- does not guarantee fairness
- if (thread != thisThread) {
- while (nestingCount != 0) {
- try {
- if(DEBUG) System.out.println("["+ thisThread.getName() + "] waiting for CVS synchronizer lock"); //$NON-NLS-1$ //$NON-NLS-2$
- wait();
- } catch(InterruptedException e) {
- // keep waiting for the lock
- if(DEBUG) System.out.println("["+ thisThread.getName() + "] interrupted in CVS synchronizer lock"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- thread = thisThread;
- if(DEBUG) System.out.println("[" + thisThread.getName() + "] acquired CVS synchronizer lock"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- nestingCount++;
- }
-
- public synchronized void release() {
- Thread thisThread = Thread.currentThread();
- Assert.isLegal(thread == thisThread,
- "Thread attempted to release a lock it did not own"); //$NON-NLS-1$
- if (--nestingCount == 0) {
- if(DEBUG) System.out.println("[" + thread.getName() + "] released CVS synchronizer lock"); //$NON-NLS-1$ //$NON-NLS-2$
- thread = null;
- notifyAll();
- }
- }
-
- public int getNestingCount() {
- Thread thisThread = Thread.currentThread();
- Assert.isLegal(thread == thisThread,
- "Thread attempted to read nesting count of a lock it did not own"); //$NON-NLS-1$
- return nestingCount;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java
deleted file mode 100644
index 8a1b46801..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java
+++ /dev/null
@@ -1,502 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.text.ParseException;
-import java.util.Date;
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-import org.eclipse.team.internal.ccvs.core.util.CVSDateFormatter;
-import org.eclipse.team.internal.ccvs.core.util.EmptyTokenizer;
-
-/**
- * Value (immutable) object that represents workspace state information about a resource contained in
- * a CVS repository. It is a specialized representation of a line in the CVS/Entry file with the addition of
- * file permissions.
- * <p>
- * ResourceSyncInfo instances are created from entry lines from the CVS server and from the CVS/Entries
- * file. Although both entry lines have slightly different formats (e.g. timestamps) they can safely be passed
- * to the constructor.</p>
- * <p>
- * A class named <code>MutableResourceSyncInfo</code> can be used to modify an existing resource
- * sync or create sync info without an entry line.</p>
- *
- * Example entry line from the CVS/Entry file:
- *
- * /new.java/1.2/Fri Dec 7 00:17:52 2001/-kb/
- * D/src////
- *
- * @see MutableResourceSyncInfo
- * @see ICVSResource#getSyncInfo()
- */
-public class ResourceSyncInfo {
-
- // [Note: permissions aren't honoured in this current implementation]
- // safe default permissions. Permissions are saved separatly so that the correct permissions
- // can be sent back to the server on systems that don't save execute bits (e.g. windows).
- private static final String DEFAULT_PERMISSIONS = "u=rw,g=rw,o=r"; //$NON-NLS-1$
-
- // file sync information can be associated with a local resource that has been deleted. This is
- // noted by prefixing the revision with this character.
- private static final String DELETED_PREFIX = "-"; //$NON-NLS-1$
-
- // a sync element with a revision of '0' is considered a new file that has
- // not been comitted to the repo. Is visible so that clients can create sync infos
- // for new files.
- protected static final String ADDED_REVISION = "0"; //$NON-NLS-1$
-
- // Timestamp constants used to identify special cases
- protected static final int TYPE_REGULAR = 1;
- protected static final int TYPE_MERGED = 2;
- protected static final int TYPE_MERGED_WITH_CONFLICTS = 3;
-
- protected static final String TIMESTAMP_DUMMY = "dummy timestamp"; //$NON-NLS-1$
- protected static final String TIMESTAMP_MERGED = "Result of merge"; //$NON-NLS-1$
- protected static final String TIMESTAMP_MERGED_WITH_CONFLICT = TIMESTAMP_MERGED + "+"; //$NON-NLS-1$
-
- protected static final String TIMESTAMP_SERVER_MERGED = "+modified"; //$NON-NLS-1$
- protected static final String TIMESTAMP_SERVER_MERGED_WITH_CONFLICT = "+="; //$NON-NLS-1$
-
- // a directory sync info will have nothing more than a name
- protected boolean isDirectory = false;
- protected boolean isDeleted = false;
-
- // utility constants
- protected static final String DIRECTORY_PREFIX = "D/"; //$NON-NLS-1$
- protected static final String SEPERATOR = "/"; //$NON-NLS-1$
-
- // fields describing the synchronization of a resource in CVS parlance
- protected String name;
- protected String revision;
- protected Date timeStamp;
- protected KSubstOption keywordMode;
- protected CVSEntryLineTag tag;
- protected String permissions;
-
- // type of sync
- protected int syncType = TYPE_REGULAR;
- protected ResourceSyncInfo() {
- }
-
- /**
- * Constructor to create a sync object from entry line formats. The entry lines are parsed by this class.
- * The constructor can handle parsing entry lines from the server or from an entry file.
- *
- * @param entryLine the entry line (e.g. /new.java/1.2/Fri Dec 07 00:17:52 2001/-kb/)
- * @param permissions the file permission (e.g. u=rw,g=rw,o=r). May be <code>null</code>.
- * @param timestamp if not included in the entry line. May be <code>null</code>.
- *
- * @exception CVSException is thrown if the entry cannot be parsed.
- */
- public ResourceSyncInfo(String entryLine, String permissions, Date timestamp) throws CVSException {
- Assert.isNotNull(entryLine);
- setEntryLine(entryLine);
-
- if (permissions != null) {
- this.permissions = permissions;
- }
- // override the timestamp that may of been in entryLine. In some cases the timestamp is not in the
- // entry line (e.g. receiving entry lines from the server versus reading them from the Entry file).
- if(timestamp!=null) {
- this.timeStamp = timestamp;
- }
- }
-
- /**
- * Constructor to create a resource sync object for a folder.
- *
- * @param name of the resource for which this sync state is associatied, cannot be <code>null</code>.
- */
- public ResourceSyncInfo(String name) {
- Assert.isNotNull(name);
- this.name = name;
- this.isDirectory = true;
- }
- /**
- * Answers if this sync information is for a folder in which case only a name is
- * available.
- *
- * @return <code>true</code> if the sync information is for a folder and <code>false</code>
- * if it is for a file.
- */
- public boolean isDirectory() {
- return isDirectory;
- }
-
- /**
- * Answers if this sync information is for a resource that has been merged by the cvs server with
- * conflicts and has not been modified yet relative to the given timestamp.
- *
- * @param otherTimestamp is the timestamp of the file associated with this resource sync
- * @return <code>true</code> if the sync information is for a file that has been merged and
- * <code>false</code> for folders and for files that have not been merged.
- */
- public boolean isNeedsMerge(Date otherTimestamp) {
- return syncType == TYPE_MERGED_WITH_CONFLICTS && timeStamp.equals(otherTimestamp);
- }
-
- /**
- * Answers if this sync information is for a resource that has been merged with conflicts by the
- * cvs server.
- *
- * @return <code>true</code> if the sync information is for a file that has been merged and
- * <code>false</code> for folders and for files that have not been merged.
- */
- public boolean isMergedWithConflicts() {
- return syncType == TYPE_MERGED_WITH_CONFLICTS;
- }
-
- /**
- * Answers if this sync information is for a resource that has been merged by the cvs server.
- *
- * @return <code>true</code> if the sync information is for a file that has been merged and
- * <code>false</code> for folders and for files that have not been merged.
- */
- public boolean isMerged() {
- return syncType == TYPE_MERGED || isMergedWithConflicts();
- }
-
- /**
- * Answers if this sync information is for a file that has been added but not comitted
- * to the CVS repository yet.
- *
- * @return <code>true</code> if the sync information is new or <code>false</code> if
- * the sync is for an file that exists remotely. For folder sync info this returns
- * <code>false</code>.
- */
- public boolean isAdded() {
- if(!isDirectory) {
- return getRevision().equals(ADDED_REVISION);
- } else {
- return false;
- }
- }
-
- /**
- * Answers if this sync information is for a file that is scheduled to be deleted
- * from the repository but the deletion has not yet been comitted.
- *
- * @return <code>true</code> if the sync information is deleted or <code>false</code> if
- * the sync is for an file that exists remotely.
- */
- public boolean isDeleted() {
- return isDeleted;
- }
-
- /**
- * Returns an entry line that can be saved in the CVS/Entries file. For sending entry lines to the
- * server use <code>getServerEntryLine</code>.
- *
- * @return a file or folder entry line reflecting the state of this sync object.
- */
- public String getEntryLine() {
- return getEntryLine(true /*include timestamps*/, null /*no timestamp override*/);
- }
-
- /**
- * Same as <code>getEntryLine</code> except it considers merged files in entry line timestamp format.
- * This is only valid for sending the file to the server.
- *
- * @param fileTimestamp is timestamp of the resource associated with this sync info.
- * @return a file or folder entry line reflecting the state of this sync object.
- */
- public String getServerEntryLine(Date fileTimestamp) {
- String serverTimestamp;
- if(fileTimestamp != null && (isMerged() || isMergedWithConflicts())) {
- if(isNeedsMerge(fileTimestamp)) {
- serverTimestamp = TIMESTAMP_SERVER_MERGED_WITH_CONFLICT;
- } else {
- serverTimestamp = TIMESTAMP_SERVER_MERGED;
- }
- return getEntryLine(true, serverTimestamp);
- } else {
- return getEntryLine(false, null);
- }
- }
-
- /**
- * Anwsers a compatible permissions line for files.
- *
- * @return a permission line for files and <code>null</code> if this sync object is
- * a directory.
- */
- public String getPermissionLine() {
- if(isDirectory) {
- return null;
- } else {
- String permissions = this.permissions;
- if (permissions == null)
- permissions = DEFAULT_PERMISSIONS;
- return SEPERATOR + name + SEPERATOR + permissions;
- }
- }
-
- /**
- * Gets the permissions. Returns <code>null</code> for directories and
- * a non-null permission for files.
- *
- * @return a string of the format "u=rw,g=rw,o=r"
- */
- public String getPermissions() {
- if(isDirectory) {
- return null;
- } else {
- if(permissions==null) {
- return DEFAULT_PERMISSIONS;
- } else {
- return permissions;
- }
- }
- }
- /**
- * Gets the tag or <code>null</code> if a tag is not available.
- *
- * @return Returns a String
- */
- public CVSTag getTag() {
- return tag;
- }
- /**
- * Gets the timeStamp or <code>null</code> if a timestamp is not available.
- *
- * @return a date instance representing the timestamp
- */
- public Date getTimeStamp() {
- return timeStamp;
- }
- /**
- * Gets the version or <code>null</code> if this is a folder sync info. The returned
- * revision will never include the DELETED_PREFIX. To found out if this sync info is
- * for a deleted resource call isDeleted().
- *
- * @return Returns a String
- */
- public String getRevision() {
- return revision;
- }
-
- /**
- * Gets the name.
- *
- * @return Returns a String
- */
- public String getName() {
- return name;
- }
- /**
- * Gets the keyword mode.
- * @return the keyword substitution option
- */
- public KSubstOption getKeywordMode() {
- return keywordMode;
- }
-
- /**
- * Answers the default permissions string.
- */
- public static String getDefaultPermissions() {
- return DEFAULT_PERMISSIONS;
- }
-
- /**
- * Name equality between resource sync info objects.
- */
- public boolean equals(Object other) {
- if(other instanceof ResourceSyncInfo) {
- ResourceSyncInfo syncInfo = ((ResourceSyncInfo)other);
- if(other == this) return true;
- if(getName() == syncInfo.getName()) return true;
- return getName().equals(syncInfo.getName());
- } else {
- return false;
- }
- }
-
- public int hashCode() {
- return getName().hashCode();
- }
-
- /*
- * @see Object#toString()
- */
- public String toString() {
- return getEntryLine(true, null /*no timestamp override*/);
- }
- public MutableResourceSyncInfo cloneMutable() {
- MutableResourceSyncInfo newSync = new MutableResourceSyncInfo(this);
- return newSync;
- }
- /**
- * Sets the tag for the resource.
- */
- protected void setTag(CVSTag tag) {
- if(tag!=null) {
- this.tag = new CVSEntryLineTag(tag);
- } else {
- this.tag = null;
- }
- }
-
-
- /*
- * Sets the sync type
- */
- protected void setSyncType(int syncType) {
- this.syncType = syncType;
- }
- /**
- * Sets the version and decides if the revision is for a deleted resource the revision field
- * will not include the deleted prefix '-'.
- *
- * @param version the version to set
- */
- protected void setRevision(String revision) {
- if(revision==null || revision.equals(ADDED_REVISION)) {
- this.revision = ADDED_REVISION;
- timeStamp = null;
- syncType = TYPE_REGULAR;
- isDeleted = false;
- } else if(revision.startsWith(DELETED_PREFIX)) {
- this.revision = revision.substring(DELETED_PREFIX.length());
- isDeleted = true;
- } else {
- this.revision = revision;
- isDeleted = false;
- }
- }
-
- /**
- * Set the entry line
- *
- * @throws CVSException if the entryLine is malformed
- */
- private void setEntryLine(String entryLine) throws CVSException {
- if(entryLine.startsWith(DIRECTORY_PREFIX)) {
- isDirectory = true;
- entryLine = entryLine.substring(1);
- } else {
- isDirectory = false;
- }
- EmptyTokenizer tokenizer = new EmptyTokenizer(entryLine,SEPERATOR);
- if(tokenizer.countTokens() != 5) {
- throw new CVSException(Policy.bind("Malformed_entry_line___11") + entryLine); //$NON-NLS-1$
- }
-
- name = tokenizer.nextToken();
-
- if(name.length()==0) {
- throw new CVSException(Policy.bind("Malformed_entry_line,_missing_name___12") + entryLine); //$NON-NLS-1$
- }
-
- String rev = tokenizer.nextToken();
-
- if(rev.length()==0 && !isDirectory()) {
- throw new CVSException(Policy.bind("Malformed_entry_line,_missing_revision___13") + entryLine); //$NON-NLS-1$
- } else {
- setRevision(rev);
- }
-
- String date = tokenizer.nextToken();
-
- // possible timestamps are:
- // from server: "+=" and "+modified"
- // from entry line: "Result of Merge+Thu May 25 12:33:33 2002"
- // "Result of Merge"
- // "Thu May 25 12:33:33 2002"
- //
- // The server will send a timestamp of "+=" if
- // the file was merged with conflicts. The '+' indicates that there are conflicts and the
- // '=' indicate that the timestamp for the file should be used. If the merge does not
- // have conflicts, simply add a text only timestamp and the file will be regarded as
- // having outgoing changes.
- // The purpose for having the two different timestamp options for merges is to
- // dissallow commit of files that have conflicts until they have been manually edited.
- if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED) != -1) {
- syncType = TYPE_MERGED;
- date = null;
- } else if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED_WITH_CONFLICT) != -1) {
- syncType = TYPE_MERGED_WITH_CONFLICTS;
- date = null;
- } else if(date.indexOf(TIMESTAMP_MERGED_WITH_CONFLICT)!=-1) {
- date = date.substring(date.indexOf("+") + 1); //$NON-NLS-1$
- syncType = TYPE_MERGED_WITH_CONFLICTS;
- } else if(date.indexOf(TIMESTAMP_MERGED)!=-1) {
- syncType = TYPE_MERGED;
- date = null;
- }
-
- if(date==null || "".equals(date)) { //$NON-NLS-1$
- timeStamp = null;
- } else {
- try {
- timeStamp = CVSDateFormatter.entryLineToDate(date);
- } catch(ParseException e) {
- // something we don't understand, just make this sync have no timestamp and
- // never be in sync with the server.
- timeStamp = null;
- }
- }
- keywordMode = KSubstOption.fromMode(tokenizer.nextToken());
- String tagEntry = tokenizer.nextToken();
-
- if(tagEntry.length()>0) {
- tag = new CVSEntryLineTag(tagEntry);
- } else {
- tag = null;
- }
- }
-
- private String getEntryLine(boolean includeTimeStamp, String timestampOverride) {
- StringBuffer result = new StringBuffer();
-
- if(isDirectory) {
- result.append(DIRECTORY_PREFIX);
- result.append(name + "////"); //$NON-NLS-1$
- } else {
- result.append(SEPERATOR);
- result.append(name);
- result.append(SEPERATOR);
-
- if(isDeleted){
- result.append(DELETED_PREFIX);
- }
- result.append(revision);
- result.append(SEPERATOR);
- if(includeTimeStamp) {
- String entryLineTimestamp = ""; //$NON-NLS-1$
- if(timestampOverride!=null) {
- entryLineTimestamp = timestampOverride;
- } else {
- switch(syncType) {
- case TYPE_REGULAR:
- if(timeStamp==null) {
- entryLineTimestamp = TIMESTAMP_DUMMY;
- } else {
- entryLineTimestamp = CVSDateFormatter.dateToEntryLine(timeStamp);
- } break;
- case TYPE_MERGED:
- entryLineTimestamp = TIMESTAMP_MERGED; break;
- case TYPE_MERGED_WITH_CONFLICTS:
- entryLineTimestamp = TIMESTAMP_MERGED_WITH_CONFLICT + CVSDateFormatter.dateToEntryLine(timeStamp); break;
- }
- }
- result.append(entryLineTimestamp);
- }
- result.append(SEPERATOR);
- if (keywordMode != null) result.append(keywordMode.toMode());
- result.append(SEPERATOR);
- if (tag != null) {
- result.append(tag.toEntryLineFormat(true));
- }
- }
- return result.toString();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AddDeleteMoveListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AddDeleteMoveListener.java
deleted file mode 100644
index ac191f878..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AddDeleteMoveListener.java
+++ /dev/null
@@ -1,442 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.Team;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * Listen for the addition of orphaned subtrees as a result of a copy or move.
- */
-public class AddDeleteMoveListener implements IResourceDeltaVisitor, IResourceChangeListener, IResourceStateChangeListener {
-
- public static final String CVS_MARKER = "org.eclipse.team.cvs.core.cvsmarker";//$NON-NLS-1$
- public static final String DELETION_MARKER = "org.eclipse.team.cvs.core.cvsremove";//$NON-NLS-1$
- public static final String ADDITION_MARKER = "org.eclipse.team.cvs.core.cvsadd";//$NON-NLS-1$
-
- public static final String NAME_ATTRIBUTE = "name";//$NON-NLS-1$
-
- public static IResource getResourceFor(IProject container, IResource destination, IPath originating) {
- switch(destination.getType()) {
- case IResource.FILE : return container.getFile(originating);
- case IResource.FOLDER: return container.getFolder(originating);
- case IResource.PROJECT: return ResourcesPlugin.getWorkspace().getRoot().getProject(originating.toString());
- }
- return destination;
- }
-
- /**
- * @see IResourceDeltaVisitor#visit(IResourceDelta)
- */
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource resource = delta.getResource();
- IProject project = resource.getProject();
- boolean movedTo = (delta.getFlags() & IResourceDelta.MOVED_TO) > 0;
- boolean movedFrom = (delta.getFlags() & IResourceDelta.MOVED_FROM) > 0;
- switch (delta.getKind()) {
- case IResourceDelta.ADDED :
- if (resource.getType() == IResource.FOLDER) {
- handleOrphanedSubtree((IContainer)resource);
- handleAddedFolder((IFolder) resource);
- } else if (resource.getType() == IResource.FILE) {
- handleAddedFile((IFile)resource);
- }
- break;
- case IResourceDelta.REMOVED :
- if (resource.getType() == IResource.FILE) {
- handleDeletedFile((IFile)resource);
- }
- break;
- case IResourceDelta.CHANGED :
- // This state means there is a resource before and after but changes were made by deleting and moving.
- // For files, we shouldn'd do anything.
- // For folders, we should purge the CVS info
- if (resource.getType() == IResource.FOLDER) {
- // When folders are moved, purge the CVS folders
- if (movedFrom)
- return ! handleOrphanedSubtree((IContainer)resource);
- }
- handleChangedResource(resource);
- break;
- }
- return true;
- }
-
- /*
- * Determine if the container is an orphaned subtree.
- * If it is, handle it and return true.
- * Otherwise, return false
- */
- private boolean handleOrphanedSubtree(IContainer resource) {
- try {
- ICVSFolder mFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)resource);
- if (mFolder.isCVSFolder() && ! mFolder.isManaged() && mFolder.getParent().isCVSFolder()) {
- mFolder.unmanage(null);
- return true;
- }
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- return false;
- }
-
-
- /*
- * Mark deleted managed files as outgoing deletions
- */
- private void handleDeletedFile(IFile resource) {
- try {
- ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource);
- if (mFile.isManaged()) {
- ResourceSyncInfo info = mFile.getSyncInfo();
- if (info.isAdded()) {
- mFile.unmanage(null);
- } else if ( ! info.isDeleted()) {
- MutableResourceSyncInfo deletedInfo = info.cloneMutable();
- deletedInfo.setDeleted(true);
- mFile.setSyncInfo(deletedInfo);
- }
- }
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- }
-
- /*
- * Handle the case where an added file has the same name as a "cvs removed" file
- * by restoring the sync info to what it was before the delete
- */
- private void handleAddedFile(IFile resource) {
- try {
- ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource);
- if (mFile.isManaged()) {
- ResourceSyncInfo info = mFile.getSyncInfo();
- if (info.isDeleted()) {
- // Handle a replaced deletion
- MutableResourceSyncInfo undeletedInfo = info.cloneMutable();
- undeletedInfo.setDeleted(false);
- mFile.setSyncInfo(undeletedInfo);
- try {
- IMarker marker = getDeletionMarker(resource);
- if (marker != null) marker.delete();
- } catch (CoreException e) {
- CVSProviderPlugin.log(e.getStatus());
- }
- } else if (info.isDirectory()) {
- // XXX This is a gender change against the server! We should prevent this creation.
- mFile.unmanage(null);
- }
- }
- createNecessaryMarkers(new IResource[] {resource});
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- }
-
- private void handleAddedFolder(IFolder resource) {
- try {
- ICVSFolder mFolder = CVSWorkspaceRoot.getCVSFolderFor(resource);
- if (mFolder.isManaged()) {
- ResourceSyncInfo info = mFolder.getSyncInfo();
- if ( ! info.isDirectory()) {
- // XXX This is a gender change against the server! We should prevent this creation.
- mFolder.unmanage(null);
- }
- }
- createNecessaryMarkers(new IResource[] {resource});
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- }
-
- private void handleChangedResource(IResource resource) {
- if (resource.getType() == IResource.PROJECT) return;
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- // Make sure that unmanaged resources whose parent is a cvs folder have an addition task on them
- if ( ! cvsResource.isManaged() && ! cvsResource.isIgnored() && cvsResource.getParent().isCVSFolder()) {
- createAdditonMarker(resource);
- }
- }
-
- public void resourceChanged(IResourceChangeEvent event) {
- try {
- IResourceDelta root = event.getDelta();
- IResourceDelta[] projectDeltas = root.getAffectedChildren();
- for (int i = 0; i < projectDeltas.length; i++) {
- IResourceDelta delta = projectDeltas[i];
- IResource resource = delta.getResource();
- RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId());
-
- // Make sure that the project is a CVS folder.
- if (provider != null) {
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(resource.getProject());
- if (! folder.isCVSFolder()) {
- try {
- Team.removeNatureFromProject(resource.getProject(), CVSProviderPlugin.getTypeId(), null);
- } catch (TeamException e) {
- CVSProviderPlugin.log(e.getStatus());
- }
- }
- }
-
- // if a project is moved the originating project will not be associated with the CVS provider
- // however listeners will probably still be interested in the move delta.
- if ((delta.getFlags() & IResourceDelta.MOVED_TO) > 0) {
- IResource destination = getResourceFor(resource.getProject(), resource, delta.getMovedToPath());
- provider = RepositoryProvider.getProvider(destination.getProject());
- }
-
- if(provider!=null) {
- delta.accept(this);
- }
- }
- } catch (CoreException e) {
- Util.logError(Policy.bind("ResourceDeltaVisitor.visitError"), e);//$NON-NLS-1$
- }
- }
-
- /*
- * @see IResourceStateChangeListener#resourceStateChanged(IResource[])
- */
- public void resourceStateChanged(IResource[] changedResources) {
- createNecessaryMarkers(changedResources);
- }
-
- /**
- * @see IResourceStateChangeListener#projectConfigured(IProject)
- */
- public void projectConfigured(final IProject project) {
- try {
- final ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(project);
- root.accept(new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {
- if (file.getParent().isCVSFolder()) {
- if (file.isManaged() && file.getSyncInfo().isDeleted()) {
- createDeleteMarker(project.getFile(file.getRelativePath(root)));
- } else if ( ! file.isManaged() && ! file.isIgnored()) {
- createAdditonMarker(project.getFile(file.getRelativePath(root)));
- }
- }
- }
- public void visitFolder(ICVSFolder folder) throws CVSException {
- if (folder.isCVSFolder()) {
- folder.acceptChildren(this);
- } else if ( ! folder.isIgnored() && folder.getParent().isCVSFolder()) {
- createAdditonMarker(project.getFolder(folder.getRelativePath(root)));
- }
- }
- });
- } catch (CVSException e) {
- CVSProviderPlugin.log(e.getStatus());
- }
- }
-
- /**
- * @see IResourceStateChangeListener#projectDeconfigured(IProject)
- */
- public void projectDeconfigured(IProject project) {
- try {
- clearCVSMarkers(project);
- } catch (CoreException e) {
- CVSProviderPlugin.log(e.getStatus());
- }
- }
-
- public static void refreshAllMarkers() throws CoreException {
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- if(RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()) != null) {
- refreshMarkers(project);
- }
- }
- }
-
- private static IMarker createDeleteMarker(IResource resource) {
- if (! CVSProviderPlugin.getPlugin().getShowTasksOnAddAndDelete()) {
- return null;
- }
- try {
- IMarker marker = getDeletionMarker(resource);
- if (marker != null) {
- return marker;
- }
- IContainer parent = resource.getParent();
- if (! parent.exists()) return null;
- marker = parent.createMarker(DELETION_MARKER);
- marker.setAttribute("name", resource.getName());//$NON-NLS-1$
- marker.setAttribute(IMarker.MESSAGE, Policy.bind("AddDeleteMoveListener.deletedResource", resource.getName()));//$NON-NLS-1$
- marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
- return marker;
- } catch (CoreException e) {
- Util.logError(Policy.bind("AddDeleteMoveListener.Error_creating_deletion_marker_1"), e); //$NON-NLS-1$
- }
- return null;
- }
-
- private static IMarker createAdditonMarker(IResource resource) {
- if (! CVSProviderPlugin.getPlugin().getShowTasksOnAddAndDelete()) {
- return null;
- }
- try {
- IMarker marker = getAdditionMarker(resource);
- if (marker != null) {
- return marker;
- }
- marker = resource.createMarker(ADDITION_MARKER);
- marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
- marker.setAttribute(IMarker.MESSAGE, Policy.bind("AddDeleteMoveListener.Local_addition_not_under_CVS_control_2")); //$NON-NLS-1$
- return marker;
- } catch (CoreException e) {
- Util.logError(Policy.bind("AddDeleteMoveListener.Error_creating_addition_marker_3"), e); //$NON-NLS-1$
- }
- return null;
- }
-
- private static IMarker getAdditionMarker(IResource resource) throws CoreException {
- IMarker[] markers = resource.findMarkers(ADDITION_MARKER, false, IResource.DEPTH_ZERO);
- if (markers.length == 1) {
- return markers[0];
- }
- return null;
- }
-
- private static IMarker getDeletionMarker(IResource resource) throws CoreException {
- if (resource.getParent().exists()) {
- String name = resource.getName();
- IMarker[] markers = resource.getParent().findMarkers(DELETION_MARKER, false, IResource.DEPTH_ZERO);
- for (int i = 0; i < markers.length; i++) {
- IMarker iMarker = markers[i];
- String markerName = (String)iMarker.getAttribute(NAME_ATTRIBUTE);
- if (markerName.equals(name))
- return iMarker;
- }
- }
- return null;
- }
-
- private static void createNecessaryMarkers(IResource[] changedResources) {
- for (int i = 0; i < changedResources.length; i++) {
- try {
- final IResource resource = changedResources[i];
- // Only update markers for projects with a provider
- RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId());
- if (provider == null) break;
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- // Handle addition markers
- if (cvsResource.isManaged() || cvsResource.isIgnored()) {
- if (cvsResource.exists()) {
- // Remove the addition marker for managed or ignored resources
- IMarker marker = getAdditionMarker(resource);
- if (marker != null)
- marker.delete();
- // For managed folders, add addition markers to unmanaged/unignored children
- if (cvsResource.isManaged() && cvsResource.isFolder()) {
- IResource[] children = ((IFolder)resource).members();
- for (int j = 0; j < children.length; j++) {
- IResource iResource = children[j];
- ICVSResource child = CVSWorkspaceRoot.getCVSResourceFor(iResource);
- if ( ! child.isManaged() && ! child.isIgnored()) {
- createAdditonMarker(iResource);
- }
- }
- }
- }
- } else if (cvsResource.exists() && cvsResource.getParent().isCVSFolder()) {
- // If the parent is a CVS folder, place an addition marker on the resource
- IMarker marker = getAdditionMarker(resource);
- if (marker == null) {
- createAdditonMarker(resource);
- }
- }
-
- // Handle deletion markers
- if (resource.getType() == IResource.FILE) {
- if (cvsResource.exists()) {
- IMarker marker = getDeletionMarker(resource);
- if (marker != null)
- marker.delete();
- } else {
- if (cvsResource.isManaged()) {
- createDeleteMarker(resource);
- } else {
- IMarker marker = getDeletionMarker(resource);
- if (marker != null)
- marker.delete();
- }
- }
- }
- } catch (CVSException e) {
- Util.logError(Policy.bind("AddDeleteMoveListener.Error_updating_marker_state_4"), e); //$NON-NLS-1$
- } catch (CoreException e) {
- Util.logError(Policy.bind("AddDeleteMoveListener.Error_updating_marker_state_4"), e); //$NON-NLS-1$
- }
- }
- }
-
- private static void refreshMarkers(IResource resource) throws CoreException {
- final List resources = new ArrayList();
- clearCVSMarkers(resource);
- resource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if(resource.getType() != IResource.PROJECT) {
- resources.add(resource);
- }
- return true;
- }
- }, IResource.DEPTH_INFINITE, true /*include phantoms*/);
- createNecessaryMarkers((IResource[]) resources.toArray(new IResource[resources.size()]));
- }
-
- public static void clearAllCVSMarkers() throws CoreException {
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- if(RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()) != null) {
- clearCVSMarkers(project);
- }
- }
- }
-
- private static void clearCVSMarkers(IResource resource) throws CoreException {
- IMarker[] markers = resource.findMarkers(CVS_MARKER, true, IResource.DEPTH_INFINITE);
- for (int i = 0; i < markers.length; i++) {
- markers[i].delete();
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Assert.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Assert.java
deleted file mode 100644
index 0204f2e24..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Assert.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * <code>Assert</code> is useful for for embedding runtime sanity checks
- * in code.
- * The predicate methods all test a condition and throw some
- * type of unchecked exception if the condition does not hold.
- * <p>
- * Assertion failure exceptions, like most runtime exceptions, are
- * thrown when something is misbehaving. Assertion failures are invariably
- * unspecified behavior; consequently, clients should never rely on
- * these being thrown (and certainly should not being catching them
- * specifically).
- * </p>
- */
-public final class Assert {
- /* This class is not intended to be instantiated. */
- private Assert() {
- }
- /** Asserts that an argument is legal. If the given boolean is
- * not <code>true</code>, an <code>IllegalArgumentException</code>
- * is thrown.
- *
- * @param expression the outcode of the check
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- * @exception IllegalArgumentException if the legality test failed
- */
- public static boolean isLegal(boolean expression) {
- return isLegal(expression, ""); //$NON-NLS-1$
- }
- /** Asserts that an argument is legal. If the given boolean is
- * not <code>true</code>, an <code>IllegalArgumentException</code>
- * is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param expression the outcode of the check
- * @param message the message to include in the exception
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- * @exception IllegalArgumentException if the legality test failed
- */
- public static boolean isLegal(boolean expression, String message) {
- if (!expression)
- throw new IllegalArgumentException(message);
- return expression;
- }
- /** Asserts that the given object is not <code>null</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- *
- * @param object the value to test
- * @exception IllegalArgumentException if the object is <code>null</code>
- */
- public static void isNotNull(Object object) {
- isNotNull(object, ""); //$NON-NLS-1$
- }
- /** Asserts that the given object is not <code>null</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param object the value to test
- * @param message the message to include in the exception
- * @exception IllegalArgumentException if the object is <code>null</code>
- */
- public static void isNotNull(Object object, String message) {
- if (object == null)
- throw new AssertionFailedException("null argument:" + message); //$NON-NLS-1$
- }
- /** Asserts that the given boolean is <code>true</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- *
- * @param expression the outcode of the check
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- */
- public static boolean isTrue(boolean expression) {
- return isTrue(expression, ""); //$NON-NLS-1$
- }
- /** Asserts that the given boolean is <code>true</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param expression the outcode of the check
- * @param message the message to include in the exception
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- */
- public static boolean isTrue(boolean expression, String message) {
- if (!expression)
- throw new AssertionFailedException("assertion failed: " + message); //$NON-NLS-1$
- return expression;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AssertionFailedException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AssertionFailedException.java
deleted file mode 100644
index df2926d74..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AssertionFailedException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * <code>AssertionFailedException</code> is a runtime exception thrown
- * by some of the methods in <code>Assert</code>.
- * <p>
- * This class is not declared public to prevent some misuses; programs that catch
- * or otherwise depend on assertion failures are susceptible to unexpected
- * breakage when assertions in the code are added or removed.
- * </p>
- */
-/* package */
-class AssertionFailedException extends RuntimeException {
-/** Constructs a new exception.
- */
-public AssertionFailedException() {
-}
-/** Constructs a new exception with the given message.
- */
-public AssertionFailedException(String detail) {
- super(detail);
-}
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java
deleted file mode 100644
index 1bc9c91f1..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-/**
- * Utility class for converting timestamps used in Entry file lines. The format
- * required in the Entry file is ISO C asctime() function (Sun Apr 7 01:29:26 1996).
- */
-public class CVSDateFormatter {
-
- private static final String ENTRYLINE_FORMAT = "E MMM d HH:mm:ss yyyy"; //$NON-NLS-1$
- private static final String SERVER_FORMAT = "dd MMM yyyy HH:mm:ss";//$NON-NLS-1$
-
- private static final SimpleDateFormat serverFormat = new SimpleDateFormat(SERVER_FORMAT, Locale.US);
- private static SimpleDateFormat entryLineFormat = new SimpleDateFormat(ENTRYLINE_FORMAT, Locale.US);
-
- static {
- entryLineFormat.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$
- }
- static public Date serverStampToDate(String text) throws ParseException {
- serverFormat.setTimeZone(getTimeZone(text));
- Date date = serverFormat.parse(text);
- return date;
- }
-
- static public String dateToServerStamp(Date date) {
- serverFormat.setTimeZone(TimeZone.getTimeZone("GMT"));//$NON-NLS-1$
- return serverFormat.format(date) + " -0000"; //$NON-NLS-1$
- }
-
- static public Date entryLineToDate(String text) throws ParseException {
- return entryLineFormat.parse(text);
- }
-
- static public String dateToEntryLine(Date date) {
- return entryLineFormat.format(date);
- }
-
- /*
- * Converts timezone text from date string from CVS server and
- * returns a timezone representing the received timezone.
- * Timezone string is of the following format: [-|+]MMSS
- */
- static private TimeZone getTimeZone(String dateFromServer) {
- String tz = null;
- StringBuffer resultTz = new StringBuffer("GMT");//$NON-NLS-1$
- if (dateFromServer.indexOf("-") != -1) {//$NON-NLS-1$
- resultTz.append("-");//$NON-NLS-1$
- tz = dateFromServer.substring(dateFromServer.indexOf("-"));//$NON-NLS-1$
- } else if (dateFromServer.indexOf("+") != -1) {//$NON-NLS-1$
- resultTz.append('+');
- tz = dateFromServer.substring(dateFromServer.indexOf("+"));//$NON-NLS-1$
- }
- try {
- if(tz!=null) {
- resultTz.append(tz.substring(1, 3) /*hours*/ + ":" + tz.substring(3, 5) /*minutes*/);//$NON-NLS-1$
- return TimeZone.getTimeZone(resultTz.toString());
- }
- } catch(IndexOutOfBoundsException e) {
- return TimeZone.getTimeZone("GMT");//$NON-NLS-1$
- }
- return TimeZone.getTimeZone("GMT");//$NON-NLS-1$
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/EmptyTokenizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/EmptyTokenizer.java
deleted file mode 100644
index 6708bb4d1..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/EmptyTokenizer.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
-
-/**
- * The EmptyTokenizer is essentialy a StringTokenizer.
- *
- * The difference is that empty Tokens are given back as
- * empty Strings.
- *
- * If giveFirst an emptyString is the first return of nextToken()
- * on line that starts with its delim.
- *
- * If giveLast an emptyString is the last retrun of nextToken() on
- * line that ends with its delim.
- */
-public class EmptyTokenizer {
-
- private StringTokenizer st;
- private boolean lastWasDelim;
- private final boolean giveLast;
- private final boolean giveFirst;
- private String delim;
- private String line;
-
- private String cacheToken;
-
- public EmptyTokenizer(String line, String delim) {
- this(line, delim, false, true);
- }
-
- public EmptyTokenizer(String line, String delim, boolean giveFirst, boolean giveLast) {
-
- this.delim = delim;
- this.line = line;
- this.giveFirst = giveFirst;
- lastWasDelim = giveFirst;
- this.giveLast = giveLast;
-
- st = new StringTokenizer(line, delim, true);
- startCacheToken();
-
- }
-
- /**
- * Call this before using cachedNextToken().
- */
- private void startCacheToken() {
- if (st.hasMoreTokens()) {
- cacheToken = st.nextToken();
- } else {
- cacheToken = null;
- }
- }
-
- /**
- * Gives the next Token back. Ensures that cacheToken holds the
- * next Token to be given back.
- * This is done to have a chance to predict if we have got a token
- * at the end of the entry.
- */
- private String cachedNextToken() throws NoSuchElementException {
-
- String oldCacheToken = cacheToken;
-
- if (cacheToken == null) {
- throw new NoSuchElementException();
- }
-
- if (st.hasMoreTokens()) {
- cacheToken = st.nextToken();
- } else {
- cacheToken = null;
- }
-
- return oldCacheToken;
- }
-
-
- public boolean hasMoreTokens() {
- return (giveLast && lastWasDelim) ||
- (cacheToken != null && !cacheToken.equals(delim)) ||
- (cacheToken != null && cacheToken.equals(delim) && st.hasMoreTokens()) ||
- (cacheToken != null && cacheToken.equals(delim) && giveLast);
- }
-
- public String nextToken() {
-
- String token;
-
- if (giveLast && lastWasDelim && cacheToken == null) {
- lastWasDelim = false;
- return ""; //$NON-NLS-1$
- }
-
- token = cachedNextToken();
-
- if (!token.equals(delim)) {
- lastWasDelim = false;
- return token;
- }
-
- if (lastWasDelim) {
- return ""; //$NON-NLS-1$
- } else {
- lastWasDelim = true;
- return nextToken();
- }
- }
-
- public int countTokens() {
-
- EmptyTokenizer tmpEmptyTokenizer;
- int i=0;
-
- tmpEmptyTokenizer = new EmptyTokenizer(line, delim, giveFirst, giveLast);
- while (tmpEmptyTokenizer.hasMoreTokens()) {
- tmpEmptyTokenizer.nextToken();
- i++;
- }
-
- return i;
-
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileNameMatcher.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileNameMatcher.java
deleted file mode 100644
index c08302ece..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileNameMatcher.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-/**
- * A FileNameMatcher associates a String with a String pattern.
- */
-public class FileNameMatcher {
-
- private List matchers = new ArrayList();
- private List results = new ArrayList();
- private static final String TRUE = "true"; //$NON-NLS-1$
-
- public FileNameMatcher() {
- }
-
- public FileNameMatcher(String[] patterns) {
- register(patterns);
- }
-
- void register(String[] patterns) {
- for (int i = 0; i < patterns.length; i++) {
- register(patterns[i],TRUE);
- }
- }
-
- public void register(String pattern, String result) {
-
- Assert.isTrue(matchers.size() == results.size());
-
- pattern = pattern.trim();
-
- // The empty pattern matches everything, but we want to match
- // nothing with it, so we just do not register anything
- if (pattern.length() == 0) {
- return;
- }
-
- matchers.add(new StringMatcher(pattern,false,false));
- results.add(result);
-
- }
-
- public String getMatch(String name) {
- StringMatcher stringMatcher;
-
- for (int i = 0; i < matchers.size(); i++) {
- stringMatcher = (StringMatcher) matchers.get(i);
- if (stringMatcher.match(name)) {
- return (String)results.get(i);
- }
- }
-
- return null;
- }
-
- public boolean match(String name) {
- return getMatch(name) != null;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/InfiniteSubProgressMonitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/InfiniteSubProgressMonitor.java
deleted file mode 100644
index 2034e162e..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/InfiniteSubProgressMonitor.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-/**
- * Provides an infinite progress monitor by subdividing by half repeatedly.
- *
- * The ticks parameter represents the number of ticks shown in the progress dialog.
- * However, the number of ticks that can actually be worked is n*ticks/2 where
- * 2^n = ticks. What this means is that if you provide a ticks of 32 (2^5) than
- * the maximum number of ticks is 5*32/2 = 80.
- *
- */
-public class InfiniteSubProgressMonitor extends SubProgressMonitor {
-
- int totalWork;
- int halfWay;
- int currentIncrement;
- int nextProgress;
- int worked;
-
- /**
- * Constructor for InfiniteSubProgressMonitor.
- * @param monitor
- * @param ticks
- */
- public InfiniteSubProgressMonitor(IProgressMonitor monitor, int ticks) {
- this(monitor, ticks, 0);
- }
-
- /**
- * Constructor for InfiniteSubProgressMonitor.
- * @param monitor
- * @param ticks
- * @param style
- */
- public InfiniteSubProgressMonitor(IProgressMonitor monitor, int ticks, int style) {
- super(monitor, ticks, style);
- }
-
- public void beginTask(String name, int totalWork) {
- super.beginTask(name, totalWork);
- this.totalWork = totalWork;
- this.halfWay = totalWork / 2;
- this.currentIncrement = 1;
- this.nextProgress = currentIncrement;
- this.worked = 0;
- }
-
- public void worked(int work) {
- if (worked >= totalWork) return;
- if (--nextProgress <= 0) {
- super.worked(1);
- worked++;
- if (worked >= halfWay) {
- // we have passed the current halfway point, so double the
- // increment and reset the halfway point.
- currentIncrement *= 2;
- halfWay += (totalWork - halfWay) / 2;
- }
- // reset the progress counter to another full increment
- nextProgress = currentIncrement;
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/MoveDeleteHook.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/MoveDeleteHook.java
deleted file mode 100644
index e1aa89f43..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/MoveDeleteHook.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*******************************************************************************
- * 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.util;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.team.IMoveDeleteHook;
-import org.eclipse.core.resources.team.IResourceTree;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * This hook exists to ensure that folders deletions will be recorded so that outgoing file
- * deletions can be properly communicated to the server.
- */
-public class MoveDeleteHook implements IMoveDeleteHook {
-
- /*
- * Delete the file and return true if an outgoing deletion will result
- * and the parent folder sync info needs to remain
- */
- private boolean makeFileOutgoingDeletion(IResourceTree tree, IFile source, IFile destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
- // Delete or move the file
- if (destination == null) {
- tree.standardDeleteFile(source, updateFlags, monitor);
- } else {
- tree.standardMoveFile(source, destination, updateFlags, monitor);
- }
- // Indicate whether the parent folder sync info must remain for outgoing deletions
- // and update the file sync info to be a deletion
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(source);
- boolean mustRemain = false;
- try {
- ResourceSyncInfo info = cvsFile.getSyncInfo();
- mustRemain = (info != null && ! info.isAdded());
- if (mustRemain) {
- MutableResourceSyncInfo newInfo = info.cloneMutable();
- newInfo.setDeleted(true);
- cvsFile.setSyncInfo(newInfo);
- }
- } catch (CVSException e) {
- tree.failed(e.getStatus());
- }
- return mustRemain;
- }
-
- /*
- * Delete the files contained in the folder structure rooted at source.
- * Return true if at least one file has been marked as an outgoing deletion and the parent folder must remain
- */
- private boolean makeFolderOutgoingDeletion(IResourceTree tree, IFolder source, IFolder destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
- boolean fileFound = false;
-
- // Create the destination for a move
- if (destination != null && ! destination.exists()) {
- destination.create(false, true, monitor);
- }
-
- // Move or delete the children
- IResource[] members = source.members();
- for (int i = 0; i < members.length; i++) {
- IResource child = members[i];
- if (child.getType() == IResource.FOLDER) {
- // Determine the corresponding destination folder
- IFolder destFolder = null;
- if (destination != null) {
- destFolder = destination.getFolder(child.getFullPath().removeFirstSegments(source.getFullPath().segmentCount()));
- }
-
- // Try to delete/move the child
- if (makeFolderOutgoingDeletion(tree, (IFolder)child, destFolder, updateFlags, monitor)) {
- fileFound = true;
- }
- } else if (child.getType() == IResource.FILE) {
- IFile destFile = null;
- if (destination != null) {
- destFile = destination.getFile(child.getFullPath().removeFirstSegments(source.getFullPath().segmentCount()));
- }
- fileFound = makeFileOutgoingDeletion(tree, (IFile)child, destFile, updateFlags, monitor);
- }
- }
-
- // If there were no files, we need to check if the folder already has outgoing deletions
- if ( ! fileFound) {
- try {
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(source);
- ICVSResource[] files = folder.members(ICVSFolder.FILE_MEMBERS | ICVSFolder.MANAGED_MEMBERS);
- for (int i = 0; i < files.length; i++) {
- ICVSFile cvsFile = (ICVSFile)files[i];
- if (cvsFile.isManaged() && ! cvsFile.getSyncInfo().isAdded()) {
- fileFound = true;
- break;
- }
- }
- // If there is still no file, we can delete the folder without any special handling
- if ( ! fileFound) {
- tree.standardDeleteFolder(source, updateFlags, monitor);
- folder.unmanage(null);
- }
- } catch (CVSException e) {
- tree.failed(e.getStatus());
- }
- }
-
- // If there were managed files found, we must remember the folder's sync info
- if (fileFound) {
- try {
- EclipseSynchronizer.getInstance().prepareForDeletion(source);
- } catch (CVSException e) {
- tree.failed(e.getStatus());
- }
- tree.standardDeleteFolder(source, updateFlags, monitor);
- }
-
- return fileFound;
- }
-
- /**
- * @see IMoveDeleteHook#deleteFile(IResourceTree, IFile, int, IProgressMonitor)
- */
- public boolean deleteFile(
- IResourceTree tree,
- IFile file,
- int updateFlags,
- IProgressMonitor monitor) {
-
- // No special action is required here.
- // The AddDeleteMoveListener will update the sync info of the file
- return false;
- }
-
- /**
- * @see IMoveDeleteHook#deleteFolder(IResourceTree, IFolder, int, IProgressMonitor)
- */
- public boolean deleteFolder(
- final IResourceTree tree,
- final IFolder folder,
- final int updateFlags,
- IProgressMonitor monitor) {
-
- final ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder);
- if (cvsFolder.isManaged()) {
- try {
- cvsFolder.run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- try {
- makeFolderOutgoingDeletion(tree, folder, null, updateFlags, monitor);
- } catch (CoreException e) {
- tree.failed(e.getStatus());
- }
- }
- }, monitor);
- } catch (CVSException e) {
- tree.failed(e.getStatus());
- }
- return true;
- }
- return false;
- }
-
- /**
- * @see IMoveDeleteHook#deleteProject(IResourceTree, IProject, int, IProgressMonitor)
- */
- public boolean deleteProject(
- IResourceTree tree,
- IProject project,
- int updateFlags,
- IProgressMonitor monitor) {
-
- // We need to flush any remembered folder deletions for the deleted project
- try {
- EclipseSynchronizer.getInstance().prepareForDeletion(project);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e.getStatus());
- }
- return false;
- }
-
- /**
- * @see IMoveDeleteHook#moveFile(IResourceTree, IFile, IFile, int, IProgressMonitor)
- */
- public boolean moveFile(
- IResourceTree tree,
- IFile source,
- IFile destination,
- int updateFlags,
- IProgressMonitor monitor) {
-
- // No special action is required here.
- // The AddDeleteMoveListener will update the sync info of the source
- return false;
- }
-
- /**
- * @see IMoveDeleteHook#moveFolder(IResourceTree, IFolder, IFolder, int, IProgressMonitor)
- */
- public boolean moveFolder(
- final IResourceTree tree,
- final IFolder source,
- final IFolder destination,
- final int updateFlags,
- IProgressMonitor monitor) {
-
- final ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(source);
- if (cvsFolder.isManaged()) {
- try {
- cvsFolder.run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- try {
- makeFolderOutgoingDeletion(tree, source, destination, updateFlags, monitor);
- } catch (CoreException e) {
- tree.failed(e.getStatus());
- }
- }
- }, monitor);
- } catch (CVSException e) {
- tree.failed(e.getStatus());
- }
- return true;
- }
-
- return false;
- }
-
- /**
- * @see IMoveDeleteHook#moveProject(IResourceTree, IProject, IProjectDescription, int, IProgressMonitor)
- */
- public boolean moveProject(
- IResourceTree tree,
- IProject source,
- IProjectDescription description,
- int updateFlags,
- IProgressMonitor monitor) {
-
- // We need to move (or flush) any remembered folder deletions for the deleted project
- // XXX We flush for now. This means that deleting a managed folder and then moving the
- // project will mean that the file deletions will be lost.
- try {
- EclipseSynchronizer.getInstance().prepareForDeletion(source);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e.getStatus());
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java
deleted file mode 100644
index 3ad0c46d8..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * 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.util;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * This class is used to prepare a local CVS workspace for replacement by
- * the corresponding remote resources. More specifically, this class will
- * unmanage added and deleted resources so that, after the operation, the
- * resources in the local workspace will either correspond to the remote
- * counterparts or be unmanaged.
- */
-public class PrepareForReplaceVisitor implements ICVSResourceVisitor {
-
- private IProgressMonitor monitor;
- private int depth;
-
- /**
- * @see ICVSResourceVisitor#visitFile(ICVSFile)
- */
- public void visitFile(ICVSFile file) throws CVSException {
- ResourceSyncInfo info = file.getSyncInfo();
- if (info == null) {
- // Delete unmanaged files if the user wants them deleted
- if (CVSProviderPlugin.getPlugin().isReplaceUnmanaged()) {
- file.delete();
- }
- } else if (info.isAdded()) {
- file.delete();
- file.unmanage(null);
- } else if (info.isDeleted()) {
- // If deleted, null the sync info so the file will be refetched
- file.unmanage(null);
- }
- monitor.worked(1);
- }
-
- /**
- * @see ICVSResourceVisitor#visitFolder(ICVSFolder)
- */
- public void visitFolder(ICVSFolder folder) throws CVSException {
- // Visit the children of the folder as appropriate
- if (depth == IResource.DEPTH_INFINITE) {
- folder.acceptChildren(this);
- } else if (depth == IResource.DEPTH_ONE) {
- ICVSResource[] files = folder.members(ICVSFolder.FILE_MEMBERS);
- for (int i = 0; i < files.length; i++) {
- files[i].accept(this);
- }
- }
- // Also delete ignored child files that start with .#
- ICVSResource[] ignoredFiles = folder.members(ICVSFolder.FILE_MEMBERS | ICVSFolder.IGNORED_MEMBERS);
- for (int i = 0; i < ignoredFiles.length; i++) {
- ICVSResource cvsResource = ignoredFiles[i];
- if (cvsResource.getName().startsWith(".#")) { //$NON-NLS-1$
- cvsResource.delete();
- }
- }
- monitor.worked(1);
- }
-
- public void visitResources(IProject project, final IResource[] resources, final String key, int depth, IProgressMonitor pm) throws CVSException {
- this.depth = depth;
- CVSWorkspaceRoot.getCVSFolderFor(project).run(new ICVSRunnable() {
- public void run(IProgressMonitor pm) throws CVSException {
- monitor = Policy.infiniteSubMonitorFor(pm, 100);
- monitor.beginTask(null, 512);
- for (int i = 0; i < resources.length; i++) {
- if (key != null) {
- monitor.subTask(Policy.bind(key, resources[i].getFullPath().toString())); //$NON-NLS-1$
- }
- IResource resource = resources[i];
- CVSWorkspaceRoot.getCVSResourceFor(resource).accept(PrepareForReplaceVisitor.this);
- }
- monitor.done();
- }
- }, pm);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionContentHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionContentHandler.java
deleted file mode 100644
index 45b5fce2f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionContentHandler.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Stack;
-
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-
-public class ProjectDescriptionContentHandler implements ContentHandler {
-
- IProjectDescription desc;
- boolean inProjectDescription = false;
-
- boolean inComment = false;
- StringBuffer buffer = new StringBuffer();
-
- boolean inBuilder = false;
- List builders = new ArrayList();
- ICommand currentBuilder = null;
- Map args = new HashMap();
-
- List natures = new ArrayList();
-
- List references = new ArrayList();
-
- Stack tagStack = new Stack();
-
- ProjectDescriptionContentHandler(IProjectDescription desc) {
- this.desc = desc;
- }
- /**
- * @see ContentHandler#characters(char[], int, int)
- */
- public void characters(char[] chars, int startIndex, int length)
- throws SAXException {
- buffer.append(chars, startIndex, length);
- }
- /**
- * @see ContentHandler#endDocument()
- */
- public void endDocument() throws SAXException {
- }
- /**
- * @see ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
- */
- public void endElement(String namespaceURI, String localName, String qName)
- throws SAXException {
- if (localName.equals("project-description") && inProjectDescription) { //$NON-NLS-1$
- inProjectDescription = false;
- desc.setBuildSpec((ICommand[]) builders.toArray(new ICommand[builders.size()]));
- desc.setNatureIds((String[]) natures.toArray(new String[natures.size()]));
- desc.setReferencedProjects(
- (IProject[]) references.toArray(new IProject[references.size()]));
- } else if (localName.equals("comment") && inProjectDescription && inComment) { //$NON-NLS-1$
- inComment = false;
- desc.setComment(buffer.toString());
- } else if (localName.equals("builder") && inProjectDescription && inBuilder) { //$NON-NLS-1$
- inBuilder = false;
- currentBuilder.setArguments(args);
- if (currentBuilder.getBuilderName() != null)
- builders.add(currentBuilder);
- }
- if (!localName.equals(tagStack.peek())) {
- throw new RuntimeException(Policy.bind("ProjectDescriptionContentHandler.xml")); //$NON-NLS-1$
- }
- tagStack.pop();
- }
- /**
- * @see ContentHandler#endPrefixMapping(java.lang.String)
- */
- public void endPrefixMapping(String arg0) throws SAXException {
- }
- /**
- * @see ContentHandler#ignorableWhitespace(char[], int, int)
- */
- public void ignorableWhitespace(char[] arg0, int arg1, int arg2)
- throws SAXException {
- }
- /**
- * @see ContentHandler#processingInstruction(java.lang.String, java.lang.String)
- */
- public void processingInstruction(String arg0, String arg1)
- throws SAXException {
- }
- /**
- * @see ContentHandler#setDocumentLocator(org.xml.sax.Locator)
- */
- public void setDocumentLocator(Locator arg0) {
- }
- /**
- * @see ContentHandler#skippedEntity(java.lang.String)
- */
- public void skippedEntity(String e) throws SAXException {
- }
- /**
- * @see ContentHandler#startDocument()
- */
- public void startDocument() throws SAXException {
- }
- /**
- * @see ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
- */
- public void startElement(
- String namespaceURI,
- String localName,
- String qName,
- Attributes atts)
- throws SAXException {
- if (localName.equals("project-description") && !inProjectDescription) { //$NON-NLS-1$
- inProjectDescription = true;
- } else if (localName.equals("comment") && inProjectDescription && !inComment) { //$NON-NLS-1$
- inComment = true;
- } else if (localName.equals("builder") && inProjectDescription && !inBuilder) { //$NON-NLS-1$
- String builderName = atts.getValue("name"); //$NON-NLS-1$
- if (builderName != null) {
- inBuilder = true;
- currentBuilder = desc.newCommand();
- currentBuilder.setBuilderName(builderName);
- args = new HashMap(11);
- }
- } else if (localName.equals("arg") && inProjectDescription && inBuilder) { //$NON-NLS-1$
- String argName = atts.getValue("name"); //$NON-NLS-1$
- String argValue = atts.getValue("value"); //$NON-NLS-1$
- if (argName != null && argValue != null)
- args.put(argName, argValue);
- } else if (localName.equals("nature") && inProjectDescription && !inBuilder) { //$NON-NLS-1$
- String natureId = atts.getValue("id"); //$NON-NLS-1$
- if (natureId != null)
- natures.add(natureId);
- } else if (
- localName.equals("reference") && inProjectDescription && !inBuilder) { //$NON-NLS-1$
- String projectName = atts.getValue("project-name"); //$NON-NLS-1$
- if (projectName != null)
- references.add(
- ResourcesPlugin.getWorkspace().getRoot().getProject(projectName));
- }
- // empty buffer
- buffer = new StringBuffer();
- tagStack.push(localName);
- }
- /**
- * @see ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
- */
- public void startPrefixMapping(String arg0, String arg1) throws SAXException {
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionManager.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionManager.java
deleted file mode 100644
index 032a96096..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionManager.java
+++ /dev/null
@@ -1,282 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.xerces.parsers.SAXParser;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * This class handles the updating of the .vcm_meta file in projects managed by the CVSTeamProvider.
- *
- * It does so by listening to deltas on the project description and the .vcm_meta file itself.
- *
- */
-public class ProjectDescriptionManager implements IResourceChangeListener {
-
- public final static IPath PROJECT_DESCRIPTION_PATH = new Path(".vcm_meta"); //$NON-NLS-1$
- public final static IPath CORE_PROJECT_DESCRIPTION_PATH = new Path(".project"); //$NON-NLS-1$
- public final static boolean UPDATE_PROJECT_DESCRIPTION_ON_LOAD = true;
-
- public static final String VCMMETA_MARKER = "org.eclipse.team.cvs.core.vcmmeta"; //$NON-NLS-1$
-
- /*
- * Read the project meta file into the provider description
- */
- public static void readProjectDescription(IProjectDescription desc, InputStream stream) throws IOException, CVSException {
- SAXParser parser = new SAXParser();
- parser.setContentHandler(new ProjectDescriptionContentHandler(desc));
- try {
- parser.parse(new InputSource(stream));
- } catch (SAXException ex) {
- throw new CVSException(IStatus.ERROR, IStatus.ERROR, Policy.bind("ProjectDescriptionManager.unableToReadDescription"), ex); //$NON-NLS-1$
- }
- }
-
- public static void writeProjectDescription(IProject project, IProgressMonitor progress) throws CVSException {
-
- // generate the new contents of the project meta file into a string
- ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
- String newContents = null;
- try {
- IProjectDescription desc = project.getDescription();
- ProjectDescriptionWriter.writeProjectDescription(desc, byteOutputStream);
- byteOutputStream.close();
- newContents = byteOutputStream.toString("UTF8"); //$NON-NLS-1$
- } catch (IOException ex) {
- throw CVSException.wrapException(project, Policy.bind("ProjectDescriptionManager.ioDescription"), ex); //$NON-NLS-1$
- } catch (CoreException ex) {
- throw CVSException.wrapException(project, Policy.bind("ProjectDescriptionManager.coreDescription"), ex); //$NON-NLS-1$
- }
-
- IFile descResource = project.getFile(PROJECT_DESCRIPTION_PATH);
- if (descResource.exists()) {
- // check if the existing contents are the same before rewriting
- String oldContents = null;
- try {
- StringBuffer stringBuffer = new StringBuffer();
- InputStream is = ((IFile) descResource).getContents();
- byte[] buf = new byte[512];
- int result = is.read(buf);
- while (result != -1) {
- stringBuffer.append(new String(buf, 0, result, "UTF8")); //$NON-NLS-1$
- result = is.read(buf);
- }
- oldContents = stringBuffer.toString();
- is.close();
- } catch (IOException ex) {
- throw CVSException.wrapException(project, Policy.bind("ProjectDescriptionManager.ioDescription"), ex); //$NON-NLS-1$
- } catch (CoreException ex) {
- throw CVSException.wrapException(project, Policy.bind("ProjectDescriptionManager.coreDescription"), ex); //$NON-NLS-1$
- }
-
- if (oldContents.equals(newContents)) {
- // the contents of the new file would be the same as the old
- return;
- }
- try {
- descResource.setContents(
- new ByteArrayInputStream(byteOutputStream.toByteArray()),
- false,
- false,
- progress);
- } catch (CoreException ex) {
- throw CVSException.wrapException(project, Policy.bind("ProjectDescriptionManager.coreDescription"), ex); //$NON-NLS-1$
- }
- } else {
- try {
- descResource.create(
- new ByteArrayInputStream(byteOutputStream.toByteArray()),
- false,
- progress);
- } catch (CoreException ex) {
- throw CVSException.wrapException(descResource, Policy.bind("ProjectDescriptionManager.coreDescription"), ex); //$NON-NLS-1$
- }
-
- }
- }
-
- /*
- * To be called whenever the project description file is believed to have changed by
- * a load/loadIfIncoming operation.
- */
- public static void updateProjectIfNecessary(IProject project, IProgressMonitor progress) throws CoreException, CVSException {
-
- IFile descResource = project.getFile(PROJECT_DESCRIPTION_PATH);
- if (descResource.exists() && UPDATE_PROJECT_DESCRIPTION_ON_LOAD) {
-
- // If a managed .project files exists, don't read the .vcm_meta
- ICVSFile coreDescResource = CVSWorkspaceRoot.getCVSFileFor(project.getFile(CORE_PROJECT_DESCRIPTION_PATH));
- if (coreDescResource.exists() && coreDescResource.isManaged()) {
- createVCMMetaMarker(descResource);
- Util.logError(Policy.bind("ProjectDescriptionManager.vcmmetaIgnored", project.getName()), null); //$NON-NLS-1$
- return;
- } else {
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project);
- if (! folder.isCVSFolder()) {
- createVCMMetaMarker(descResource);
- Util.logError(Policy.bind("ProjectDescriptionManager.vcmmetaIgnored", project.getName()), null); //$NON-NLS-1$
- return;
- }
- }
-
- // update project description file (assuming it has changed)
- IProjectDescription desc = project.getDescription();
- DataInputStream is = null;
- try {
- is = new DataInputStream(((IFile) descResource).getContents());
- try {
- readProjectDescription(desc, is);
- } finally {
- is.close();
- }
- try {
- project.setDescription(desc, IResource.FORCE | IResource.KEEP_HISTORY, progress);
- } catch (CoreException ex) {
- // Failing to set the description is probably due to a missing nature
- // Other natures are still set
- Util.logError(Policy.bind("ProjectDescriptionManager.unableToSetDescription"), ex); //$NON-NLS-1$
- }
- // Make sure we have the cvs nature (the above read may have removed it)
- if (!project.getDescription().hasNature(CVSProviderPlugin.getTypeId())) {
- try {
- // TeamPlugin.addNatureToProject(project, CVSProviderPlugin.getTypeId(), progress);
-
- // Set the nature manually in order to override any .project file
- IProjectDescription description = project.getDescription();
- String[] prevNatures= description.getNatureIds();
- String[] newNatures= new String[prevNatures.length + 1];
- System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
- newNatures[prevNatures.length]= CVSProviderPlugin.getTypeId();
- description.setNatureIds(newNatures);
- project.setDescription(description, IResource.FORCE | IResource.KEEP_HISTORY, progress);
- } catch (CoreException ex) {
- // Failing to set the provider is probably due to a missing nature.
- // Other natures are still set
- Util.logError(Policy.bind("ProjectDescriptionManager.unableToSetDescription"), ex); //$NON-NLS-1$
- }
- }
- // Mark the .vcm_meta file with a problem marker
- if (project.getFile(CORE_PROJECT_DESCRIPTION_PATH).exists()) {
- createVCMMetaMarker(descResource);
- }
- } catch(TeamException ex) {
- Util.logError(Policy.bind("ProjectDescriptionManager.unableToReadDescription"), ex); //$NON-NLS-1$
- // something went wrong, delete the project description file
- descResource.delete(true, progress);
- } catch (IOException ex) {
- Util.logError(Policy.bind("ProjectDescriptionManager.unableToReadDescription"), ex); //$NON-NLS-1$
- // something went wrong, delete the project description file
- descResource.delete(true, progress);
- }
- }
- }
-
- /*
- * Write out the project description file.
- *
- * For now just do it. It would be nice to detect the proper conditions
- *
- */
- public static void writeProjectDescriptionIfNecessary(CVSTeamProvider provider, IResource resource, IProgressMonitor monitor) throws CVSException {
- if (resource.getType() == IResource.PROJECT || isProjectDescription(resource)) {
- IProject project = resource.getProject();
- if (project.getFile(PROJECT_DESCRIPTION_PATH).exists() /* || ! project.getFile(CORE_PROJECT_DESCRIPTION_PATH).exists() */) {
- writeProjectDescription(project, monitor);
- }
- }
- }
-
- public static boolean isProjectDescription(IResource resource) {
- return resource.getProjectRelativePath().equals(PROJECT_DESCRIPTION_PATH);
- }
-
- public void resourceChanged(IResourceChangeEvent event) {
- try {
- IResourceDelta root = event.getDelta();
- IResourceDelta[] projectDeltas = root.getAffectedChildren(IResourceDelta.CHANGED | IResourceDelta.ADDED);
- for (int i = 0; i < projectDeltas.length; i++) {
- IResourceDelta delta = projectDeltas[i];
- IResource resource = delta.getResource();
- if (resource.getType() == IResource.PROJECT) {
- IProject project = (IProject)resource;
- RepositoryProvider provider = RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId());
- if (provider == null) continue;
- // First, check if the .vcm_meta file for the project is in the delta.
- IResourceDelta[] children = delta.getAffectedChildren(IResourceDelta.ADDED);
- boolean inSync = false;
- for (int j = 0; j < children.length; j++) {
- IResourceDelta childDelta = children[j];
- IResource childResource = childDelta.getResource();
- if (isProjectDescription(childResource))
- switch (childDelta.getKind()) {
- case IResourceDelta.REMOVED:
- writeProjectDescriptionIfNecessary((CVSTeamProvider)provider, project, Policy.monitorFor(null));
- inSync = true;
- break;
- case IResourceDelta.CHANGED:
- case IResourceDelta.ADDED:
- updateProjectIfNecessary(project, Policy.monitorFor(null));
- inSync = true;
- break;
- }
- }
- // Check if we didn't do anything above and the project description changed.
- if (! inSync && (delta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
- writeProjectDescriptionIfNecessary((CVSTeamProvider)provider, project, Policy.monitorFor(null));
- }
- }
- }
- } catch (CVSException ex) {
- Util.logError(Policy.bind("ProjectDescriptionManager.cannotUpdateDesc"), ex); //$NON-NLS-1$
- } catch (CoreException ex) {
- Util.logError(Policy.bind("ProjectDescriptionManager.cannotUpdateDesc"), ex); //$NON-NLS-1$
- }
- }
-
- protected static IMarker createVCMMetaMarker(IResource resource) {
- try {
- IMarker[] markers = resource.findMarkers(VCMMETA_MARKER, false, IResource.DEPTH_ZERO);
- if (markers.length == 1) {
- return markers[0];
- }
- IMarker marker = resource.createMarker(VCMMETA_MARKER);
- marker.setAttribute(IMarker.MESSAGE, Policy.bind("ProjectDescriptionManager.vcmmetaMarker" , resource.getName(), resource.getProject().getName())); //$NON-NLS-1$
- return marker;
- } catch (CoreException e) {
- Util.logError(Policy.bind("ProjectDescriptionManager.markerError"), e); //$NON-NLS-1$
- }
- return null;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionWriter.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionWriter.java
deleted file mode 100644
index a0bd2b49c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionWriter.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-import java.util.*;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-
-import java.io.*;
-
-// NIK: Maybe we should make the Strings constants ?
-
-public class ProjectDescriptionWriter {
- private static void appendEscapedChar(StringBuffer buffer, char c) {
- String replacement = getReplacement(c);
- if (replacement != null) {
- buffer.append('&');
- buffer.append(replacement);
- buffer.append(';');
- } else {
- if ((c >= ' ' && c <= 0x7E) || c == '\n' || c == '\r' || c == '\t') {
- buffer.append(c);
- } else {
- buffer.append("&#"); //$NON-NLS-1$
- buffer.append(Integer.toString(c));
- buffer.append(';');
- }
- }
- }
- public static String getEscaped(String s) {
- StringBuffer result = new StringBuffer(s.length() + 10);
- for (int i = 0; i < s.length(); ++i)
- appendEscapedChar(result, s.charAt(i));
- return result.toString();
- }
- private static String getReplacement(char c) {
- // Encode special XML characters into the equivalent character references.
- // These five are defined by default for all XML documents.
- switch (c) {
- case '<' :
- return "lt"; //$NON-NLS-1$
- case '>' :
- return "gt"; //$NON-NLS-1$
- case '"' :
- return "quot"; //$NON-NLS-1$
- case '\'' :
- return "apos"; //$NON-NLS-1$
- case '&' :
- return "amp"; //$NON-NLS-1$
- }
- return null;
- }
- public static void writeProjectDescription(
- IProjectDescription desc,
- OutputStream os)
- throws IOException {
- PrintWriter writer = new PrintWriter(new OutputStreamWriter(os, "UTF8")); //$NON-NLS-1$
- writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //$NON-NLS-1$
- writer.println("<project-description>"); //$NON-NLS-1$
-
- String comment = desc.getComment();
- if (comment != null) {
- writer.print("\t<comment>"); //$NON-NLS-1$
- writer.print(getEscaped(desc.getComment()));
- writer.println("</comment>"); //$NON-NLS-1$
- }
-
- String[] natures = desc.getNatureIds();
- for (int i = 0; i < natures.length; i++) {
- if ( ! natures[i].equals(CVSProviderPlugin.getTypeId()))
- writer.println("\t<nature id=\"" + getEscaped(natures[i]) + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- IProject[] references = desc.getReferencedProjects();
- for (int i = 0; i < references.length; i++) {
- writer.println(
- "\t<reference project-name=\"" + getEscaped(references[i].getName()) + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- ICommand[] commands = desc.getBuildSpec();
- for (int i = 0; i < commands.length; i++) {
- writer.println(
- "\t<builder name=\"" + getEscaped(commands[i].getBuilderName()) + "\">"); //$NON-NLS-1$ //$NON-NLS-2$
- Map args = commands[i].getArguments();
- for (Iterator it = args.keySet().iterator(); it.hasNext();) {
- String argName = (String) it.next();
- String argValue = (String) args.get(argName);
- writer.println(
- "\t\t<arg name=\"" //$NON-NLS-1$
- + getEscaped(argName)
- + "\" value=\"" //$NON-NLS-1$
- + getEscaped(argValue)
- + "\"/>"); //$NON-NLS-1$
- }
- writer.println("\t</builder>"); //$NON-NLS-1$
- }
-
- writer.println("</project-description>"); //$NON-NLS-1$
- writer.flush();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java
deleted file mode 100644
index 2a126e028..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * 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.util;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-public class ReplaceWithBaseVisitor implements ICVSResourceVisitor {
-
- private IProgressMonitor monitor;
- private int depth;
-
- /**
- * @see ICVSResourceVisitor#visitFile(ICVSFile)
- */
- public void visitFile(final ICVSFile file) throws CVSException {
- ResourceSyncInfo info = file.getSyncInfo();
- if (info == null) {
- // Delete unmanaged files if the user wants them deleted
- if (CVSProviderPlugin.getPlugin().isReplaceUnmanaged()) {
- file.delete();
- }
- } else if (info.isAdded()) {
- file.delete();
- file.unmanage(null);
- } else {
- CVSTag tag = info.getTag();
- boolean isModified = file.isModified();
- if (info.isDeleted()) {
- // If deleted, null the sync info so the file will be refetched
- MutableResourceSyncInfo mutable = info.cloneMutable();
- mutable.setDeleted(false);
- file.setSyncInfo(mutable);
- isModified = true;
- }
- // Fetch the file from the server
- if (isModified) {
- ICVSFolder parent = file.getParent();
- FolderSyncInfo folderInfo = parent.getFolderSyncInfo();
- Session.run(CVSProviderPlugin.getProvider().getRepository(folderInfo.getRoot()), parent, true, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- Command.UPDATE.execute(Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] {Update.makeTagOption(CVSTag.BASE), Update.IGNORE_LOCAL_CHANGES},
- new ICVSResource[] { file }, null, monitor);
- }
- }, Policy.subMonitorFor(monitor, 1));
-
- // Set the tag to be the original tag
- info = file.getSyncInfo();
- MutableResourceSyncInfo mutable = info.cloneMutable();
- mutable.setTag(tag);
- file.setSyncInfo(mutable);
- }
- }
- monitor.worked(1);
- }
-
- /**
- * @see ICVSResourceVisitor#visitFolder(ICVSFolder)
- */
- public void visitFolder(ICVSFolder folder) throws CVSException {
- // Visit the children of the folder as appropriate
- if (depth == IResource.DEPTH_INFINITE) {
- folder.acceptChildren(this);
- } else if (depth == IResource.DEPTH_ONE) {
- ICVSResource[] files = folder.members(ICVSFolder.FILE_MEMBERS);
- for (int i = 0; i < files.length; i++) {
- files[i].accept(this);
- }
- }
- // Also delete ignored child files that start with .#
- ICVSResource[] ignoredFiles = folder.members(ICVSFolder.FILE_MEMBERS | ICVSFolder.IGNORED_MEMBERS);
- for (int i = 0; i < ignoredFiles.length; i++) {
- ICVSResource cvsResource = ignoredFiles[i];
- if (cvsResource.getName().startsWith(".#")) { //$NON-NLS-1$
- cvsResource.delete();
- }
- }
- monitor.worked(1);
- }
-
- public void replaceWithBase(IProject project, final IResource[] resources, int depth, IProgressMonitor pm) throws CVSException {
- this.depth = depth;
- final ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(project);
- FolderSyncInfo folderInfo = root.getFolderSyncInfo();
- Session.run(CVSProviderPlugin.getProvider().getRepository(folderInfo.getRoot()), root, true, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- root.run(new ICVSRunnable() {
- public void run(IProgressMonitor pm) throws CVSException {
- ReplaceWithBaseVisitor.this.monitor = Policy.infiniteSubMonitorFor(pm, 100);
- ReplaceWithBaseVisitor.this.monitor.beginTask(null, 512);
- for (int i = 0; i < resources.length; i++) {
- ReplaceWithBaseVisitor.this.monitor.subTask(Policy.bind("ReplaceWithBaseVisitor.replacing", resources[i].getFullPath().toString())); //$NON-NLS-1$
- CVSWorkspaceRoot.getCVSResourceFor(resources[i]).accept(ReplaceWithBaseVisitor.this);
- }
- ReplaceWithBaseVisitor.this.monitor.done();
- }
- }, monitor);
- }
- }, pm);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/StringMatcher.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/StringMatcher.java
deleted file mode 100644
index b6c84ef2d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/StringMatcher.java
+++ /dev/null
@@ -1,389 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.*;
-
-/**
- * A string pattern matcher, suppporting * and ? wildcards.
- * Note: code copied from org.eclipse.jdt.internal.core.util.StringMatcher on April 3, 2001
- * (version 0.1 - 010901H18 [rename jbl]).
- */
-public class StringMatcher {
- protected String fPattern;
- protected int fLength; // pattern length
- protected boolean fIgnoreWildCards;
- protected boolean fIgnoreCase;
- protected boolean fHasLeadingStar;
- protected boolean fHasTrailingStar;
- protected String fSegments[]; //the given pattern is split into * separated segments
-
- /* boundary value beyond which we don't need to search in the text */
- protected int fBound = 0;
-
-
- protected static final char fSingleWildCard = '\u0000';
-
- public static class Position {
- int start; //inclusive
- int end; //exclusive
- public Position(int start, int end) {
- this.start = start;
- this.end = end;
- }
- public int getStart() {
- return start;
- }
- public int getEnd() {
- return end;
- }
- }
- /**
- * Find the first occurrence of the pattern between <code>start</code)(inclusive)
- * and <code>end</code>(exclusive).
- * @param <code>text</code>, the String object to search in
- * @param <code>start</code>, the starting index of the search range, inclusive
- * @param <code>end</code>, the ending index of the search range, exclusive
- * @return an <code>StringMatcher.Position</code> object that keeps the starting
- * (inclusive) and ending positions (exclusive) of the first occurrence of the
- * pattern in the specified range of the text; return null if not found or subtext
- * is empty (start==end). A pair of zeros is returned if pattern is empty string
- * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
- * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
- */
-
- public StringMatcher.Position find(String text, int start, int end) {
- if (fPattern == null|| text == null)
- throw new IllegalArgumentException();
-
- int tlen = text.length();
- if (start < 0)
- start = 0;
- if (end > tlen)
- end = tlen;
- if (end < 0 ||start >= end )
- return null;
- if (fLength == 0)
- return new Position(start, start);
- if (fIgnoreWildCards) {
- int x = posIn(text, start, end);
- if (x < 0)
- return null;
- return new Position(x, x+fLength);
- }
-
- int segCount = fSegments.length;
- if (segCount == 0)//pattern contains only '*'(s)
- return new Position (start, end);
-
- int curPos = start;
- int matchStart = -1;
- int i;
- for (i = 0; i < segCount && curPos < end; ++i) {
- String current = fSegments[i];
- int nextMatch = regExpPosIn(text, curPos, end, current);
- if (nextMatch < 0 )
- return null;
- if(i == 0)
- matchStart = nextMatch;
- curPos = nextMatch + current.length();
- }
- if (i < segCount)
- return null;
- return new Position(matchStart, curPos);
- }
- /**
- * StringMatcher constructor takes in a String object that is a simple
- * pattern which may contain *  for 0 and many characters and
- * ?  for exactly one character.
- *
- * Literal '*' and '?' characters must be escaped in the pattern
- * e.g., "\*" means literal "*", etc.
- *
- * Escaping any other character (including the escape character itself),
- * just results in that character in the pattern.
- * e.g., "\a" means "a" and "\\" means "\"
- *
- * If invoking the StringMatcher with string literals in Java, don't forget
- * escape characters are represented by "\\".
- *
- * @param aPattern the pattern to match text against
- * @param ignoreCase if true, case is ignored
- * @param ignoreWildCards if true, wild cards and their escape sequences are ignored
- * (everything is taken literally).
- */
- public StringMatcher(String aPattern, boolean ignoreCase, boolean ignoreWildCards) {
- fIgnoreCase = ignoreCase;
- fIgnoreWildCards = ignoreWildCards;
- fLength = aPattern.length();
-
- /* convert case */
- if (fIgnoreCase) {
- fPattern = aPattern.toUpperCase();
- } else {
- fPattern = aPattern;
- }
-
- if (fIgnoreWildCards) {
- parseNoWildCards();
- } else {
- parseWildCards();
- }
- }
- /**
- * Given the starting (inclusive) and the ending (exclusive) poisitions in the
- * <code>text</code>, determine if the given substring matches with aPattern
- * @return true if the specified portion of the text matches the pattern
- * @param String <code>text</code>, a String object that contains the substring to match
- * @param int <code>start<code> marks the starting position (inclusive) of the substring
- * @param int <code>end<code> marks the ending index (exclusive) of the substring
- */
- public boolean match(String text, int start, int end) {
- if (null == fPattern || null == text)
- throw new IllegalArgumentException();
-
- if (start >= end)
- return false;
-
- if (fIgnoreWildCards)
- return fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
- int segCount = fSegments.length;
- if (segCount == 0)//pattern contains only '*'(s) or empty pattern
- return true;
- if (start == end)
- return fLength == 0;
- if (fLength == 0)
- return start == end;
-
- int tlen = text.length();
- if (start < 0)
- start = 0;
- if (end > tlen)
- end = tlen;
-
- int tCurPos = start;
- int bound = end - fBound;
- if ( bound < 0)
- return false;
- int i=0;
- String current = fSegments[i];
- int segLength = current.length();
-
- /* process first segment */
- if (!fHasLeadingStar){
- if(!regExpRegionMatches(text, start, current, 0, segLength)) {
- return false;
- } else {
- ++i;
- tCurPos = tCurPos + segLength;
- }
- }
-
- /* process middle segments */
- while ( i < segCount) {
- current = fSegments[i];
- int currentMatch;
- int k = current.indexOf(fSingleWildCard);
- if (k < 0) {
- currentMatch = textPosIn(text, tCurPos, end, current);
- if (currentMatch < 0)
- return false;
- } else {
- currentMatch = regExpPosIn(text, tCurPos, end, current);
- if (currentMatch < 0)
- return false;
- }
- tCurPos = currentMatch + current.length();
- i++;
- }
-
- /* process final segment */
- if (!fHasTrailingStar && tCurPos != end) {
- int clen = current.length();
- return regExpRegionMatches(text, end - clen, current, 0, clen);
- }
- return i == segCount ;
- }
- /**
- * match the given <code>text</code> with the pattern
- * @return true if matched eitherwise false
- * @param <code>text</code>, a String object
- */
- public boolean match(String text) {
- return match(text, 0, text.length());
- }
- /**
- * This method parses the given pattern into segments seperated by wildcard '*' characters.
- * Since wildcards are not being used in this case, the pattern consists of a single segment.
- */
- private void parseNoWildCards() {
- fSegments = new String[1];
- fSegments[0] = fPattern;
- fBound = fLength;
- }
- /**
- * This method parses the given pattern into segments seperated by wildcard '*' characters.
- * @param p, a String object that is a simple regular expression with *  and/or ? 
- */
- private void parseWildCards() {
- if(fPattern.startsWith("*"))//$NON-NLS-1$
- fHasLeadingStar = true;
- if(fPattern.endsWith("*")) {//$NON-NLS-1$
- /* make sure it's not an escaped wildcard */
- if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
- fHasTrailingStar = true;
- }
- }
-
- Vector temp = new Vector();
-
- int pos = 0;
- StringBuffer buf = new StringBuffer();
- while (pos < fLength) {
- char c = fPattern.charAt(pos++);
- switch (c) {
- case '\\':
- if (pos >= fLength) {
- buf.append(c);
- } else {
- char next = fPattern.charAt(pos++);
- /* if it's an escape sequence */
- if (next == '*' || next == '?' || next == '\\') {
- buf.append(next);
- } else {
- /* not an escape sequence, just insert literally */
- buf.append(c);
- buf.append(next);
- }
- }
- break;
- case '*':
- if (buf.length() > 0) {
- /* new segment */
- temp.addElement(buf.toString());
- fBound += buf.length();
- buf.setLength(0);
- }
- break;
- case '?':
- /* append special character representing single match wildcard */
- buf.append(fSingleWildCard);
- break;
- default:
- buf.append(c);
- }
- }
-
- /* add last buffer to segment list */
- if (buf.length() > 0) {
- temp.addElement(buf.toString());
- fBound += buf.length();
- }
-
- fSegments = new String[temp.size()];
- temp.copyInto(fSegments);
- }
- /**
- * @param <code>text</code>, a string which contains no wildcard
- * @param <code>start</code>, the starting index in the text for search, inclusive
- * @param <code>end</code>, the stopping point of search, exclusive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int posIn(String text, int start, int end) {//no wild card in pattern
- int max = end - fLength;
-
- if (!fIgnoreCase) {
- int i = text.indexOf(fPattern, start);
- if (i == -1 || i > max)
- return -1;
- return i;
- }
-
- for (int i = start; i <= max; ++i) {
- if (text.regionMatches(true, i, fPattern, 0, fLength))
- return i;
- }
-
- return -1;
- }
- /**
- * @param <code>text</code>, a simple regular expression that may only contain '?'(s)
- * @param <code>start</code>, the starting index in the text for search, inclusive
- * @param <code>end</code>, the stopping point of search, exclusive
- * @param <code>p</code>, a simple regular expression that may contains '?'
- * @param <code>caseIgnored</code>, wether the pattern is not casesensitive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int regExpPosIn(String text, int start, int end, String p) {
- int plen = p.length();
-
- int max = end - plen;
- for (int i = start; i <= max; ++i) {
- if (regExpRegionMatches(text, i, p, 0, plen))
- return i;
- }
- return -1;
- }
- /**
- *
- * @return boolean
- * @param <code>text</code>, a String to match
- * @param <code>start</code>, int that indicates the starting index of match, inclusive
- * @param <code>end</code> int that indicates the ending index of match, exclusive
- * @param <code>p</code>, String, String, a simple regular expression that may contain '?'
- * @param <code>ignoreCase</code>, boolean indicating wether code>p</code> is case sensitive
- */
- protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) {
- while (plen-- > 0) {
- char tchar = text.charAt(tStart++);
- char pchar = p.charAt(pStart++);
-
- /* process wild cards */
- if (!fIgnoreWildCards) {
- /* skip single wild cards */
- if (pchar == fSingleWildCard) {
- continue;
- }
- }
- if (pchar == tchar)
- continue;
- if (fIgnoreCase) {
- char tc = Character.toUpperCase(tchar);
- if (tc == pchar)
- continue;
- }
- return false;
- }
- return true;
- }
- /**
- * @param <code>text</code>, the string to match
- * @param <code>start</code>, the starting index in the text for search, inclusive
- * @param <code>end</code>, the stopping point of search, exclusive
- * @param code>p</code>, a string that has no wildcard
- * @param <code>ignoreCase</code>, boolean indicating wether code>p</code> is case sensitive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int textPosIn(String text, int start, int end, String p) {
-
- int plen = p.length();
- int max = end - plen;
-
- if (!fIgnoreCase) {
- int i = text.indexOf(p, start);
- if (i == -1 || i > max)
- return -1;
- return i;
- }
-
- for (int i = start; i <= max; ++i) {
- if (text.regionMatches(true, i, p, 0, plen))
- return i;
- }
-
- return -1;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java
deleted file mode 100644
index 422679659..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * 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 implementation
- ******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.util;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-
-/*
- * Listens to CVS meta-file changes and notifies the EclipseSynchronizer of changes made to sync files
- * by 3rd parties.
- *
- * If CVS meta-directories are created outside of the CVS plugin their team-private state will be set
- * by this listener however this change won't be known to other plugins because it does not generate
- * a delta. As a result views, such as the navigator, may show CVS team-private directories. There
- * are some common scenarios where a user may (depending on the order of delta traversal) see
- * this behavior:
- *
- * 1. A user has an existing CVS project outside of Eclipse. By creating the project in Eclipse to point
- * to the existing location the project's contents will be brought into Eclipse and the CVS folders
- * will be marlked as team-private but other delta listeners that have handled the event already won't receive
- * notification that the resource is now team-private. As a result, the user may have to close views or
- * restart the workbench to have the CVS folders filtered.
- *
- * 2. A user performs CVS command line operations outside of Eclipse that result in new CVS folders.
- * From Eclipse the refresh local will bring in the new folders and they will be marked as team-private.
- * But as in 1, they may not appear in the UI.
- *
- * See: http://dev.eclipse.org/bugs/show_bug.cgi?id=12386
- */
-public class SyncFileChangeListener implements IResourceChangeListener {
- /*
- * When a resource changes this method will detect if the changed resources is a meta file that has changed
- * by a 3rd party. For example, if the command line tool was run and then the user refreshed from local. To
- * distinguish changes made by this class and thoses made by others a modification stamp is persisted with each
- * metafile.
- *
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- try {
- final Set changedContainers = new HashSet();
- event.getDelta().accept(new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource resource = delta.getResource();
-
- if(resource.getType()==IResource.ROOT) {
- // continue with the delta
- return true;
- }
-
- String name = resource.getName();
- int kind = delta.getKind();
- IResource[] toBeNotified = new IResource[0];
-
- if(name.equals(SyncFileWriter.CVS_DIRNAME)) {
- handleCVSDir((IContainer)resource, kind);
- } else {
- // Inform the synchronizer about folder creations
- if (kind == delta.ADDED && resource.getType() == IResource.FOLDER) {
- try {
- EclipseSynchronizer.getInstance().folderCreated((IFolder)resource);
- } catch (CVSException e) {
- throw new CoreException(e.getStatus());
- }
- }
- }
-
- if(isMetaFile(resource)) {
- toBeNotified = handleChangedMetaFile(resource, kind);
- } else if(name.equals(SyncFileWriter.IGNORE_FILE)) {
- toBeNotified = handleChangedIgnoreFile(resource, kind);
- }
-
- if(toBeNotified.length>0 && isModifiedBy3rdParty(resource)) {
- for (int i = 0; i < toBeNotified.length; i++) {
- changedContainers.add(toBeNotified[i]);
- }
- if(Policy.DEBUG_METAFILE_CHANGES) {
- System.out.println("[cvs] metafile changed by 3rd party: " + resource.getFullPath()); //$NON-NLS-1$
- }
- return false; /*don't visit any children we have all the information we need*/
- } else {
- return true;
- }
- }
- }, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
-
- if(!changedContainers.isEmpty()) {
- EclipseSynchronizer.getInstance().syncFilesChanged((IContainer[])changedContainers.toArray(new IContainer[changedContainers.size()]));
- }
- } catch(CoreException e) {
- CVSProviderPlugin.log(e.getStatus());
- } catch(CVSException e) {
- CVSProviderPlugin.log(e.getStatus());
- }
- }
-
- /*
- * Consider non-existing resources as being recently deleted and thus modified, and resources
- * with modification stamps that differ from when the CVS plugin last modified the meta-file.
- */
- protected boolean isModifiedBy3rdParty(IResource resource) {
- if(!resource.exists()) return true;
- long modStamp = resource.getModificationStamp();
- Long whenWeWrote;
- try {
- whenWeWrote = (Long)resource.getSessionProperty(SyncFileWriter.MODSTAMP_KEY);
- } catch(CoreException e) {
- CVSProviderPlugin.log(e.getStatus());
- whenWeWrote = null;
- }
- return (whenWeWrote==null || whenWeWrote.longValue() != modStamp);
- }
-
- /*
- * If it's a new CVS directory with the canonical child metafiles then mark it as team-private. Otherwise
- * if changed or deleted
- */
- protected void handleCVSDir(IContainer cvsDir, int kind) {
- if((kind & IResourceDelta.ALL_WITH_PHANTOMS)!=0) {
- if(kind==IResourceDelta.ADDED) {
- // should this dir be made team-private? If it contains CVS/Root and CVS/Repository then yes!
- IFile rootFile = cvsDir.getFile(new Path(SyncFileWriter.ROOT));
- IFile repositoryFile = cvsDir.getFile(new Path(SyncFileWriter.REPOSITORY));
- if(rootFile.exists() && repositoryFile.exists() && !cvsDir.isTeamPrivateMember()) {
- try {
- cvsDir.setTeamPrivateMember(true);
- if(Policy.DEBUG_METAFILE_CHANGES) {
- System.out.println("[cvs] found a new CVS meta folder, marking as team-private: " + cvsDir.getFullPath()); //$NON-NLS-1$
- }
- } catch(CoreException e) {
- CVSProviderPlugin.log(CVSException.wrapException(cvsDir, Policy.bind("SyncFileChangeListener.errorSettingTeamPrivateFlag"), e)); //$NON-NLS-1$
- }
- }
- }
- }
- }
-
- /*
- * It's a meta file if it's parent is a team-private CVS folder.
- */
- protected boolean isMetaFile(IResource resource) {
- IContainer parent = resource.getParent();
- return resource.getType() == IResource.FILE &&
- parent!=null &&
- parent.getName().equals(SyncFileWriter.CVS_DIRNAME) &&
- parent.isTeamPrivateMember();
- }
-
- /*
- * This is a meta file (e.g. folder/CVS/Entries), notify that 'folder' and it's immediate children
- * may have their CVS sync state changed. If the 'folder' is deleted than no notification is
- * required.
- */
- protected IContainer[] handleChangedMetaFile(IResource resource, int kind) {
- IContainer changedContainer = resource.getParent().getParent();
- if(changedContainer.exists()) {
- return new IContainer[] {changedContainer};
- } else {
- return new IContainer[0];
- }
- }
-
- /*
- * This is an ignore file (e.g. folder/.cvsignore), notify that 'folder' and it's immediate children
- * may have their CVS sync state changed.
- */
- protected IContainer[] handleChangedIgnoreFile(IResource resource, int kind) {
- IContainer changedContainer = resource.getParent();
- if(changedContainer.exists()) {
- return new IContainer[] {changedContainer};
- } else {
- return new IContainer[0];
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java
deleted file mode 100644
index 10bdfbf03..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java
+++ /dev/null
@@ -1,375 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/*
- * This is a helper class that knows the format of the CVS metafiles. It
- * provides a bridge between the CVS metafile formats and location to the
- * Eclipse CVS client ResourceSyncInfo and FolderSyncInfo types.
- */
-public class SyncFileWriter {
-
- // the famous CVS meta directory name
- public static final String CVS_DIRNAME = "CVS"; //$NON-NLS-1$
-
- // CVS meta files located in the CVS subdirectory
- public static final String REPOSITORY = "Repository"; //$NON-NLS-1$
- public static final String ROOT = "Root"; //$NON-NLS-1$
- public static final String STATIC = "Entries.Static"; //$NON-NLS-1$
- public static final String TAG = "Tag"; //$NON-NLS-1$
- public static final String ENTRIES = "Entries"; //$NON-NLS-1$
- //private static final String PERMISSIONS = "Permissions"; //$NON-NLS-1$
- public static final String ENTRIES_LOG="Entries.Log"; //$NON-NLS-1$
-
- // the local workspace file that contains pattern for ignored resources
- public static final String IGNORE_FILE = ".cvsignore"; //$NON-NLS-1$
-
- // Some older CVS clients may of added a line to the entries file consisting
- // of only a 'D'. It is safe to ingnore these entries.
- private static final String FOLDER_TAG="D"; //$NON-NLS-1$
-
- // Command characters found in the Entries.log file
- private static final String ADD_TAG="A "; //$NON-NLS-1$
- private static final String REMOVE_TAG="R "; //$NON-NLS-1$
-
- // file and folder patterns that are ignored by default by the CVS server on import.
- public static final String[] PREDEFINED_IGNORE_PATTERNS = {
- "CVS", ".#*", "#*", ",*", "_$*", "*~", "*$", "*.a", "*.bak", "*.BAK", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
- "*.elc", "*.exe", "*.ln", "*.o", "*.obj", "*.olb", "*.old", "*.orig", "*.rej", "*.so", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
- "*.Z", ".del-*", ".make.state", ".nse_depinfo", "CVS.adm", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- "cvslog.*", "RCS", "RCSLOG", "SCCS", "tags", "TAGS"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
-
- // file and folder patterns that are ignored by default by the CVS server on import.
- public static final String[] BASIC_IGNORE_PATTERNS = {"CVS", ".#*"}; //$NON-NLS-1$ //$NON-NLS-2$
-
- // key for saving the mod stamp for each writen meta file
- public static final QualifiedName MODSTAMP_KEY = new QualifiedName("org.eclipse.team.cvs.core", "meta-file-modtime"); //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * Reads the CVS/Entries, CVS/Entries.log and CVS/Permissions files from the
- * specified folder and returns ResourceSyncInfo instances for the data stored therein.
- * If the folder does not have a CVS subdirectory then <code>null</code> is returned.
- */
- public static ResourceSyncInfo[] readAllResourceSync(IContainer parent) throws CVSException {
- IFolder cvsSubDir = getCVSSubdirectory(parent);
- if (! cvsSubDir.exists()) return null;
-
- // process Entries file contents
- String[] entries = readLines(cvsSubDir.getFile(ENTRIES));
- if (entries == null) return null;
- Map infos = new TreeMap();
- for (int i = 0; i < entries.length; i++) {
- String line = entries[i];
- if(!FOLDER_TAG.equals(line) && !"".equals(line)) { //$NON-NLS-1$
- ResourceSyncInfo info = new ResourceSyncInfo(line, null, null);
- infos.put(info.getName(), info);
- }
- }
-
- // process Entries.log file contents
- String[] entriesLog = readLines(cvsSubDir.getFile(ENTRIES_LOG));
- if (entriesLog != null) {
- for (int i = 0; i < entriesLog.length; i++) {
- String line = entriesLog[i];
- if (line.startsWith(ADD_TAG)) {
- line = line.substring(ADD_TAG.length());
- ResourceSyncInfo info = new ResourceSyncInfo(line, null, null);
- infos.put(info.getName(), info);
- } else if (line.startsWith(REMOVE_TAG)) {
- line = line.substring(REMOVE_TAG.length());
- ResourceSyncInfo info = new ResourceSyncInfo(line, null, null);
- infos.remove(info.getName());
- }
- }
- }
-
- // XXX no longer processes CVS/Permissions (was never written) -- should we?
-
- return (ResourceSyncInfo[])infos.values().toArray(new ResourceSyncInfo[infos.size()]);
- }
-
- /**
- * Writes the CVS/Entries, CVS/Entries.log and CVS/Permissions files to the
- * specified folder using the data contained in the specified ResourceSyncInfo instance.
- * If the folder does not have a CVS subdirectory then <code>null</code> is returned.
- */
- public static void writeAllResourceSync(IContainer parent, ResourceSyncInfo[] infos) throws CVSException {
- try {
- IFolder cvsSubDir = createCVSSubdirectory(parent);
-
- // format file contents
- String[] entries = new String[infos.length];
- for (int i = 0; i < infos.length; i++) {
- ResourceSyncInfo info = infos[i];
- entries[i] = info.getEntryLine();
- }
-
- // write Entries
- writeLines(cvsSubDir.getFile(ENTRIES), entries);
-
- // delete Entries.log
- cvsSubDir.getFile(ENTRIES_LOG).delete(IResource.NONE, null);
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Reads the CVS/Root, CVS/Repository, CVS/Tag, and CVS/Entries.static files from
- * the specified folder and returns a FolderSyncInfo instance for the data stored therein.
- * If the folder does not have a CVS subdirectory then <code>null</code> is returned.
- */
- public static FolderSyncInfo readFolderSync(IContainer folder) throws CVSException {
- IFolder cvsSubDir = getCVSSubdirectory(folder);
- if (! cvsSubDir.exists()) return null;
-
- // read CVS/Root
- String root = readFirstLine(cvsSubDir.getFile(ROOT));
- if (root == null) return null;
-
- // read CVS/Repository
- String repository = readFirstLine(cvsSubDir.getFile(REPOSITORY));
- if (repository == null) return null;
-
- // read CVS/Tag
- String tag = readFirstLine(cvsSubDir.getFile(TAG));
- CVSTag cvsTag = (tag != null) ? new CVSEntryLineTag(tag) : null;
-
- // read Entries.Static
- String staticDir = readFirstLine(cvsSubDir.getFile(STATIC));
- boolean isStatic = (staticDir != null);
-
- // return folder sync
- return new FolderSyncInfo(repository, root, cvsTag, isStatic);
- }
-
- /**
- * Writes the CVS/Root, CVS/Repository, CVS/Tag, and CVS/Entries.static files to the
- * specified folder using the data contained in the specified FolderSyncInfo instance.
- */
- public static void writeFolderSync(IContainer folder, FolderSyncInfo info) throws CVSException {
- try {
- IFolder cvsSubDir = createCVSSubdirectory(folder);
-
- // write CVS/Root
- writeLines(cvsSubDir.getFile(ROOT), new String[] {info.getRoot()});
-
- // write CVS/Repository
- writeLines(cvsSubDir.getFile(REPOSITORY), new String[] {info.getRepository()});
-
- // write CVS/Tag
- IFile tagFile = cvsSubDir.getFile(TAG);
- if (info.getTag() != null) {
- writeLines(tagFile, new String[] {info.getTag().toEntryLineFormat(false)});
- } else {
- if(tagFile.exists()) {
- tagFile.delete(IResource.NONE, null);
- }
- }
-
- // write CVS/Entries.Static
- IFile staticFile = cvsSubDir.getFile(STATIC);
- if(info.getIsStatic()) {
- // the existance of the file is all that matters
- writeLines(staticFile, new String[] {""}); //$NON-NLS-1$
- } else {
- if(staticFile.exists()) {
- staticFile.delete(IResource.NONE, null);
- }
- }
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Returns all .cvsignore entries for the specified folder.
- */
- public static String[] readCVSIgnoreEntries(IContainer folder) throws CVSException {
- IFile ignoreFile = folder.getFile(new Path(IGNORE_FILE));
- if (ignoreFile != null) {
- return readLines(ignoreFile);
- }
- return null;
- }
-
- /**
- * Adds a .cvsignore entry to the folder for the specified file.
- */
- public static void addCVSIgnoreEntries(IContainer folder, String[] patterns) throws CVSException {
- IFile ignoreFile = folder.getFile(new Path(IGNORE_FILE));
- writeLines(ignoreFile, patterns);
- }
-
- /**
- * Delete folder sync is equilavent to removing the CVS subdir.
- */
- public static void deleteFolderSync(IContainer folder) throws CVSException {
- try {
- getCVSSubdirectory(folder).delete(IResource.NONE, null);
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Returns the CVS subdirectory for this folder.
- */
- private static IFolder getCVSSubdirectory(IContainer folder) throws CVSException {
- return folder.getFolder(new Path(CVS_DIRNAME));
- }
-
- /**
- * Creates and makes team-private and returns a CVS subdirectory in this folder.
- */
- private static IFolder createCVSSubdirectory(IContainer folder) throws CVSException {
- try {
- final IFolder cvsSubDir = getCVSSubdirectory(folder);
- if (! cvsSubDir.exists()) {
- // important to have both the folder creation and setting of team-private in the
- // same runnable so that the team-private flag is set before other delta listeners
- // sees the CVS folder creation.
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- cvsSubDir.create(false /*don't force*/, true /*make local*/, null);
- cvsSubDir.setTeamPrivateMember(true);
- }
- }, null);
- }
- return cvsSubDir;
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /*
- * Reads the first line of the specified file.
- * Returns null if the file does not exist, or the empty string if it is blank.
- */
- private static String readFirstLine(IFile file) throws CVSException {
- if (! file.exists()) return null;
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()));
- try {
- String line = reader.readLine();
- if (line == null) return ""; //$NON-NLS-1$
- return line;
- } finally {
- reader.close();
- }
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /*
- * Reads all lines of the specified file.
- * Returns null if the file does not exist.
- */
- private static String[] readLines(IFile file) throws CVSException {
- if (! file.exists()) return null;
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()));
- List fileContentStore = new ArrayList();
- try {
- String line;
- while ((line = reader.readLine()) != null) {
- fileContentStore.add(line);
- }
- return (String[]) fileContentStore.toArray(new String[fileContentStore.size()]);
- } finally {
- reader.close();
- }
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /*
- * Writes all lines to the specified file, using linefeed terminators for
- * compatibility with other CVS clients.
- */
- private static void writeLines(final IFile file, final String[] contents) throws CVSException {
- try {
- // The creation of sync files has to be in a runnable in order for the resulting delta
- // to include the MODSTAMP value. If not in a runnable then create/setContents
- // will trigger a delta and the SyncFileWriter change listener won't know that the delta
- // was a result of our own creation.
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- try {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- writeLinesToStreamAndClose(os, contents);
- if(!file.exists()) {
- file.create(new ByteArrayInputStream(os.toByteArray()), IResource.NONE /*don't keep history and don't force*/, null);
- } else {
- file.setContents(new ByteArrayInputStream(os.toByteArray()), IResource.NONE /*don't keep history and don't force*/, null);
- }
- file.setSessionProperty(MODSTAMP_KEY, new Long(file.getModificationStamp()));
- } catch(CVSException e) {
- throw new CoreException(e.getStatus());
- }
- }
- }, null);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- private static void writeLinesToStreamAndClose(OutputStream os, String[] contents) throws CVSException {
- try {
- try {
- for (int i = 0; i < contents.length; i++) {
- os.write(contents[i].getBytes()); // XXX should we specify a character encoding?
- os.write(0x0A); // newline byte
- }
- } finally {
- os.close();
- }
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
deleted file mode 100644
index 46deb13ea..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-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.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-
-/**
- * Unsorted static helper-methods
- */
-public class Util {
- /**
- * Get the extention of the path of resource
- * relative to the path of root
- *
- * @throws CVSException if root is not a root-folder of resource
- */
- public static String getRelativePath(String rootName, String resourceName)
- throws CVSException {
-
- if (!resourceName.startsWith(rootName) || rootName.length() > resourceName.length()) {
- throw new CVSException(Policy.bind("Util.Internal_error,_resource_does_not_start_with_root_3")); //$NON-NLS-1$
- }
-
- // Otherwise we would get an ArrayOutOfBoundException
- // in case of two equal Resources
- if (rootName.length() == resourceName.length()) {
- return ""; //$NON-NLS-1$
- }
-
- // Remove leading slash if there is one
- String result = resourceName.substring(rootName.length()).replace('\\', '/');
- if (result.startsWith("/")) { //$NON-NLS-1$
- result = result.substring(1);
- }
- return result;
- }
-
- /**
- * Append the prefix and suffix to form a valid CVS path.
- */
- public static String appendPath(String prefix, String suffix) {
- if (prefix.length() == 0 || prefix.equals(Session.CURRENT_LOCAL_FOLDER)) {
- return suffix;
- } else if (prefix.endsWith(Session.SERVER_SEPARATOR)) {
- if (suffix.startsWith(Session.SERVER_SEPARATOR))
- return prefix + suffix.substring(1);
- else
- return prefix + suffix;
- } else if (suffix.startsWith(Session.SERVER_SEPARATOR))
- return prefix + suffix;
- else
- return prefix + Session.SERVER_SEPARATOR + suffix;
- }
-
- public static void logError(String message, Throwable throwable) {
- CVSProviderPlugin.log(new Status(IStatus.ERROR, CVSProviderPlugin.ID, IStatus.ERROR, message, throwable));
- }
-
- /**
- * If the number of segments in the relative path of <code>resource</code> to <code>root</code> is
- * greater than <code>split</code> then the returned path is truncated to <code>split</code> number
- * of segments and '...' is shown as the first segment of the path.
- */
- public static String toTruncatedPath(ICVSResource resource, ICVSFolder root, int split) {
- try {
- IPath path = new Path(resource.getRelativePath(root));
- int segments = path.segmentCount();
- if(segments>split) {
- IPath last = path.removeFirstSegments(segments - split);
- return "..." + path.SEPARATOR + last.toString(); //$NON-NLS-1$
- }
- return path.toString();
- } catch(CVSException e) {
- return resource.getName();
- }
- }
-} \ No newline at end of file

Back to the top