Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-03-06 19:38:25 +0000
committerJean Michel-Lemieux2002-03-06 19:38:25 +0000
commit8d097d790e4f15f4f7b82069754b442294e01e08 (patch)
tree17ff535afa67ec4146cd3137cc1284cffe13f0dd
parenta615398377adec55eb8c308b3056c3a2013c7fee (diff)
downloadeclipse.platform.team-8d097d790e4f15f4f7b82069754b442294e01e08.tar.gz
eclipse.platform.team-8d097d790e4f15f4f7b82069754b442294e01e08.tar.xz
eclipse.platform.team-8d097d790e4f15f4f7b82069754b442294e01e08.zip
IResource support in CVS.
- new cvs synchronizer based on the Eclipse sync info support - performance improvements for batching of cvs operations
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java102
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java35
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java18
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java494
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java (renamed from bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSFile.java)178
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java (renamed from bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSFolder.java)216
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSProvider.java6
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java5
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java (renamed from bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSResource.java)274
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java (renamed from bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSResourceVisitor.java)36
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java37
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java7
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java7
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java5
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java16
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java101
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java17
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java6
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java5
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java6
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java5
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java8
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java34
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java5
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java6
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ResourceStatus.java47
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSFileNotFoundException.java30
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java40
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java13
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java139
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java221
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java275
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java (renamed from bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalResource.java)460
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java522
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSSynchronizer.java122
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java157
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFolder.java264
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/NotCVSFolderException.java82
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java16
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java9
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java1
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java (renamed from bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/RemoteFolderTreeBuilder.java)1179
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java17
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FileSystemSynchronizer.java447
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileUtil.java5
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/OrphanedFolderListener.java17
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java356
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java235
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java24
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java5
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java32
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java54
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java10
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSResourceNode.java11
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java5
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java24
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagSelectionDialog.java21
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java12
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java9
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java11
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java20
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java15
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java15
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java28
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RemoveRootAction.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java18
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java15
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java23
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java17
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java11
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java20
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardEndPage.java3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardStartPage.java8
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java9
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/IgnoreAction.java25
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizard.java5
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java6
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java (renamed from tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceException.java)6
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java7
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java106
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java98
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java45
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java427
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/NullOutputStream.java28
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/BasicTest.java53
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/CompatibleTestSetup.java21
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java17
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ModuleTest.java247
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceClient.java233
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java481
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTests.java4
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFileTest.java220
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFolderTest.java446
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/SynchronizerTest.java253
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTests.java2
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java17
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CommandsTest.java513
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java85
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java25
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/SyncElementTest.java66
128 files changed, 4122 insertions, 6121 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
index a63157e39..ea37f7bcb 100644
--- 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
@@ -13,114 +13,70 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.ccvs.core.CVSStatus;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.connection.ResourceStatus;
/**
- * This is an exception that is thrown by the cvs-adaptor
- * for vcm
- *
- * @see CoreExcpetion
+ * 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 {
-
- public CVSException(
- int severity,
- int code,
- IPath path,
- String message,
- Throwable exception) {
- super(new ResourceStatus(severity, code, path, message, exception));
- }
- public CVSException(
- int severity,
- int code,
- IPath path,
- String message) {
- this(severity, code, path, message, null);
- }
- public CVSException(
- int severity,
- int code,
- IPath path,
- Throwable exception) {
- this(severity, code, path, null, exception);
- }
- public CVSException(
- int severity,
- int code,
- String message,
- Exception e) {
- super(new Status(severity, CVSProviderPlugin.ID, code, message, null));
+
+ /*
+ * 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) {
+
+ public CVSException(int severity, int code, String message) {
this(severity, code, message, null);
}
- public CVSException(
- int severity,
- int code,
- Exception e) {
- super(new Status(severity, CVSProviderPlugin.ID, code, null, e));
-
- }
-
public CVSException(String message) {
- super(new Status(IStatus.ERROR, CVSProviderPlugin.ID, UNABLE, message, null));
+ super(new CVSStatus(IStatus.ERROR, UNABLE, message, null));
}
- public CVSException(String message, IPath path) {
- this(message, path, null);
- }
-
public CVSException(String message, Exception e) {
this(IStatus.ERROR, UNABLE, message, e);
}
public CVSException(String message, IPath path, Throwable throwable) {
- this(new ResourceStatus(IStatus.ERROR, path, message, 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) {
+ 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 Status(
- IStatus.ERROR,
- CVSProviderPlugin.ID,
- IO_FAILED,
- message,
- e));
+ 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 Status(
- IStatus.ERROR,
- CVSProviderPlugin.ID,
- UNABLE,
- message,
- e));
+ return new CVSException(new CVSStatus(IStatus.ERROR, UNABLE, message, e));
}
+
/*
* Static helper methods for creating exceptions
*/
public static CVSException wrapException(Exception e) {
- return new CVSException(new Status(
- IStatus.ERROR,
- CVSProviderPlugin.ID,
- UNABLE,
- e.getMessage() != null ? e.getMessage() : "", //$NON-NLS-1$
- e));
+ return new CVSException(new CVSStatus(IStatus.ERROR, UNABLE, e.getMessage() != null ? e.getMessage() : "", e)); //$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/CVSProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
index cb55bf037..f2adc63f5 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
@@ -33,10 +33,12 @@ 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.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSStatus;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSListener;
import org.eclipse.team.ccvs.core.ICVSProvider;
import org.eclipse.team.ccvs.core.ICVSRemoteFolder;
@@ -56,13 +58,12 @@ 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.ICVSFolder;
+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.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;
-import org.eclipse.team.internal.ccvs.core.Policy;
public class CVSProvider implements ICVSProvider {
@@ -198,7 +199,7 @@ public class CVSProvider implements ICVSProvider {
pm.beginTask(null, 1000 * resources.length);
// Get the location of the workspace root
- ICVSFolder root = (ICVSFolder)Session.getManagedResource(ResourcesPlugin.getWorkspace().getRoot());
+ ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot());
for (int i=0;i<resources.length;i++) {
IProject project = null;
@@ -393,7 +394,7 @@ public class CVSProvider implements ICVSProvider {
if (resources.length == 0) return new String[0];
// Get the location of the workspace root
- ICVSFolder root = Session.getManagedFolder(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile());
+ ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot());
// Get the command arguments
String[] arguments = new String[resources.length];
@@ -430,17 +431,7 @@ public class CVSProvider implements ICVSProvider {
}
- /**
- * Get the print stream to which information from CVS commands
- * is sent.
- */
- public PrintStream getPrintStream() {
- if (printStream == null)
- return System.out;
- else
- return printStream;
- }
-
+
/**
* @see ICVSProvider#getRepository(String)
*/
@@ -472,6 +463,8 @@ public class CVSProvider implements ICVSProvider {
// 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
@@ -498,9 +491,7 @@ public class CVSProvider implements ICVSProvider {
} finally {
s.close();
}
-
- // Set the folder sync info of the project to point to the remote module
- ICVSFolder folder = (ICVSFolder)Session.getManagedResource(project);
+
folder.setFolderSyncInfo(new FolderSyncInfo(moduleName, location.getLocation(), null, false));
// Register the project with Team
@@ -518,8 +509,6 @@ public class CVSProvider implements ICVSProvider {
if ( ! alreadyExists)
disposeRepository(location);
throw e;
- } finally {
- CVSProviderPlugin.getSynchronizer().save(project.getLocation().toFile(), Policy.subMonitorFor(monitor, 5));
}
// Add the repository if it didn't exist already
if ( ! alreadyExists)
@@ -569,7 +558,7 @@ public class CVSProvider implements ICVSProvider {
public void setSharing(IProject project, FolderSyncInfo info, IProgressMonitor monitor) throws TeamException {
// Ensure provided info matches that of the project
- ICVSFolder folder = (ICVSFolder)Session.getManagedResource(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$
@@ -589,8 +578,6 @@ public class CVSProvider implements ICVSProvider {
TeamPlugin.getManager().setProvider(project, CVSProviderPlugin.NATURE_ID, null, monitor);
} catch (CoreException e) {
throw wrapException(e);
- } finally {
- CVSProviderPlugin.getSynchronizer().save(project.getLocation().toFile(), Policy.subMonitorFor(monitor, 5));
}
}
@@ -638,7 +625,7 @@ public class CVSProvider implements ICVSProvider {
ITeamProvider provider = manager.getProvider(projects[i]);
if (provider instanceof CVSTeamProvider) {
CVSTeamProvider cvsProvider = (CVSTeamProvider)provider;
- ICVSFolder folder = (ICVSFolder)Session.getManagedResource(projects[i]);
+ ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(projects[i]);
FolderSyncInfo info = folder.getFolderSyncInfo();
if (info != null) {
ICVSRepositoryLocation result = getRepository(info.getRoot());
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
index 7c1d05b3c..1db4af642 100644
--- 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
@@ -18,14 +18,11 @@ import org.eclipse.core.runtime.Plugin;
import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
-import org.eclipse.team.core.sync.ISyncProvider;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProvider;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSSynchronizer;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FileSystemSynchronizer;
+import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
import org.eclipse.team.internal.ccvs.core.util.OrphanedFolderListener;
import org.eclipse.team.internal.ccvs.core.util.ProjectDescriptionManager;
import org.eclipse.team.internal.ccvs.core.util.Util;
@@ -56,7 +53,6 @@ public class CVSProviderPlugin extends Plugin {
private String cvsServer = DEFAULT_CVS_SERVER;
private static CVSProviderPlugin instance;
- private static ICVSSynchronizer synchronizer;
/**
* The identifier for the CVS nature
@@ -156,9 +152,8 @@ public class CVSProviderPlugin extends Plugin {
super.startup();
Policy.localize("org.eclipse.team.internal.ccvs.core.messages"); //$NON-NLS-1$
- synchronizer = new FileSystemSynchronizer();
-
CVSProvider.startup();
+ EclipseSynchronizer.startup();
ProjectDescriptionManager.initializeChangeListener();
new OrphanedFolderListener().register();
}
@@ -169,15 +164,10 @@ public class CVSProviderPlugin extends Plugin {
public void shutdown() throws CoreException {
super.shutdown();
CVSProvider.shutdown();
- }
-
- /**
- * Returns the synchronizer reponsible for managing the CVS meta information.
- */
- public static ICVSSynchronizer getSynchronizer() {
- return synchronizer;
+ EclipseSynchronizer.shutdown();
}
+
/*
* 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.
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
index 4b8ea6a16..98bde2a93 100644
--- 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
@@ -9,6 +9,7 @@ import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
@@ -24,7 +25,6 @@ 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.IFileTypeRegistry;
import org.eclipse.team.core.ITeamNature;
@@ -46,19 +46,13 @@ import org.eclipse.team.internal.ccvs.core.client.listeners.DiffListener;
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.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
+import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTreeBuilder;
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.RemoteFolderTreeBuilder;
/**
* This class acts as both the ITeamNature and the ITeamProvider instances
@@ -91,8 +85,7 @@ import org.eclipse.team.internal.ccvs.core.util.RemoteFolderTreeBuilder;
*/
public class CVSTeamProvider implements ITeamNature, ITeamProvider {
- // Instance variables
- private ICVSFolder managedProject;
+ private CVSWorkspaceRoot workspaceRoot;
private IProject project;
private String comment = ""; //$NON-NLS-1$
@@ -106,7 +99,6 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
* @see IProjectNature#configure()
*/
public void configure() throws CoreException {
- // Do nothing
}
/**
@@ -121,6 +113,12 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
public IProject getProject() {
return project;
}
+
+ /**
+ * @see ITeamNature#configureProvider(Properties)
+ */
+ public void configureProvider(Properties configuration) throws TeamException {
+ }
/**
* @see IProjectNature#setProject(IProject)
@@ -128,9 +126,9 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
public void setProject(IProject project) {
this.project = project;
try {
- this.managedProject = Session.getManagedFolder(project.getLocation().toFile());
+ this.workspaceRoot = new CVSWorkspaceRoot(project);
// Ensure that the project has CVS info
- if (managedProject.getFolderSyncInfo() == null) {
+ if (workspaceRoot.getLocalRoot().getFolderSyncInfo() == null) {
throw new CVSException(new CVSStatus(CVSStatus.ERROR, Policy.bind("CVSTeamProvider.noFolderInfo", project.getName()))); //$NON-NLS-1$
}
} catch (CVSException e) {
@@ -143,21 +141,13 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
* @see ITeamNature#getProvider()
*/
public ITeamProvider getProvider() throws TeamException {
- if (managedProject == null) {
- // An error must have occured when we were configured
+ if (workspaceRoot == null) {
throw new TeamException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, Policy.bind("CVSTeamProvider.initializationFailed", new Object[]{project.getName()}), null)); //$NON-NLS-1$
}
return this;
}
/**
- * @see ITeamNature#configureProvider(Properties)
- */
- public void configureProvider(Properties configuration) throws TeamException {
- // Do nothing
- }
-
- /**
* Add the given resources to the project.
* <p>
* The sematics follow that of CVS in the sense that any folders
@@ -202,35 +192,28 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
try {
// Auto-add parents if they are not already managed
IContainer parent = currentResource.getParent();
- // XXX Need to consider workspace root
-
- while (parent.getType() != IResource.ROOT && ! isManaged(parent)) {
- folders.add(parent.getFullPath().removeFirstSegments(1).toString());
+ 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) {
- try {
- ICVSResource mResource = (ICVSResource)Session.getManagedResource(resource);
- // Add the resource is its not already managed and it was either
- // added explicitly (is equal currentResource) or is not ignored
- if (! isManaged(resource) && (currentResource.equals(resource) || ! mResource.isIgnored())) {
- String name = resource.getFullPath().removeFirstSegments(1).toString();
- if (resource.getType() == IResource.FILE) {
- String extension = resource.getFileExtension();
- if ((extension != null) && ("true".equals(registry.getValue(extension, "isText")))) //$NON-NLS-1$ //$NON-NLS-2$
- textfiles.add(name);
- else
- binaryfiles.add(name);
- } else
- folders.add(name);
- }
- } catch (TeamException e) {
- // Record the exception to be thrown again later
- eHolder[0] = e;
- return false;
+ 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) {
+ String extension = resource.getFileExtension();
+ if ((extension != null) && ("true".equals(registry.getValue(extension, "isText")))) //$NON-NLS-1$ //$NON-NLS-2$
+ textfiles.add(name);
+ else
+ binaryfiles.add(name);
+ } else
+ folders.add(name);
}
// Always return true and let the depth determine if children are visited
return true;
@@ -248,7 +231,7 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
// Add the folders, followed by files!
IStatus status;
- Session s = new Session(getRemoteRoot(), managedProject);
+ Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
progress.beginTask(null, 100);
try {
// Opening the session takes 10% of the time
@@ -314,7 +297,7 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
// Commit the resources
IStatus status;
- Session s = new Session(getRemoteRoot(), managedProject);
+ Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
progress.beginTask(null, 100);
try {
// Opening the session takes 20% of the time
@@ -342,18 +325,7 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
*/
public void checkout(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException {
}
-
- /*
- * 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));
- }
-
+
/**
* @see ITeamProvider#delete(IResource[], int, IProgressMonitor)
*/
@@ -368,23 +340,21 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
final List files = new ArrayList(resources.length);
final TeamException[] eHolder = new TeamException[1];
for (int i=0;i<resources.length;i++) {
- checkIsChild(resources[i]);
+ IResource resource = resources[i];
+ checkIsChild(resource);
try {
- if (resources[i].exists()) {
- resources[i].accept(new IResourceVisitor() {
+ if (resource.exists()) {
+ resource.accept(new IResourceVisitor() {
public boolean visit(IResource resource) {
try {
- if (isManaged(resource)) {
- String name = resource.getFullPath().removeFirstSegments(1).toString();
+ 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 (TeamException e) {
- eHolder[0] = e;
- // If there was a problem, don't visit the children
- return false;
} catch (CoreException e) {
eHolder[0] = wrapException(e);
// If there was a problem, don't visit the children
@@ -394,9 +364,9 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
return true;
}
}, IResource.DEPTH_INFINITE, false);
- } else if (resources[i].getType() == IResource.FILE) {
+ } else if (resource.getType() == IResource.FILE) {
// If the resource doesn't exist but is a file, queue it for removal
- files.add(resources[i].getFullPath().removeFirstSegments(1).toString());
+ files.add(resource.getProjectRelativePath().toString());
}
} catch (CoreException e) {
throw wrapException(e);
@@ -409,7 +379,7 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
// Remove the files remotely
IStatus status;
- Session s = new Session(getRemoteRoot(), managedProject);
+ Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
s.open(progress);
try {
status = Command.REMOVE.execute(s,
@@ -423,7 +393,7 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
}
if (status.getCode() == CVSStatus.SERVER_ERROR) {
throw new CVSServerException(status);
- }
+ }
} finally {
progress.done();
}
@@ -441,7 +411,7 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
String[] arguments = getValidArguments(resources, options);
IStatus status;
- Session s = new Session(getRemoteRoot(), managedProject);
+ Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
progress.beginTask(null, 100);
try {
s.open(Policy.subMonitorFor(progress, 20));
@@ -504,8 +474,7 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
for (int i = 0; i < resources.length; i++) {
subProgress.subTask(Policy.bind("CVSTeamProvider.scrubbingResource", resources[i].getFullPath().toString()));
IResource resource = resources[i];
- getChild(resource).accept(visitor);
- CVSProviderPlugin.getSynchronizer().save(resource.getLocation().toFile(), progress);
+ workspaceRoot.getLocalRoot().getChild(resource.getProjectRelativePath().toString()).accept(visitor);
}
subProgress.done();
@@ -522,198 +491,24 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
}
}
- /*
- * Get the corresponding managed child for the given resource.
- */
- private ICVSResource getChild(IResource resource) throws CVSException {
- if (resource.equals(project))
- return managedProject;
- return managedProject.getChild(resource.getFullPath().removeFirstSegments(1).toString());
- }
-
- /**
- * Answer the name of the connection method for the given resource's
- * project.
- */
- public String getConnectionMethod(IResource resource) throws TeamException {
- checkIsChild(resource);
- return getRemoteRoot().getMethod().getName();
- }
-
- /**
- * Get the print stream to which information from CVS commands
- * is sent.
- */
- private PrintStream getPrintStream() {
- return CVSProviderPlugin.getProvider().getPrintStream();
- }
-
- /**
- * Get the remote resource corresponding to the base of the local resource.
- * This method returns null if the corresponding local resource does not have a base.
- *
- * Use getRemoteSyncTree() to get the current remote state of HEAD or a branch.
- */
- public ICVSRemoteResource getRemoteResource(IResource resource) throws TeamException {
- checkIsChild(resource);
- ICVSResource managed = getChild(resource);
- if (managed.isFolder()) {
- ICVSFolder folder = (ICVSFolder)managed;
- if (folder.isCVSFolder()) {
- FolderSyncInfo syncInfo = folder.getFolderSyncInfo();
- return new RemoteFolder(null, CVSProvider.getInstance().getRepository(syncInfo.getRoot()), new Path(syncInfo.getRepository()), syncInfo.getTag());
- }
- } else {
- if (managed.isManaged())
- return RemoteFile.getBase((RemoteFolder)getRemoteResource(resource.getParent()), (ICVSFile)managed);
- }
- return null;
- }
-
- /**
- * Return the repository location to which the provider is connected
- */
- public ICVSRepositoryLocation getRemoteRoot() throws CVSException {
- return CVSProvider.getInstance().getRepository(managedProject.getFolderSyncInfo().getRoot());
- }
-
- /*
- * 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 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();
- if (!parent.isCVSFolder()) {
- // Check to make sure the project still has the CVS information
- if (managedProject.getFolderSyncInfo() == null) {
- // This is a catastrophic error. The project should have CVS information
- TeamPlugin.getManager().removeProvider(project, progress);
- throw new CVSException(new CVSStatus(CVSStatus.ERROR, project.getFullPath(), Policy.bind("CVSTeamProvider.invalidProjectState", managedProject.getName()), null)); //$NON-NLS-1$
- } else {
- throw new CVSException(new CVSStatus(CVSStatus.ERROR, resource.getFullPath(), Policy.bind("CVSTeamProvider.unmanagedParent", resource.getFullPath().toString()), null)); //$NON-NLS-1$
- }
- }
-
- // Fetch the parent tree.
- // The progress monitor is only passed to one method so no wrapping is needed
- 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 IRemoteSyncElement getRemoteSyncTree(IResource resource, CVSTag tag, IProgressMonitor progress) throws TeamException {
- checkIsChild(resource);
- ICVSResource managed = getChild(resource);
- ICVSRemoteResource remote = getRemoteResource(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) {
- // The progress monitor is only passed to one method so no wrapping is needed
- remote = getRemoteTreeFromParent(resource, managed, tag, progress);
- } else if(resource.getType() == IResource.FILE) {
- // The progress monitor is only passed to one method so no wrapping is needed
- baseTree = remote;
- remote = RemoteFile.getLatest((RemoteFolder)getRemoteResource(resource.getParent()), (ICVSFile)managed, tag, progress);
- } else {
- try {
- progress.beginTask(null, 100);
- ICVSRepositoryLocation location = remote.getRepository();
- baseTree = RemoteFolderTreeBuilder.buildBaseTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, Policy.subMonitorFor(progress, 20));
- remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, Policy.subMonitorFor(progress, 80));
- } finally {
- progress.done();
- }
- }
- return new CVSRemoteSyncElement(false, resource, baseTree, remote);
- }
-
- public ICVSRemoteResource getRemoteTree(IResource resource, CVSTag tag, IProgressMonitor progress) throws TeamException {
- checkIsChild(resource);
- ICVSResource managed = getChild(resource);
- ICVSRemoteResource remote = getRemoteResource(resource);
- if (remote == null) {
- // The progress monitor is only passed to one method so no wrapping is needed
- remote = getRemoteTreeFromParent(resource, managed, tag, progress);
- } else if(resource.getType() == IResource.FILE) {
- // The progress monitor is only passed to one method so no wrapping is needed
- remote = RemoteFile.getLatest((RemoteFolder)getRemoteResource(resource.getParent()), (ICVSFile)managed, tag, progress);
- } else {
- // The progress monitor is only passed to one method so no wrapping is needed
- ICVSRepositoryLocation location = remote.getRepository();
- remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress);
- }
- return remote;
- }
-
- /**
- * Returns an IUserInfo instance that can be used to access and set the
- * user name and set the password. To have changes take place, the user must
- * invoke the setUserInfo() method.
- */
- public IUserInfo getUserInfo(IResource resource) throws TeamException {
- checkIsChild(resource);
- // Get the repository location for the receiver
- CVSRepositoryLocation location = (CVSRepositoryLocation)getRemoteRoot();
- return location.getUserInfo(true);
- }
-
- /*
- * Get the arguments to be passed to a commit or update
- */
- private String[] getValidArguments(IResource[] resources, LocalOption[] options) throws CVSException {
- int depth = Command.DO_NOT_RECURSE.isElementOf(options) ? IResource.DEPTH_ZERO : IResource.DEPTH_INFINITE;
- List arguments = new ArrayList(resources.length);
- for (int i=0;i<resources.length;i++) {
- checkIsChild(resources[i]);
- // A depth of zero is only valid for files
- if ((depth != IResource.DEPTH_ZERO) || (resources[i].getType() == IResource.FILE)) {
- 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()]);
- }
-
/**
* @see ITeamProvider#hasRemote(IResource)
* XXX to be removed when sync methods are removed from ITeamProvider
*/
public boolean hasRemote(IResource resource) {
try {
- LocalResource cvsResource;
+ ICVSResource cvsResource = workspaceRoot.getCVSResourceFor(resource);
int type = resource.getType();
if(type!=IResource.FILE) {
- cvsResource = new LocalFolder(resource.getLocation().toFile());
if(type==IResource.PROJECT) {
return ((ICVSFolder)cvsResource).isCVSFolder();
} else {
return cvsResource.isManaged();
}
} else {
- cvsResource = new LocalFile(resource.getLocation().toFile());
ResourceSyncInfo info = cvsResource.getSyncInfo();
if(info!=null) {
- return !info.getRevision().equals(ResourceSyncInfo.ADDED_REVISION);
+ return !info.isAdded();
} else {
return false;
}
@@ -728,42 +523,8 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
* XXX to be removed when sync methods are removed from ITeamProvider
*/
public boolean isCheckedOut(IResource resource) {
- // check to see if the resource exists and has an entry
- try {
- return isManaged(resource);
- } catch (TeamException e) {
- // Something went wrong. Log it and say the file is not checked out
- CVSProviderPlugin.log(e);
- return false;
- }
- }
-
- /*
- * Helper to indicate if the resource is a child of the receiver's project
- */
- private boolean isChildResource(IResource resource) {
- return resource.getProject().getName().equals(managedProject.getName());
- }
-
- /**
- * Return whether the given resource is managed.
- *
- * From a CVS standpoint, this means that we have a CVS entry
- * for the resource and that uodates and commits may effect the
- * resource or its children.
- */
- public boolean isManaged(IResource resource) throws TeamException {
-
- if (resource.equals(project))
- return true;
-
- // Ensure that the resource is a child of our project
- if (!isChildResource(resource))
- // Is returning false enough or should we throw an exception
- return false;
-
- // Get the ICVSResource corresponding to the resource and check if its managed
- return getChild(resource).isManaged();
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ return cvsResource.isManaged();
}
/**
@@ -782,18 +543,7 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
/**
* @see ITeamProvider#move(IResource, IPath, IProgressMonitor)
*/
- public void moved(IPath source, IResource resource, IProgressMonitor progress)
- throws TeamException {
-
- // this translates to a delete and an add
-
- // How is this managed? Do we do the move or is that done after?
- // It becomes complicated if the local and remote operations
- // are independant as this is not the way CVS works!
-
- // Could implement a CVSProvider.MOVE!!!
-
- // XXX ????
+ public void moved(IPath source, IResource resource, IProgressMonitor progress) throws TeamException {
}
/**
@@ -815,9 +565,9 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
if (!CVSRepositoryLocation.validateConnectionMethod(methodName))
return false;
-
+
// Get the original location
- ICVSRepositoryLocation location = getRemoteRoot();
+ ICVSRepositoryLocation location = workspaceRoot.getRemoteLocation();
// Make a copy to work on
CVSRepositoryLocation newLocation = CVSRepositoryLocation.fromString(location.getLocation());
@@ -844,39 +594,6 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
}
}
- /*
- * This method expects to be passed an InfiniteSubProgressMonitor
- */
- private void setRemoteRoot(ICVSRepositoryLocation location, final IProgressMonitor monitor) throws TeamException {
-
- // Check if there is a differnece between the new and old roots
- final String root = location.getLocation();
- if (root.equals(getRemoteRoot().getLocation()))
- return;
-
- try {
- // 256 ticks gives us a maximum of 1024 which seems reasonable for folders is a project
- 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
- managedProject.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);
- }
- };
- });
- CVSProviderPlugin.getSynchronizer().save(project.getLocation().toFile(), monitor);
- } finally {
- monitor.done();
- }
- }
-
/**
* Tag the resources in the CVS repository with the given tag.
*/
@@ -907,7 +624,7 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
arguments = (String[])args.toArray(new String[args.size()]);
IStatus status;
- Session s = new Session(getRemoteRoot(), managedProject);
+ Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
progress.beginTask(null, 100);
try {
// Opening the session takes 20% of the time
@@ -968,7 +685,7 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
String[] arguments = getValidArguments(resources, commandOptions);
IStatus status;
- Session s = new Session(getRemoteRoot(), managedProject);
+ Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
progress.beginTask(null, 100);
try {
// Opening the session takes 20% of the time
@@ -991,22 +708,7 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
throw new CVSServerException(status);
}
}
-
- private static TeamException wrapException(CoreException e) {
- return new TeamException(statusFor(e));
- }
-
- public static TeamException wrapException(CVSException e, List errors) {
- // NOTE: Need to find out how to pass MultiStatus. Is it up to me to subclass?
- return 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 static String getMessageFor(Exception e) {
String message = Policy.bind(e.getClass().getName(), new Object[] {e.getMessage()});
if (message.equals(e.getClass().getName()))
@@ -1046,6 +748,7 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
Assert.isTrue(false);
return false;
}
+
/*
* @see ITeamProvider#isDirty(IResource)
*/
@@ -1053,4 +756,89 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
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 {
+ int depth = Command.DO_NOT_RECURSE.isElementOf(options) ? IResource.DEPTH_ZERO : IResource.DEPTH_INFINITE;
+ List arguments = new ArrayList(resources.length);
+ for (int i=0;i<resources.length;i++) {
+ checkIsChild(resources[i]);
+ // A depth of zero is only valid for files
+ if ((depth != IResource.DEPTH_ZERO) || (resources[i].getType() == IResource.FILE)) {
+ 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
+ */
+ private void setRemoteRoot(ICVSRepositoryLocation location, final 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 {
+ // 256 ticks gives us a maximum of 1024 which seems reasonable for folders is a project
+ 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 {
+ 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);
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
index bb4d3aed6..1934b6a5c 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
@@ -1,84 +1,96 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-/**
- * 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 {
-
- /**
- * 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 getInputStream() throws CVSException;
-
- /**
- * Gets an output stream for writing to the file.
- * It is the responsibility of the caller to close the stream when finished.
- */
- OutputStream getOutputStream() throws CVSException;
-
- /**
- * Sets the file's read-only permission.
- */
- void setReadOnly() throws CVSException;
-
- /**
- * Move the resource to another location. Does overwrite without
- * promting.
- */
- void moveTo(String filename) throws CVSException;
-
- /**
- * Answers the current timestamp for this file. The returned format must be in the
- * following format:
- *
- * E MMM dd HH:mm:ss yyyy
- *
- * @throws CVSFileNotFoundException if exists() = false
- */
- String getTimeStamp() throws CVSFileNotFoundException;
-
- /**
- * Sets the current timestamp for this file. The supplied date must be in the
- * following format:
- *
- * E MMM dd HH:mm:ss yyyy
- *
- * If the date is <code>null</code> then the current time is used as
- * the timestamp.
- */
- void setTimeStamp(String date) throws CVSException;
-
- /**
- * Answers <code>true</code> if the file differs from its base. If the file has no
- * base, it is not dirty
- */
- boolean isDirty() 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;
+package org.eclipse.team.ccvs.core;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.*;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+
+/**
+ * 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 {
+
+ /**
+ * 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 getInputStream() throws CVSException;
+
+ /**
+ * Gets an output stream for writing to the file.
+ * It is the responsibility of the caller to close the stream when finished.
+ */
+ OutputStream getOutputStream() throws CVSException;
+
+ /**
+ * Gets an appending output stream for writing to the file.
+ * It is the responsibility of the caller to close the stream when finished.
+ */
+ OutputStream getAppendingOutputStream() 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 moveTo(String filename) throws CVSException;
+
+ /**
+ * Answers the current timestamp for this file. The returned format must be in the
+ * following format:
+ *
+ * E MMM dd HH:mm:ss yyyy
+ *
+ * @throws CVSFileNotFoundException if exists() = false
+ */
+ String getTimeStamp();
+
+ /**
+ * Sets the current timestamp for this file. The supplied date must be in the
+ * following format:
+ *
+ * E MMM dd HH:mm:ss yyyy
+ *
+ * If the date is <code>null</code> then the current time is used as
+ * the timestamp.
+ */
+ void setTimeStamp(String date) throws CVSException;
+
+ /**
+ * Answers <code>true</code> if the file differs from its base. If the file has no
+ * base, it is not dirty
+ */
+ boolean isDirty() 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;
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java
index f5dbd3ae5..8ab8bcb8a 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSFolder.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java
@@ -1,96 +1,122 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
-
-/**
- * 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 {
-
- /**
- * Answers the immediate folder children of this resource. This includes the union
- * of children that satisfy the following criteria:
- * <ul>
- * <li> exists but is not managed (not under CVS control)
- * <li> does not exist() but is managed (deleted folder)
- * <li> exist() and isManaged() (normal registered file)
- * </ul>
- * If the folder does not exist then a zero length array is returned.
- */
- ICVSFolder[] getFolders() throws CVSException;
-
- /**
- * Answers the immediate file children of this resource. This includes the union
- * of children that satisfy the following criteria:
- * <ul>
- * <li> exists but is not managed (not under CVS control)
- * <li> does not exist() but is managed (deleted file)
- * <li> exist() and isManaged() (normal registered file)
- * </ul>
- */
- ICVSFile[] getFiles() 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.
- */
- 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.
- */
- ICVSFile getFile(String name) throws CVSException;
-
- /**
- * Return the child resource at the given path relative to
- * the receiver.
- */
- 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
- */
- 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>
- */
- 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.
- */
- 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 CVS synchronization information and
- * <code>false</code> otherwise.
- */
- public boolean isCVSFolder();
+package org.eclipse.team.ccvs.core;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+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 {
+
+ /**
+ * Answers the immediate folder children of this resource. This includes the union
+ * of children that satisfy the following criteria:
+ * <ul>
+ * <li> exists but is not managed (not under CVS control)
+ * <li> does not exist() but is managed (deleted folder)
+ * <li> exist() and isManaged() (normal registered file)
+ * </ul>
+ * If the folder does not exist then a zero length array is returned.
+ */
+ ICVSFolder[] getFolders() throws CVSException;
+
+ /**
+ * Answers the immediate file children of this resource. This includes the union
+ * of children that satisfy the following criteria:
+ * <ul>
+ * <li> exists but is not managed (not under CVS control)
+ * <li> does not exist() but is managed (deleted file)
+ * <li> exist() and isManaged() (normal registered file)
+ * </ul>
+ */
+ ICVSFile[] getFiles() 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.
+ */
+ 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.
+ */
+ ICVSFile getFile(String name) throws CVSException;
+
+ /**
+ * Return the child resource at the given path relative to
+ * the receiver.
+ */
+ 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
+ */
+ 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>
+ */
+ 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.
+ */
+ 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 CVS synchronization information and
+ * <code>false</code> otherwise.
+ */
+ 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/ICVSProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSProvider.java
index eb82f7dda..808a88b79 100644
--- 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
@@ -147,11 +147,7 @@ public interface ICVSProvider {
*/
public String[] getSupportedConnectionMethods();
- /**
- * Get the stream to which command message and error output is sent
- */
- public PrintStream getPrintStream();
-
+
/**
* Set the print stream to which command message and error output is sent
*/
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
index 23f68405e..fbf5a6dee 100644
--- 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
@@ -83,6 +83,11 @@ public interface ICVSRepositoryLocation extends IAdaptable {
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
*
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java
index b57ab8371..e5e4b120f 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSResource.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java
@@ -1,137 +1,139 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-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() 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;
+package org.eclipse.team.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.CVSException;
+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() 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/resources/ICVSResourceVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java
index a61b0b6c4..c181ee8cc 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSResourceVisitor.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java
@@ -1,19 +1,17 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-/**
- * Interface for an visitor of the IManagedResources.
- */
-public interface ICVSResourceVisitor {
-
- public void visitFile(ICVSFile file) throws CVSException;
- public void visitFolder(ICVSFolder folder) throws CVSException;
-
-}
-
+package org.eclipse.team.ccvs.core;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.team.internal.ccvs.core.CVSException;
+
+/**
+ * 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
new file mode 100644
index 000000000..69916b0d2
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java
@@ -0,0 +1,37 @@
+package org.eclipse.team.ccvs.core;
+
+/*
+ * (c) Copyright IBM Corp. 2001, 2002.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+
+/**
+ * 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/client/AbstractMessageCommand.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java
index 7e5cba7b9..ae5b410c4 100644
--- 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
@@ -6,10 +6,11 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.*;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
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.resources.ICVSResource;
/**
* Superclass for commands that do not change the structure on
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
index 7dd8544b6..87c5db444 100644
--- 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
@@ -6,12 +6,11 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResourceVisitor;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
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;
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
index db81258e3..a50c0f01f 100644
--- 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
@@ -6,14 +6,15 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSStatus;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
+import org.eclipse.team.ccvs.core.ICVSResourceVisitor;
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.GlobalOption;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResourceVisitor;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.Assert;
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
index eb664c723..fd5a10dbd 100644
--- 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
@@ -9,9 +9,9 @@ import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.util.Assert;
/**
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java
index bb655c8f4..9a7d0ced2 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java
@@ -6,10 +6,9 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
/**
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
index f06abf583..3e47bbfcd 100644
--- 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
@@ -7,8 +7,11 @@ package org.eclipse.team.internal.ccvs.core.client;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSStatus;
import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSResource;
+import org.eclipse.team.ccvs.core.ICVSResourceVisitor;
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.GlobalOption;
@@ -17,8 +20,6 @@ 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.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResourceVisitor;
import org.eclipse.team.internal.ccvs.core.resources.RemoteModule;
import org.eclipse.team.internal.ccvs.core.util.Assert;
@@ -109,7 +110,7 @@ public class Checkout extends Command {
/**
* Override execute to perform a expand-modules before the checkout
*/
- public IStatus execute(Session session, GlobalOption[] globalOptions,
+ protected IStatus doExecute(Session session, GlobalOption[] globalOptions,
LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener,
IProgressMonitor monitor) throws CVSException {
monitor.beginTask(null, 100);
@@ -129,14 +130,7 @@ public class Checkout extends Command {
}
}
- // Execute the checkout command
- status = super.execute(session, globalOptions, localOptions, arguments, listener, Policy.subMonitorFor(monitor, 90));
- if (status.getCode() == CVSStatus.SERVER_ERROR)
- return status;
-
- // Make the checked out resources known to the workbench
-
- return status;
+ return super.doExecute(session, globalOptions, localOptions, arguments, listener, Policy.subMonitorFor(monitor, 90));
}
/**
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
index 3986e77c8..9988ccffb 100644
--- 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
@@ -18,13 +18,12 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSStatus;
import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
+import org.eclipse.team.ccvs.core.ICVSRunnable;
import org.eclipse.team.internal.ccvs.core.CVSException;
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.resources.CVSFileNotFoundException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
/**
* Abstract base class for the commands which implements the ICommand
@@ -258,12 +257,20 @@ public abstract class Command {
// of the local root folder.
ICVSResource[] resources = new ICVSResource[arguments.length];
for (int i = 0; i < arguments.length; i++) {
- try {
- resources[i] = localRoot.getChild(arguments[i]);
- } catch (CVSFileNotFoundException e) {
- // XXX Temporary fix to allow non-managed resources to be used as arguments
- resources[i] = localRoot.getFile(arguments[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;
}
@@ -292,55 +299,18 @@ public abstract class Command {
protected void checkResourcesManaged(ICVSResource[] resources) throws CVSException {
for (int i = 0; i < resources.length; ++i) {
ICVSFolder folder;
- /// XXX should perhaps use a visitor instead of type checking
- if (resources[i].isFolder()) folder = (ICVSFolder) resources[i];
- else folder = resources[i].getParent();
- if (! folder.isCVSFolder()) {
- throw new CVSException(Policy.bind("Command.argumentNotManaged", folder.getName()));//$NON-NLS-1$
+ if (resources[i].isFolder()) {
+ folder = (ICVSFolder) resources[i];
}
- }
- }
-
- /**
- * Reloads the sync info for all resource arguments.
- *
- * @param resources the resource arguments for the command
- * @param monitor the progress monitor
- */
- private void reloadSyncInfo(ICVSResource[] resources, IProgressMonitor monitor) throws CVSException {
- try {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(Policy.bind("Command.loadingSyncInfo"), 100 * resources.length);//$NON-NLS-1$
- for (int i = 0; i < resources.length; i++) {
- if(resources[i] instanceof LocalResource && resources[i].exists()) {
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)resources[i]).getLocalFile(), Policy.subMonitorFor(monitor, 100));
- }
+ else {
+ folder = resources[i].getParent();
}
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Saves the sync info for all resource arguments.
- *
- * @param resources the resource arguments for the command
- * @param monitor the progress monitor
- */
- private void saveSyncInfo(ICVSResource[] resources, IProgressMonitor monitor) throws CVSException {
- try {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(Policy.bind("Command.savingSyncInfo"), 100 * resources.length);//$NON-NLS-1$
- for (int i = 0; i < resources.length; i++) {
- if(resources[i] instanceof LocalResource) {
- CVSProviderPlugin.getSynchronizer().save(((LocalResource)resources[i]).getLocalFile(), Policy.subMonitorFor(monitor, 100));
- }
+ if (folder==null || (!folder.isCVSFolder() && folder.exists())) {
+ throw new CVSException(Policy.bind("Command.argumentNotManaged", folder.getName()));//$NON-NLS-1$
}
- } finally {
- monitor.done();
}
}
-
+
/**
* Executes a CVS command.
* <p>
@@ -358,9 +328,23 @@ public abstract class Command {
* @return a status code indicating success or failure of the operation
* @throws CVSException if a fatal error occurs (e.g. connection timeout)
*/
- public IStatus execute(Session session, GlobalOption[] globalOptions,
+ 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 {
+ status[0] = doExecute(session, globalOptions, localOptions, arguments, listener, monitor);
+ }
+ };
+ session.getLocalRoot().run(job, pm);
+ return status[0];
+ }
+
+ 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);
@@ -370,8 +354,7 @@ public abstract class Command {
/*** prepare for command ***/
// Ensure that the commands run with the latest contents of the CVS subdirectory sync files
// and not the cached values. Allow 10% of work.
- resources = computeWorkResources(session, localOptions, arguments);
- reloadSyncInfo(resources, Policy.subMonitorFor(monitor, 10));
+ resources = computeWorkResources(session, localOptions, arguments);
Policy.checkCanceled(monitor);
// clear stale command state from previous runs
@@ -402,11 +385,7 @@ public abstract class Command {
commandFinished(session, gOptions, lOptions, resources, Policy.subMonitorFor(monitor, 5),
status.getCode() != CVSStatus.SERVER_ERROR);
return status;
- } finally {
- // Give the synchronizer a chance to persist any pending changes.
- if(resources != null) {
- saveSyncInfo(resources, Policy.subMonitorFor(monitor, 5));
- }
+ } finally {
monitor.done();
}
}
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
index 721d388c2..b11cf7375 100644
--- 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
@@ -6,11 +6,11 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
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.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
public class Commit extends Command {
/*** Local options: specific to commit ***/
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
index 210ade9ed..39387390f 100644
--- 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
@@ -6,9 +6,9 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.util.Assert;
/**
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
index 5aa2b17e0..84f94d224 100644
--- 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
@@ -7,12 +7,13 @@ package org.eclipse.team.internal.ccvs.core.client;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.team.ccvs.core.*;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
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;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
/**
* Runs the CVS diff command.
@@ -29,15 +30,13 @@ public class Diff extends Command {
}
/**
- * 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.
+ * 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.
*/
- public IStatus execute(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener,
- IProgressMonitor monitor)
- throws CVSException {
+ protected IStatus doExecute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions,
+ String[] arguments, ICommandOutputListener listener, IProgressMonitor monitor) throws CVSException {
try {
- return super.execute(session, globalOptions, localOptions, arguments, listener, monitor);
+ return super.doExecute(session, globalOptions, localOptions, arguments, listener, monitor);
} catch (CVSServerException e) {
if (e.containsErrors()) throw e;
return e.getStatus();
@@ -53,5 +52,5 @@ public class Diff extends Command {
for (int i = 0; i < resources.length; i++) {
resources[i].accept(fsVisitor);
}
- }
+ }
} \ 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
index 6d94c0b2c..c820db88b 100644
--- 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
@@ -4,10 +4,8 @@ package org.eclipse.team.internal.ccvs.core.client;
* All Rights Reserved.
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
/**
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
index 5bad4d19f..6ea5b4e8c 100644
--- 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
@@ -7,10 +7,11 @@ package org.eclipse.team.internal.ccvs.core.client;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.team.ccvs.core.*;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
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.resources.ICVSResource;
public class ExpandModules extends Command {
@@ -46,7 +47,6 @@ public class ExpandModules extends Command {
* Convenient execute method
*/
public IStatus execute(Session session, String[] modules, IProgressMonitor monitor) throws CVSException {
- return execute(session, NO_GLOBAL_OPTIONS, NO_LOCAL_OPTIONS, modules, null, monitor);
+ return super.execute(session, NO_GLOBAL_OPTIONS, NO_LOCAL_OPTIONS, modules, null, 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
index ca98df7ce..7db300be7 100644
--- 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
@@ -9,9 +9,9 @@ import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
/**
* This visitor send the fileStructure to the requestSender.
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
index 2a7ed6902..a0abe7784 100644
--- 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
@@ -6,11 +6,12 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.*;
+import org.eclipse.team.ccvs.core.ICVSResource;
+import org.eclipse.team.ccvs.core.ICVSResourceVisitor;
import org.eclipse.team.internal.ccvs.core.CVSException;
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.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResourceVisitor;
public class Import extends Command {
/*** Local options: specific to import ***/
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
index 8db40237c..937114194 100644
--- 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
@@ -8,9 +8,9 @@ package org.eclipse.team.internal.ccvs.core.client;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.FileNameMatcher;
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
index 904815da8..679dbb116 100644
--- 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
@@ -6,9 +6,9 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
public class NewEntryHandler extends ResponseHandler {
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
index 30b3635ee..b58159f35 100644
--- 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
@@ -5,10 +5,10 @@ package org.eclipse.team.internal.ccvs.core.client;
* All Rights Reserved.
*/
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResourceVisitor;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResourceVisitor;
/**
* Goes recursivly through the folders checks if they are empyty
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
index 251bae6df..9a2bb693e 100644
--- 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
@@ -11,12 +11,13 @@ import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
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.resources.ICVSResource;
public class RTag extends Command {
/*** Local options: specific to tag ***/
@@ -74,7 +75,7 @@ public class RTag extends Command {
ICVSResource resource = resources[i];
arguments.add(resource.getRemoteLocation(null));
}
- return execute(session, globalOptions,
+ return super.execute(session, globalOptions,
(LocalOption[]) modifiedLocalOptions.toArray(new LocalOption[modifiedLocalOptions.size()]),
(String[]) arguments.toArray(new String[arguments.size()]), null, monitor);
}
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
index 930328d51..a62719d94 100644
--- 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
@@ -6,10 +6,11 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.*;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
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.resources.ICVSResource;
public class Remove extends Command {
/*** Local options: specific to remove ***/
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
index 49776b0a0..98d5c7674 100644
--- 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
@@ -6,9 +6,9 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.util.Assert;
/**
@@ -44,10 +44,6 @@ class RemoveEntryHandler extends ResponseHandler {
String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$
ICVSFolder mParent = session.getLocalRoot().getFolder(localDir);
ICVSFile mFile = mParent.getFile(fileName);
-
- // NOTE: Should we do something here other than throw a run-time exception
- Assert.isTrue(mParent.exists() && !mFile.exists());
-
mFile.unmanage();
}
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
index 38b31032f..796161fa9 100644
--- 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
@@ -6,9 +6,9 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.util.Assert;
/**
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
index f5fd6ebca..c01565358 100644
--- 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
@@ -6,9 +6,10 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.*;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.syncinfo.*;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.Util;
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
index 5553f19e5..3740ce43b 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
@@ -6,7 +6,6 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import java.io.ByteArrayInputStream;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -14,18 +13,15 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
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.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
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;
@@ -183,28 +179,6 @@ public class Session {
}
/**
- * Gives you an LocalFolder for a absolute path in
- * platform dependend style.
- *
- * @throws CVSException on path.indexOf("CVS") != -1
- * @throws CVSException on internal IOExeption
- */
- public static ICVSFolder getManagedFolder(File folder) throws CVSException {
- return new LocalFolder(folder);
- }
- public static ICVSFile getManagedFile(File file) throws CVSException {
- return new LocalFile(file);
- }
-
- public static ICVSResource getManagedResource(IResource resource) throws CVSException {
- File file = resource.getLocation().toFile();
- if (resource.getType() == IResource.FILE)
- return getManagedFile(file);
- else
- return getManagedFolder(file);
- }
-
- /**
* Returns the local root folder for this session.
* <p>
* Generally speaking, specifies the "current working directory" at
@@ -781,4 +755,6 @@ public class Session {
boolean isOutputToConsole() {
return outputToConsole;
}
+
+
}
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
index 36c099bd4..16ff3baee 100644
--- 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
@@ -6,8 +6,9 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.*;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.syncinfo.*;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.Assert;
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
index 00adcca10..b27dc6e9e 100644
--- 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
@@ -6,9 +6,10 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.*;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.syncinfo.*;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.Assert;
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
index aedbdb29c..2bb5e359e 100644
--- 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
@@ -6,10 +6,11 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.*;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
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.resources.ICVSResource;
public class Tag extends Command {
/*** Local options: specific to tag ***/
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
index 9b874367c..2349f5214 100644
--- 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
@@ -9,15 +9,16 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSResource;
+import org.eclipse.team.ccvs.core.ICVSResourceVisitor;
import org.eclipse.team.internal.ccvs.core.CVSException;
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;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResourceVisitor;
public class Update extends Command {
/*** Local options: specific to update ***/
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
index 7dbf2f89e..602d0ed8a 100644
--- 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
@@ -8,9 +8,9 @@ package org.eclipse.team.internal.ccvs.core.client;
import java.util.Date;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
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.EntryFileDateFormat;
@@ -78,7 +78,7 @@ class UpdatedHandler extends ResponseHandler {
boolean readOnly = permissionsLine.indexOf(READ_ONLY_FLAG) == -1;
session.receiveFile(mFile, binary, monitor);
- if (readOnly) mFile.setReadOnly();
+ if (readOnly) mFile.setReadOnly(true);
// Set the timestamp in the file, set the result in the fileInfo
String timestamp = null;
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
index 1cfafb721..fe10f61f0 100644
--- 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
@@ -1,10 +1,11 @@
package org.eclipse.team.internal.ccvs.core.client;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.*;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
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.resources.ICVSResource;
/*
* (c) Copyright IBM Corp. 2000, 2002.
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
index 2f972bd87..2a4e5fa04 100644
--- 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
@@ -9,8 +9,9 @@ import java.io.PrintStream;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSFolder;
public class DiffListener implements ICommandOutputListener {
PrintStream patchStream;
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
index f29c8238c..642d40d2d 100644
--- 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
@@ -7,9 +7,10 @@ package org.eclipse.team.internal.ccvs.core.client.listeners;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSStatus;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
public interface ICommandOutputListener {
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
index 228bb299c..87a82a3a8 100644
--- 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
@@ -10,10 +10,10 @@ import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry;
public class LogListener implements ICommandOutputListener {
private List entries;
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
index 8a16a0566..78aa8134c 100644
--- 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
@@ -10,8 +10,9 @@ import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSFolder;
/*
* This class pares the output of the "cvs checkout -c" command which returns the list of modules
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
index cda878cf5..b96d2859f 100644
--- 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
@@ -9,8 +9,9 @@ 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.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSFolder;
public class StatusListener implements ICommandOutputListener {
private static boolean isFolder = false;
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
index f21fed1bc..30e99ee75 100644
--- 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
@@ -10,11 +10,12 @@ 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.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSStatus;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
public class UpdateListener implements ICommandOutputListener {
static final String SERVER_PREFIX = "cvs server: "; //$NON-NLS-1$
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
index 3a8495bc1..1991e57d0 100644
--- 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
@@ -57,7 +57,7 @@ public class CVSServerException extends CVSException {
if (children.length > 0) {
return new CVSServerException(message, children);
} else {
- return new CVSServerException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, CVSStatus.SERVER_ERROR, message, null));
+ return new CVSServerException(new CVSStatus(IStatus.ERROR, CVSStatus.SERVER_ERROR, message, null));
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ResourceStatus.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ResourceStatus.java
deleted file mode 100644
index cf07cb05b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ResourceStatus.java
+++ /dev/null
@@ -1,47 +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.core.runtime.Status;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-/**
- *
- */
-public class ResourceStatus extends Status {
-
- private IPath path;
-
-
- public ResourceStatus(
- int type,
- int code,
- IPath path,
- String message,
- Throwable exception) {
- super(type, CVSProviderPlugin.ID, code, message, exception);
- this.path = path;
- }
- public ResourceStatus(int code, String message) {
- this(getSeverity(code), code, null, message, null);
- }
- public ResourceStatus(int code, IPath path, String message) {
- this(getSeverity(code), code, path, message, null);
- }
- public ResourceStatus(
- int code,
- IPath path,
- String message,
- Throwable exception) {
- this(getSeverity(code), code, path, message, exception);
- }
- public IPath getPath() {
- return path;
- }
- protected static int getSeverity(int code) {
- return code;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSFileNotFoundException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSFileNotFoundException.java
deleted file mode 100644
index e1438007c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSFileNotFoundException.java
+++ /dev/null
@@ -1,30 +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.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException;
-import org.eclipse.team.internal.ccvs.core.connection.ResourceStatus;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-
-/**
- * This exception represents the attemp to access a file/folder
- * that did not exist.
- */
-public class CVSFileNotFoundException extends CVSException {
-
- public CVSFileNotFoundException(IStatus status) {
- super(status);
- }
-
- public CVSFileNotFoundException(String message) {
- super(message);
- }
-}
-
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
index 368de9183..f8af2d450 100644
--- 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
@@ -5,37 +5,24 @@ package org.eclipse.team.internal.ccvs.core.resources;
* All Rights Reserved.
*/
-import java.io.File;
-
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.ccvs.core.*;
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.CVSProvider;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
+import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
public class CVSLocalSyncElement extends LocalSyncElement {
- protected ICVSResource cvsResource;
protected IRemoteResource base;
protected IResource local;
public CVSLocalSyncElement(IResource local, IRemoteResource base) {
-
this.local = local;
- this.base = base;
-
- File file = new File(local.getLocation().toOSString());
- if(local.getType() != IResource.FILE) {
- this.cvsResource = new LocalFolder(file);
- } else {
- this.cvsResource = new LocalFile(file);
- }
+ this.base = base;
}
/*
@@ -63,6 +50,7 @@ public class CVSLocalSyncElement extends LocalSyncElement {
* @see ILocalSyncElement#isDirty()
*/
public boolean isDirty() {
+ ICVSResource cvsResource = getCVSResourceFor(getLocal());
if(cvsResource == null) {
return false;
} else {
@@ -95,14 +83,14 @@ public class CVSLocalSyncElement extends LocalSyncElement {
* @see ILocalSyncElement#isCheckedOut()
*/
public boolean isCheckedOut() {
- return cvsResource != null;
+ return getLocal() != null;
}
/*
* @see ILocalSyncElement#hasRemote()
*/
public boolean hasRemote() {
- return cvsResource != null;
+ return getLocal() != null;
}
/*
@@ -116,12 +104,14 @@ public class CVSLocalSyncElement extends LocalSyncElement {
* Answers the CVS resource for this sync element
*/
public ICVSResource getCVSResource() {
- return cvsResource;
+ return getCVSResourceFor(getLocal());
}
+
/*
* @see LocalSyncElement#isIgnored(IResource)
*/
protected boolean isIgnored(IResource child) {
+ ICVSResource cvsResource = getCVSResourceFor(getLocal());
if(cvsResource==null || !cvsResource.isFolder() ) {
return false;
} else {
@@ -133,4 +123,12 @@ public class CVSLocalSyncElement extends LocalSyncElement {
}
}
}
+
+ 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
index 2601ebf00..0d8bd1670 100644
--- 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
@@ -9,7 +9,9 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.ILocalSyncElement;
import org.eclipse.team.core.sync.IRemoteResource;
@@ -18,7 +20,6 @@ import org.eclipse.team.core.sync.RemoteSyncElement;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProvider;
import org.eclipse.team.internal.ccvs.core.Policy;
-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.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
@@ -33,7 +34,7 @@ public class CVSRemoteSyncElement extends RemoteSyncElement {
public CVSRemoteSyncElement(boolean ignoreBaseTree, IResource local, IRemoteResource base, IRemoteResource remote) {
localSync = new CVSLocalSyncElement(local, base);
this.remote = remote;
- this.ignoreBaseTree = ignoreBaseTree;
+ this.ignoreBaseTree = ignoreBaseTree;
}
/*
@@ -159,7 +160,8 @@ public class CVSRemoteSyncElement extends RemoteSyncElement {
if (local.exists()) {
// We could have an incoming change or deletion
if (remote == null) {
- info = new ResourceSyncInfo(local.getName(), ResourceSyncInfo.ADDED_REVISION, ResourceSyncInfo.DUMMY_TIMESTAMP, CVSProvider.isText(local.getName())?ResourceSyncInfo.USE_SERVER_MODE:ResourceSyncInfo.BINARY_TAG, local.getParent().getFolderSyncInfo().getTag(), null);
+ info = new ResourceSyncInfo(local.getName(), ResourceSyncInfo.ADDED_REVISION, ResourceSyncInfo.DUMMY_TIMESTAMP,
+ CVSProvider.isText(local.getName()) ? ResourceSyncInfo.USE_SERVER_MODE:ResourceSyncInfo.BINARY_TAG, local.getParent().getFolderSyncInfo().getTag(), null);
revision = info.getRevision();
} else {
info = remote.getSyncInfo();
@@ -201,13 +203,11 @@ public class CVSRemoteSyncElement extends RemoteSyncElement {
} else {
// We have conflicting deletions. Clear the sync info
local.setSyncInfo(null);
- CVSProviderPlugin.getSynchronizer().save(((LocalResource)local).getLocalFile(), Policy.monitorFor(monitor));
return;
}
}
info = new ResourceSyncInfo(info.getName(), revision, ResourceSyncInfo.DUMMY_TIMESTAMP, info.getKeywordMode(), local.getParent().getFolderSyncInfo().getTag(), info.getPermissions());
local.setSyncInfo(info);
- CVSProviderPlugin.getSynchronizer().save(((LocalResource)local).getLocalFile(), Policy.monitorFor(monitor));
}
/*
@@ -218,7 +218,7 @@ public class CVSRemoteSyncElement extends RemoteSyncElement {
// 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.
- Session.getManagedResource(getLocal()).unmanage();
+ CVSWorkspaceRoot.getCVSResourceFor(getLocal()).unmanage();
}
/*
@@ -259,7 +259,6 @@ public class CVSRemoteSyncElement extends RemoteSyncElement {
FolderSyncInfo remoteInfo = remote.getFolderSyncInfo();
FolderSyncInfo localInfo = local.getParent().getFolderSyncInfo();
local.setFolderSyncInfo(new FolderSyncInfo(remoteInfo.getRepository(), remoteInfo.getRoot(), localInfo.getTag(), localInfo.getIsStatic()));
- CVSProviderPlugin.getSynchronizer().save(((LocalResource)local).getLocalFile(), Policy.monitorFor(monitor));
}
/*
* @see ILocalSyncElement#getSyncKind(int, IProgressMonitor)
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
new file mode 100644
index 000000000..c6a45e510
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java
@@ -0,0 +1,139 @@
+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.ccvs.core.CVSStatus;
+import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSRemoteResource;
+import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.ccvs.core.ICVSResource;
+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.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);
+ if (managed.isFolder()) {
+ ICVSFolder folder = (ICVSFolder)managed;
+ if (folder.isCVSFolder()) {
+ FolderSyncInfo syncInfo = folder.getFolderSyncInfo();
+ return new RemoteFolder(null, CVSProvider.getInstance().getRepository(syncInfo.getRoot()), new Path(syncInfo.getRepository()), syncInfo.getTag());
+ }
+ } else {
+ if (managed.isManaged())
+ return RemoteFile.getBase((RemoteFolder)getRemoteResourceFor(resource.getParent()), (ICVSFile)managed);
+ }
+ 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();
+ if (!parent.isCVSFolder()) {
+ 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;
+ ICVSRemoteResource remoteParent = CVSWorkspaceRoot.getRemoteResourceFor(resource.getParent());
+ remote = RemoteFile.getLatest((RemoteFolder)remoteParent, (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(false, 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) {
+ ICVSRemoteResource remoteParent = CVSWorkspaceRoot.getRemoteResourceFor(resource.getParent());
+ remote = RemoteFile.getLatest((RemoteFolder)remoteParent, (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 {
+ return CVSProvider.getInstance().getRepository(localRoot.getFolderSyncInfo().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
new file mode 100644
index 000000000..2a04a3154
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
@@ -0,0 +1,221 @@
+package org.eclipse.team.internal.ccvs.core.resources;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.ParseException;
+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.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResourceVisitor;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.Policy;
+import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
+import org.eclipse.team.internal.ccvs.core.util.EntryFileDateFormat;
+
+/**
+ * Represents handles to CVS resource on the local file system. Synchronization
+ * information is taken from the CVS subdirectories.
+ */
+class EclipseFile extends EclipseResource implements ICVSFile {
+
+ /**
+ * Create a handle based on the given local resource.
+ */
+ protected EclipseFile(IFile file) {
+ super(file);
+ }
+
+ public long getSize() {
+ return getIOFile().length();
+ }
+
+ public InputStream getInputStream() throws CVSException {
+ try {
+ return getIFile().getContents();
+ } catch (CoreException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
+ public OutputStream getOutputStream() throws CVSException {
+ return new ByteArrayOutputStream() {
+ public void close() throws IOException {
+ try {
+ IFile file = getIFile();
+ if(resource.exists()) {
+ file.setContents(new ByteArrayInputStream(toByteArray()), false /*force*/, true /*keep history*/, null);
+ } else {
+ file.create(new ByteArrayInputStream(toByteArray()), false /*force*/, null);
+ }
+ } catch(CoreException e) {
+ throw new IOException("Error setting file contents: " + e.getMessage());
+ } finally {
+ super.close();
+ }
+ }
+ };
+ }
+
+ /*
+ * @see ICVSFile#getAppendingOutputStream()
+ */
+ public OutputStream getAppendingOutputStream() throws CVSException {
+ return new ByteArrayOutputStream() {
+ public void close() throws IOException {
+ try {
+ IFile file = getIFile();
+ if(resource.exists()) {
+ file.appendContents(new ByteArrayInputStream(toByteArray()), false /*force*/, true /*keep history*/, null);
+ } else {
+ file.create(new ByteArrayInputStream(toByteArray()), false /*force*/, null);
+ }
+ } catch(CoreException e) {
+ throw new IOException("Error setting file contents: " + e.getMessage());
+ } finally {
+ super.close();
+ }
+ }
+ };
+ }
+
+ /*
+ * @see ICVSFile#getTimeStamp()
+ */
+ public String getTimeStamp() {
+ EntryFileDateFormat timestamp = new EntryFileDateFormat();
+ return timestamp.format(new Date(getIOFile().lastModified()));
+ }
+
+ /*
+ * @see ICVSFile#setTimeStamp(String)
+ */
+ public void setTimeStamp(String date) throws CVSException {
+ long millSec;
+ if (date==null) {
+ // get the current time
+ millSec = new Date().getTime();
+ } else {
+ try {
+ EntryFileDateFormat timestamp = new EntryFileDateFormat();
+ millSec = timestamp.toDate(date).getTime();
+ } catch (ParseException e) {
+ throw new CVSException(Policy.bind("LocalFile.invalidDateFormat", date), e); //$NON-NLS-1$
+ }
+ }
+ getIOFile().setLastModified(millSec);
+ 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#isDirty()
+ */
+ public boolean isDirty() throws CVSException {
+ if (!exists() || !isManaged()) {
+ return true;
+ } else {
+ ResourceSyncInfo info = getSyncInfo();
+ if (info.isAdded()) return false;
+ if (info.isDeleted()) return true;
+ return !getTimeStamp().equals(info.getTimeStamp());
+ }
+ }
+
+ /*
+ * @see ICVSFile#isModified()
+ */
+ public boolean isModified() throws CVSException {
+ if (!exists() || !isManaged()) {
+ return true;
+ } else {
+ ResourceSyncInfo info = getSyncInfo();
+ 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 moveTo(String filename) throws CVSException {
+ try {
+ getIFile().move(new Path(filename), true /*force*/, true /*keep history*/, 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 setReadOnly(boolean readOnly) throws CVSException {
+ getIFile().setReadOnly(readOnly);
+ }
+
+ /*
+ * @see ICVSFile#isReadOnly()
+ */
+ public boolean isReadOnly() throws CVSException {
+ return getIFile().isReadOnly();
+ }
+
+ /*
+ * Typecasting helper
+ */
+ private 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;
+ }
+} \ 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
new file mode 100644
index 000000000..ff4329dae
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java
@@ -0,0 +1,275 @@
+package org.eclipse.team.internal.ccvs.core.resources;
+
+/*
+ * (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.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.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
+import org.eclipse.team.ccvs.core.ICVSResourceVisitor;
+import org.eclipse.team.ccvs.core.ICVSRunnable;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+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#getFolders()
+ */
+ public ICVSFolder[] getFolders() throws CVSException {
+ IContainer folder = (IContainer)resource;
+ final List folders = new ArrayList();
+
+ IResource[] resources = EclipseSynchronizer.getInstance().members(folder);
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ if(resources[i].getType()!=IResource.FILE) {
+ ICVSResource cvsResource = new EclipseFolder((IContainer)resources[i]);
+ if(!cvsResource.isIgnored()) {
+ folders.add(cvsResource);
+ }
+ }
+ }
+ return (ICVSFolder[]) folders.toArray(new ICVSFolder[folders.size()]);
+ }
+
+ /**
+ * @see ICVSFolder#getFiles()
+ */
+ public ICVSFile[] getFiles() throws CVSException {
+ IContainer folder = (IContainer)resource;
+ final List files = new ArrayList();
+
+ IResource[] resources = EclipseSynchronizer.getInstance().members(folder);
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ if(resources[i].getType()==IResource.FILE) {
+ ICVSResource cvsResource = new EclipseFile((IFile)resources[i]);
+ if(!cvsResource.isIgnored()) {
+ files.add(cvsResource);
+ }
+ }
+ }
+ return (ICVSFile[]) files.toArray(new ICVSFile[files.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);
+ }
+ } catch (CoreException e) {
+ throw new CVSException(e.getStatus());
+ }
+ }
+
+ /**
+ * @see ICVSResource#isFolder()
+ */
+ public boolean isFolder() {
+ return true;
+ }
+
+ /**
+ * @see ICVSFolder#acceptChildren(ICVSResourceVisitor)
+ */
+ public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException {
+
+ ICVSResource[] subFiles;
+ ICVSResource[] subFolders;
+
+ subFiles = getFiles();
+ subFolders = getFolders();
+
+ for (int i=0; i<subFiles.length; i++) {
+ subFiles[i].accept(visitor);
+ }
+
+ 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() throws CVSException {
+ EclipseSynchronizer.getInstance().deleteFolderSync((IContainer)resource, new NullProgressMonitor());
+ super.unmanage();
+ }
+
+ /*
+ * @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);
+ 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];
+ 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, 85));
+ } finally {
+ EclipseSynchronizer.getInstance().endOperation(Policy.subMonitorFor(monitor, 8));
+ }
+ } catch(CVSException e) {
+ error[0] = e;
+ } finally {
+ monitor.done();
+ }
+ }
+ }, monitor);
+ } catch(CoreException e) {
+ throw CVSException.wrapException(e);
+ }
+ if(error[0]!=null) {
+ throw error[0];
+ }
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java
index e3b2a06b6..2be2a08ce 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalResource.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java
@@ -1,219 +1,243 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.io.File;
-
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.core.IIgnoreInfo;
-import org.eclipse.team.core.TeamPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-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.FileUtil;
-import org.eclipse.team.internal.ccvs.core.util.SyncFileUtil;
-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
- */
-public abstract class LocalResource 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 file represented by this handle.
- */
- File ioResource;
-
- /**
- * A local handle
- */
- public LocalResource(File ioResource) {
- Assert.isNotNull(ioResource);
- this.ioResource = ioResource;
- }
-
- /**
- * 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 {
-
- LocalResource rootFolder;
- String result;
-
- try {
- rootFolder = (LocalResource)root;
- } catch (ClassCastException e) {
- throw new CVSException(Policy.bind("LocalResource.invalidResourceClass"),e); //$NON-NLS-1$
- }
-
- result = Util.getRelativePath(rootFolder.getPath(),getPath());
- return result;
- }
-
- /**
- * Do a DEEP delete.
- * @see ICVSResource#delete()
- */
- public void delete() {
- FileUtil.deepDelete(ioResource);
- // XXX Should we clear the cache in all cases?
- // XXX If not, should we provide a boolean parameter as a choice
- }
-
- /**
- * @see ICVSResource#exists()
- */
- public boolean exists() {
- return ioResource.exists();
- }
-
- /**
- * @see ICVSResource#getParent()
- */
- public ICVSFolder getParent() {
- File parentFile = ioResource.getParentFile();
- if (parentFile == null) return null;
- return new LocalFolder(parentFile);
- }
-
- /**
- * @see ICVSResource#getName()
- */
- public String getName() {
- return ioResource.getName();
- }
-
- /**
- * @see ICVSResource#isIgnored()
- */
- public boolean isIgnored() {
- // a managed resource is never ignored
- if(isManaged()) {
- return false;
- }
-
- // initialize matcher with global ignores and basic CVS ignore patterns
- IIgnoreInfo[] ignorePatterns = TeamPlugin.getManager().getGlobalIgnore();
- FileNameMatcher matcher = new FileNameMatcher(SyncFileUtil.BASIC_IGNORE_PATTERNS);
- for (int i = 0; i < ignorePatterns.length; i++) {
- IIgnoreInfo info = ignorePatterns[i];
- if(info.getEnabled()) {
- matcher.register(info.getPattern(), "true"); //$NON-NLS-1$
- }
- }
-
- // 1. check CVS default patterns and global ignores
- boolean ignored = matcher.match(ioResource.getName());
-
- // 2. check .cvsignore file
- if(!ignored) {
- ignored = CVSProviderPlugin.getSynchronizer().isIgnored(ioResource);
- }
-
- // 3. check the parent
- if(!ignored) {
- ICVSFolder parent = getParent();
- if(parent==null) return false;
- return parent.isIgnored();
- } else {
- return ignored;
- }
- }
-
- public void setIgnored() throws CVSException {
- CVSProviderPlugin.getSynchronizer().setIgnored(ioResource, null);
- }
-
- public void setIgnoredAs(String pattern) throws CVSException {
- CVSProviderPlugin.getSynchronizer().setIgnored(ioResource, 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 LocalResource)) {
- return false;
- } else {
- return getPath().equals(((LocalResource) obj).getPath());
- }
- }
-
- /*
- * @see ICVSResource#getPath()
- */
- public String getPath() {
- return ioResource.getAbsolutePath();
- }
-
- /*
- * @see ICVSResource#isFolder()
- */
- public boolean isFolder() {
- return false;
- }
-
- /*
- * @see ICVSResource#getSyncInfo()
- */
- public ResourceSyncInfo getSyncInfo() throws CVSException {
- return CVSProviderPlugin.getSynchronizer().getResourceSync(ioResource);
- }
-
- /*
- * @see ICVSResource#setSyncInfo(ResourceSyncInfo)
- */
- public void setSyncInfo(ResourceSyncInfo info) throws CVSException {
- CVSProviderPlugin.getSynchronizer().setResourceSync(ioResource, 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();
- }
-
- public File getLocalFile() {
- return ioResource;
- }
+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.NullProgressMonitor;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
+import org.eclipse.team.core.IIgnoreInfo;
+import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+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("LocalResource.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()) {
+ return false;
+ }
+
+ // 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);
+ } catch(CVSException e) {
+ cvsIgnorePatterns = null;
+ }
+ IIgnoreInfo[] ignorePatterns = TeamPlugin.getManager().getGlobalIgnore();
+ 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");
+ }
+ }
+
+ // 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().setIgnored(resource, null);
+ }
+
+ /*
+ * @see ICVSResource#setIgnoredAs(String)
+ */
+ public void setIgnoredAs(String pattern) throws CVSException {
+ EclipseSynchronizer.getInstance().setIgnored(resource, 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() throws CVSException {
+ if(isManaged()) {
+ EclipseSynchronizer.getInstance().deleteResourceSync(resource, new NullProgressMonitor());
+ }
+ }
} \ 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
new file mode 100644
index 000000000..a6918d814
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java
@@ -0,0 +1,522 @@
+package org.eclipse.team.internal.ccvs.core.resources;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+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.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+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.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
+import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.core.sync.ISyncProvider;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+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;
+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.
+ *
+ * [Notes:
+ * 1. how can we expire cache elements and purge to safe memory?
+ * 2. how can we safeguard against overwritting meta files changes made outside of Eclipse? I'm
+ * not sure we should force setting file contents in EclipseFile handles?
+ * 4. how do we reload
+ * ]
+ *
+ * @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");
+ private static final QualifiedName RESOURCE_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "resource-sync");
+ private static final QualifiedName RESOURCE_SYNC_LOADED_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-has-loaded-childsync");
+ private static final QualifiedName IGNORE_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-ignore");
+
+ private static final byte[] EMPTY_BYTES = new byte[0];
+ private static final FolderSyncInfo EMPTY_FOLDER_SYNC_INFO = new FolderSyncInfo("", "", null, false);
+
+ // the cvs eclipse synchronizer is a singleton
+ private static EclipseSynchronizer instance;
+
+ // track resources that have changed in a given operation
+ private int nestingCount = 0;
+ private Set changedResources = new HashSet();
+ private Set changedFolders = new HashSet();
+
+ private static final boolean USE_PHANTOMS = false;
+
+ private EclipseSynchronizer() {
+ }
+
+ public static EclipseSynchronizer getInstance() {
+ return instance;
+ }
+
+ public void setFolderSync(IContainer folder, FolderSyncInfo info) throws CVSException {
+ Assert.isNotNull(info);
+ try {
+ beginOperation(null);
+ setCachedFolderSync(folder, info);
+ changedFolders.add(folder);
+ } finally {
+ endOperation(null);
+ }
+ }
+
+ public FolderSyncInfo getFolderSync(IContainer folder) throws CVSException {
+ if (folder.getType() == IResource.ROOT) return null;
+ FolderSyncInfo info = getCachedFolderSync(folder);
+ if (info == null && folder.exists()) {
+ // read folder sync info and remember it
+ // -- if none found then remember that fact for later
+ info = SyncFileWriter.readFolderConfig(CVSWorkspaceRoot.getCVSFolderFor(folder));
+ if (info == null) info = EMPTY_FOLDER_SYNC_INFO;
+ setCachedFolderSync(folder, info);
+ }
+ if (info == EMPTY_FOLDER_SYNC_INFO) info = null;
+ return info;
+ }
+
+ public void setResourceSync(IResource resource, ResourceSyncInfo info) throws CVSException {
+ Assert.isNotNull(info);
+ try {
+ beginOperation(null);
+ ensureChildResourceSyncLoaded(resource.getParent());
+ setCachedResourceSync(resource, info);
+ changedResources.add(resource);
+ } finally {
+ endOperation(null);
+ }
+ }
+
+ public ResourceSyncInfo getResourceSync(IResource resource) throws CVSException {
+ if (resource.getType() == IResource.ROOT) return null;
+ ensureChildResourceSyncLoaded(resource.getParent());
+ return getCachedResourceSync(resource);
+ }
+
+ public void deleteFolderSync(IContainer folder, IProgressMonitor monitor) throws CVSException {
+ try {
+ beginOperation(null);
+ FolderSyncInfo info = getCachedFolderSync(folder);
+ if (info != null && info != EMPTY_FOLDER_SYNC_INFO) {
+ // remember that we deleted the folder sync info
+ setCachedFolderSync(folder, EMPTY_FOLDER_SYNC_INFO);
+ changedFolders.add(folder);
+ }
+ } finally {
+ endOperation(null);
+ }
+ }
+
+ public void deleteResourceSync(IResource resource, IProgressMonitor monitor) throws CVSException {
+ try {
+ beginOperation(null);
+ ensureChildResourceSyncLoaded(resource.getParent());
+ setCachedResourceSync(resource, null);
+ changedResources.add(resource);
+ } finally {
+ endOperation(null);
+ }
+ }
+
+ public String[] getIgnored(IResource resource) throws CVSException {
+ IContainer parent = resource.getParent();
+ if(parent==null || parent.getType()==IResource.ROOT) return null;
+ String[] ignores = getCachedFolderIgnores(parent);
+ if(ignores==null) {
+ ICVSFile ignoreFile = CVSWorkspaceRoot.getCVSFileFor(parent.getFile(new Path(SyncFileWriter.IGNORE_FILE)));
+ if(ignoreFile.exists()) {
+ ignores = SyncFileWriter.readLines(ignoreFile);
+ setCachedFolderIgnores(parent, ignores);
+ }
+ }
+ return ignores;
+ }
+
+ public void setIgnored(IResource resource, String pattern) throws CVSException {
+ SyncFileWriter.addCvsIgnoreEntry(CVSWorkspaceRoot.getCVSResourceFor(resource), pattern);
+ TeamPlugin.getManager().broadcastResourceStateChanges(new IResource[] {resource});
+ }
+
+ public IResource[] members(IContainer folder) throws CVSException {
+ try {
+ // initialize cache if needed, this will create phantoms
+ ensureChildResourceSyncLoaded(folder);
+ IResource[] children = folder.members(true);
+ List list = new ArrayList(children.length);
+ for (int i = 0; i < children.length; ++i) {
+ IResource child = children[i];
+ // return phantoms for files only, until we can handle phantoms for files.
+ if(child.isPhantom()) {
+ // it's a phantom because it has CVS sync info and not another plugins sync
+ if(child.getType()==IResource.FILE && getCachedResourceSync(child) != null) {
+ list.add(child);
+ }
+ } else {
+ list.add(child);
+ }
+ }
+ return (IResource[]) list.toArray(new IResource[list.size()]);
+ } catch (CoreException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
+ static public void startup() {
+ Assert.isTrue(instance==null);
+ instance = new EclipseSynchronizer();
+ getSynchronizer().add(RESOURCE_SYNC_KEY);
+ getSynchronizer().add(RESOURCE_SYNC_LOADED_KEY);
+ getSynchronizer().add(FOLDER_SYNC_KEY);
+ getSynchronizer().add(IGNORE_SYNC_KEY);
+ try {
+ flushAll(ResourcesPlugin.getWorkspace().getRoot(), false /*don't purge from disk*/);
+ } catch(CVSException e) {
+ // // severe problem, it would mean that we are working with stale sync info
+ CVSProviderPlugin.log(e.getStatus());
+ }
+ }
+
+ static public void shutdown() {
+ // so that the workspace won't persist cached sync info
+ getSynchronizer().remove(RESOURCE_SYNC_KEY);
+ getSynchronizer().remove(RESOURCE_SYNC_LOADED_KEY);
+ getSynchronizer().remove(FOLDER_SYNC_KEY);
+ getSynchronizer().remove(IGNORE_SYNC_KEY);
+ }
+
+ public void beginOperation(IProgressMonitor monitor) throws CVSException {
+ nestingCount += 1;
+ if (nestingCount == 1) {
+ // any work here?
+
+ // uncomment this line to bypass cache for testing
+ //flushAll(ResourcesPlugin.getWorkspace().getRoot(), false /*don't purge from disk*/);
+ }
+ }
+
+ public void endOperation(IProgressMonitor monitor) throws CVSException {
+ if (nestingCount == 1) {
+ if (! changedFolders.isEmpty() || ! changedResources.isEmpty()) {
+ try {
+ monitor = Policy.monitorFor(monitor);
+ int numResources = changedFolders.size() + changedResources.size();
+ monitor.beginTask(null, numResources);
+ monitor.subTask("Updating CVS synchronization information...");
+ /* write sync info to disk */
+ List deletedFolderSync = new ArrayList();
+
+ // folder sync info changes
+ for(Iterator it = changedFolders.iterator(); it.hasNext();) {
+ IContainer folder = (IContainer) it.next();
+ FolderSyncInfo info = getCachedFolderSync(folder);
+ ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder);
+ if (info == EMPTY_FOLDER_SYNC_INFO) {
+ // deleted folder sync info since we loaded it, postpone change until later
+ deletedFolderSync.add(folder);
+ } else if (info == null) {
+ // attempted to delete folder sync info for a previously unmanaged folder
+ // no-op
+ } else {
+ // modified or created new folder sync info since we loaded it
+ SyncFileWriter.writeFolderConfig(cvsFolder, info);
+ }
+ monitor.worked(1);
+ }
+
+ // resource sync info changes
+ Set parentsWithDirtyEntries = new HashSet();
+ for(Iterator it = changedResources.iterator(); it.hasNext();) {
+ IResource resource = (IResource) it.next();
+ ResourceSyncInfo info = getCachedResourceSync(resource);
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ Assert.isTrue(isChildResourceSyncLoaded(resource.getParent()));
+ // if the parent doesn't exists there is no point writing out the sync info
+ // to disk.
+ if(cvsResource.getParent().exists()) {
+ parentsWithDirtyEntries.add(cvsResource.getParent());
+ if (info == null) {
+ // deleted resource sync info since we loaded it
+ SyncFileWriter.deleteSync(cvsResource);
+ } else {
+ // modified or created new resource sync info since we loaded it
+ SyncFileWriter.writeResourceSync(cvsResource, info);
+ }
+ monitor.worked(1);
+ }
+ }
+
+ // folder sync info deletes
+ for(Iterator it = deletedFolderSync.iterator(); it.hasNext();) {
+ IContainer folder = (IContainer) it.next();
+ // flush everything that was cached from the CVS subdirectory
+ flushAll(folder, true /*purge from disk*/);
+ }
+
+ // merge entry file to ensure that the Entries.log file doesn't
+ for(Iterator it = parentsWithDirtyEntries.iterator(); it.hasNext();) {
+ SyncFileWriter.mergeEntriesLogFiles((ICVSFolder)it.next());
+ }
+
+ // broadcast events
+ changedResources.addAll(changedFolders);
+ IResource[] resources = (IResource[]) changedResources.toArray(
+ new IResource[changedResources.size()]);
+ TeamPlugin.getManager().broadcastResourceStateChanges(resources);
+ changedResources.clear();
+ changedFolders.clear();
+ } finally {
+ monitor.done();
+ }
+ }
+ }
+ nestingCount -= 1;
+ Assert.isTrue(nestingCount>= 0);
+ }
+
+ private static ISynchronizer getSynchronizer() {
+ return ResourcesPlugin.getWorkspace().getSynchronizer();
+ }
+
+ /*
+ * Returns the cached resource sync info, or null if none found.
+ */
+ private ResourceSyncInfo getCachedResourceSync(IResource resource) throws CVSException {
+ try {
+ byte[] bytes = getSynchronizer().getSyncInfo(RESOURCE_SYNC_KEY, resource);
+ if(bytes == null) return null;
+ return new ResourceSyncInfo(new String(bytes), null, null);
+ } catch(CoreException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
+ /*
+ * Sets the cached resource sync info, use null to delete it.
+ */
+ private void setCachedResourceSync(IResource resource, ResourceSyncInfo info) throws CVSException {
+ try {
+ if(info==null) {
+ getSynchronizer().setSyncInfo(RESOURCE_SYNC_KEY, resource, null); // faster than flush
+ } else {
+ getSynchronizer().setSyncInfo(RESOURCE_SYNC_KEY, resource, info.getEntryLine(true).getBytes());
+ }
+ } catch(CoreException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
+ /*
+ * Returns the cached sync info for a folder, null if none found, or
+ * special placeholder EMPTY_FOLDER_SYNC_INFO for deleted sync info.
+ */
+ private FolderSyncInfo getCachedFolderSync(IContainer folder) throws CVSException {
+ try {
+ byte[] bytes = getSynchronizer().getSyncInfo(FOLDER_SYNC_KEY, folder);
+ if (bytes == null) return null;
+ if (bytes.length == 0) return EMPTY_FOLDER_SYNC_INFO; // return placeholder for deleted sync info
+ DataInputStream is = new DataInputStream(new ByteArrayInputStream(bytes));
+ String repo = is.readUTF();
+ String root = is.readUTF();
+ String tag = is.readUTF();
+ CVSTag cvsTag = null;
+ boolean isStatic = is.readBoolean();
+ if(!tag.equals("null")) {
+ cvsTag = new CVSEntryLineTag(tag);
+ }
+ return new FolderSyncInfo(repo, root, cvsTag, isStatic);
+ } catch (CoreException e) {
+ throw CVSException.wrapException(e);
+ } catch(IOException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
+ /*
+ * Sets the cached sync info for a folder, use null to flush, or special
+ * EMPTY_FOLDER_SYNC_INFO placeholder for deleted sync info.
+ */
+ private void setCachedFolderSync(IContainer folder, FolderSyncInfo info) throws CVSException {
+ try {
+ if (info == null) {
+ getSynchronizer().setSyncInfo(FOLDER_SYNC_KEY, folder, null); // faster than flush
+ } else if (info == EMPTY_FOLDER_SYNC_INFO ) {
+ // memorize placeholder for deleted sync info
+ getSynchronizer().setSyncInfo(FOLDER_SYNC_KEY, folder, EMPTY_BYTES);
+ } else {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ DataOutputStream os = new DataOutputStream(bos);
+ os.writeUTF(info.getRepository());
+ os.writeUTF(info.getRoot());
+ CVSEntryLineTag tag = info.getTag();
+ if(tag==null) {
+ os.writeUTF("null");
+ } else {
+ os.writeUTF(info.getTag().toEntryLineFormat(false));
+ }
+ os.writeBoolean(info.getIsStatic());
+ getSynchronizer().setSyncInfo(FOLDER_SYNC_KEY, folder, bos.toByteArray());
+ os.close();
+ }
+ } catch (CoreException e) {
+ throw CVSException.wrapException(e);
+ } catch(IOException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
+ private String[] getCachedFolderIgnores(IContainer folder) throws CVSException {
+ try {
+ byte[] bytes = getSynchronizer().getSyncInfo(IGNORE_SYNC_KEY, folder);
+ if (bytes == null) return null;
+ DataInputStream is = new DataInputStream(new ByteArrayInputStream(bytes));
+ int count = is.readInt();
+ String[] ignoreList = new String[count];
+ for(int i = 0; i < count; ++i) {
+ ignoreList[i] = is.readUTF();
+ }
+ return ignoreList;
+ } catch (CoreException e) {
+ throw CVSException.wrapException(e);
+ } catch(IOException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
+ private void setCachedFolderIgnores(IContainer folder, String[] ignores) throws CVSException {
+ try {
+ if (ignores == null) {
+ getSynchronizer().setSyncInfo(IGNORE_SYNC_KEY, folder, null); // faster than flush
+ } else {
+ // a zero-length array indicates there were no ignores found
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ DataOutputStream os = new DataOutputStream(bos);
+ os.writeInt(ignores.length);
+ for(int i = 0; i < ignores.length; ++i) {
+ os.writeUTF(ignores[i]);
+ }
+ getSynchronizer().setSyncInfo(IGNORE_SYNC_KEY, folder, bos.toByteArray());
+ os.close();
+ }
+ } catch (CoreException e) {
+ throw CVSException.wrapException(e);
+ } catch(IOException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
+ /*
+ * Reads and caches the ResourceSyncInfos for this folder if not already cached.
+ */
+ private void ensureChildResourceSyncLoaded(IContainer folder) throws CVSException {
+ // don't try to load if the information is already cached
+ if (isChildResourceSyncLoaded(folder)) return;
+ ResourceSyncInfo[] infos = SyncFileWriter.readEntriesFile(CVSWorkspaceRoot.getCVSFolderFor(folder));
+ if (infos != null) {
+ for (int i = 0; i < infos.length; i++) {
+ ResourceSyncInfo syncInfo = infos[i];
+ IResource peer;
+ IPath path = new Path(syncInfo.getName());
+ if (syncInfo.isDirectory()) {
+ peer = folder.getFolder(path);
+ } else {
+ peer = folder.getFile(path);
+ }
+ // may create a phantom if the sibling resource does not exist.
+ setCachedResourceSync(peer, syncInfo);
+ }
+ }
+ setChildResourceSyncLoaded(folder, true);
+ }
+
+ private boolean isChildResourceSyncLoaded(IContainer folder) throws CVSException {
+ try {
+ // root folder has no entries therefore info is always loaded
+ if (folder.getType() == IResource.ROOT || ! folder.exists()) return true;
+ return getSynchronizer().getSyncInfo(RESOURCE_SYNC_LOADED_KEY, folder) != null;
+ } catch(CoreException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
+ private void setChildResourceSyncLoaded(IContainer folder, boolean isLoaded) throws CVSException {
+ try {
+ getSynchronizer().setSyncInfo(RESOURCE_SYNC_LOADED_KEY, folder, isLoaded ? EMPTY_BYTES : null);
+ } catch(CoreException e) {
+ throw CVSException.wrapException(e);
+ }
+
+ }
+
+ private void flushChildResourceSync(IContainer folder, int depth) throws CVSException {
+ // flushSyncInfo fails with an exception if the folder does not exist
+ if (! folder.exists()) return;
+ try {
+ byte[] folderSyncBytes = getSynchronizer().getSyncInfo(RESOURCE_SYNC_KEY, folder);
+ getSynchronizer().flushSyncInfo(RESOURCE_SYNC_KEY, folder, depth);
+ getSynchronizer().setSyncInfo(RESOURCE_SYNC_KEY, folder, folderSyncBytes);
+ } catch(CoreException e) {
+ throw CVSException.wrapException(folder, "Error flushing a folder's children sync", e);
+ }
+ }
+
+ static public void flushAll(final IContainer root, final boolean purgeFromDisk) throws CVSException {
+ if (! (root.exists() || root.isPhantom())) return;
+ try {
+ // purge sync information from children
+ root.accept(new IResourceVisitor() {
+ public boolean visit(IResource resource) throws CoreException {
+ if(! root.equals(resource)) {
+ // don't clear resource sync on root since it might still be managed
+ // by its parent
+ getSynchronizer().setSyncInfo(RESOURCE_SYNC_KEY, resource, null);
+ }
+ if(resource.getType()!=IResource.FILE) {
+ IContainer folder = (IContainer) resource;
+ getSynchronizer().setSyncInfo(RESOURCE_SYNC_LOADED_KEY, folder, null);
+ getSynchronizer().setSyncInfo(FOLDER_SYNC_KEY, folder, null);
+ getSynchronizer().setSyncInfo(IGNORE_SYNC_KEY, folder, null);
+ if(purgeFromDisk && root.exists()) {
+ SyncFileWriter.deleteCVSSubDirectory(folder);
+ }
+ }
+ return true;
+ }
+
+ }, IResource.DEPTH_INFINITE, true /*include phantoms*/);
+ } catch(CoreException e) {
+ throw CVSException.wrapException(root, "Problems occured flushing synchronizer cache", e);
+ }
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSSynchronizer.java
deleted file mode 100644
index 7ed3120be..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSSynchronizer.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.File;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
-
-/**
- * A synchronizer is responsible for managing synchronization information for local
- * CVS resources.
- *
- * @see ResourceSyncInfo
- * @see FolderSyncInfo
- */
-public interface ICVSSynchronizer {
-
- /**
- * Associates the provided folder sync information with the given folder. The folder
- * must exist on the file system.
- * <p>
- * The workbench and team plugins are notified that the state of this resources has
- * changed.</p>
- *
- * @param file the file or folder for which to associate the sync info.
- * @param info the folder sync to set.
- *
- * @throws CVSException if there was a problem adding sync info.
- */
- public void setFolderSync(File folder, FolderSyncInfo info) throws CVSException;
-
- /**
- * Answers the folder sync information associated with this folder or <code>null</code>
- * if none is available.
- *
- * @param folder the folder for which to return folder sync info.
- * @throws CVSException if there was a problem adding folder sync info.
- */
- public FolderSyncInfo getFolderSync(File file) throws CVSException;
-
- /**
- * Associates the provided sync information with the given file or folder. The resource
- * may or may not exist on the file system however the parent folder must be a cvs
- * folder.
- * <p>
- * The workbench and team plugins are notified that the state of this resources has
- * changed.</p>
- *
- * @param file the file or folder for which to associate the sync info.
- * @param info to set. The name in the resource info must match the file or folder name.
- *
- * @throws CVSException if there was a problem adding sync info.
- */
- public void setResourceSync(File file, ResourceSyncInfo info) throws CVSException;
-
- /**
- * Answers the sync information associated with this file of folder or <code>null</code>
- * if none is available. A resource cannot have sync information if its parent folder
- * does not exist.
- *
- * @param file the file or folder for which to return sync info.
- * @throws CVSException if there was a problem adding sync info or broadcasting
- * the changes.
- */
- public ResourceSyncInfo getResourceSync(File file) throws CVSException;
-
- /**
- * Removes the folder's and all children's folder sync information. This will essentially remove
- * all CVS knowledge from these resources.
- */
- public void deleteFolderSync(File file, IProgressMonitor monitor) throws CVSException;
-
- /**
- * Removes the resource's sync information.
- */
- public void deleteResourceSync(File file) throws CVSException;
-
- /**
- * Answers if the following resource is ignored
- */
- public boolean isIgnored(File file);
-
- /**
- * Adds a pattern or file name to be ignored in the current files directory.
- */
- public void setIgnored(File file, String pattern) throws CVSException;
-
- /**
- * Allows the synchronizer to update the workspace with changes made by an 3rd
- * party tool to the sync info.
- */
- public void reload(File file, IProgressMonitor monitor) throws CVSException;
-
- /**
- * Call to allow the synchronizer to save any pending or buffered changes and dispatch
- * state change notifications.
- */
- public void save(File file, IProgressMonitor monitor) throws CVSException;
-
- /**
- * Answers an array with the sync information for immediate child resources of this folder. Note
- * that the returned sync information may be for resources that no longer exist (e.g. in the
- * case of a pending deletion).
- *
- * @param folder the folder for which to return the children resource sync infos. The folder
- * must exist.
- *
- * @throws CVSException if an error occurs retrieving the sync info.
- */
- public ResourceSyncInfo[] members(File folder) throws CVSException;
-
- /**
- * XXX: Should be removed. Currently only used by tests and instead the tests should be
- * created for the different types of concrete sync classes.
- */
- public boolean isEmpty();
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java
deleted file mode 100644
index ce8c55128..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-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.text.ParseException;
-import java.util.Date;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
-import org.eclipse.team.internal.ccvs.core.util.EntryFileDateFormat;
-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
- */
-public class LocalFile extends LocalResource implements ICVSFile {
- /**
- * Create a handle based on the given local resource.
- */
- public LocalFile(File file) {
- super(file);
- }
-
- public long getSize() {
- return ioResource.length();
- }
-
- public InputStream getInputStream() throws CVSException {
- try {
- return new FileInputStream(ioResource);
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- public OutputStream getOutputStream() throws CVSException {
- try {
- return new FileOutputStream(ioResource);
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- public void setReadOnly() throws CVSException {
- ioResource.setReadOnly();
- }
-
- public String getTimeStamp() throws CVSFileNotFoundException {
- EntryFileDateFormat timestamp = new EntryFileDateFormat();
- return timestamp.format(new Date(ioResource.lastModified()));
- }
-
- public void setTimeStamp(String date) throws CVSException {
- long millSec;
- if (date==null) {
- // get the current time
- millSec = new Date().getTime();
- } else {
- try {
- EntryFileDateFormat timestamp = new EntryFileDateFormat();
- millSec = timestamp.toDate(date).getTime();
- } catch (ParseException e) {
- throw new CVSException(Policy.bind("LocalFile.invalidDateFormat", date), e); //$NON-NLS-1$
- }
- }
- ioResource.setLastModified(millSec);
- }
-
- public boolean isFolder() {
- return false;
- }
-
- public boolean isDirty() throws CVSException {
- if (!exists() || !isManaged()) {
- return true;
- } else {
- ResourceSyncInfo info = getSyncInfo();
- if (info.isAdded()) return false;
- if (info.isDeleted()) return true;
- return !getTimeStamp().equals(info.getTimeStamp());
- }
- }
-
- public boolean isModified() throws CVSException {
- if (!exists() || !isManaged()) {
- return true;
- } else {
- ResourceSyncInfo info = getSyncInfo();
- return !getTimeStamp().equals(info.getTimeStamp());
- }
- }
-
- 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 moveTo(String filename) throws CVSException {
-
- // Move the file to newFile (we know we do not need the
- // original any more anyway)
- // If this file exists then overwrite it
- LocalFile file;
- try {
- file = (LocalFile)getParent().getFile(filename);
- } catch(ClassCastException e) {
- throw CVSException.wrapException(e);
- }
-
- // We are deleting the old .#filename if it exists
- if (file.exists()) {
- file.delete();
- }
-
- boolean success = ioResource.renameTo(file.getFile());
-
- if (!success) {
- throw new CVSException(Policy.bind("LocalFile.moveFailed", ioResource.toString(), file.toString())); //$NON-NLS-1$
- }
- }
-
- File getFile() {
- return ioResource;
- }
-
- /**
- * @see ICVSResource#getRemoteLocation()
- */
- public String getRemoteLocation(ICVSFolder stopSearching) throws CVSException {
- return getParent().getRemoteLocation(stopSearching) + SEPARATOR + getName();
- }
- /*
- * @see ICVSResource#unmanage()
- */
- public void unmanage() throws CVSException {
- CVSProviderPlugin.getSynchronizer().deleteResourceSync(ioResource);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFolder.java
deleted file mode 100644
index 4c689b834..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFolder.java
+++ /dev/null
@@ -1,264 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-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
- */
-public class LocalFolder extends LocalResource implements ICVSFolder {
-
- public LocalFolder(File ioResource) {
- super(ioResource);
- }
-
- /**
- *
- * @see ICVSFolder#getFolders()
- */
- public ICVSFolder[] getFolders() throws CVSException {
-
- if(!getLocalFile().exists()) {
- return new ICVSFolder[0];
- }
-
- final List folders = new ArrayList();
-
- ResourceSyncInfo[] syncDirs = CVSProviderPlugin.getSynchronizer().members(ioResource);
- for (int i = 0; i < syncDirs.length; i++) {
- if(syncDirs[i].isDirectory()) {
- folders.add((new LocalFolder(new File(ioResource, syncDirs[i].getName()))));
- }
- }
-
- File[] realDirs = ioResource.listFiles(new FileFilter() {
- public boolean accept(File file) {
- if(file.isDirectory()) {
- LocalFolder cvsFolder = new LocalFolder(file);
- if(!cvsFolder.isIgnored() && !folders.contains(cvsFolder)) {
- folders.add(cvsFolder);
- }
- }
- return false;
- }
- });
-
- return (ICVSFolder[]) folders.toArray(new ICVSFolder[folders.size()]);
- }
-
- /**
- * @see ICVSFolder#getFiles()
- */
- public ICVSFile[] getFiles() throws CVSException {
-
- if(!getLocalFile().exists()) {
- return new ICVSFile[0];
- }
-
- final List files = new ArrayList();
-
- ResourceSyncInfo[] syncDirs = CVSProviderPlugin.getSynchronizer().members(ioResource);
- for (int i = 0; i < syncDirs.length; i++) {
- if(!syncDirs[i].isDirectory()) {
- files.add((new LocalFile(new File(ioResource, syncDirs[i].getName()))));
- }
- }
-
- File[] realDirs = ioResource.listFiles(new FileFilter() {
- public boolean accept(File file) {
- if(!file.isDirectory()) {
- LocalFile cvsFile = new LocalFile(file);
- if(!cvsFile.isIgnored() && !files.contains(cvsFile)) {
- files.add(cvsFile);
- }
- }
- return false;
- }
- });
- return (ICVSFile[]) files.toArray(new ICVSFile[files.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;
- return new LocalFolder(new File(ioResource, name));
- }
-
- /**
- * @see ICVSFolder#createFile(String)
- */
- public ICVSFile getFile(String name) throws CVSException {
- return new LocalFile(new File(ioResource, name));
- }
-
- /**
- * @see ICVSFolder#getChild(String)
- */
- public ICVSResource getChild(String name) throws CVSException {
-
- boolean isDirectory;
-
- File child = new File(ioResource, name);
- if(child.exists()) {
- isDirectory = child.isDirectory();
- } else {
- LocalFile localFile = new LocalFile(child);
- ResourceSyncInfo info = localFile.getSyncInfo();
- if (info == null)
- throw new CVSFileNotFoundException(Policy.bind("LocalFolder.invalidChild", child.getAbsolutePath())); //$NON-NLS-1$
- isDirectory = info.isDirectory();
- }
-
- if(isDirectory) {
- return getFolder(name);
- } else {
- return getFile(name);
- }
- }
- /**
- * @see ICVSFolder#mkdir()
- */
- public void mkdir() throws CVSException {
- ioResource.mkdir();
- }
-
- /**
- * @see ICVSResource#isFolder()
- */
- public boolean isFolder() {
- return true;
- }
-
-// /**
-// * Remove the fileInfo for a specific file. If it was not there
-// * before nothing happens.
-// *
-// * @param file has to satisfy file.getParent().equals(this)
-// */
-// void removeFileInfo(IManagedFile file) throws CVSException {
-//
-// Assert.isTrue(file.getParent().equals(this));
-//
-// fileInfoContainer.removeFileInfo(file.getName());
-// }
-
- /**
- * @see ICVSFolder#acceptChildren(ICVSResourceVisitor)
- */
- public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException {
-
- ICVSResource[] subFiles;
- ICVSResource[] subFolders;
-
- subFiles = getFiles();
- subFolders = getFolders();
-
- for (int i=0; i<subFiles.length; i++) {
- subFiles[i].accept(visitor);
- }
-
- 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 {
-
- String parentLocation;
-
- if (getFolderSyncInfo() != null) {
- return getFolderSyncInfo().getRemoteLocation();
- }
-
- if (equals(stopSearching)) {
- return null;
- }
-
- parentLocation = getParent().getRemoteLocation(stopSearching);
- if (parentLocation == null) {
- return null;
- } else {
- return parentLocation + SEPARATOR + getName();
- }
-
- }
-
- /*
- * @see ICVSFolder#childExists(String)
- */
- public boolean childExists(String path) {
- return false;
- }
-
- /*
- * @see ICVSFolder#getFolderInfo()
- */
- public FolderSyncInfo getFolderSyncInfo() throws CVSException {
- return CVSProviderPlugin.getSynchronizer().getFolderSync(ioResource);
- }
-
- /*
- * @see ICVSFolder#setFolderInfo(FolderSyncInfo)
- */
- public void setFolderSyncInfo(FolderSyncInfo folderInfo) throws CVSException {
- CVSProviderPlugin.getSynchronizer().setFolderSync(ioResource, folderInfo);
- }
-
- /*
- * @see ICVSFolder#isCVSFolder()
- */
- public boolean isCVSFolder() {
- try {
- return CVSProviderPlugin.getSynchronizer().getFolderSync(ioResource) != null;
- } catch(CVSException e) {
- return false;
- }
- }
-
- /*
- * @see ICVSResource#unmanage()
- */
- public void unmanage() throws CVSException {
- CVSProviderPlugin.getSynchronizer().deleteFolderSync(ioResource, new NullProgressMonitor());
- }
-
- /*
- * @see ICVSResource#isIgnored()
- */
- public boolean isIgnored() {
- if(isCVSFolder()) {
- return false;
- }
- return super.isIgnored();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/NotCVSFolderException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/NotCVSFolderException.java
deleted file mode 100644
index c5a4ee972..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/NotCVSFolderException.java
+++ /dev/null
@@ -1,82 +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.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.connection.ResourceStatus;
-
-/**
- * This Exception indicates that you have tried to call
- * a CVSFolder-Specific function on a folder that is not
- * (yet) a cvs-folder.
- */
-public class NotCVSFolderException extends CVSException {
-
- public NotCVSFolderException(
- int severity,
- int code,
- IPath path,
- String message,
- Throwable exception) {
- super(new ResourceStatus(severity, code, path, message, exception));
- }
- public NotCVSFolderException(
- int severity,
- int code,
- IPath path,
- String message) {
- this(severity, code, path, message, null);
- }
- public NotCVSFolderException(
- int severity,
- int code,
- IPath path,
- Throwable exception) {
- this(severity, code, path, null, exception);
- }
- public NotCVSFolderException(
- int severity,
- int code,
- String message,
- Exception e) {
- super(new Status(severity, CVSProviderPlugin.ID, code, message, null));
- }
- public NotCVSFolderException(
- int severity,
- int code,
- String message) {
- this(severity, code, message, null);
- }
-
- public NotCVSFolderException(
- int severity,
- int code,
- Exception e) {
- super(new Status(severity, CVSProviderPlugin.ID, code, null, e));
-
- }
-
- public NotCVSFolderException(String message) {
- super(new Status(IStatus.ERROR, CVSProviderPlugin.ID, IStatus.ERROR, message, null));
- }
-
- public NotCVSFolderException(String message, IPath path) {
- this(message, path, null);
- }
-
- public NotCVSFolderException(String message, IPath path, Throwable throwable) {
- this(new ResourceStatus(IStatus.ERROR, path, message, throwable));
- }
- public NotCVSFolderException(IStatus status) {
- super(status);
- }
-}
-
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
index 8fea7a8a4..f1f951764 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
@@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSStatus;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.ICVSRemoteFile;
@@ -320,13 +321,17 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
};
}
- public void setReadOnly() throws CVSException {
+ public void setReadOnly(boolean readOnly) throws CVSException {
}
+ public boolean isReadOnly() throws CVSException {
+ return true;
+ }
+
/**
* @see IManagedFile#getTimeStamp()
*/
- public String getTimeStamp() throws CVSFileNotFoundException {
+ public String getTimeStamp() {
return info.getTimeStamp();
}
@@ -394,4 +399,11 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
RemoteFile remote = (RemoteFile) target;
return super.equals(target) && remote.getRevision().equals(getRevision());
}
+
+ /*
+ * @see ICVSFile#getAppendingOutputStream()
+ */
+ public OutputStream getAppendingOutputStream() throws CVSException {
+ return null;
+ }
} \ 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
index ce3d34d51..8b856723a 100644
--- 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
@@ -16,12 +16,14 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSStatus;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.ccvs.core.ICVSRunnable;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
@@ -609,4 +611,11 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC
children = oldChildren;
}
}
+
+ /*
+ * @see ICVSFolder#run(ICVSRunnable, IProgressMonitor)
+ */
+ public void run(ICVSRunnable job, IProgressMonitor monitor) throws CVSException {
+ job.run(monitor);
+ }
} \ 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
index 2bf59497e..9fb0013c4 100644
--- 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
@@ -7,6 +7,7 @@ package org.eclipse.team.internal.ccvs.core.resources;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/RemoteFolderTreeBuilder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java
index 21591953a..31da9ae6f 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/RemoteFolderTreeBuilder.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java
@@ -1,591 +1,588 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (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.Path;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.ccvs.core.CVSStatus;
-import org.eclipse.team.ccvs.core.CVSTag;
-import org.eclipse.team.ccvs.core.ICVSRemoteResource;
-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;
-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.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.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTree;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-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 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$
- 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, Session.getManagedFolder(root.getLocation().toFile()), 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);
- }
-
- private RemoteFolderTree buildTree(IProgressMonitor monitor) throws CVSException {
-
- try {
- monitor.beginTask(null, 100);
-
- Session session = new Session(repository, root, false);
- session.open(Policy.subMonitorFor(monitor, 10));
- try {
- fetchDelta(session, Policy.subMonitorFor(monitor, 50));
- if (projectDoesNotExist) {
- return null;
- }
- } finally {
- session.close();
- }
- // FIXME: We need a second session because of the use of a different handle on the same remote resource
- // We didn't need one before!!! 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);
- if (!changedFiles.isEmpty())
- fetchFileRevisions(session, (String[])changedFiles.toArray(new String[changedFiles.size()]), Policy.subMonitorFor(monitor, 20));
- return remoteRoot;
- } finally {
- session.close();
- }
- } finally {
- 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 {
-
- // 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
- ICVSFolder[] folders = local.getFolders();
- for (int i=0;i<folders.length;i++) {
- if (folders[i].isManaged() && folders[i].isCVSFolder()) {
- monitor.subTask("Building base for " + folders[i].getRelativePath(root));
- monitor.worked(1);
- children.add(buildBaseTree(remote, folders[i], monitor));
- }
- }
-
- // Build the child files corresponding to local files base
- ICVSFile[] files = local.getFiles();
- for (int i=0;i<files.length;i++) {
- ICVSFile file = 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())
- info = new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions());
- 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 {
-
- // Add the remote folder to the remote folder lookup table (used to update file revisions)
- remoteFolderTable.put(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
- ICVSFolder[] folders = local.getFolders();
- for (int i=0;i<folders.length;i++) {
- DeltaNode d = (DeltaNode)deltas.get(folders[i].getName());
- if (folders[i].isCVSFolder() && ! isOrphanedSubtree(session, folders[i]) && (d==null || d.getRevision() != DELETED)) {
- children.put(folders[i].getName(),
- new RemoteFolderTree(remote, folders[i].getName(), repository,
- new Path(folders[i].getFolderSyncInfo().getRepository()),
- tagForRemoteFolder(folders[i],tag)));
- }
- }
- // Build the child files corresponding to local files
- ICVSFile[] files = local.getFiles();
- for (int i=0;i<files.length;i++) {
- ICVSFile file = 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.getFiles().length == 0 && localFolder.getFolders().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, 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(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()));
- // Record new directory to be used as a parameter to fetch its contents
- newChildDirectories.add(path.toString());
- }
- }
- public void directoryDoesNotExist(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()));
- }
- }
- public void fileInformation(int type, 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));
- break;
- }
- }
- public void fileDoesNotExist(String filename) {
- recordDelta(new Path(filename), DELETED, Update.STATE_NONE);
- monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", filename));
- }
- };
-
- // 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[] { Session.CURRENT_LOCAL_FOLDER },
- 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(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()));
- }
- }
- public void directoryDoesNotExist(IPath path) {
- }
- public void fileInformation(int type, String filename) {
- // NOTE: Check path prefix
- changedFiles.add(filename);
- recordDelta(new Path(filename), ADDED, type);
- monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", filename));
- }
- public void fileDoesNotExist(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 int[] count = new int[] {0};
- final Map revisions = new HashMap();
- IStatusListener listener = new IStatusListener() {
- public void fileStatus(IPath path, String remoteRevision) {
- try {
- updateRevision(path, remoteRevision);
- monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingRevision", path.toString()));
- count[0]++;
- } catch (CVSException e) {
- // The count will be off which will trigger another exception
- CVSProviderPlugin.log(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);
- }
-
- // XXX we can't make this check because it may be valid to call this method
- // without any file names (e.g. fileNames array empty) which would run the
- // status on all files.
- //if (count[0] != fileNames.length)
- // throw new CVSException(Policy.bind("RemoteFolder.errorFetchingRevisions"));
- }
-
- 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).toString());
- ((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();
- }
-}
-
+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.Path;
+import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.ccvs.core.CVSStatus;
+import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSRemoteResource;
+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;
+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.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.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 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$
+ 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);
+ }
+
+ private RemoteFolderTree buildTree(IProgressMonitor monitor) throws CVSException {
+
+ try {
+ monitor.beginTask(null, 100);
+
+ Session session = new Session(repository, root, false);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ fetchDelta(session, Policy.subMonitorFor(monitor, 50));
+ if (projectDoesNotExist) {
+ return null;
+ }
+ } finally {
+ session.close();
+ }
+ // FIXME: We need a second session because of the use of a different handle on the same remote resource
+ // We didn't need one before!!! 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);
+ if (!changedFiles.isEmpty())
+ fetchFileRevisions(session, (String[])changedFiles.toArray(new String[changedFiles.size()]), Policy.subMonitorFor(monitor, 20));
+ return remoteRoot;
+ } finally {
+ session.close();
+ }
+ } finally {
+ 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 {
+
+ // 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
+ ICVSFolder[] folders = local.getFolders();
+ for (int i=0;i<folders.length;i++) {
+ if (folders[i].isManaged() && folders[i].isCVSFolder()) {
+ monitor.subTask("Building base for " + folders[i].getRelativePath(root));
+ monitor.worked(1);
+ children.add(buildBaseTree(remote, folders[i], monitor));
+ }
+ }
+
+ // Build the child files corresponding to local files base
+ ICVSFile[] files = local.getFiles();
+ for (int i=0;i<files.length;i++) {
+ ICVSFile file = 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())
+ info = new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions());
+ 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 {
+
+ // Add the remote folder to the remote folder lookup table (used to update file revisions)
+ remoteFolderTable.put(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
+ ICVSFolder[] folders = local.getFolders();
+ for (int i=0;i<folders.length;i++) {
+ DeltaNode d = (DeltaNode)deltas.get(folders[i].getName());
+ if (folders[i].isCVSFolder() && ! isOrphanedSubtree(session, folders[i]) && (d==null || d.getRevision() != DELETED)) {
+ children.put(folders[i].getName(),
+ new RemoteFolderTree(remote, folders[i].getName(), repository,
+ new Path(folders[i].getFolderSyncInfo().getRepository()),
+ tagForRemoteFolder(folders[i],tag)));
+ }
+ }
+ // Build the child files corresponding to local files
+ ICVSFile[] files = local.getFiles();
+ for (int i=0;i<files.length;i++) {
+ ICVSFile file = 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.getFiles().length == 0 && localFolder.getFolders().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, 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(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()));
+ // Record new directory to be used as a parameter to fetch its contents
+ newChildDirectories.add(path.toString());
+ }
+ }
+ public void directoryDoesNotExist(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()));
+ }
+ }
+ public void fileInformation(int type, 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));
+ break;
+ }
+ }
+ public void fileDoesNotExist(String filename) {
+ recordDelta(new Path(filename), DELETED, Update.STATE_NONE);
+ monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", filename));
+ }
+ };
+
+ // 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[] { Session.CURRENT_LOCAL_FOLDER },
+ 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(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()));
+ }
+ }
+ public void directoryDoesNotExist(IPath path) {
+ }
+ public void fileInformation(int type, String filename) {
+ // NOTE: Check path prefix
+ changedFiles.add(filename);
+ recordDelta(new Path(filename), ADDED, type);
+ monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", filename));
+ }
+ public void fileDoesNotExist(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 int[] count = new int[] {0};
+ final Map revisions = new HashMap();
+ IStatusListener listener = new IStatusListener() {
+ public void fileStatus(IPath path, String remoteRevision) {
+ try {
+ updateRevision(path, remoteRevision);
+ monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingRevision", path.toString()));
+ count[0]++;
+ } catch (CVSException e) {
+ // The count will be off which will trigger another exception
+ CVSProviderPlugin.log(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);
+ }
+
+ // XXX we can't make this check because it may be valid to call this method
+ // without any file names (e.g. fileNames array empty) which would run the
+ // status on all files.
+ //if (count[0] != fileNames.length)
+ // throw new CVSException(Policy.bind("RemoteFolder.errorFetchingRevisions"));
+ }
+
+ 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).toString());
+ ((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
index b85a273e2..efed3e615 100644
--- 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
@@ -17,6 +17,7 @@ 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.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
@@ -42,7 +43,7 @@ public class RemoteModule extends RemoteFolder {
public static RemoteModule[] getRemoteModules(ICVSRepositoryLocation repository, CVSTag tag, IProgressMonitor monitor) throws TeamException {
RemoteModule[] modules;
- Session s = new Session(repository, (ICVSFolder)Session.getManagedResource(ResourcesPlugin.getWorkspace().getRoot()), false);
+ Session s = new Session(repository, (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(ResourcesPlugin.getWorkspace().getRoot()), false);
s.open(monitor);
try {
modules = Command.CHECKOUT.getRemoteModules(s, tag, monitor);
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
index 0b817fa0f..3696c9d28 100644
--- 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
@@ -7,12 +7,14 @@ package org.eclipse.team.internal.ccvs.core.resources;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
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.*;
+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;
@@ -149,4 +151,17 @@ public abstract class RemoteResource extends PlatformObject implements ICVSRemot
// ensure that clients are not trying to set sync info on remote handles.
Assert.isTrue(false);
}
+ /*
+ * @see ICVSResource#reloadSyncInfo(IProgressMonitor)
+ */
+ public void reloadSyncInfo(IProgressMonitor monitor) throws CVSException {
+ // NO-OP
+ }
+
+ /*
+ * @see ICVSResource#saveSyncInfo(IProgressMonitor)
+ */
+ public void saveSyncInfo(IProgressMonitor monitor) throws CVSException {
+ // NO-OP
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FileSystemSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FileSystemSynchronizer.java
deleted file mode 100644
index defe46701..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FileSystemSynchronizer.java
+++ /dev/null
@@ -1,447 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-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.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.core.TeamPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSSynchronizer;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
-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.FileUtil;
-import org.eclipse.team.internal.ccvs.core.util.ResourceDeltaVisitor;
-import org.eclipse.team.internal.ccvs.core.util.SyncFileUtil;
-import org.eclipse.team.internal.ccvs.core.Policy;
-
-/**
- * The FileSystemSynchronizer stores sync information to be compatible with CVS command line
- * clients. It is also responsible for synchronizing the workbench when changes are made to CVS
- * metafiles (CVS/Entries, CVS/Root..) from outside of the workbench by 3rd party tools.
- *
- * @see ICVSSynchronizer
- */
-public class FileSystemSynchronizer implements ICVSSynchronizer {
-
- // caches for resource and folder sync. These are required to provide timely access to
- // sync information that may be shown in the UI.
- private ICache resourceSyncCache;
- private ICache folderSyncCache;
- private ICache cvsIgnoreCache;
-
- // a specialized resource listener required to interpret metafile changes made to CVS managed
- // resources.
- private SyncResourceChangeListener resourceListener;
-
- // time in minutes that a cached sync object should remain in the cache. A time of 0 indicates
- // that the cache object will never expire.
- private final static int CACHE_EXPIRATION_MINUTES = 0;
-
- /**
- * Initialize the caches and register as a resource listener.
- */
- public FileSystemSynchronizer() {
- resourceSyncCache = new SimpleCache();
- resourceSyncCache.registerLoader(new ResourceSyncCacheLoader());
-
- folderSyncCache = new SimpleCache();
- folderSyncCache.registerLoader(new FolderSyncCacheLoader());
-
- cvsIgnoreCache = new SimpleCache();
- cvsIgnoreCache.registerLoader(new CVSIgnoreFileLoader());
-
- resourceListener = new SyncResourceChangeListener();
- resourceListener.register();
- }
-
- /**
- * For every get request from the cache, load the entire entries and permissions file.
- */
- private class ResourceSyncCacheLoader implements ICacheLoader {
- /*
- * @see ICacheLoader#load(Object, ICache)
- */
- public CacheData load(Object id, ICache cache) {
- CacheData idInfo = null;
- try {
- File file = (File)id;
- File parent = file.getParentFile();
-
- ResourceSyncInfo infos[] = SyncFileUtil.readEntriesFile(parent);
- // if null then, entries file does not exist
- if(infos!=null) {
- for (int i = 0; i < infos.length; i++) {
- ResourceSyncInfo info = infos[i];
- CacheData cacheInfo = new CacheData(new File(parent, info.getName()), info, CACHE_EXPIRATION_MINUTES);
- if(file.getName().equals(info.getName())) {
- idInfo = cacheInfo;
- } else {
- cache.put(cacheInfo);
- }
- }
- }
- } catch(CVSException e) {
- TeamPlugin.log(IStatus.ERROR, Policy.bind("FileSystemSynchronizer_Error_loading_from_CVS/Entries_file_1"), e); //$NON-NLS-1$
- return null;
- }
- return idInfo;
- }
- }
-
- /**
- * For every get request from the cache, load the .cvsignore file
- */
- private class CVSIgnoreFileLoader implements ICacheLoader {
- /*
- * @see ICacheLoader#load(Object, ICache)
- */
- public CacheData load(Object id, ICache cache) {
- CacheData idInfo = null;
- try {
- File file = (File)id;
- File cvsignore = new File(file, SyncFileUtil.IGNORE_FILE);
- String[] patterns = SyncFileUtil.readLines(cvsignore);
- if(patterns.length>0) {
- idInfo = new CacheData(file, patterns, CACHE_EXPIRATION_MINUTES);
- cache.put(idInfo);
- }
- } catch(CVSException e) {
- TeamPlugin.log(IStatus.ERROR, Policy.bind("FileSystemSynchronizer_Error_loading_from_.cvsignore_file_2"), e); //$NON-NLS-1$
- return null;
- }
- return idInfo;
- }
- }
-
- /**
- * For every get request from the cache that fails, load the files that contain the folder sync info.
- */
- private class FolderSyncCacheLoader implements ICacheLoader {
- /*
- * @see ICacheLoader#load(Object, ICache)
- */
- public CacheData load(Object id, ICache cache) {
- try {
- File folder = (File)id;
- FolderSyncInfo info = SyncFileUtil.readFolderConfig(folder);
-
- // no CVS sub-directory
- if(info==null) {
- return null;
- } else {
- return new CacheData(folder, info, CACHE_EXPIRATION_MINUTES);
- }
- } catch(CVSException e) {
- TeamPlugin.log(IStatus.ERROR, Policy.bind("FileSystemSynchronizer_Error_loading_from_CVS/Root,Repository_files_3"), e); //$NON-NLS-1$
- return null;
- }
- }
- }
-
- /**
- * Handle changes made to meta files.
- * 1.
- */
- private class SyncResourceChangeListener extends ResourceDeltaVisitor {
- final private Set delta = new HashSet();
-
- protected void handleAdded(IResource[] resources) {
- handleDefault(resources);
- }
-
- protected void handleRemoved(IResource[] resources) {
- handleDefault(resources);
- }
-
- protected void handleChanged(IResource[] resources) {
- handleDefault(resources);
- }
-
- protected void finished() {
- TeamPlugin.getManager().broadcastResourceStateChanges((IResource[]) delta.toArray(new IResource[delta.size()]));
- delta.clear();
- }
-
- /**
- * If a meta file has changed the cache will be out-of-date. It will be cleared and subsequent access
- * will force a reload of the sync information when needed by a client.
- */
- private void handleMetaChange(File cvsdir, IResource resource, boolean deep) {
- File parent = cvsdir.getParentFile();
- clearCache(parent, IResource.DEPTH_ONE);
-
- // generate deltas for children of the parent because their state may of changed.
- // it is safe to get the parent two up from the metafile because we have already
- // confirmed that this is a meta directory.
- if(resource.getParent().exists()) {
- IContainer resourceParent = resource.getParent();
- delta.add(resourceParent);
- try {
- IResource[] children = resourceParent.members();
- for (int i = 0; i < children.length; i++) {
- if(deep) {
- children[i].accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- delta.add(resource);
- return true;
- }
- });
- } else {
- delta.add(children[i]);
- }
- }
- } catch(CoreException e) {
- // XXX what can you do in a resource listener when an exception occurs???
- }
- }
- }
-
- /**
- * Canonical handling of a resource change
- */
- private void handleDefault(IResource[] resources) {
- for (int i = 0; i < resources.length; i++) {
- // it's seems that sometimes the resources in the array are null.
- IResource resource = resources[i];
- if(resource!=null) {
- IPath location = resource.getLocation();
- // if the resource does not exist on disk, ignore it.
- if(location!=null) {
- File file = location.toFile();
- String name = file.getName();
- if(SyncFileUtil.isMetaFile(file)) {
- handleMetaChange(file.getParentFile(), resources[i].getParent(), false);
- } else if(name.equals(SyncFileUtil.IGNORE_FILE)) {
- handleMetaChange(file, resource, true);
- } else if(!name.equals("CVS")) { //$NON-NLS-1$
- delta.add(resources[i]);
- }
- }
- }
- }
- }
- }
-
- /*
- * @see ICVSSynchronizer#getFolderSync(File)
- */
- public FolderSyncInfo getFolderSync(File file) throws CVSException {
- if(file.exists() && file.isDirectory()) {
- LocalFolder folder = new LocalFolder(file);
- if(SyncFileUtil.getCVSSubdirectory(file).exists()) {
- CacheData data = (CacheData)folderSyncCache.get(file, null);
- if(data!=null) {
- return (FolderSyncInfo)data.getData();
- }
- }
- }
- return null;
- }
-
- /*
- * @see ICVSSynchronizer#getResourceSync(File)
- */
- public ResourceSyncInfo getResourceSync(File file) throws CVSException {
- File parentFile = file.getParentFile();
- if (parentFile != null) {
- LocalFolder parent = new LocalFolder(parentFile);
- if(parent.exists() && parent.isCVSFolder()) {
- CacheData data = (CacheData)resourceSyncCache.get(file, null);
- if(data!=null) {
- return (ResourceSyncInfo)data.getData();
- }
- }
- }
- return null;
- }
-
- /*
- * @see ICVSSynchronizer#setFolderSync(File, FolderSyncInfo)
- */
- public void setFolderSync(File file, FolderSyncInfo info) throws CVSException {
- SyncFileUtil.writeFolderConfig(file, info);
- folderSyncCache.put(new CacheData(file, info, CACHE_EXPIRATION_MINUTES));
-
- // the server won't add directories as sync info, therefore it must be done when
- // a directory is shared with the repository.
- setResourceSync(file, new ResourceSyncInfo(file.getName()));
-
- }
-
- /*
- * @see ICVSSynchronizer#setResourceSync(File, ResourceSyncInfo)
- */
- public void setResourceSync(File file, ResourceSyncInfo info) throws CVSException {
- Assert.isNotNull(info);
- Assert.isTrue(file.getName().equals(info.getName()));
-
- try {
- LocalFolder parent = new LocalFolder(file.getParentFile());
- if(parent.exists() && parent.isCVSFolder()) {
- SyncFileUtil.writeResourceSync(file, info);
- }
- } catch(CVSException e) {
- // XXX Bad eating of exception
- }
- resourceSyncCache.put(new CacheData(file, info, CACHE_EXPIRATION_MINUTES));
- }
-
- /*
- * @see ICVSSynchronizer#deleteFolderSync(File, IProgressMonitor)
- */
- public void deleteFolderSync(File file, IProgressMonitor monitor) throws CVSException {
- destroySyncDeep(file, monitor);
- }
-
- /*
- * @see ICVSSynchronizer#deleteResourceSync(File)
- */
- public void deleteResourceSync(File file) {
- try {
- SyncFileUtil.deleteSync(file);
- } catch(CVSException e) {
- // XXX Bad eating of exception
- }
- resourceSyncCache.remove(file);
- }
-
- /*
- * If the file no longer exists, then clear the cache, or else, refresh from local and allow the
- * resource change listener to adapt to changes.
- *
- * @see ICVSSynchronizer#reload(File, IProgressMonitor)
- */
- public void reload(File file, IProgressMonitor monitor) throws CVSException {
- reloadDeep(file, false, monitor);
- }
-
- /*
- * Simply reload to absorb changes made to the underlying file system.
- *
- * @see ICVSSynchronizer#save(File, IProgressMonitor)
- */
- public void save(File file, IProgressMonitor monitor) throws CVSException {
- reload(file, monitor);
- }
-
- /*
- * Answers if the caches are empty.
- *
- * @see ICVSSynchronizer#isEmpty()
- */
- public boolean isEmpty() {
- return resourceSyncCache.isEmpty() && folderSyncCache.isEmpty();
- }
-
- /*
- * @see ICVSSynchronizer#members(File)
- */
- public ResourceSyncInfo[] members(File folder) throws CVSException {
- // read the entries file and cache if needed
- Assert.isTrue(folder.exists());
- ResourceSyncInfo[] infos = SyncFileUtil.readEntriesFile(folder);
- if(infos==null) {
- return new ResourceSyncInfo[0];
- } else {
- return infos;
- }
- }
-
- protected void destroySyncDeep(File file, IProgressMonitor monitor) {
- if (file.isDirectory()) {
- File[] fileList = file.listFiles();
- for (int i = 0; i < fileList.length; i++) {
- destroySyncDeep(fileList[i], monitor);
- }
- folderSyncCache.remove(file);
- File metaDir = SyncFileUtil.getCVSSubdirectory(file);
- if(metaDir.exists()) {
- FileUtil.deepDelete(metaDir);
- }
- }
- deleteResourceSync(file);
- }
-
- protected void clearCache(File file, int depth) {
- clearCacheForChildren(file);
- }
-
- protected void clearCacheForChildren(File file) {
- // XXX not optimal, could instead have implement the cache as a tree
- // and be able to traverse children. This is the safest for now.
- resourceSyncCache.clear();
- folderSyncCache.clear();
- cvsIgnoreCache.clear();
- }
-
- protected void reloadDeep(File file, boolean refreshFromParent, IProgressMonitor monitor) throws CVSException {
-
- clearCache(file, IResource.DEPTH_INFINITE);
-
- if(!file.exists()) {
- // a non-existant file implies that there is no longer any meta information
- // on disk, we can safely clear the cache.
- // we can safely reload the parent if it exists.
- file = file.getParentFile();
- if(!file.exists()) {
- return;
- }
- }
-
- // the following is to refresh the workbench with the local file changes.
- if(file.equals(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile())) {
- return;
- }
-
- IResource resource;
- if(file.isDirectory() && !refreshFromParent) {
- resource = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(new Path(file.getAbsolutePath()));
- } else {
- // reload a container always, or else sync info changes won't be loaded!
- resource = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(new Path(file.getParentFile().getAbsolutePath()));
- }
- try {
- if(resource!=null) {
- resource.refreshLocal(IResource.DEPTH_INFINITE, monitor);
- }
- } catch(CoreException e) {
- throw new CVSException(IStatus.ERROR, 0, Policy.bind("FileSystemSynchronizer_Error_reloading_sync_information_5"), e); //$NON-NLS-1$
- }
- }
-
- /*
- * @see ICVSSynchronizer#isIgnored(File)
- */
- public boolean isIgnored(File file) {
- CacheData data = cvsIgnoreCache.get(file.getParentFile(), null);
- if(data==null) return false;
- String[] patterns = (String[])data.getData();
- FileNameMatcher matcher = new FileNameMatcher(patterns);
- return matcher.match(file.getName());
- }
-
- /*
- * @see ICVSSynchronizer#setIgnored(File, String)
- */
- public void setIgnored(File file, String pattern) throws CVSException {
- SyncFileUtil.addCvsIgnoreEntry(file, pattern);
- reloadDeep(file, true, new NullProgressMonitor());
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileUtil.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileUtil.java
index 41c72d2fd..67e6771a4 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileUtil.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileUtil.java
@@ -10,6 +10,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
+
public class FileUtil {
public static void deepDelete(File resource) {
@@ -21,7 +24,7 @@ public class FileUtil {
}
resource.delete();
}
-
+
public static void transfer(InputStream in, OutputStream out) throws IOException {
final byte[] BUFFER = new byte[4096];
int read = 0;
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/OrphanedFolderListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/OrphanedFolderListener.java
index d0df28564..d2fe07313 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/OrphanedFolderListener.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/OrphanedFolderListener.java
@@ -5,14 +5,15 @@ package org.eclipse.team.internal.ccvs.core.util;
* 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.resources.IResourceChangeEvent;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
/**
@@ -26,10 +27,9 @@ public class OrphanedFolderListener extends ResourceDeltaVisitor {
private void handleOrphanedSubtree(IResource resource) {
if (resource.getType() == IResource.FOLDER) {
try {
- ICVSFolder mFolder = (ICVSFolder)Session.getManagedResource(resource);
+ ICVSFolder mFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)resource);
if (mFolder.isCVSFolder() && ! mFolder.isManaged() && mFolder.getParent().isCVSFolder()) {
mFolder.unmanage();
- CVSProviderPlugin.getSynchronizer().reload(resource.getLocation().toFile(), Policy.monitorFor(null));
}
} catch (CVSException e) {
CVSProviderPlugin.log(e);
@@ -40,7 +40,7 @@ public class OrphanedFolderListener extends ResourceDeltaVisitor {
private void handleDeletedResource(IResource resource) {
if (resource.getType() == IResource.FILE) {
try {
- ICVSFile mFile = (ICVSFile)Session.getManagedResource(resource);
+ ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource);
if (mFile.isManaged()) {
ResourceSyncInfo info = mFile.getSyncInfo();
if (info.isAdded()) {
@@ -48,7 +48,6 @@ public class OrphanedFolderListener extends ResourceDeltaVisitor {
} else {
mFile.setSyncInfo(new ResourceSyncInfo(info.getName(), info.DELETED_PREFIX + info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions()));
}
- CVSProviderPlugin.getSynchronizer().reload(resource.getLocation().toFile(), Policy.monitorFor(null));
}
} catch (CVSException e) {
CVSProviderPlugin.log(e);
@@ -90,4 +89,4 @@ public class OrphanedFolderListener extends ResourceDeltaVisitor {
return IResourceChangeEvent.PRE_AUTO_BUILD;
}
-}
+} \ 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
new file mode 100644
index 000000000..f55486c27
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java
@@ -0,0 +1,356 @@
+package org.eclipse.team.internal.ccvs.core.util;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.Policy;
+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;
+
+/*
+ * 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 {
+
+ // 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$
+ public 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$
+
+ /*
+ * Reads the CVS/Entry and CVS/Permissions files for the given folder. If the folder does not have a
+ * CVS subdirectory then <code>null</code> is returned.
+ */
+ public static ResourceSyncInfo[] readEntriesFile(ICVSFolder parent) throws CVSException {
+
+ ICVSFolder cvsSubDir = getCVSSubdirectory(parent);
+
+ if(!cvsSubDir.exists()) {
+ return null;
+ }
+
+ // The Eclipse CVS client does not write to the Entries.log file. Thus
+ // merging is required for external command line client compatibility.
+ mergeEntriesLogFiles(parent);
+
+ Map infos = new TreeMap();
+ String[] entries = getContents(cvsSubDir.getFile(ENTRIES));
+ String[] permissions = getContents(cvsSubDir.getFile(PERMISSIONS));
+
+ if (entries == null) {
+ return null;
+ }
+
+ 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);
+ }
+ }
+
+ if (permissions != null) {
+ for (int i = 0; i < permissions.length; i++) {
+ if ("".equals(permissions[i])) { //$NON-NLS-1$
+ continue;
+ }
+ String line = permissions[i];
+ EmptyTokenizer tokenizer = new EmptyTokenizer(line,"/"); //$NON-NLS-1$
+ String name = tokenizer.nextToken();
+ String perms = tokenizer.nextToken();
+ ResourceSyncInfo info = (ResourceSyncInfo) infos.get(name);
+ // Running the command line tool will update the Entries file and thus cause
+ // the Permissions to be out-of-sync.
+ if (info != null) {
+ infos.put(name, new ResourceSyncInfo(info.getEntryLine(true), perms, null));
+ }
+ }
+ }
+ return (ResourceSyncInfo[])infos.values().toArray(new ResourceSyncInfo[infos.size()]);
+ }
+
+ public static void writeResourceSync(ICVSResource file, ResourceSyncInfo info) throws CVSException {
+ writeEntriesLog(file, info, ADD_TAG);
+ }
+
+ /*
+ * Delete this file from Entries/Permissions file
+ */
+ public static void deleteSync(ICVSResource file) throws CVSException {
+ ICVSFolder parent = file.getParent();
+ if(parent!=null && parent.exists()) {
+ if(file.isFolder()) {
+ writeEntriesLog(file, new ResourceSyncInfo(file.getName()), REMOVE_TAG);
+ } else {
+ writeEntriesLog(file, new ResourceSyncInfo(file.getName(), "0", "", "", null, ""), REMOVE_TAG); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+ }
+ }
+
+ public static void deleteCVSSubDirectory(IContainer folder) throws CoreException {
+ IContainer cvsSubDir = folder.getFolder(new Path("CVS"));
+ cvsSubDir.delete(false /*force*/, null);
+ }
+
+ /**
+ * Read folder sync info, returns <code>null</code> if the folder does not have
+ * a CVS subdirectory.
+ */
+ public static FolderSyncInfo readFolderConfig(ICVSFolder folder) throws CVSException {
+
+ ICVSFolder cvsSubDir = getCVSSubdirectory(folder);
+
+ if(!cvsSubDir.exists()) {
+ return null;
+ }
+
+ String staticDir = readLine(cvsSubDir.getFile(STATIC));
+ String repo = readLine(cvsSubDir.getFile(REPOSITORY));
+ String root = readLine(cvsSubDir.getFile(ROOT));
+ String tag = readLine(cvsSubDir.getFile(TAG));
+
+ boolean isStatic = false;
+ if (staticDir != null)
+ isStatic = true;
+
+ if(root == null || repo == null) {
+ return null;
+ }
+
+ CVSTag cvsTag = null;
+ if(tag != null) {
+ cvsTag = new CVSEntryLineTag(tag);
+ }
+
+ return new FolderSyncInfo(repo, root, cvsTag, isStatic);
+ }
+
+ public static void writeFolderConfig(ICVSFolder folder, FolderSyncInfo info) throws CVSException {
+
+ ICVSFolder cvsSubDir = getCVSSubdirectory(folder);
+
+ if(!cvsSubDir.exists()) {
+ cvsSubDir.mkdir();
+ }
+
+ writeLines(cvsSubDir.getFile(ROOT), new String[] {info.getRoot()});
+ ICVSFile tagFile = cvsSubDir.getFile(TAG);
+ if (info.getTag() != null) {
+ writeLines(tagFile, new String[] {info.getTag().toEntryLineFormat(false)});
+ } else {
+ if(tagFile.exists()) {
+ tagFile.delete();
+ }
+ }
+ ICVSFile 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();
+ }
+ }
+ writeLines(cvsSubDir.getFile(REPOSITORY), new String[] {info.getRepository()});
+ }
+
+ protected static String readLine(ICVSFile file) throws CVSException {
+ String[] contents = getContents(file);
+ if (contents == null) {
+ return null;
+ } else if (contents.length == 0) {
+ return ""; //$NON-NLS-1$
+ } else {
+ return contents[0];
+ }
+ }
+
+ protected static String[] getContents(ICVSFile file) throws CVSException {
+ // If the property does not exsist we return null
+ // this is specified
+ if (file.exists()) {
+ return readLines(file);
+ } else {
+ return null;
+ }
+ }
+
+ public static ICVSFolder getCVSSubdirectory(ICVSFolder folder) throws CVSException {
+ return folder.getFolder("CVS"); //$NON-NLS-1$
+ }
+
+ public static void mergeEntriesLogFiles(ICVSFolder root) throws CVSException {
+
+ ICVSFile logEntriesFile = getCVSSubdirectory(root).getFile(ENTRIES_LOG);
+ ICVSFile entriesFile = getCVSSubdirectory(root).getFile(ENTRIES);
+
+ if (!logEntriesFile.exists()) {
+ // If we do not have an Entries.Log file we are done because there is nothing
+ // to merge (this includes the case where we do not have CVSDirectory)
+ return;
+ }
+
+ // The map contains the name of the resource as the key and the entryLine as the
+ // value
+ // "new ResourceSyncInfo(entryLine,null)).getName()" ist used to parse the name
+ // out of the entryLine and shoud maybe be replaced sometime
+
+ Map mergedEntries = new HashMap();
+
+ if(entriesFile.exists()) {
+ String[] entries = readLines(entriesFile);
+ for (int i = 0; i < entries.length; i++) {
+ if (!FOLDER_TAG.equals(entries[i])) {
+ mergedEntries.put((new ResourceSyncInfo(entries[i],null, null)).getName(),entries[i]);
+ }
+ }
+ }
+
+ String[] logEntries = readLines(logEntriesFile);
+ for (int i = 0; i < logEntries.length; i++) {
+
+ if (logEntries[i].startsWith(ADD_TAG)) {
+ String newEntry = logEntries[i].substring(ADD_TAG.length());
+ mergedEntries.put((new ResourceSyncInfo(newEntry,null, null)).getName(),newEntry);
+ } else if (logEntries[i].startsWith(REMOVE_TAG)) {
+ String newEntry = logEntries[i].substring(REMOVE_TAG.length());
+ mergedEntries.remove((new ResourceSyncInfo(newEntry,null, null)).getName());
+ }
+ }
+
+ writeLines(entriesFile,(String[]) mergedEntries.values().toArray(new String[mergedEntries.size()]));
+ logEntriesFile.delete();
+ }
+
+ public static String[] readLines(ICVSFile file) throws CVSException {
+ BufferedReader fileReader;
+ List fileContentStore = new ArrayList();
+ String line;
+
+ try {
+ fileReader = new BufferedReader(new InputStreamReader(file.getInputStream()));
+ while ((line = fileReader.readLine()) != null) {
+ fileContentStore.add(line);
+ }
+ fileReader.close();
+ } catch (IOException e) {
+ throw CVSException.wrapException(e);
+ }
+
+ return (String[]) fileContentStore.toArray(new String[fileContentStore.size()]);
+ }
+
+ /*
+ * To be compatible with other CVS clients meta files must be written with lines
+ * terminating with a carriage return only.
+ */
+ private static void writeLines(ICVSFile file, String[] content) throws CVSException {
+
+ BufferedWriter fileWriter;
+
+ try {
+ fileWriter = new BufferedWriter(new OutputStreamWriter(file.getOutputStream()));
+ for (int i = 0; i<content.length; i++) {
+ fileWriter.write(content[i] + "\n"); //$NON-NLS-1$
+ }
+ fileWriter.close();
+ } catch (IOException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
+ public static void addCvsIgnoreEntry(ICVSResource resource, String pattern) throws CVSException {
+ OutputStream out = null;
+ try {
+ ICVSFile cvsignore = resource.getParent().getFile(IGNORE_FILE);
+ String line = pattern == null ? resource.getName() : pattern;
+ line += "\n"; //$NON-NLS-1$
+ out = cvsignore.getAppendingOutputStream();
+ out.write(line.getBytes());
+ } catch(IOException e) {
+ throw new CVSException(IStatus.ERROR, 0, Policy.bind("SyncFileUtil_Error_writing_to_.cvsignore_61"), e); //$NON-NLS-1$
+ } finally {
+ try {
+ if(out!=null) {
+ out.close();
+ }
+ } catch(IOException e) {
+ throw new CVSException(IStatus.ERROR, 0, Policy.bind("SyncFileUtil_Cannot_close_.cvsignore_62"), e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /*
+ * Append to Entries.log file
+ */
+ private static void writeEntriesLog(ICVSResource file, ResourceSyncInfo info, String prefix) throws CVSException {
+ OutputStream out = null;
+ try {
+ ICVSFile entriesLogFile = getCVSSubdirectory(file.getParent()).getFile(ENTRIES_LOG);
+ String line = prefix + info.getEntryLine(true) +"\n"; //$NON-NLS-1$
+ out = entriesLogFile.getAppendingOutputStream();
+ out.write(line.getBytes());
+ } catch(IOException e) {
+ throw new CVSException(IStatus.ERROR, 0, Policy.bind("SyncFileUtil_Error_writing_to_Entries.log_48"), e); //$NON-NLS-1$
+ } finally {
+ try {
+ if(out!=null) {
+ out.close();
+ }
+ } catch(IOException e) {
+ throw new CVSException(IStatus.ERROR, 0, Policy.bind("SyncFileUtil_Cannot_close_Entries.log_49"), e); //$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/Util.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
index 0be5cea3f..6f297ca58 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
@@ -9,242 +9,18 @@ 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.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
import org.eclipse.team.internal.ccvs.core.Policy;
/**
* Unsorted static helper-methods
*/
public class Util {
-
- private static final String AT = "@"; //$NON-NLS-1$
- private static final String COLON = ":"; //$NON-NLS-1$
-
-
- // private static final String newLine = System.getProperty("line.separator");
-
- /**
- * Looks for search in original. If it findes search it puts excange
- * in the result. Otherwise it copies original in the result.
- */
- public static byte[] replace(final byte[] original,final byte[] search,final byte[] excange) {
-
- final int tmpMulti;
- final byte[] tmpResult;
- final byte[] result;
-
- int size=0;
- boolean replaced;
-
- // create an array, that can hold the result for sure
- tmpMulti = (int) Math.ceil((double)excange.length/(double)search.length);
-
- Assert.isTrue((long)tmpMulti * (long)original.length < Integer.MAX_VALUE);
- tmpResult = new byte[tmpMulti * original.length];
-
- int i=0;
- while (i < original.length) {
- replaced = false;
- for (int j = 0; j < search.length; j++) {
-
- if ((i+j >= original.length) || (original[i+j] != search[j])) {
- // Send another letter to the result
- // array
- break;
- }
-
- if (j == search.length-1) {
- // We have found the search and going to
- // put excange intead of it
- System.arraycopy(excange,0,tmpResult,size,excange.length);
- size += excange.length;
- i += search.length;
- replaced = true;
- }
- }
-
- if (!replaced) {
- tmpResult[size] = original[i];
- i++;
- size++;
- }
- }
-
- result = new byte[size];
- System.arraycopy(tmpResult,0,result,0,size);
- return result;
- }
-
- /**
- * @see Util#getOptions(String[],String,boolean)
- */
- public static String getOption(String[] options, String key, boolean deleteOption) {
-
- String[] result;
-
- result = getOptions(options,key,deleteOption);
-
- if (result.length == 0) {
- return null;
- } else {
- return result[0];
- }
- }
-
- /**
- * Get an option out of an array of options. It assumes, that
- * the next field to the key contains the parameter to the
- * option.
- *
- * @param options not null
- * @param key not null
- * @param deleteOption nulls both the option-tag and the information
- * @return String[0] if the option could not be found
- */
- public static String[] getOptions(String[] options, String key, boolean deleteOption) {
-
- String[] tmpResult;
- String[] result;
- int size = 0;
-
- Assert.isNotNull(options);
- Assert.isNotNull(key);
-
- tmpResult = new String[options.length];
-
- for (int i=0; i<options.length; i++) {
- if (key.equals(options[i]) && i<options.length-1) {
- tmpResult[size++] = options[i+1];
-
- // This should be done in another way maybe we should
- // have an options Object or give the array modified
- // back.
- // Maybe we are going to change that.
- if (deleteOption) {
- options[i] = null;
- options[i+1] = null;
- }
- }
- }
-
- result = new String[size];
- System.arraycopy(tmpResult,0,result,0,size);
- return result;
- }
-
- /**
- * Checks wether the Array options contains the String
- * key.
- * @param options not null
- * @param key not null
- */
- public static boolean isOption(String[] options, String key) {
-
- Assert.isNotNull(options);
- Assert.isNotNull(key);
-
- for (int i=0; i<options.length; i++) {
- if (key.equals(options[i])) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Remove or get the password out of a repoString.
- */
- // FIXME: This is only used for tests ... move it
- private static String passwordHandle(String repoName, boolean remove) {
-
- int atPlace = -1;
- int colonPlace = -1;
- int colonCount = 0;
- String currentChar;
-
- Assert.isTrue(repoName.indexOf(AT) != -1);
- Assert.isTrue(repoName.indexOf(COLON) != -1);
-
- for (int i=0; i<repoName.length(); i++) {
-
- currentChar = repoName.substring(i,i+1);
-
- if (currentChar.equals(COLON)) {
- colonCount++;
-
- if (colonCount == 3) {
- colonPlace = i;
- }
- }
-
- if (currentChar.equals(AT)) {
- if (colonPlace == -1) {
-
- // If the @ comes before the third colon, then
- // we do not have a password and return with the
- // same string
- return repoName;
- } else {
- atPlace = i;
- }
-
- }
- }
-
- if (atPlace == -1) {
- return repoName;
- }
-
- if (remove) {
- return repoName.substring(0,colonPlace) + repoName.substring(atPlace);
- } else {
- return repoName.substring(colonPlace + 1, atPlace);
- }
- }
-
- /**
- * returns ":pserver:nkrambro@fiji:/home/nkrambro/repo"
- * when you insert ":pserver:nkrambro:password@fiji:/home/nkrambro/repo"
- */
- // FIXME: This is only used for tests ... move it
- public static String removePassword(String root) {
- return passwordHandle(root,true);
- }
-
- /**
- *
- * returns "password"
- * when you insert ":pserver:nkrambro:password@fiji:/home/nkrambro/repo"
- */
- // FIXME: This is only used for tests ... move it
- public static String getPassword(String root) {
- return passwordHandle(root,false);
- }
-
- // FIXME: This is only used for tests ... move it
- public static String mergeRoot(String rootWithoutPwd, String password) {
-
- StringBuffer result = new StringBuffer();
-
- Assert.isTrue(rootWithoutPwd.indexOf(AT) != -1);
- Assert.isTrue(rootWithoutPwd.indexOf(COLON) != -1);
-
- if (password == null) {
- return rootWithoutPwd;
- }
-
- result.append(rootWithoutPwd.substring(0,rootWithoutPwd.indexOf(AT)));
- result.append(COLON);
- result.append(password);
- result.append(rootWithoutPwd.substring(rootWithoutPwd.indexOf(AT)));
-
- return result.toString();
- }
-
/**
* Get the extention of the path of resource
* relative to the path of root
@@ -283,12 +59,11 @@ public class Util {
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
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
index c593e864a..a13bfab1d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
@@ -22,18 +22,15 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSFile;
import org.eclipse.team.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.CVSLocalSyncElement;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
/**
@@ -304,23 +301,16 @@ public class CVSCompareEditorInput extends CompareEditorInput {
} else if (left instanceof ResourceNode) {
IResource resource = ((ResourceNode)left).getResource();
try {
- ICVSResource element = null;
- if(resource.getType()==IResource.FILE) {
- element = new LocalFile(resource.getLocation().toFile());
- if (((LocalFile)element).isDirty()) {
- return NODE_NOT_EQUAL;
- }
- } else {
- element = new LocalFolder(resource.getLocation().toFile());
+ ICVSResource element = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ if (resource.getType() == IResource.FILE) {
+ if (((ICVSFile) element).isDirty()) return NODE_NOT_EQUAL;
}
if(cvsProvider==null) {
return NODE_UNKNOWN;
}
- leftEdition = cvsProvider.getRemoteResource(resource);
+ leftEdition = CVSWorkspaceRoot.getRemoteResourceFor(resource);
} catch(CVSException e) {
return NODE_UNKNOWN;
- } catch(TeamException e) {
- return NODE_UNKNOWN;
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java
index bb2b2c0ea..a5a3c6275 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareRevisionsInput.java
@@ -57,6 +57,7 @@ import org.eclipse.team.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.ccvs.core.ILogEntry;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
public class CVSCompareRevisionsInput extends CompareEditorInput {
@@ -86,7 +87,7 @@ public class CVSCompareRevisionsInput extends CompareEditorInput {
if (revisionName != null) {
IResource resource = CVSCompareRevisionsInput.this.resource;
try {
- ICVSRemoteFile currentEdition = (ICVSRemoteFile)provider.getRemoteResource(resource);
+ ICVSRemoteFile currentEdition = (ICVSRemoteFile) CVSWorkspaceRoot.getRemoteResourceFor(resource);
if (currentEdition != null && currentEdition.getRevision().equals(revisionName)) {
return "*" + revisionName;
} else {
@@ -392,7 +393,7 @@ public class CVSCompareRevisionsInput extends CompareEditorInput {
}
private void updateCurrentEdition() {
try {
- this.currentEdition = ((ICVSRemoteFile)provider.getRemoteResource(resource));
+ this.currentEdition = ((ICVSRemoteFile) CVSWorkspaceRoot.getRemoteResourceFor(resource));
} catch (TeamException e) {
handle(e);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java
index 9dc4f12f3..6f64d8043 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java
@@ -10,6 +10,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.runtime.CoreException;
@@ -22,16 +24,14 @@ import org.eclipse.swt.graphics.ImageData;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
+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.ResourceSyncInfo;
import org.eclipse.team.ui.ISharedImages;
@@ -98,12 +98,7 @@ public class CVSDecorationRunnable implements Runnable {
continue;
}
- ICVSResource cvsResource;
- if (resource.getType() == IResource.FILE) {
- cvsResource = new LocalFile(resource.getLocation().toFile());
- } else {
- cvsResource = new LocalFolder(resource.getLocation().toFile());
- }
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
if (cvsResource.isIgnored()) continue;
// determine a if resource has outgoing changes (e.g. is dirty).
@@ -154,7 +149,7 @@ public class CVSDecorationRunnable implements Runnable {
switch (type) {
case IResource.FOLDER :
case IResource.PROJECT :
- ICVSFolder folder = new LocalFolder(resourceLocation.toFile());
+ ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor((IContainer) resource);
FolderSyncInfo folderInfo = folder.getFolderSyncInfo();
if (folderInfo != null) {
CVSTag tag = folderInfo.getTag();
@@ -171,7 +166,7 @@ public class CVSDecorationRunnable implements Runnable {
break;
case IResource.FILE :
format = store.getString(ICVSUIConstants.PREF_FILETEXT_DECORATION);
- ICVSFile file = new LocalFile(resourceLocation.toFile());
+ ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile) resource);
ResourceSyncInfo fileInfo = file.getSyncInfo();
if (fileInfo != null) {
CVSTag tag = fileInfo.getTag();
@@ -208,7 +203,7 @@ public class CVSDecorationRunnable implements Runnable {
try {
IPath location = resource.getLocation();
if(location!=null) {
- ICVSFile cvsFile = new LocalFile(location.toFile());
+ ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile) resource);
ResourceSyncInfo info = cvsFile.getSyncInfo();
// show merged icon if file has been merged but has not been edited (e.g. on commit it will be ignored)
if(info!=null && info.isNeedsMerge(cvsFile.getTimeStamp())) {
@@ -257,12 +252,7 @@ public class CVSDecorationRunnable implements Runnable {
return false;
}
- ICVSResource cvsResource;
- if (resource.getType() == IResource.FILE) {
- cvsResource = new LocalFile(resource.getLocation().toFile());
- } else {
- cvsResource = new LocalFolder(resource.getLocation().toFile());
- }
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
try {
if (!cvsResource.isManaged()) {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java
index 0e672e95f..faf85c07b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java
@@ -6,20 +6,24 @@ package org.eclipse.team.internal.ccvs.ui;
*/
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Hashtable;
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.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.LabelProvider;
@@ -33,6 +37,7 @@ import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.internal.ccvs.core.CVSProvider;
import org.eclipse.team.internal.ccvs.core.util.Assert;
+import org.eclipse.team.internal.ccvs.core.util.ResourceDeltaVisitor;
/**
* Classes registered with the workbench decoration extension point. The <code>CVSDecorationRunnable</code> class
@@ -53,8 +58,18 @@ public class CVSDecorator extends LabelProvider implements ILabelDecorator, IRes
private static CVSDecorator theDecorator = null;
- // Resources that need an icon and text computed for display to the user, no order
- private Set decoratorNeedsUpdating = Collections.synchronizedSet(new HashSet());
+ // Resources that need an icon and text computed for display to the user, sorted by canonical path
+ private SortedSet decoratorNeedsUpdating = Collections.synchronizedSortedSet(
+ new TreeSet(new Comparator() {
+ public boolean equals(Object a, Object b) {
+ return a == b || a.equals(b);
+ }
+ public int compare(Object a, Object b) {
+ IPath pathA = ((IResource) a).getFullPath();
+ IPath pathB = ((IResource) b).getFullPath();
+ return pathA.toString().compareTo(pathB.toString());
+ }
+ }));
// When decorations are computed they are added to this cache via decorated() method
private Map cache = Collections.synchronizedMap(new HashMap());
@@ -66,6 +81,25 @@ public class CVSDecorator extends LabelProvider implements ILabelDecorator, IRes
private Hashtable imageCache = new Hashtable();
+ private ChangeListener changeListener;
+
+ private class ChangeListener extends ResourceDeltaVisitor {
+ List changedResources = new ArrayList();
+ protected void handleAdded(IResource[] resources) {
+ }
+ protected void handleRemoved(IResource[] resources) {
+ }
+ protected void handleChanged(IResource[] resources) {
+ changedResources.addAll(Arrays.asList(resources));
+ }
+ protected void finished() {
+ resourceStateChanged((IResource[])changedResources.toArray(new IResource[changedResources.size()]));
+ }
+ protected int getEventMask() {
+ return IResourceChangeEvent.PRE_AUTO_BUILD;
+ }
+ }
+
public CVSDecorator() {
// The decorator is a singleton, there should never be more than one instance.
// temporary until the UI component properly calls dispose when the workbench shutsdown
@@ -76,6 +110,8 @@ public class CVSDecorator extends LabelProvider implements ILabelDecorator, IRes
decoratorUpdateThread = new Thread(new CVSDecorationRunnable(this), "CVS"); //$NON-NLS-1$
decoratorUpdateThread.start();
TeamPlugin.getManager().addResourceStateChangeListener(this);
+ changeListener = new ChangeListener();
+ changeListener.register();
}
public String decorateText(String text, Object o) {
@@ -155,9 +191,8 @@ public class CVSDecorator extends LabelProvider implements ILabelDecorator, IRes
// The decorator was awakened by the plug-in as it was shutting down.
return null;
}
- Iterator iterator = decoratorNeedsUpdating.iterator();
- IResource resource = (IResource) iterator.next();
- iterator.remove();
+ IResource resource = (IResource) decoratorNeedsUpdating.first();
+ decoratorNeedsUpdating.remove(resource);
//System.out.println("++ Next: " + resource.getFullPath() + " remaining in cache: " + cache.size());
@@ -348,10 +383,15 @@ public class CVSDecorator extends LabelProvider implements ILabelDecorator, IRes
*/
public void dispose() {
super.dispose();
+
+ // terminate decoration thread
shutdown();
+ // unregister change listeners
+ changeListener.register();
TeamPlugin.getManager().removeResourceStateChangeListener(this);
+ // dispose of images created as overlays
decoratorNeedsUpdating.clear();
cache.clear();
Iterator it = imageCache.values().iterator();
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java
index c08f9677b..300dc96d9 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java
@@ -14,9 +14,9 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSFile;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.ui.dialogs.PropertyPage;
@@ -36,7 +36,7 @@ public class CVSFilePropertiesPage extends PropertyPage {
composite.setLayout(layout);
try {
- LocalFile cvsResource = new LocalFile(file.getLocation().toFile());
+ ICVSFile cvsResource = CVSWorkspaceRoot.getCVSFileFor(file);
if (!cvsResource.isManaged()) {
if (cvsResource.isIgnored()) {
createLabel(composite, Policy.bind("CVSFilePropertiesPage.ignored"));
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java
index 2c935d78e..5f9cdda1d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java
@@ -23,7 +23,6 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
@@ -35,6 +34,7 @@ import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.ccvs.core.IUserInfo;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.ui.dialogs.PropertyPage;
public class CVSPropertiesPage extends PropertyPage {
@@ -166,15 +166,17 @@ public class CVSPropertiesPage extends PropertyPage {
provider = (CVSTeamProvider)TeamPlugin.getManager().getProvider(project);
if (provider == null) return;
+ CVSWorkspaceRoot cvsRoot = provider.getCVSWorkspaceRoot();
String[] methods = CVSProviderPlugin.getProvider().getSupportedConnectionMethods();
for (int i = 0; i < methods.length; i++) {
methodType.add(methods[i]);
}
try {
- String method = provider.getConnectionMethod(project);
+ ICVSRepositoryLocation location = cvsRoot.getRemoteLocation();
+ String method = location.getMethod().getName();
methodType.select(methodType.indexOf(method));
- info = provider.getUserInfo(project);
+ info = location.getUserInfo(true);
userText.setText(info.getUsername());
} catch (TeamException e) {
handle(e);
@@ -182,7 +184,7 @@ public class CVSPropertiesPage extends PropertyPage {
passwordText.setText("*********");
try {
- ICVSRemoteResource resource = provider.getRemoteResource(project);
+ ICVSRemoteResource resource = cvsRoot.getRemoteResourceFor(project);
ICVSRepositoryLocation location = resource.getRepository();
hostLabel.setText(location.getHost());
int port = location.getPort();
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSResourceNode.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSResourceNode.java
index 0e7358b5e..9d5cd8640 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSResourceNode.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSResourceNode.java
@@ -13,10 +13,10 @@ import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
/**
* This class is a wrapper for a CVSResource. We use it instead of the standard
@@ -36,7 +36,8 @@ public class CVSResourceNode extends ResourceNode {
IResource resource = getResource();
if (resource instanceof IContainer) {
try {
- ICVSFile[] files = new LocalFolder(resource.getLocation().toFile()).getFiles();
+ ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer) resource);
+ ICVSFile[] files = cvsFolder.getFiles();
for (int i= 0; i < files.length; i++) {
IResource child = getFile((IContainer)resource, files[i].getName());
if (child.exists()) {
@@ -46,7 +47,7 @@ public class CVSResourceNode extends ResourceNode {
}
}
}
- ICVSFolder[] folders = new LocalFolder(resource.getLocation().toFile()).getFolders();
+ ICVSFolder[] folders = cvsFolder.getFolders();
for (int i= 0; i < folders.length; i++) {
IResource child = getFolder((IContainer)resource, folders[i].getName());
if (child.exists()) {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
index ab57f7f73..5a90bf177 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
@@ -20,14 +20,15 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.ui.model.CVSAdapterFactory;
import org.eclipse.team.ui.TeamUIPlugin;
import org.eclipse.ui.IWorkbenchPage;
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java
index 0a3de1568..8826530e1 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryView.java
@@ -64,6 +64,7 @@ import org.eclipse.team.ccvs.core.ILogEntry;
import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.actions.OpenLogEntryAction;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISelectionListener;
@@ -117,7 +118,7 @@ public class HistoryView extends ViewPart implements ISelectionListener {
String revision = entry.getRevision();
if (file == null) return revision;
try {
- ICVSRemoteFile currentEdition = (ICVSRemoteFile)provider.getRemoteResource(file);
+ ICVSRemoteFile currentEdition = (ICVSRemoteFile) CVSWorkspaceRoot.getRemoteResourceFor(file);
if (currentEdition != null && currentEdition.getRevision().equals(revision)) {
return "*" + revision;
}
@@ -631,7 +632,7 @@ public class HistoryView extends ViewPart implements ISelectionListener {
if (teamProvider != null && teamProvider instanceof CVSTeamProvider) {
this.provider = (CVSTeamProvider)teamProvider;
try {
- tableViewer.setInput(provider.getRemoteResource(file));
+ tableViewer.setInput(CVSWorkspaceRoot.getRemoteResourceFor(file));
} catch (TeamException e) {
ErrorDialog.openError(getViewSite().getShell(), null, null, e.getStatus());
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java
index e3a506c12..8dd81df8b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java
@@ -13,9 +13,11 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.ui.dialogs.PropertyPage;
/**
@@ -40,14 +42,20 @@ public class ResourcePropertiesPage extends PropertyPage {
try {
IResource resource = getSelectedElement();
if (resource != null) {
- CVSTeamProvider provider = (CVSTeamProvider)TeamPlugin.getManager().getProvider(resource.getProject());;
- if (!provider.isManaged(resource)) {
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ if (!cvsResource.isManaged()) {
createPair(composite, Policy.bind("ResourcePropertiesPage.status"), Policy.bind("ResourcePropertiesPage.notManaged"));
} else {
- createPair(composite, Policy.bind("ResourcePropertiesPage.status"), provider.hasRemote(resource) ? Policy.bind("ResourcePropertiesPage.versioned") : Policy.bind("ResourcePropertiesPage.notVersioned"));
- createPair(composite, Policy.bind("ResourcePropertiesPage.state"), provider.isCheckedOut(resource) ? Policy.bind("ResourcePropertiesPage.checkedOut") : Policy.bind("ResourcePropertiesPage.checkedIn"));
-
- //createPair(composite, Policy.bind("ResourcePropertiesPage.baseRevision"), common != null ? common.getVersionName() : Policy.bind("ResourcePropertiesPage.none"));
+ boolean hasRemote = false;
+ if(cvsResource.isFolder()) {
+ hasRemote = ((ICVSFolder)cvsResource).isCVSFolder();
+ } else {
+ ResourceSyncInfo info = cvsResource.getSyncInfo();
+ if(info!=null && !info.isAdded()) {
+ hasRemote = true;
+ }
+ }
+ createPair(composite, Policy.bind("ResourcePropertiesPage.status"), hasRemote ? Policy.bind("ResourcePropertiesPage.versioned") : Policy.bind("ResourcePropertiesPage.notVersioned"));
}
}
} catch (TeamException e) {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagSelectionDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagSelectionDialog.java
index 3647c3a15..ca43adad5 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagSelectionDialog.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagSelectionDialog.java
@@ -7,26 +7,15 @@ package org.eclipse.team.internal.ccvs.ui;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -38,24 +27,18 @@ import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
import org.eclipse.team.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.merge.ProjectElement;
import org.eclipse.team.internal.ccvs.ui.merge.TagElement;
-import org.eclipse.team.internal.ccvs.ui.model.BranchTag;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.team.internal.ccvs.ui.Policy;
/**
* Dialog to prompt the user to choose a tag for a selected resource
@@ -208,7 +191,7 @@ public class TagSelectionDialog extends Dialog {
// initialize the table contents
try {
CVSTeamProvider provider = (CVSTeamProvider)TeamPlugin.getManager().getProvider(resource);
- tagTree.setInput(new ProjectElement((ICVSRemoteFolder)provider.getRemoteResource(resource.getProject()), getShell()));
+ tagTree.setInput(new ProjectElement((ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(resource.getProject()), getShell()));
} catch (TeamException e) {
// To do: error dialog
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java
index 6d97730e6..c60407907 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java
@@ -16,10 +16,13 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.ITeamManager;
import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.ui.actions.TeamAction;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
@@ -66,8 +69,13 @@ public class AddAction extends TeamAction {
ITeamManager manager = TeamPlugin.getManager();
for (int i = 0; i < resources.length; i++) {
ITeamProvider provider = manager.getProvider(resources[i].getProject());
- if (provider == null) return false;
- if (((CVSTeamProvider)provider).isManaged(resources[i])) return false;
+ if(provider == null) return false;
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resources[i]);
+ if(cvsResource.isFolder()) {
+ if(((ICVSFolder)cvsResource).isCVSFolder()) return false;
+ } else {
+ if (cvsResource.isManaged()) return false;
+ }
}
return true;
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java
index ac429c083..2f08cec9a 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java
@@ -9,11 +9,12 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.ITeamManager;
import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.wizards.BranchWizard;
import org.eclipse.team.ui.actions.TeamAction;
@@ -44,9 +45,11 @@ public class BranchAction extends TeamAction {
if (resources.length == 0) return false;
ITeamManager manager = TeamPlugin.getManager();
for (int i = 0; i < resources.length; i++) {
- ITeamProvider provider = manager.getProvider(resources[i].getProject());
+ IResource resource = resources[i];
+ ITeamProvider provider = manager.getProvider(resource.getProject());
if (provider == null) return false;
- if (!((CVSTeamProvider)provider).isManaged(resources[i])) return false;
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ if (resource.getType()!=IResource.PROJECT&&!cvsResource.isManaged()) return false;
}
return true;
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java
index 9dc6a0b36..855420295 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java
@@ -10,11 +10,12 @@ import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
-import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.ITeamManager;
import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.RepositoryManager;
@@ -53,11 +54,11 @@ public class CommitAction extends TeamAction {
if (resources.length == 0) return false;
ITeamManager manager = TeamPlugin.getManager();
for (int i = 0; i < resources.length; i++) {
- ITeamProvider provider = manager.getProvider(resources[i].getProject());
+ IResource resource = resources[i];
+ ITeamProvider provider = manager.getProvider(resource.getProject());
if (provider == null) return false;
- CVSTeamProvider cvsProvider = (CVSTeamProvider)provider;
- if (!cvsProvider.isManaged(resources[i])) return false;
- if (!cvsProvider.isCheckedOut(resources[i])) return false;
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ if (resource.getType()!=IResource.PROJECT&&!cvsResource.isManaged()) return false;
}
return true;
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java
index c1d7aa1c2..2c77c24a1 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java
@@ -16,14 +16,13 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
+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.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.ui.CVSCompareEditorInput;
@@ -50,17 +49,10 @@ public class CompareWithRemoteAction extends TeamAction {
CVSTeamProvider provider = (CVSTeamProvider)TeamPlugin.getManager().getProvider(resources[0].getProject());
- LocalResource cvsResource = null;
- if (resources[0].getType()==IResource.FILE) {
- cvsResource = new LocalFile(resource.getLocation().toFile());
- } else {
- cvsResource = new LocalFolder(resource.getLocation().toFile());
- }
-
-
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
CVSTag tag = null;
if (cvsResource.isFolder()) {
- FolderSyncInfo folderInfo = ((LocalFolder)cvsResource).getFolderSyncInfo();
+ FolderSyncInfo folderInfo = ((ICVSFolder)cvsResource).getFolderSyncInfo();
if (folderInfo!=null) {
tag = folderInfo.getTag();
}
@@ -79,7 +71,7 @@ public class CompareWithRemoteAction extends TeamAction {
}
}
- ICVSRemoteResource remoteResource = (ICVSRemoteResource)provider.getRemoteTree(resource, tag, new NullProgressMonitor());
+ ICVSRemoteResource remoteResource = CVSWorkspaceRoot.getRemoteTree(resource, tag, new NullProgressMonitor());
// Just to be safe...
if (remoteResource == null) {
MessageDialog.openInformation(getShell(), Policy.bind("CompareWithRemoteAction.noRemote"), Policy.bind("CompareWithRemoteAction.noRemoteLong"));
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java
index 1b997b583..dc3386400 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRevisionAction.java
@@ -6,28 +6,23 @@ package org.eclipse.team.internal.ccvs.ui.actions;
*/
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
import org.eclipse.compare.CompareUI;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
import org.eclipse.team.ccvs.core.ICVSRemoteFile;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.ccvs.core.ILogEntry;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.CVSCompareRevisionsInput;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.HistoryView;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.ui.actions.TeamAction;
@@ -42,7 +37,7 @@ public class CompareWithRevisionAction extends TeamAction {
IFile file = (IFile)resources[0];
CVSTeamProvider provider = (CVSTeamProvider)TeamPlugin.getManager().getProvider(file.getProject());
try {
- return (ICVSRemoteFile)provider.getRemoteResource(file);
+ return (ICVSRemoteFile)CVSWorkspaceRoot.getRemoteResourceFor(file);
} catch (TeamException e) {
handle(e, null, null);
return null;
@@ -76,7 +71,7 @@ public class CompareWithRevisionAction extends TeamAction {
protected boolean isEnabled() throws TeamException {
IResource[] resources = getSelectedResources();
if (resources.length != 1) return false;
- CVSTeamProvider provider = (CVSTeamProvider)TeamPlugin.getManager().getProvider(resources[0]);
- return provider.isManaged(resources[0]);
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resources[0]);
+ return cvsResource.isManaged();
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java
index 3a5fbb5bb..d22031ef3 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java
@@ -6,21 +6,19 @@ package org.eclipse.team.internal.ccvs.ui.actions;
*/
import java.lang.reflect.InvocationTargetException;
+
import org.eclipse.compare.CompareUI;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.CVSCompareEditorInput;
import org.eclipse.team.internal.ccvs.ui.CVSResourceNode;
import org.eclipse.team.internal.ccvs.ui.Policy;
@@ -46,13 +44,6 @@ public class CompareWithTagAction extends TeamAction {
IResource resource = resources[0];
CVSTeamProvider provider = (CVSTeamProvider)TeamPlugin.getManager().getProvider(resource.getProject());
- LocalResource cvsResource = null;
- if (resources[0].getType()==IResource.FILE) {
- cvsResource = new LocalFile(resource.getLocation().toFile());
- } else {
- cvsResource = new LocalFolder(resource.getLocation().toFile());
- }
-
TagSelectionDialog dialog = new TagSelectionDialog(getShell(), resource);
dialog.setBlockOnOpen(true);
int result = dialog.open();
@@ -60,7 +51,7 @@ public class CompareWithTagAction extends TeamAction {
return;
}
CVSTag tag = dialog.getResult();
- ICVSRemoteResource remoteResource = (ICVSRemoteResource)provider.getRemoteTree(resource, tag, new NullProgressMonitor());
+ ICVSRemoteResource remoteResource = CVSWorkspaceRoot.getRemoteTree(resource, tag, new NullProgressMonitor());
CompareUI.openCompareEditor(new CVSCompareEditorInput(new CVSResourceNode(resource), new ResourceEditionNode(remoteResource)));
} catch (TeamException e) {
throw new InvocationTargetException(e);
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java
index 619b60508..74d6de59f 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java
@@ -11,11 +11,10 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.ui.actions.TeamAction;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
@@ -26,17 +25,8 @@ public class IgnoreAction extends TeamAction {
if (resources.length == 0) return false;
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
- ICVSResource cvsResource = null;
- switch (resource.getType()) {
- case IResource.FILE:
- cvsResource = new LocalFile(resource.getLocation().toFile());
- break;
- case IResource.FOLDER:
- cvsResource = new LocalFolder(resource.getLocation().toFile());
- break;
- default:
- return false;
- }
+ if (resource.getType() == IResource.PROJECT) return false;
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
if (cvsResource.isManaged()) return false;
if (cvsResource.isIgnored()) return false;
}
@@ -48,15 +38,7 @@ public class IgnoreAction extends TeamAction {
IResource[] resources = getSelectedResources();
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
- ICVSResource cvsResource = null;
- switch (resource.getType()) {
- case IResource.FILE:
- cvsResource = new LocalFile(resource.getLocation().toFile());
- break;
- case IResource.FOLDER:
- cvsResource = new LocalFolder(resource.getLocation().toFile());
- break;
- }
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
if (cvsResource == null) return;
try {
cvsResource.setIgnored();
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RemoveRootAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RemoveRootAction.java
index aa2b7b8c4..0bb9cdcc4 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RemoveRootAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RemoveRootAction.java
@@ -86,7 +86,7 @@ public class RemoveRootAction extends TeamAction {
ITeamProvider teamProvider = manager.getProvider(projects[j]);
if (teamProvider instanceof CVSTeamProvider) {
CVSTeamProvider cvsProvider = (CVSTeamProvider)teamProvider;
- if (cvsProvider.getRemoteRoot().equals(roots[i])) {
+ if (cvsProvider.getCVSWorkspaceRoot().getRemoteLocation().equals(roots[i])) {
shared = true;
break;
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java
index b7246e93a..4bffd3456 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java
@@ -12,14 +12,12 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.ui.actions.TeamAction;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.ui.actions.TeamAction;
public abstract class ReplaceWithAction extends TeamAction {
private boolean confirmOverwrite = true;
@@ -43,13 +41,7 @@ public abstract class ReplaceWithAction extends TeamAction {
return false;
}
- ICVSResource cvsResource;
- if (resource.getType() == IResource.FILE) {
- cvsResource = new LocalFile(resource.getLocation().toFile());
- } else {
- cvsResource = new LocalFolder(resource.getLocation().toFile());
- }
-
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
try {
if (!cvsResource.isManaged()) {
if (cvsResource.isIgnored()) {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java
index 0770e7a57..072d15544 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java
@@ -6,26 +6,17 @@ package org.eclipse.team.internal.ccvs.ui.actions;
*/
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.team.ccvs.core.CVSTeamProvider;
-import org.eclipse.team.ccvs.core.ICVSRemoteFile;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.TeamPlugin;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.HistoryView;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.ui.actions.TeamAction;
@@ -55,7 +46,7 @@ public class ShowResourceInHistoryAction extends TeamAction {
if (resources.length != 1) return false;
IResource resource = resources[0];
if (!(resource instanceof IFile)) return false;
- ICVSResource cvsResource = new LocalFile(resource.getLocation().toFile());
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
if (!cvsResource.isManaged()) return false;
if (cvsResource.getSyncInfo().isAdded()) return false;
return true;
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
index 0ee86e472..8d7ac36b2 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
@@ -5,26 +5,19 @@ package org.eclipse.team.internal.ccvs.ui.actions;
* All Rights Reserved.
*/
-import java.util.ArrayList;
-
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.sync.CVSSyncCompareInput;
-import org.eclipse.team.ui.TeamUIPlugin;
import org.eclipse.team.ui.actions.TeamAction;
import org.eclipse.team.ui.sync.SyncView;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
/**
@@ -58,14 +51,14 @@ public class SyncAction extends TeamAction {
protected boolean isEnabled() throws TeamException {
IResource[] resources = getSelectedResources();
for (int i = 0; i < resources.length; i++) {
- if (!resources[i].isAccessible()) return false;
- ITeamProvider provider = TeamPlugin.getManager().getProvider(resources[i].getProject());
- if (!(provider instanceof CVSTeamProvider)) return false;
+ IResource resource = resources[i];
+ if (!resource.isAccessible()) return false;
+ if(resource.getType()==IResource.PROJECT) continue;
// If the resource is not managed and its parent is not managed, disable.
- CVSTeamProvider cvsProvider = (CVSTeamProvider)provider;
- if (!cvsProvider.isManaged(resources[i])) {
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ if (!cvsResource.isManaged()) {
// The resource is not managed. See if its parent is managed.
- if (!cvsProvider.isManaged(resources[i].getParent())) return false;
+ if (!cvsResource.getParent().isManaged()) return false;
}
}
return true;
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
index c82fdbd5d..51f2ae686 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
@@ -11,7 +11,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -20,15 +19,14 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.ITeamManager;
import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.ui.actions.TeamAction;
@@ -81,14 +79,11 @@ public class TagAction extends TeamAction {
if (resources.length == 0) return false;
ITeamManager manager = TeamPlugin.getManager();
for (int i = 0; i < resources.length; i++) {
- ITeamProvider provider = manager.getProvider(resources[i].getProject());
+ IResource resource = resources[i];
+ ITeamProvider provider = manager.getProvider(resource.getProject());
if (provider == null) return false;
- if (!((CVSTeamProvider)provider).isManaged(resources[i])) return false;
- // If resource is a file and does not exist remotely yet, disable tag.
- if (resources[i] instanceof IFile) {
- ICVSResource cvsResource = new LocalFile(resources[i].getLocation().toFile());
- if (cvsResource.getSyncInfo().isAdded()) return false;
- }
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ if (resource.getType()!=IResource.PROJECT&&!cvsResource.isManaged()) return false;
}
return true;
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java
index a078d7c08..24e567cba 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java
@@ -12,6 +12,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -30,11 +31,13 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.ITeamManager;
import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.CVSDecorator;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.ui.actions.TeamAction;
@@ -144,10 +147,9 @@ public class UnmanageAction extends TeamAction {
IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
for (int i = 0; i < providerResources.length; i++) {
IResource resource = providerResources[i];
- LocalFolder folder = new LocalFolder(resource.getLocation().toFile());
+ ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor((IContainer) resource);
if(deleteContent) {
folder.unmanage();
- CVSProviderPlugin.getSynchronizer().reload(folder.getLocalFile(), Policy.subMonitorFor(subMonitor, 90));
}
TeamPlugin.getManager().removeProvider((IProject)resource, Policy.subMonitorFor(subMonitor, 10));
CVSDecorator.refresh(resource);
@@ -187,7 +189,8 @@ public class UnmanageAction extends TeamAction {
if(resources[i].getType()!=IResource.PROJECT) return false;
ITeamProvider provider = manager.getProvider(resources[i].getProject());
if (provider == null) return false;
- if (!((CVSTeamProvider)provider).isManaged(resources[i])) return false;
+ ICVSFolder project = CVSWorkspaceRoot.getCVSFolderFor((IContainer)resources[i]);
+ if (!project.isCVSFolder()) return false;
}
return true;
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java
index d3eb6f4c4..ba3af11c5 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java
@@ -11,19 +11,20 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.ITeamManager;
import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.ui.actions.TeamAction;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
@@ -72,12 +73,15 @@ public class UpdateAction extends TeamAction {
if (resources.length == 0) return false;
ITeamManager manager = TeamPlugin.getManager();
for (int i = 0; i < resources.length; i++) {
- ITeamProvider provider = manager.getProvider(resources[i].getProject());
+ IResource resource = resources[i];
+ ITeamProvider provider = manager.getProvider(resource.getProject());
if (provider == null) return false;
- if (!((CVSTeamProvider)provider).isManaged(resources[i])) return false;
- if (resources[i] instanceof IFile) {
- LocalFile file = new LocalFile(resources[i].getLocation().toFile());
- if (file.getSyncInfo().isAdded()) return false;
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ ResourceSyncInfo info = cvsResource.getSyncInfo();
+ if(cvsResource.isFolder()) {
+ if(!((ICVSFolder)cvsResource).isCVSFolder()) return false;
+ } else {
+ if (!cvsResource.isManaged() || info.isAdded()) return false;
}
}
return true;
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java
index d59030497..c761429fc 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java
@@ -20,6 +20,7 @@ import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.core.sync.IRemoteResource;
import org.eclipse.team.core.sync.IRemoteSyncElement;
import org.eclipse.team.internal.ccvs.core.resources.CVSRemoteSyncElement;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.sync.CVSSyncCompareInput;
import org.eclipse.team.ui.sync.CatchupReleaseViewer;
@@ -45,9 +46,8 @@ public class MergeEditorInput extends CVSSyncCompareInput {
protected IRemoteSyncElement[] createSyncElements(IProgressMonitor monitor) throws TeamException {
monitor.beginTask(null, 100);
try {
- CVSTeamProvider provider = (CVSTeamProvider)TeamPlugin.getManager().getProvider(project);
- IRemoteResource base = provider.getRemoteTree(project, start, Policy.subMonitorFor(monitor, 50));
- IRemoteResource remote = provider.getRemoteTree(project, end, Policy.subMonitorFor(monitor, 50));
+ IRemoteResource base = CVSWorkspaceRoot.getRemoteTree(project, start, Policy.subMonitorFor(monitor, 50));
+ IRemoteResource remote = CVSWorkspaceRoot.getRemoteTree(project, end, Policy.subMonitorFor(monitor, 50));
return new IRemoteSyncElement[] {new CVSRemoteSyncElement(false, project, base, remote)};
} finally {
monitor.done();
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardEndPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardEndPage.java
index 6beb89808..5513b098b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardEndPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardEndPage.java
@@ -23,6 +23,7 @@ import org.eclipse.team.ccvs.core.CVSTeamProvider;
import org.eclipse.team.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.wizards.CVSWizardPage;
import org.eclipse.ui.model.WorkbenchContentProvider;
@@ -97,7 +98,7 @@ public class MergeWizardEndPage extends CVSWizardPage {
this.project = project;
try {
this.provider = ((CVSTeamProvider)TeamPlugin.getManager().getProvider(project));
- this.remote = (ICVSRemoteFolder)provider.getRemoteResource(project);
+ this.remote = (ICVSRemoteFolder) CVSWorkspaceRoot.getRemoteResourceFor(project);
} catch (TeamException e) {
// To do
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardStartPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardStartPage.java
index 0cdb0a3f7..c552157e7 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardStartPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizardStartPage.java
@@ -24,11 +24,9 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.team.ccvs.core.CVSTag;
-import org.eclipse.team.ccvs.core.CVSTeamProvider;
import org.eclipse.team.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.core.ITeamProvider;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.wizards.CVSWizardPage;
import org.eclipse.ui.model.WorkbenchContentProvider;
@@ -110,10 +108,8 @@ public class MergeWizardStartPage extends CVSWizardPage {
setPageComplete(false);
}
private void initialize() {
- ITeamProvider provider = TeamPlugin.getManager().getProvider(project);
- if (!(provider instanceof CVSTeamProvider)) return;
try {
- ICVSRemoteFolder remoteResource = (ICVSRemoteFolder)((CVSTeamProvider)provider).getRemoteResource(project);
+ ICVSRemoteFolder remoteResource = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project);
table.setInput(new VersionsElement(remoteResource, getShell()));
} catch (TeamException e) {
// To do. This could only happen if the resource was not a child of the provider.
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java
index 874c97f0e..84f98ec5b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java
@@ -24,12 +24,13 @@ import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.ccvs.core.ICVSFile;
import org.eclipse.team.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteResource;
import org.eclipse.team.core.sync.IRemoteSyncElement;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.ui.CVSDecorator;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
@@ -144,7 +145,8 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
IResource resource = node.getResource();
if (resource.getType() == IResource.FILE) {
try {
- if (new LocalFile(((IFile)resource).getLocation().toFile()).getSyncInfo() == null) {
+ ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile) resource);
+ if (cvsFile.getSyncInfo() == null) {
DiffImage diffImage = new DiffImage(image, questionableDescriptor);
return diffImage.createImage();
}
@@ -164,7 +166,8 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
IResource resource = node.getResource();
if (resource.exists() && resource.getType() == IResource.FILE) {
try {
- ResourceSyncInfo info = new LocalFile(((IFile)resource).getLocation().toFile()).getSyncInfo();
+ ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile) resource);
+ ResourceSyncInfo info = cvsFile.getSyncInfo();
String kw;
if (info!=null) {
kw = CVSDecorator.getFileTypeString(resource.getName(), info.getKeywordMode());
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java
index 3277b0544..57623a908 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java
@@ -22,6 +22,7 @@ import org.eclipse.team.core.ITeamProvider;
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.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.ui.sync.CatchupReleaseViewer;
@@ -60,8 +61,7 @@ public class CVSSyncCompareInput extends SyncCompareInput {
monitor.beginTask(null, work);
try {
for (int i = 0; i < trees.length; i++) {
- CVSTeamProvider provider = (CVSTeamProvider)TeamPlugin.getManager().getProvider(resources[i].getProject());
- trees[i] = provider.getRemoteSyncTree(resources[i], null, Policy.subMonitorFor(monitor, 1000));
+ trees[i] = CVSWorkspaceRoot.getRemoteSyncTree(resources[i], null, Policy.subMonitorFor(monitor, 1000));
}
} finally {
monitor.done();
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/IgnoreAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/IgnoreAction.java
index eeff7e5ed..fb413ec3b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/IgnoreAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/IgnoreAction.java
@@ -7,19 +7,18 @@ package org.eclipse.team.internal.ccvs.ui.sync;
import org.eclipse.compare.structuremergeviewer.IDiffContainer;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
+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.jface.action.Action;
import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.sync.IRemoteSyncElement;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.ui.sync.ChangedTeamContainer;
import org.eclipse.team.ui.sync.ITeamNode;
import org.eclipse.team.ui.sync.SyncSet;
@@ -45,10 +44,10 @@ public class IgnoreAction extends Action {
ICVSResource cvsResource = null;
if (first instanceof TeamFile) {
IResource resource = ((TeamFile)first).getMergeResource().getResource();
- cvsResource = new LocalFile(resource.getLocation().toFile());
+ cvsResource = CVSWorkspaceRoot.getCVSFileFor((IFile) resource);
} else if (first instanceof ChangedTeamContainer) {
IResource resource = ((ChangedTeamContainer)first).getMergeResource().getResource();
- cvsResource = new LocalFolder(resource.getLocation().toFile());
+ cvsResource = CVSWorkspaceRoot.getCVSFolderFor((IContainer) resource);
}
if (cvsResource != null) {
try {
@@ -72,17 +71,7 @@ public class IgnoreAction extends Action {
ITeamNode node = (ITeamNode)nodes[0];
if (node.getKind() != (ITeamNode.OUTGOING | IRemoteSyncElement.ADDITION)) return false;
IResource resource = node.getResource();
- ICVSResource cvsResource = null;
- switch (resource.getType()) {
- case IResource.FILE:
- cvsResource = new LocalFile(resource.getLocation().toFile());
- break;
- case IResource.FOLDER:
- cvsResource = new LocalFolder(resource.getLocation().toFile());
- break;
- default:
- return false;
- }
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
return !cvsResource.isManaged();
}
public void update() {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizard.java
index 98085f88c..d016de05b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizard.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizard.java
@@ -29,6 +29,7 @@ import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.client.Command;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
import org.eclipse.team.internal.ccvs.ui.Policy;
@@ -74,13 +75,13 @@ public class BranchWizard extends Wizard {
CVSTeamProvider provider = (CVSTeamProvider)iterator.next();
List list = (List)table.get(provider);
IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
- ICVSRepositoryLocation root = provider.getRemoteRoot();
+ ICVSRepositoryLocation root = provider.getCVSWorkspaceRoot().getRemoteLocation();
CVSTag tag = new CVSTag(tagString, CVSTag.BRANCH);
try {
if (versionTag != null) {
provider.tag(providerResources, IResource.DEPTH_INFINITE, versionTag, subMonitor);
for (int i = 0; i < providerResources.length; i++) {
- ICVSRemoteFolder remoteResource = (ICVSRemoteFolder)provider.getRemoteResource(providerResources[i]);
+ ICVSRemoteFolder remoteResource = (ICVSRemoteFolder) CVSWorkspaceRoot.getRemoteResourceFor(providerResources[i]);
manager.addVersionTags(remoteResource, new CVSTag[] { versionTag });
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java
index c082f21d3..c8f6295fe 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java
@@ -17,13 +17,15 @@ import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.client.Session;
import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.ui.Policy;
@@ -104,7 +106,7 @@ public class ConfigurationWizardAutoconnectPage extends CVSWizardPage {
}
public void setProject(IProject project) {
try {
- ICVSFolder folder = (ICVSFolder)Session.getManagedResource(project);
+ ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project);
info = folder.getFolderSyncInfo();
if (info == null) {
// This should never happen
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java
index c137b8400..5ee0d821b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java
@@ -21,12 +21,12 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.ui.CVSDecorator;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
@@ -299,7 +299,7 @@ public class SharingWizard extends Wizard implements IConfigurationWizard {
// Determine if there is an existing CVS/ directory from which configuration
// information can be retrieved.
try {
- ICVSFolder folder = (ICVSFolder)Session.getManagedResource(project);
+ ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project);
FolderSyncInfo info = folder.getFolderSyncInfo();
return info != null;
} catch (TeamException e) {
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceException.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java
index 2f5678bdf..b8bd8746e 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceException.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java
@@ -1,13 +1,13 @@
-package org.eclipse.team.tests.ccvs.core.compatible;
+package org.eclipse.team.tests.ccvs.core;
/*
* (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
import org.eclipse.team.internal.ccvs.core.CVSException;
-public class ReferenceException extends CVSException {
+public class CVSClientException extends CVSException {
- public ReferenceException(String message) {
+ public CVSClientException(String message) {
super(message);
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java
index cb6de755b..6db103257 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java
@@ -19,11 +19,10 @@ import org.eclipse.team.internal.ccvs.core.CVSProvider;
import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
public class CVSTestSetup extends TestSetup {
- public static String REPOSITORY_LOCATION;
- public static boolean INITIALIZE_REPO;
+ public static final String REPOSITORY_LOCATION;
+ public static final boolean INITIALIZE_REPO;
public static final boolean DEBUG;
public static final String RSH;
-
public static CVSRepositoryLocation repository;
@@ -88,8 +87,6 @@ public class CVSTestSetup extends TestSetup {
public void setUp() throws CVSException {
if (repository == null)
repository = setupRepository(REPOSITORY_LOCATION);
- if (!DEBUG)
- CVSProviderPlugin.getProvider().setPrintStream(new PrintStream(new NullOutputStream()));
}
protected CVSRepositoryLocation setupRepository(String location) throws CVSException {
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java
new file mode 100644
index 000000000..db621ca41
--- /dev/null
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java
@@ -0,0 +1,106 @@
+package org.eclipse.team.tests.ccvs.core;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+
+import junit.framework.Assert;
+
+import org.eclipse.team.internal.ccvs.core.CVSException;
+
+public class CommandLineCVSClient {
+ private static final String cvsExecutable =
+ System.getProperty("eclipse.cvs.command");
+
+ public static void execute(
+ String repositoryLocation, File localRoot, String command,
+ String[] globalOptions, String[] localOptions,
+ String[] arguments) throws CVSException {
+ // test arguments
+ Assert.assertNotNull(repositoryLocation);
+ Assert.assertNotNull(localRoot);
+ Assert.assertNotNull(command);
+ Assert.assertNotNull(globalOptions);
+ Assert.assertNotNull(localOptions);
+ Assert.assertNotNull(arguments);
+ Assert.assertTrue(localRoot.exists());
+
+ // build command line
+ StringBuffer commandLineBuf = new StringBuffer(cvsExecutable);
+ commandLineBuf.append(" -d \"");
+ commandLineBuf.append(repositoryLocation);
+ commandLineBuf.append('"');
+ appendStrings(commandLineBuf, globalOptions);
+ commandLineBuf.append(' ');
+ commandLineBuf.append(command);
+ appendStrings(commandLineBuf, localOptions);
+ appendStrings(commandLineBuf, arguments);
+
+ // execute command
+ try {
+ PrintStream debugStream = CVSTestSetup.DEBUG ? System.out : null;
+ String commandLine = commandLineBuf.toString();
+
+ if (debugStream != null) {
+ // while debugging, dump CVS command line client results to stdout
+ // prefix distinguishes between message source stream
+ debugStream.println();
+ debugStream.println("CMD> " + commandLine);
+ debugStream.println("DIR> " + localRoot.toString());
+ }
+ Process cvsProcess = Runtime.getRuntime().exec(commandLine, null, localRoot);
+ // stream output must be dumped to avoid blocking the process or causing a deadlock
+ startBackgroundPipeThread(cvsProcess.getErrorStream(), debugStream, "ERR> ");
+ startBackgroundPipeThread(cvsProcess.getInputStream(), debugStream, "MSG> ");
+ int returnCode = cvsProcess.waitFor();
+
+ if (debugStream != null) {
+ debugStream.println("RESULT> " + returnCode);
+ }
+ if (returnCode != 0) {
+ throw new CVSClientException("Command line client returned non-zero code: " + returnCode);
+ }
+ } catch (IOException e) {
+ throw new CVSClientException("IOException while executing command line client: " + e);
+ } catch (InterruptedException e) {
+ throw new CVSClientException("InterruptedException while executing command line client: " + e);
+ }
+ }
+
+ private static void appendStrings(StringBuffer commandLine, String[] strings) {
+ for (int i = 0; i < strings.length; i++) {
+ String string = strings[i];
+ if (string != null && string.length() != 0) {
+ commandLine.append(" \"");
+ commandLine.append(string);
+ commandLine.append('"');
+ }
+ }
+ }
+
+ private static void startBackgroundPipeThread(final InputStream is, final PrintStream os,
+ final String prefix) {
+ new Thread() {
+ public void run() {
+ BufferedReader reader = null;
+ try {
+ try {
+ reader = new BufferedReader(new InputStreamReader(is));
+ for (;;) {
+ String line = reader.readLine();
+ if (line == null) break;
+ if (os != null) os.println(prefix + line);
+ }
+ } finally {
+ if (reader != null) reader.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }.start();
+ }
+}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java
new file mode 100644
index 000000000..9c6fd69ae
--- /dev/null
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java
@@ -0,0 +1,98 @@
+package org.eclipse.team.tests.ccvs.core;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.team.ccvs.core.CVSStatus;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+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.Command.GlobalOption;
+import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
+
+public class EclipseCVSClient {
+ private static final HashMap commandPool = new HashMap();
+ static {
+ commandPool.put("update", Command.UPDATE);
+ commandPool.put("co", Command.CHECKOUT);
+ commandPool.put("ci", Command.COMMIT);
+ commandPool.put("import", Command.IMPORT);
+ commandPool.put("add", Command.ADD);
+ commandPool.put("remove", Command.REMOVE);
+ commandPool.put("status", Command.STATUS);
+ commandPool.put("log", Command.LOG);
+ commandPool.put("tag", Command.TAG);
+ commandPool.put("rtag", Command.RTAG);
+ commandPool.put("admin", Command.ADMIN);
+ commandPool.put("diff", Command.DIFF);
+ }
+
+ public static void execute(
+ ICVSRepositoryLocation cvsRepositoryLocation, ICVSFolder cvsLocalRoot,
+ String command, String[] globalOptions, String[] localOptions,
+ String[] arguments) throws CVSException {
+ // test arguments
+ Assert.assertNotNull(cvsRepositoryLocation);
+ Assert.assertNotNull(cvsLocalRoot);
+ Assert.assertNotNull(command);
+ Assert.assertNotNull(globalOptions);
+ Assert.assertNotNull(localOptions);
+ Assert.assertNotNull(arguments);
+ Assert.assertTrue(cvsLocalRoot.exists());
+
+ // get command instance
+ Command cvsCommand = (Command) commandPool.get(command);
+
+ // get global options
+ List globals = new ArrayList();
+ for (int i = 0; i < globalOptions.length; i++) {
+ globals.add(new CustomGlobalOption(globalOptions[i]));
+ }
+ GlobalOption[] cvsGlobalOptions = (GlobalOption[]) globals.toArray(new GlobalOption[globals.size()]);
+
+ // get local options
+ List locals = new ArrayList();
+ for (int i = 0; i < localOptions.length; i++) {
+ String option = localOptions[i];
+ String argument = null;
+ if ((i < localOptions.length - 1) && (localOptions[i + 1].charAt(0) != '-')) {
+ argument = localOptions[++i];
+ }
+ locals.add(new CustomLocalOption(option, argument));
+ }
+ LocalOption[] cvsLocalOptions = (LocalOption[]) locals.toArray(new LocalOption[locals.size()]);
+
+ // execute command
+ IProgressMonitor monitor = new NullProgressMonitor();
+ Session session = new Session(cvsRepositoryLocation, cvsLocalRoot);
+ try {
+ session.open(monitor);
+ IStatus status = cvsCommand.execute(session,
+ cvsGlobalOptions, cvsLocalOptions, arguments, null, monitor);
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ throw new CVSClientException("Eclipse client returned non-ok status: " + status);
+ }
+ } finally {
+ session.close();
+ }
+ }
+
+ private static class CustomGlobalOption extends GlobalOption {
+ public CustomGlobalOption(String option) {
+ super(option);
+ }
+ }
+
+ private static class CustomLocalOption extends LocalOption {
+ public CustomLocalOption(String option, String arg) {
+ super(option, arg);
+ }
+ }
+}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
index b891115e5..e401c4b1c 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
@@ -31,7 +31,11 @@ import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSStatus;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.internal.ccvs.core.CVSException;
@@ -43,11 +47,7 @@ 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.connection.CVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
@@ -149,9 +149,8 @@ public class EclipseTest extends EclipseWorkspaceTest {
public void unmanageResources(IContainer container, String[] hierarchy) throws CoreException, TeamException {
IResource[] resources = getResources(container, hierarchy);
for (int i=0;i<resources.length;i++) {
- Session.getManagedResource(resources[i]).unmanage();
+ CVSWorkspaceRoot.getCVSResourceFor(resources[i]).unmanage();
}
- CVSProviderPlugin.getSynchronizer().save(container.getLocation().toFile(), DEFAULT_MONITOR);
}
/**
@@ -220,7 +219,7 @@ public class EclipseTest extends EclipseWorkspaceTest {
// Check the project out under a different name and validate that the results are the same
IProject copy = getWorkspace().getRoot().getProject(project.getName() + postfix);
- CVSProviderPlugin.getProvider().checkout(getRepository(), copy, ((ICVSFolder)Session.getManagedResource(project)).getFolderSyncInfo().getRepository(), null, DEFAULT_MONITOR);
+ CVSProviderPlugin.getProvider().checkout(getRepository(), copy, CVSWorkspaceRoot.getCVSFolderFor(project).getFolderSyncInfo().getRepository(), null, DEFAULT_MONITOR);
return copy;
}
@@ -230,7 +229,9 @@ public class EclipseTest extends EclipseWorkspaceTest {
// Check the project out under a different name and validate that the results are the same
IProject copy = getWorkspace().getRoot().getProject(project.getName() + tag.getName());
- CVSProviderPlugin.getProvider().checkout(getRepository(), copy, ((ICVSFolder)Session.getManagedResource(project)).getFolderSyncInfo().getRepository(), tag, DEFAULT_MONITOR);
+ CVSProviderPlugin.getProvider().checkout(getRepository(), copy,
+ CVSWorkspaceRoot.getCVSFolderFor(project).getFolderSyncInfo().getRepository(),
+ tag, DEFAULT_MONITOR);
return copy;
}
@@ -259,9 +260,6 @@ public class EclipseTest extends EclipseWorkspaceTest {
protected void assertEquals(IProject project1, IProject project2) throws CoreException, TeamException, IOException {
assertEquals(project1, project2, false, false);
}
- protected void assertEquals(String message, IProject project1, IProject project2) throws CoreException, TeamException, IOException {
- assertEquals(project1, project2, false, false);
- }
protected void assertEquals(IProject project1, IProject project2, boolean includeTimestamps, boolean includeTags) throws CoreException, TeamException, IOException {
assertEquals(getProvider(project1), getProvider(project2), includeTimestamps, includeTags);
@@ -271,7 +269,9 @@ public class EclipseTest extends EclipseWorkspaceTest {
* Compare CVS team providers by comparing the cvs resource corresponding to the provider's project
*/
protected void assertEquals(CVSTeamProvider provider1, CVSTeamProvider provider2, boolean includeTimestamps, boolean includeTags) throws CoreException, TeamException, IOException {
- assertEquals(Path.EMPTY, (ICVSFolder)Session.getManagedFolder(provider1.getProject().getLocation().toFile()), (ICVSFolder)Session.getManagedFolder(provider2.getProject().getLocation().toFile()), includeTimestamps, includeTags);
+ assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSFolderFor(provider1.getProject()),
+ CVSWorkspaceRoot.getCVSFolderFor(provider2.getProject()),
+ includeTimestamps, includeTags);
}
/*
@@ -432,26 +432,17 @@ public class EclipseTest extends EclipseWorkspaceTest {
assertNotNull(provider);
}
protected InputStream getContents(ICVSFile file) throws CVSException, IOException {
- if (file instanceof LocalFile)
- return new BufferedInputStream(new FileInputStream(getFile(file)));
- else
+ if (file instanceof ICVSRemoteFile)
return ((RemoteFile)file).getContents(DEFAULT_MONITOR);
+ else
+ return new BufferedInputStream(file.getInputStream());
}
/*
* Get the CVS Resource for the given resource
*/
protected ICVSResource getCVSResource(IResource resource) throws CVSException {
- if (resource.getType() == IResource.FILE)
- return Session.getManagedFile(resource.getLocation().toFile());
- else
- return Session.getManagedFolder(resource.getLocation().toFile());
- }
- /*
- * Get the IO File for the given CVS resource
- */
- protected File getFile(ICVSResource mResource) {
- return new File(((LocalResource)mResource).getPath());
+ return CVSWorkspaceRoot.getCVSResourceFor(resource);
}
protected IProject getNamedTestProject(String name) throws CoreException {
@@ -514,7 +505,7 @@ public class EclipseTest extends EclipseWorkspaceTest {
protected void importProject(IProject project) throws TeamException {
// Create the root folder for the import operation
- ICVSFolder root = (ICVSFolder)Session.getManagedResource(project);
+ ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(project);
// Perform the import
IStatus status;
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java
index c5bf9c5ec..f6c873314 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java
@@ -4,38 +4,28 @@ package org.eclipse.team.tests.ccvs.core;
* All Rights Reserved.
*/
import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import junit.awtui.TestRunner;
import junit.framework.TestCase;
+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.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.ccvs.core.CVSStatus;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.CVSException;
-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.Command.GlobalOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-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.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
-import org.eclipse.team.internal.ccvs.core.util.FileUtil;
-import org.eclipse.team.internal.ccvs.core.util.Util;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
/**
* Base-class to the low level-testcases for the Session.
@@ -43,198 +33,41 @@ import org.eclipse.team.internal.ccvs.core.util.Util;
* Especally data for a default-connection to the server is stored.
*/
public abstract class JUnitTestCase extends TestCase {
-
protected static final int RANDOM_CONTENT_SIZE = 10000;
protected static final boolean NEWLINE_TEST = false;
protected static final String PLATFORM_NEWLINE = System.getProperty("line.separator");
- protected static final File workspaceRoot = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile();
+ protected static final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
public static final String[] EMPTY_ARGS = new String[0];
-
- // Predefined parameters for calles of the client
- protected final String[] globalOptions;
- protected final IProgressMonitor monitor;
- protected final String[] arguments;
- protected static final String REPOSITORY_NAME = CVSTestSetup.REPOSITORY_LOCATION;
- static boolean propertiesSet = false;
-
- private static final HashMap commandPool = new HashMap();
- static {
- commandPool.put("update", Command.UPDATE);
- commandPool.put("co", Command.CHECKOUT);
- commandPool.put("ci", Command.COMMIT);
- commandPool.put("import", Command.IMPORT);
- commandPool.put("add", Command.ADD);
- commandPool.put("remove", Command.REMOVE);
- commandPool.put("status", Command.STATUS);
- commandPool.put("log", Command.LOG);
- commandPool.put("tag", Command.TAG);
- commandPool.put("rtag", Command.RTAG);
- commandPool.put("admin", Command.ADMIN);
- commandPool.put("diff", Command.DIFF);
- }
-
- /**
- * Convinience method for:<br>
- * Session.execute(request,globalOptions,localOptions,arguments,Session.getManagedFolder(root),monitor,messageOut)
- */
- public static void execute(String request,
- String[] globalOptions,
- String[] localOptions,
- String[] arguments,
- File root,
- IProgressMonitor monitor,
- PrintStream messageOut)
- throws CVSException {
- if (!CVSTestSetup.DEBUG)
- messageOut = new PrintStream(new NullOutputStream());
-
- List globals = new ArrayList();
- for (int i=0;i<globalOptions.length;i++) {
- if (globalOptions[i].equals("-d")) {
- i++;
- continue;
- }
- globals.add(new CustomGlobalOption(globalOptions[i]));
- }
- List locals = new ArrayList();
- for (int i=0;i<localOptions.length;i++) {
- if ((i < localOptions.length - 1) && (localOptions[i + 1].charAt(0) != '-')) {
- locals.add(new CustomLocalOption(localOptions[i], localOptions[i + 1]));
- i++;
- } else {
- locals.add(new CustomLocalOption(localOptions[i], null));
- }
- }
- Session s = new Session(getRepository(globalOptions, Session.getManagedFolder(root)), Session.getManagedFolder(root));
- s.open(monitor);
- try {
- IStatus status = ((Command)commandPool.get(request)).execute(s,
- (GlobalOption[]) globals.toArray(new GlobalOption[globals.size()]),
- (LocalOption[]) locals.toArray(new LocalOption[locals.size()]),
- arguments,
- null,
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- s.close();
- }
- }
-
- public static class CustomGlobalOption extends GlobalOption {
- public CustomGlobalOption(String option) {
- super(option);
- }
- }
- public static class CustomLocalOption extends LocalOption {
- public CustomLocalOption(String option, String arg) {
- super(option, arg);
- }
- }
- /**
- * This give you a new repo either from the global "-d" option
- * or form the root-property in the folder.
- *
- * This has to be rewritten in a nicer style.
- */
- private static CVSRepositoryLocation getRepository(String[] globalOptions,
- ICVSFolder mFolder)
- throws CVSException {
-
- String repoName = null;
-
- // look if the repo is specified in the global Options
- // this delets the option as well which is not so beatyful, but
- // we have got a copy and we do not want this option to appear
- // any more
- repoName = Util.getOption(globalOptions, "-d", true);
-
- // look if we have got an root-entrie in the root-folder
- if (repoName == null && mFolder.exists() && mFolder.isCVSFolder()) {
- repoName = mFolder.getFolderSyncInfo().getRoot();
- }
-
- if (repoName == null) {
- throw new CVSException("CVSROOT is not specified");
- }
-
- return CVSRepositoryLocation.fromString(repoName);
- }
-
- /**
- * Get a File relative to the working directory.
- */
- protected static File getFile(String relativePath) {
- // We need to get the cononical file in case relativePath contains a dot indicating the root directory
- try {
- return new File(workspaceRoot, relativePath).getCanonicalFile();
- } catch (IOException e) {
- fail(e.getMessage());
- return null;
- }
- }
-
- /**
- * Get the IO File for the given CVS resource
- */
- protected static File getFile(ICVSResource mResource) {
- return new File(((LocalResource)mResource).getPath());
- }
-
- /**
- * Get a CVSFolder relative to the working directory.
- */
- protected static ICVSFolder getManagedFolder(String relativePath) {
- try {
- return Session.getManagedFolder(getFile(relativePath));
- } catch (CVSException e) {
- fail(e.getMessage());
- return null;
- }
- }
-
/**
* Init the options and arguments to standard-values
*/
public JUnitTestCase(String name) {
super(name);
-
- monitor = new NullProgressMonitor();
- globalOptions = new String[]{"-d",REPOSITORY_NAME};
- arguments = new String[]{"proj1"};
}
/**
* Delete a project/resource form the standard cvs-server
*/
- protected void deleteRemoteResource(String project) throws CVSException {
- CVSRepositoryLocation location = CVSRepositoryLocation.fromString(REPOSITORY_NAME);
- String host = location.getHost();
- String repoRoot = location.getRootDirectory();
- deleteRemoteResource(location, project);
+ protected void magicDeleteRemote(String remoteName) throws CVSException {
+ magicDeleteRemote(CVSTestSetup.repository, remoteName);
}
/**
- * Delete a project/resource form the standard cvs-server
+ * Delete a project/resource form the specified cvs-server
*/
- protected static void deleteRemoteResource(ICVSRepositoryLocation location, String project) throws CVSException {
-
- String commandLine;
- Process process;
-
- commandLine = new String(CVSTestSetup.RSH + " " + location.getHost() + " -l " + location.getUsername() + " rm -rf " + new Path(location.getRootDirectory()).append(project).toString());
-
+ protected static void magicDeleteRemote(ICVSRepositoryLocation location, String remoteName)
+ throws CVSException {
+ String commandLine = new String(CVSTestSetup.RSH + " " + location.getHost() +
+ " -l " + location.getUsername() + " rm -rf " +
+ new Path(location.getRootDirectory()).append(remoteName).toString());
try {
- process = Runtime.getRuntime().exec(commandLine);
+ Process process = Runtime.getRuntime().exec(commandLine);
process.waitFor();
-
if (process.exitValue() != 0) {
// throw new CVSException("Return Code of magicDeleteProject :" + process.exitValue());
}
-
} catch (IOException e) {
throw new CVSException("IOException in magicDeleteProject");
} catch (InterruptedException e) {
@@ -243,42 +76,38 @@ public abstract class JUnitTestCase extends TestCase {
}
/**
- * Set the project on the standard cvs-server up so that it contains the resources
- * in createResources. The files have random content.
+ * Sends the project to the standard cvs-server so that it contains the resources
+ * described in createResources. The files have random content.
+ *
+ * @param projectName the name of the project to import
+ * @param createResources e.g. new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt"}
*/
- public void createRemoteProject(String project, String[] createResources) throws CVSException {
- CVSRepositoryLocation location = CVSRepositoryLocation.fromString(REPOSITORY_NAME);
- createRemoteProject(workspaceRoot, location ,project, createResources);
+ protected void magicSetUpRepo(String projectName, String[] createResources)
+ throws IOException, CoreException, CVSException {
+ magicSetUpRepo(CVSTestSetup.repository, projectName, createResources);
}
/**
- * Set the project on the standard cvs-server up so that it contains the resources
- * in createResources. The files have random content.
+ * Sends the project to the specified cvs-server so that it contains the resources
+ * described in createResources. The files have random content.
*
- * @param root a folder to place files temporaryly
- * @param host e.g. dev.eclipse.org:2401
- * @param repoRoot e.g. /home/cvs
- * @param repoName e.g. :pserver:anonymous@dev.eclipse.org:2401:/home/eclipse
- * @param project e.g. org.eclipse.swt
+ * @param location the CVS repository location
+ * @param projectName the name of the project to import
* @param createResources e.g. new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt"}
*/
- private static void createRemoteProject(File root, ICVSRepositoryLocation location, String project, String[] createResources) throws CVSException {
-
- File workFolder;
-
- workFolder = new File(root, project + "tmpXXXtmp");
+ protected static void magicSetUpRepo(ICVSRepositoryLocation location, String projectName,
+ String[] createResources) throws IOException, CoreException, CVSException {
+ IProject projectRoot = workspaceRoot.getProject(projectName + "-setup-tmp");
+ mkdirs(projectRoot);
+ createRandomFile(projectRoot, createResources);
+ magicDeleteRemote(location, projectName);
- createRandomFile(workFolder, createResources);
-
- deleteRemoteResource(location, project);
-
- String[] gOptions = new String[]{"-d", location.getLocation()};
String[] lOptions = new String[]{"-m","msg"};
- String[] args = new String[]{project,"a","b"};
-
- execute("import",gOptions,lOptions,args,workFolder,new NullProgressMonitor(),System.err);
-
- FileUtil.deepDelete(workFolder);
+ String[] args = new String[]{projectName,"a","b"};
+
+ EclipseCVSClient.execute(location, CVSWorkspaceRoot.getCVSFolderFor(projectRoot),
+ "import", EMPTY_ARGS, lOptions, args);
+ projectRoot.delete(false /*force*/, null);
}
/**
@@ -310,69 +139,64 @@ public abstract class JUnitTestCase extends TestCase {
}
- protected static void assertSynchronizerEmpty() {
- assertTrue(CVSProviderPlugin.getSynchronizer().isEmpty());
- }
-
/**
- * Write String[] to file as lines
+ * Write text lines to file from an array of strings.
*/
- protected static void writeToFile(File file, String[] content)
- throws IOException {
-
- BufferedWriter fileWriter;
-
- fileWriter = new BufferedWriter(new FileWriter(file));
- for (int i = 0; i<content.length; i++) {
- fileWriter.write(content[i]);
- fileWriter.newLine();
+ protected static void writeToFile(IFile file, String[] contents)
+ throws IOException, CoreException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ PrintStream os = new PrintStream(bos);
+ try {
+ for (int i = 0; i < contents.length; i++) {
+ os.println(contents[i]);
+ }
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ if (file.exists()) {
+ file.setContents(bis, false /*force*/, true /*keepHistory*/, null);
+ } else {
+ mkdirs(file.getParent());
+ file.create(bis, false /*force*/, null);
+ }
+ } finally {
+ os.close();
}
- fileWriter.close();
}
/**
- * load file in lines to String[]
+ * Read text lines from file into an array of strings.
*/
- protected static String[] readFromFile(File file)
- throws IOException {
-
- BufferedReader fileReader;
+ protected static String[] readFromFile(IFile file)
+ throws IOException, CoreException {
+ if (! file.exists()) return null;
+ BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()));
List fileContentStore = new ArrayList();
- String line;
-
- if (!file.exists()) {
- return null;
- }
-
- fileReader = new BufferedReader(new FileReader(file));
- while ((line = fileReader.readLine()) != null) {
- fileContentStore.add(line);
+ try {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ fileContentStore.add(line);
+ }
+ } finally {
+ reader.close();
}
- fileReader.close();
-
return (String[]) fileContentStore.toArray(new String[fileContentStore.size()]);
}
/**
- * Append a String to an file (acctally to both of the files, that are going
- * to have the same content)
- * If the file is empty we create a new file with the content txt.
+ * Append text files to file from an array of strings, create new file if it
+ * does not exist yet.
*/
- protected void appendToFile(File file, String txt) throws IOException {
- String[] content;
- String[] newContent;
-
- content = readFromFile(file);
-
- if (content == null) {
- content = new String[0];
+ protected static void appendToFile(IFile file, String[] contents)
+ throws IOException, CoreException {
+ String[] oldContents = readFromFile(file);
+ String[] newContents;
+ if (contents != null) {
+ newContents = contents;
+ } else {
+ newContents = new String[oldContents.length + contents.length];
+ System.arraycopy(oldContents, 0, newContents, 0, oldContents.length);
+ System.arraycopy(contents, 0, newContents, oldContents.length, contents.length);
}
-
- newContent = new String[content.length + 1];
- System.arraycopy(content,0,newContent,0,content.length);
- newContent[content.length] = txt;
-
- writeToFile(file,newContent);
+ writeToFile(file, newContents);
}
/**
@@ -424,26 +248,43 @@ public abstract class JUnitTestCase extends TestCase {
}
/**
- * Creates the file with random contend, and all the folders on the
- * way to there
+ * Creates a folder (and its parents if needed).
*/
- private static void createRandomFile(File file) throws CVSException {
- try {
- file.getParentFile().mkdirs();
- writeToFile(file,new String[]{createRandomContent()});
- } catch (IOException e) {
- throw new CVSException(0,0,"IOException in test-setup",e);
- }
+ protected static void mkdirs(IContainer container) throws CoreException {
+ if (container.getType() == IResource.PROJECT) {
+ IProject project = (IProject) container;
+ if (! project.exists()) {
+ project.create(null);
+ }
+ project.open(null);
+ } else if (container.getType() == IResource.FOLDER) {
+ IFolder folder = (IFolder) container;
+ if (! folder.exists()) {
+ mkdirs(folder.getParent());
+ folder.create(false /*force*/, true /*local*/, null);
+ }
+ }
+ }
+
+ /**
+ * Creates the file with random content, and all the folders on the
+ * way to there.
+ */
+ private static void createRandomFile(IFile file)
+ throws IOException, CoreException {
+ mkdirs(file.getParent());
+ writeToFile(file, new String[] { createRandomContent() });
}
/**
* Build the given fileStructure, all files are going to have
- * sample content, all folders on the way are created
+ * sample content, all folders on the way are created.
*/
- protected static void createRandomFile(File root, String[] fileNameArray)
- throws CVSException {
- for (int i=0; i<fileNameArray.length; i++) {
- createRandomFile(new File(root, fileNameArray[i]));
+ protected static void createRandomFile(IContainer parent, String[] fileNameArray)
+ throws IOException, CoreException {
+ for (int i = 0; i < fileNameArray.length; i++) {
+ IFile file = parent.getFile(new Path(fileNameArray[i]));
+ createRandomFile(file);
}
}
@@ -463,37 +304,9 @@ public abstract class JUnitTestCase extends TestCase {
* It initialises some required parameter and runs the testcase.
*/
protected static void run(Class test) {
- System.setProperty("eclipse.cvs.standalone","true");
+ // XXX is this property used anywhere?
+ System.setProperty("eclipse.cvs.standalone", "true");
TestRunner.run(test);
}
-
- /**
- * This delte does a deepDelete for an ICVSResource and deletes all
- * the cached information for the resource and all its children as
- * well.
- * At some point this should be integrated into the LocalResource ...
- */
- public static void delete(ICVSResource resource) throws CVSException {
-
- // Deleting a file is an add-on that we need for the same-result
- // enviorment
- if (!resource.isFolder()) {
- resource.delete();
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)resource.getParent()).getLocalFile(), new NullProgressMonitor());
- return;
- }
-
- ICVSFolder folder = (ICVSFolder) resource;
-
- if (!folder.isCVSFolder()) {
- ICVSFolder[] folders = folder.getFolders();
- for (int i = 0; i < folders.length; i++) {
- delete(folders[i]);
- }
- }
-
- folder.delete();
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)folder).getLocalFile(), new NullProgressMonitor());
- }
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/NullOutputStream.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/NullOutputStream.java
deleted file mode 100644
index 6419fb047..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/NullOutputStream.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.eclipse.team.tests.ccvs.core;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * @version 1.0
- * @author ${user}
- */
-public class NullOutputStream extends OutputStream {
-
- /**
- * Constructor for NullOutputStream.
- */
- public NullOutputStream() {
- super();
- }
-
- /*
- * @see OutputStream#write(int)
- */
- public void write(int arg0) throws IOException {
- }
-
-}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/BasicTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/BasicTest.java
index 3ad5d3062..03205888a 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/BasicTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/BasicTest.java
@@ -8,22 +8,20 @@ import java.util.GregorianCalendar;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
public class BasicTest extends JUnitTestCase {
-
SameResultEnv env1;
SameResultEnv env2;
public BasicTest(String arg) {
super(arg);
- env1 = new SameResultEnv(arg,getFile("checkout1"));
- env2 = new SameResultEnv(arg,getFile("checkout2"));
+ env1 = new SameResultEnv(arg + "-checkout1");
+ env2 = new SameResultEnv(arg + "-checkout2");
}
public BasicTest() {
- this(null);
+ this("BasicTest");
}
public static void main(String[] args) {
@@ -33,21 +31,20 @@ public class BasicTest extends JUnitTestCase {
public static Test suite() {
TestSuite suite = new TestSuite(BasicTest.class);
return new CompatibleTestSetup(suite);
- //return new CompatibleTestSetup(new BasicTest("testRTag"));
+ //return new CompatibleTestSetup(new BasicTest("testDate"));
}
public void setUp() throws Exception {
env1.setUp();
env2.setUp();
// Set the project to the content we need ...
- env1.createRemoteProject("proj2",new String[]{"a.txt","f1/b.txt","f1/c.txt"});
+ env1.magicSetUpRepo("proj2",new String[]{"a.txt","f1/b.txt","f1/c.txt"});
env2.deleteFile("proj2");
}
- public void tearDown() throws CVSException {
+ public void tearDown() throws Exception {
env1.tearDown();
env2.tearDown();
- assertSynchronizerEmpty();
}
public void testAdd() throws Exception {
@@ -130,7 +127,7 @@ public class BasicTest extends JUnitTestCase {
// change the file "proj1/folder1/c.txt" in env1 check it in
// on the server
- env1.appendToFile("proj2/f1/c.txt","AppendIt");
+ env1.appendToFile("proj2/f1/c.txt", new String[] { "AppendIt" });
env1.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},"");
// assure that the file is different in env1 and env2
@@ -167,7 +164,7 @@ public class BasicTest extends JUnitTestCase {
env1.deleteFile("proj2/a.txt");
env1.deleteFile("proj2/f1/c.txt");
- env1.appendToFile("proj2/f1/b.txt","AppendIt");
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt" });
env1.execute("status",EMPTY_ARGS,new String[]{"proj2"});
env1.execute("status",EMPTY_ARGS,new String[0],"proj2");
@@ -186,7 +183,7 @@ public class BasicTest extends JUnitTestCase {
env1.deleteFile("proj2/a.txt");
env1.deleteFile("proj2/f1/c.txt");
- env1.appendToFile("proj2/f1/b.txt","AppendIt");
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt" });
env1.execute("log",EMPTY_ARGS,new String[]{"proj2"});
env1.execute("log",EMPTY_ARGS,new String[0],"proj2");
@@ -205,7 +202,7 @@ public class BasicTest extends JUnitTestCase {
env1.deleteFile("proj2/a.txt");
env1.deleteFile("proj2/f1/c.txt");
- env1.appendToFile("proj2/f1/b.txt","AppendIt");
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt" });
env1.execute("tag",new String[]{"-b"},new String[]{"tag2","proj2"});
@@ -215,7 +212,7 @@ public class BasicTest extends JUnitTestCase {
// Try an commit and an add in the two different streams
env1.execute("co",new String[]{"-r","tag1"},new String[]{"proj2"});
- env1.appendToFile("proj2/f1/b.txt","AppendItTwo");
+ env1.appendToFile("proj2/f1/b.txt", new String[] { "AppendItTwo" });
env1.createRandomFile("proj2/d.txt");
env1.execute("add",new String[0],new String[]{"d.txt"},"proj2");
env1.execute("ci",new String[]{"-m","branch"},new String[]{"proj2"});
@@ -223,7 +220,7 @@ public class BasicTest extends JUnitTestCase {
env1.execute("co",new String[]{"-r","tag1"},new String[]{"proj2"});
env2.execute("co",new String[]{"-r","tag2"},new String[]{"proj2"});
- env2.appendToFile("proj2/f1/b.txt","AppendItThree");
+ env2.appendToFile("proj2/f1/b.txt", new String[] { "AppendItThree" });
env2.createRandomFile("proj2/d.txt");
env2.execute("add",new String[0],new String[]{"d.txt"},"proj2");
env2.execute("ci",new String[]{"-m","branch"},new String[]{"proj2"});
@@ -235,7 +232,7 @@ public class BasicTest extends JUnitTestCase {
// Try to branch of a workspace with local changes
env1.execute("co",EMPTY_ARGS,new String[]{"proj2"});
JUnitTestCase.waitMsec(1500);
- env1.appendToFile("proj2/f1/b.txt","AppendIt");
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt" });
env1.execute("tag",new String[]{"-b"},new String[]{"branch-with-changes","proj2"});
env1.execute("update",new String[]{"-r", "branch-with-changes"},new String[]{"proj2"});
}
@@ -247,7 +244,7 @@ public class BasicTest extends JUnitTestCase {
env1.deleteFile("proj2/a.txt");
env1.deleteFile("proj2/f1/c.txt");
- env1.appendToFile("proj2/f1/b.txt","AppendIt");
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt" });
env1.execute("tag",EMPTY_ARGS,new String[]{"tag2","proj2"});
env1.execute("tag",EMPTY_ARGS,new String[]{"tag2"},"proj2");
@@ -347,8 +344,8 @@ public class BasicTest extends JUnitTestCase {
env1.setIgnoreExceptions(true);
- env1.appendToFile("proj2/f1/c.txt","AppendIt2");
- env1.appendToFile("proj2/f1/b.txt","AppendIt");
+ env1.appendToFile("proj2/f1/c.txt",new String[] {"AppendIt2" });
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt" });
env1.execute("diff",EMPTY_ARGS,new String[]{"proj2"});
env1.execute("diff",EMPTY_ARGS,new String[0],"proj2");
@@ -365,7 +362,7 @@ public class BasicTest extends JUnitTestCase {
public void testReadOnly() throws Exception {
env1.execute("co",new String[]{"-r"},EMPTY_ARGS,new String[]{"proj2"},"");
env1.execute("update",new String[0],EMPTY_ARGS,new String[]{"proj2"},"");
- env1.deleteFile(".");
+ env1.deleteFile("");
env1.writeToFile("tmp.txt",new String[0]);
env1.deleteFile("tmp.txt");
env1.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
@@ -383,7 +380,7 @@ public class BasicTest extends JUnitTestCase {
public void testImportWrappers() throws Exception {
// Make the project empty
- env1.createRemoteProject("proj3",new String[]{"NoImportant.txt"});
+ env1.magicSetUpRepo("proj3",new String[]{"NoImportant.txt"});
env2.deleteFile("proj3");
// Create resouces and import them with the
@@ -400,7 +397,7 @@ public class BasicTest extends JUnitTestCase {
public void testImportIgnores() throws Exception {
// Make the project empty
- env1.createRemoteProject("proj3",new String[]{"NoImportant.txt"});
+ env1.magicSetUpRepo("proj3",new String[]{"NoImportant.txt"});
env2.deleteFile("proj3");
// Create resouces and import them with the
@@ -437,14 +434,14 @@ public class BasicTest extends JUnitTestCase {
waitMsec(1100);
- env1.appendToFile("proj2/a.txt","AppendIt");
+ env1.appendToFile("proj2/a.txt",new String[] { "AppendIt" });
env1.execute("ci",new String[]{"-m","msg"},new String[]{"proj2"});
firstChange = GregorianCalendar.getInstance().getTime();
waitMsec(1100);
- env1.appendToFile("proj2/a.txt","AppendIt2");
- env1.appendToFile("proj2/f1/b.txt","AppendIt2");
+ env1.appendToFile("proj2/a.txt",new String[] { "AppendIt2" });
+ env1.appendToFile("proj2/f1/b.txt",new String[] { "AppendIt2" });
env1.execute("ci",new String[]{"-m","msg"},new String[]{"proj2"});
secondChange = GregorianCalendar.getInstance().getTime();
@@ -475,12 +472,12 @@ public class BasicTest extends JUnitTestCase {
// We get try to merge changes from different dates
env1.execute("co",new String[0],new String[]{"proj2"});
- env1.appendToFile("proj2/a.txt","This is the world ...");
+ env1.appendToFile("proj2/a.txt", new String[] { "This is the world ..." });
env1.execute("update",new String[]{"-D",toGMTString(beforeChange)},new String[]{"proj2"});
- env1.appendToFile("proj2/a.txt","... witch constantly changes");
+ env1.appendToFile("proj2/a.txt", new String[] {"... which constantly changes" });
env1.execute("update",new String[]{"-A"},new String[]{"proj2"});
// Change something to be able to commit
- env1.appendToFile("proj2/a.txt","... and the changes are aproved");
+ env1.appendToFile("proj2/a.txt", new String[] { "... and the changes are approved" });
env1.execute("ci",new String[]{"-m","msg"},new String[]{"proj2"});
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/CompatibleTestSetup.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/CompatibleTestSetup.java
index ffac0a0db..c5e991654 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/CompatibleTestSetup.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/CompatibleTestSetup.java
@@ -14,13 +14,16 @@ import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
* @author ${user}
*/
public class CompatibleTestSetup extends CVSTestSetup {
-
- public static final String REFERENCE_CLIENT_REPOSITORY=System.getProperty("eclipse.cvs.repository1");
- public static final String ECLIPSE_CLIENT_REPOSITORY=System.getProperty("eclipse.cvs.repository2");
-
+ public static final String ECLIPSE_REPOSITORY_LOCATION;
+ public static final String REFERENCE_REPOSITORY_LOCATION;
public static CVSRepositoryLocation referenceClientRepository;
public static CVSRepositoryLocation eclipseClientRepository;
+ static {
+ REFERENCE_REPOSITORY_LOCATION = System.getProperty("eclipse.cvs.repository1");
+ ECLIPSE_REPOSITORY_LOCATION = System.getProperty("eclipse.cvs.repository2");
+ }
+
/**
* Constructor for CompatibleTestSetup.
*/
@@ -34,10 +37,12 @@ public class CompatibleTestSetup extends CVSTestSetup {
public void setUp() throws CVSException {
CVSProviderPlugin.getPlugin().setPruneEmptyDirectories(false);
CVSProviderPlugin.getPlugin().setFetchAbsentDirectories(false);
- if ((referenceClientRepository != null) && (eclipseClientRepository != null))
- return;
- referenceClientRepository = setupRepository(REFERENCE_CLIENT_REPOSITORY);
- eclipseClientRepository = setupRepository(ECLIPSE_CLIENT_REPOSITORY);
+
+ // setup the repositories
+ if (referenceClientRepository == null)
+ referenceClientRepository = setupRepository(REFERENCE_REPOSITORY_LOCATION);
+ if (eclipseClientRepository == null)
+ eclipseClientRepository = setupRepository(ECLIPSE_REPOSITORY_LOCATION);
}
public void tearDown() throws CVSException {
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java
index 16080d5e9..1957df21f 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java
@@ -5,12 +5,9 @@ package org.eclipse.team.tests.ccvs.core.compatible;
*/
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
public class ConflictTest extends JUnitTestCase {
-
SameResultEnv env1;
SameResultEnv env2;
@@ -20,8 +17,8 @@ public class ConflictTest extends JUnitTestCase {
public ConflictTest(String arg) {
super(arg);
- env1 = new SameResultEnv(arg, getFile("checkout1"));
- env2 = new SameResultEnv(arg, getFile("checkout2"));
+ env1 = new SameResultEnv(arg + "checkout1");
+ env2 = new SameResultEnv(arg + "checkout2");
}
public void setUp() throws Exception {
@@ -29,11 +26,11 @@ public class ConflictTest extends JUnitTestCase {
env2.setUp();
// Set the project to the content we need ...
- env1.createRemoteProject("proj2",new String[]{"a.txt","f1/b.txt","f1/c.txt"});
+ env1.magicSetUpRepo("proj2",new String[]{"a.txt","f1/b.txt","f1/c.txt"});
env2.deleteFile("proj2");
}
- public void tearDown() throws CVSException {
+ public void tearDown() throws Exception {
env1.tearDown();
env2.tearDown();
}
@@ -50,8 +47,8 @@ public class ConflictTest extends JUnitTestCase {
env2.execute("co",EMPTY_ARGS,new String[]{"proj2"},"");
// change the file in both directories in a different way
- env1.appendToFile("proj2/f1/c.txt","AppendIt This");
- env2.appendToFile("proj2/f1/c.txt","AppendIt That");
+ env1.appendToFile("proj2/f1/c.txt", new String[] { "AppendIt This" });
+ env2.appendToFile("proj2/f1/c.txt", new String[] { "AppendIt That" });
// commit changes of the first
env1.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},"");
@@ -68,7 +65,7 @@ public class ConflictTest extends JUnitTestCase {
// Make a change to the file in order to let the cvs-client know
// that we solved the confilict
- env2.appendToFile("proj2/f1/c.txt","That's allright");
+ env2.appendToFile("proj2/f1/c.txt", new String[] { "That's allright" });
env2.execute("ci",new String[]{"-m","TestMessage"},new String[]{"proj2"},"");
}
} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ModuleTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ModuleTest.java
index b444713f1..fd9080cc8 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ModuleTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ModuleTest.java
@@ -3,34 +3,38 @@ package org.eclipse.team.tests.ccvs.core.compatible;
* (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
-import junit.awtui.TestRunner;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
public class ModuleTest extends JUnitTestCase {
-
SameResultEnv env1;
-
- public ModuleTest() {
- this(null);
- }
+ SameResultEnv env2;
public ModuleTest(String arg) {
super(arg);
- env1 = new SameResultEnv(arg, getFile("checkout1"));
+ env1 = new SameResultEnv(arg + "checkout1");
+ env2 = new SameResultEnv(arg + "checkout2");
+ }
+
+ public static void main(String[] args) {
+ run(ModuleTest.class);
}
public void setUp() throws Exception {
env1.setUp();
+ env2.setUp();
// Set the project to the content we need ...
- env1.deleteRemoteResource("CVSROOT/modules");
- env1.deleteRemoteResource("CVSROOT/modules,v");
+ env1.magicDeleteRemote("CVSROOT/modules");
+ env1.magicDeleteRemote("CVSROOT/modules,v");
+ env1.magicSetUpRepo("proj2",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt","f2/f3/e.txt"});
+ env2.deleteFile("proj2");
}
public void tearDown() throws Exception {
env1.tearDown();
+ env2.tearDown();
}
public static Test suite() {
@@ -51,239 +55,34 @@ public class ModuleTest extends JUnitTestCase {
}
public void testSimpleModule() throws Exception {
-
setUpModuleFile(new String[]{"mod1 proj2"});
- env1.createRemoteProject("proj2",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt","f2/f3/e.txt"});
-
env1.execute("co",EMPTY_ARGS,new String[]{"mod1"});
- env1.execute("co",new String[] {"-d", "mod1-copy"}, new String[]{"mod1"});
-
- env1.appendToFile("mod1/a.txt","Append");
+ env1.appendToFile("mod1/a.txt", new String[] { "Append" });
env1.execute("ci",new String[]{"-m","m"},new String[]{"mod1"});
-
env1.execute("update",EMPTY_ARGS,new String[]{"mod1"});
- env1.execute("update",EMPTY_ARGS,new String[]{"mod1-copy"});
}
public void testCompositeModule() throws Exception {
-
- setUpModuleFile(new String[]{
- "mod1-f1 proj2/f1",
- "mod1-f2 proj2/f2",
- "mod1f &mod1-f1 &mod1-f2"});
- env1.createRemoteProject("proj2",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt","f2/f3/e.txt"});
+ setUpModuleFile(new String[]{ "mod1-f1 proj2/f1",
+ "mod1-f2 proj2/f2",
+ "mod1f &mod1-f1 &mod1-f2"});
env1.execute("co",EMPTY_ARGS,new String[]{"mod1f"});
- env1.execute("co",new String[] {"-d", "mod1f-copy"}, new String[]{"mod1f"});
-
- env1.appendToFile("mod1f/mod1-f1/b.txt","Append");
- env1.appendToFile("mod1f/mod1-f2/d.txt","Append");
+ env1.appendToFile("mod1f/mod1-f1/b.txt", new String[] { "Append" });
env1.execute("ci",new String[]{"-m","m"},new String[]{"mod1f"});
-
env1.execute("update",EMPTY_ARGS,new String[]{"mod1f"});
- env1.execute("update",EMPTY_ARGS,new String[]{"mod1f-copy"});
}
public void testCompositeAliasModule() throws Exception {
-
- setUpModuleFile(new String[]{
- "mod1-f1 proj2/f1",
- "mod1t proj2/f1 b.txt",
- "mod1-f2 &proj2/f2 &mod1t", // XXX &proj2 is not a moduel definition!!!
- "mod1f -a mod1-f1 mod1-f2"});
- env1.createRemoteProject("proj2",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt","f2/f3/e.txt"});
+ setUpModuleFile(new String[]{"mod1-f1 proj2/f1",
+ "mod1t proj2/f1 b.txt",
+ "mod1-f2 &proj2/f2 &mod1t",
+ "mod1f -a mod1-f1 mod1-f2"});
env1.execute("co",EMPTY_ARGS,new String[]{"mod1f"});
- env1.execute("co",new String[] {"-d", "mod1f-copy"}, new String[]{"mod1f"});
-
- env1.appendToFile("mod1-f1/c.txt","Append");
- env1.appendToFile("mod1-f2/mod1t/b.txt","Append");
- env1.appendToFile("mod1-f1/b.txt","Append");
+ env1.appendToFile("mod1-f1/b.txt", new String[] { "Append" });
env1.execute("ci",new String[]{"-m","m"},new String[]{"mod1-f1","mod1-f2"});
-
env1.execute("update",EMPTY_ARGS,new String[]{"mod1-f1","mod1-f2"});
- env1.execute("update",EMPTY_ARGS,new String[]{"mod1f-copy"});
- }
-
- public void testSelfReferencingModule() throws Exception {
-
- // Setup the modules file and
- setUpModuleFile(new String[]{
- "project1 project1 &project2",
- "project2 project2"});
- env1.createRemoteProject("project1",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt","f2/f3/e.txt"});
- env1.createRemoteProject("project2",new String[]{"e.txt","f10/b.txt","f10/c.txt","f20/d.txt","f20/f30/e.txt"});
-
- // Checkout the module and a copy of the module
- env1.execute("co",EMPTY_ARGS,new String[]{"project1"});
- env1.execute("co",new String[] {"-d", "project1-copy"}, new String[]{"project1"});
-
- // Change some files in directories mapped to different remote dirs
- env1.appendToFile("project1/a.txt","Append");
- env1.appendToFile("project1/project2/e.txt","Append More");
- env1.execute("ci", new String[]{"-m","m"}, new String[]{"project1"});
-
- // Update the project and the copy
- env1.execute("update",EMPTY_ARGS,new String[]{"project1"});
- env1.execute("update",EMPTY_ARGS,new String[]{"project1-copy"});
- }
-
- public void testMinusD() throws Exception {
-
- // Setup the modules file and
- setUpModuleFile(new String[]{
- "help-docs -d docs common/docs",
- "macros common/macros",
- "project project &help-docs" });
- env1.createRemoteProject("common",new String[]{"docs/readme.txt","macros/macro1"});
- env1.createRemoteProject("project",new String[]{"file-p2.txt"});
-
- // Checkout the module and a copy of the module
- env1.execute("co",EMPTY_ARGS,new String[]{"help-docs"});
- env1.execute("co",new String[] {"-d", "docs-copy"}, new String[]{"help-docs"});
-
- // Change some files in directories mapped to different remote dirs
- env1.appendToFile("docs/readme.txt","Append");;
- env1.execute("ci", new String[]{"-m","m"}, new String[]{"docs"});
-
- // Update the project and the copy
- env1.execute("update",EMPTY_ARGS,new String[]{"docs"});
- env1.execute("update",EMPTY_ARGS,new String[]{"docs-copy"});
-
- // Checkout the module and a copy of the module
- env1.execute("co",EMPTY_ARGS,new String[]{"macros"});
- env1.execute("co",new String[] {"-d", "macros-copy"}, new String[]{"macros"});
-
- // Change some files in directories mapped to different remote dirs
- env1.appendToFile("macros/macro1","Append");;
- env1.execute("ci", new String[]{"-m","m"}, new String[]{"macros"});
-
- // Update the project and the copy
- env1.execute("update",EMPTY_ARGS,new String[]{"macros"});
- env1.execute("update",EMPTY_ARGS,new String[]{"macros-copy"});
-
- // Checkout the module and a copy of the module
- env1.execute("co",EMPTY_ARGS,new String[]{"project"});
- env1.execute("co",new String[] {"-d", "project-copy"}, new String[]{"project"});
-
- // Change some files in directories mapped to different remote dirs
- env1.appendToFile("project/docs/readme.txt","Append");;
- env1.execute("ci", new String[]{"-m","m"}, new String[]{"project"});
-
- // Update the project and the copy
- env1.execute("update",EMPTY_ARGS,new String[]{"project"});
- env1.execute("update",EMPTY_ARGS,new String[]{"project-copy"});
- }
-
- public void testFileAlias() throws Exception {
-
- // Setup the modules file and
- setUpModuleFile(new String[]{
- "project3-src project3/src",
- "project3-src_file -a project3-src/file.c project3-src/file.h",
- "project3-sub project3/sub &project3-src_file" });
- env1.createRemoteProject("project3",new String[]{"src/file.c", "src/file.h", "sub/file-sub.txt"});
-
- // Checkout the module and a copy of the module
- env1.execute("co",EMPTY_ARGS,new String[]{"project3-sub"});
- env1.execute("co",new String[] {"-d", "project3-sub-copy"}, new String[]{"project3-sub"});
-
- // Change some files in directories mapped to different remote dirs
- env1.appendToFile("project3-sub/project3-src/file.c","Append");
- env1.execute("ci", new String[]{"-m","m"}, new String[]{"project3-sub"});
-
- // Update the project and the copy
- env1.execute("update",EMPTY_ARGS,new String[]{"project3-sub"});
- env1.execute("update",EMPTY_ARGS,new String[]{"project3-sub-copy"});
}
-
- public void testEmbedding() throws Exception {
-
- // Setup the modules file and
- setUpModuleFile(new String[]{
- "macros common/macros",
- "project4 project4 &macros",
- "project5-project4 -d extensions/project4 project4",
- "project5 project5 &project5-project4 &macros", });
- env1.createRemoteProject("common",new String[]{"docs/readme.txt","macros/macro1"});
- env1.createRemoteProject("project4",new String[]{"file-p4.txt"});
- env1.createRemoteProject("project5",new String[]{"file-p5.txt"});
-
- // Checkout the module and a copy of the module
- env1.execute("co",EMPTY_ARGS,new String[]{"project4"});
- env1.execute("co",new String[] {"-d", "project4-copy"}, new String[]{"project4"});
-
- // Change some files in directories mapped to different remote dirs
- env1.appendToFile("project4/file-p4.txt","Append");
- env1.appendToFile("project4/macros/macro1","Append");;
- env1.execute("ci", new String[]{"-m","m"}, new String[]{"project4"});
-
- // Update the project and the copy
- env1.execute("update",EMPTY_ARGS,new String[]{"project4"});
- env1.execute("update",EMPTY_ARGS,new String[]{"project4-copy"});
-
- // Checkout the module and a copy of the module
- env1.execute("co",EMPTY_ARGS,new String[]{"project5"});
- env1.execute("co",new String[] {"-d", "project5-copy"}, new String[]{"project5"});
-
- // Change some files in directories mapped to different remote dirs
- env1.appendToFile("project5/file-p5.txt","Append");
- env1.appendToFile("project5/extensions/project4/file-p4.txt","Append");
- env1.appendToFile("project5/macros/macro1","Append");
- env1.execute("ci", new String[]{"-m","m"}, new String[]{"project5"});
-
- // Update the project and the copy
- env1.execute("update",EMPTY_ARGS,new String[]{"project5"});
- env1.execute("update",EMPTY_ARGS,new String[]{"project5-copy"});
-
- }
-
- public void testEmbeddingDirectories() throws Exception {
-
- // Setup the modules file and
- setUpModuleFile(new String[]{
- "project6-dirA -d dirA project6/A",
- "project6-dirB -d dirB project6/B",
- "project6 &project6-dirA &project6-dirB" });
- env1.createRemoteProject("project6",new String[]{"A/a.txt", "B/b.txt", "c.txt"});
-
- // Checkout the module and a copy of the module
- env1.execute("co",EMPTY_ARGS,new String[]{"project6"});
- env1.execute("co",new String[] {"-d", "project6-copy"}, new String[]{"project6"});
-
- // Change some files in directories mapped to different remote dirs
- env1.appendToFile("project6/dirA/a.txt","Append");
- env1.appendToFile("project6/dirB/b.txt","Append");
- env1.execute("ci", new String[]{"-m","m"}, new String[]{"project6"});
-
- // Update the project and the copy
- env1.execute("update",EMPTY_ARGS,new String[]{"project6"});
- env1.execute("update",EMPTY_ARGS,new String[]{"project6-copy"});
- }
-
- public void testAliasPackaging() throws Exception {
-
- // Setup the modules file and
- setUpModuleFile(new String[]{
- "project7-common -a project7/common",
- "project7-pc -a project7-common project7/pc",
- "project7-linux -a project7-common project7/linux" });
- env1.createRemoteProject("project7",new String[]{"common/com.txt", "pc/file.txt", "linux/file.txt"});
-
- // Checkout the module and a copy of the module
- env1.execute("co",EMPTY_ARGS,new String[]{"project7-pc"});
- // XXX The reference client does not allow the following checkout
-// env1.execute("co",new String[] {"-d", "project7-pc-copy"}, new String[]{"project7-pc"});
-
- // Change some files in directories mapped to different remote dirs
- env1.appendToFile("project7/common/com.txt","Append");
- env1.appendToFile("project7/pc/file.txt","Append");
- env1.execute("ci", new String[]{"-m","m"}, new String[]{"project7"});
-
- // Update the project and the copy
- env1.execute("update",EMPTY_ARGS,new String[]{"project7"});
-// env1.execute("update",EMPTY_ARGS,new String[]{"project7-pc-copy"});
- }
-
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceClient.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceClient.java
deleted file mode 100644
index 6b47c08b2..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ReferenceClient.java
+++ /dev/null
@@ -1,233 +0,0 @@
-package org.eclipse.team.tests.ccvs.core.compatible;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.util.SyncFileUtil;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-
-/**
- * This class is responsible for executing cvs commands using
- * a reference CVS command line client.
- */
-public class ReferenceClient {
-
- public static final String cvsLocation = System.getProperty("eclipse.cvs.command");
-
- private static final String logFileName = "cvslog";
-
- /**
- * Puts opetions into one String seperated by
- * space.
- * starts and ends with a space.
- */
- private static String flatenOptions(String[] options) {
-
- StringBuffer result = new StringBuffer(" ");
- String quote;
-
- for (int i=0; i<options.length; i++) {
-
- if (options[i].indexOf(" ")==-1) {
- quote = "";
- } else {
- quote = "\"";
- }
- result.append(quote);
- result.append(options[i]);
- result.append(quote);
- result.append(' ');
- }
-
- return result.toString();
- }
-
- public static void execute(String request,
- String[] globalOptions,
- String[] localOptions,
- String[] arguments,
- File ioRoot,
- IProgressMonitor monitor,
- PrintStream messageOut)
- throws CVSException {
-
- Runtime runtime;
- Process process;
- BufferedReader stdIn;
- BufferedReader errIn;
- ICVSFolder mRoot;
-
- String global;
- String local;
- String arg;
- String commandLine;
-
- globalOptions = (String[]) globalOptions.clone();
- mRoot = Session.getManagedFolder(ioRoot);
-
- runtime = Runtime.getRuntime();
- global = flatenOptions(globalOptions);
- local = flatenOptions(localOptions);
- arg = flatenOptions(arguments);
-
- commandLine = cvsLocation + " ";
- commandLine = commandLine + global;
- commandLine = commandLine + request + " ";
- commandLine = commandLine + local;
- commandLine = commandLine + arg;
-
- // System.out.println(ioRoot.getPath() + "> " + commandLine);
-
- try {
- String[] envVars = null;
- if (CVSTestSetup.DEBUG) {
- // XXX This doesn't work.
-// envVars = new String[] { "CVS_CLIENT_LOG=" + logFileName };
- }
- process = runtime.exec(commandLine, envVars, ioRoot);
- } catch (IOException e) {
- throw new CVSException("IOException while executing ReferenceClient",e);
- }
-
- stdIn = new BufferedReader(new InputStreamReader(process.getInputStream()));
- new ContiniousPipe(stdIn, messageOut, "M ");
-
- errIn = new BufferedReader(new InputStreamReader(process.getErrorStream()));
- new ContiniousPipe(errIn, messageOut, "E ");
-
- try {
- process.waitFor();
- } catch (InterruptedException e) {
- throw new CVSException("InterruptedException while executing ReferenceClient",e);
- }
-
- if (CVSTestSetup.DEBUG) {
-// try {
-// File logFileIn = new File(ioRoot, logFileName + ".in");
-// File logFileOut = new File(ioRoot, logFileName + ".out");
-// printLogFile(logFileIn);
-// printLogFile(logFileOut);
-// logFileIn.delete();
-// logFileOut.delete();
-// } catch (IOException e) {
-// throw new ReferenceException("Error reading log files");
-// }
- }
-
- if (process.exitValue() != 0) {
- throw new ReferenceException("Return Code of CVS reference client: " +
- process.exitValue() + "\nwhile executing: " +
- commandLine);
- }
-
- SyncFileUtil.mergeEntriesLogFiles(ioRoot);
-
- }
-
- /**
- *
- * returns ":pserver:username@host:/cvs/root"
- * when you insert ":pserver:username:password@host:/cvs/root"
- */
- public static String removePassword(String repoName) {
-
- int atPlace = -1;
- int colonPlace = -1;
- int colonCount = 0;
- String currentChar;
-
- for (int i=0; i<repoName.length(); i++) {
-
- currentChar = repoName.substring(i,i+1);
-
- if (currentChar.equals(":")) {
- colonCount++;
-
- if (colonCount == 3) {
- colonPlace = i;
- }
- }
-
- if (currentChar.equals("@")) {
- if (colonPlace == -1) {
-
- // If the @ comes before the third colon, then
- // we do not have a password and return with the
- // same string
- return repoName;
- } else {
- atPlace = i;
- }
-
- }
- }
-
- if (atPlace == -1) {
- return repoName;
- }
-
- return repoName.substring(0,colonPlace) + repoName.substring(atPlace);
- }
-
- private static void printLogFile(File logFile) throws IOException {
- System.out.println("/nReference client: " + logFile.getName());
- BufferedReader reader = new BufferedReader(new FileReader(logFile));
- String line;
- while ((line = reader.readLine()) != null) {
- System.out.println(line);
- }
- }
-}
-
-/**
- * This class does continiously pipe from a bufferdReader
- * to a printStream. It does stop as soon, as the bufferdReader is
- * closed an therefore an IOException is thrown or the pipe returns null.
- *
- * It does close the BufferedReader on it's own (to be sure that it got
- * everything)
- */
-class ContiniousPipe implements Runnable {
-
- BufferedReader in;
- PrintStream out;
- String prefix;
-
- ContiniousPipe(BufferedReader in, PrintStream out, String prefix) {
- this.in = in;
- this.out = out;
- this.prefix = prefix;
- (new Thread(this)).start();
- }
-
- public void run() {
-
- String line;
-
- try {
- while ((line=in.readLine()) != null) {
- out.println(prefix + line);
- }
- } catch (IOException e) {
- // Should not happen, as the PrintStream does not throw IOExceptions
- // at all an in is a stream from a process
- } finally {
-
- try {
- in.close();
- } catch (IOException e) {}
-
- }
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
index b2235d6c6..4b06d1c69 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
@@ -4,27 +4,33 @@ package org.eclipse.team.tests.ccvs.core.compatible;
* All Rights Reserved.
*/
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.PrintStream;
import java.text.ParseException;
+import java.util.StringTokenizer;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+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.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-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.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
+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.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.EntryFileDateFormat;
import org.eclipse.team.internal.ccvs.core.util.Util;
+import org.eclipse.team.tests.ccvs.core.CVSClientException;
+import org.eclipse.team.tests.ccvs.core.CommandLineCVSClient;
+import org.eclipse.team.tests.ccvs.core.EclipseCVSClient;
import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
-import org.eclipse.team.tests.ccvs.core.NullOutputStream;
/**
@@ -40,229 +46,178 @@ import org.eclipse.team.tests.ccvs.core.NullOutputStream;
* two (or more) different enviorments to test certain things.
*/
public final class SameResultEnv extends JUnitTestCase {
-
- public static final String REFERENCE_CLIENT_WORKSPACE="reference";
- public static final String ECLIPSE_CLIENT_WORKSPACE="eclipse";
-
- private File workspace;
- private File referenceClientRoot;
- private File eclipseClientRoot;
- private boolean ignoreExceptions=false;
- private boolean expectExceptions=false;
-
- private CVSRepositoryLocation referenceClientRepository;
- private CVSRepositoryLocation eclipseClientRepository;
-
- public SameResultEnv(String arg, File workspace) {
+ private IProject referenceProject;
+ private ICVSFolder referenceRoot;
+ private IProject eclipseProject;
+ private ICVSFolder eclipseRoot;
+
+ private boolean ignoreExceptions;
+
+ public SameResultEnv(String arg) {
super(arg);
- this.workspace = workspace;
- referenceClientRoot = new File(workspace, REFERENCE_CLIENT_WORKSPACE);
- eclipseClientRoot = new File(workspace, ECLIPSE_CLIENT_WORKSPACE);
-
- try {
- deleteFile(".");
- } catch (CVSException e) {
- fail();
- }
}
/**
* Always to be called in the setUp of the testCase that wants to
* use the same-result Enviorment.
*/
- public void setUp() throws CVSException {
+ public void setUp() throws Exception {
+ super.setUp();
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ // setup reference client test project
+ referenceProject = root.getProject(getName() + "-reference");
+ referenceProject.delete(true /*deleteContent*/, true /*force*/, null);
+ mkdirs(referenceProject);
+ referenceRoot = CVSWorkspaceRoot.getCVSFolderFor(referenceProject);
+
+ // setup eclipse client test project
+ eclipseProject = root.getProject(getName() + "-eclipse");
+ eclipseProject.delete(true /*deleteContent*/, true /*force*/, null);
+ mkdirs(eclipseProject);
+ eclipseRoot = CVSWorkspaceRoot.getCVSFolderFor(eclipseProject);
+
// By default, exceptions are not ignored.
// Specific test cases can choose to ignore exceptions
ignoreExceptions = false;
- mkdirs(".");
}
/**
* Always to be called in the tearDown of the testCase that wants to
* use the same-result Enviorment.
*/
- public void tearDown() throws CVSException {
- deleteFile("");
- }
-
- /**
- * Deletes files on the both of the cvs-servers.
- */
- public void deleteRemoteResource(String project) throws CVSException {
- deleteRemoteResource(CompatibleTestSetup.referenceClientRepository,project);
- deleteRemoteResource(CompatibleTestSetup.eclipseClientRepository,project);
+ public void tearDown() throws Exception {
+ // we deliberately don't clean up test projects to simplify debugging
+ super.tearDown();
}
/**
- * Set up both of the repos on the cvs-server(s) with a filestructre
- * resulting for your input in the parameter createResources.
- */
- public void createRemoteProject(String project,String[] createResources) throws CVSException {
-
- // This will trigger asynchronizer reload
- // deleteFile(project);
- deleteRemoteResource(project);
-
- createRandomFile(createResources, project);
- execute("import",new String[]{"-m","msg"},new String[]{project,"a","b"},project);
-
- deleteFile(".");
- mkdirs(".");
- }
-
- /**
- * Give null this gives an empty string-array back, otherwise
- * the parameter.
- */
- private static String[] notNull(String[] arg) {
- if (arg == null) {
- return new String[0];
- } else {
- return arg;
- }
- }
-
- /**
- * Convienience Method, does the same like:<br>
- * execute(request,null,localOptions,arguments,rootExtention)
+ * Helper method.
+ * Calls execute(command, EMPTY_ARGS, localOptions, arguments, pathRelativeToRoot)
*/
- public void execute(String request,
- String[] localOptions,
- String[] arguments,
- String rootExtention)
- throws CVSException {
-
- execute(request,new String[0],localOptions,arguments,rootExtention);
+ public void execute(String command, String[] localOptions, String[] arguments, String pathRelativeToRoot)
+ throws CVSException {
+ execute(command, EMPTY_ARGS, localOptions, arguments, pathRelativeToRoot);
}
/**
- * Convienience Method, does the same like:<br>
- * execute(request,null,localOptions,arguments,null)
- */
- public void execute(String request,
- String[] localOptions,
- String[] arguments)
- throws CVSException {
-
- execute(request,new String[0],localOptions,arguments,"");
+ * Helper method.
+ * Calls execute(command, EMPTY_ARGS, localOptions, arguments, "")
+ */
+ public void execute(String command, String[] localOptions, String[] arguments)
+ throws CVSException {
+ execute(command, EMPTY_ARGS, localOptions, arguments, "");
}
-
- /**
- * Run a command in the two folders of this enviorment. In one folder the
- * reference-client runs in the the other the eclipse-client. After that
- * the results on disc are compared (the output of the clients is not
- * considert for the comparison)
- */
- public void execute(String request,
- String[] globalOptions,
- String[] localOptions,
- String[] arguments,
- String rootExtention)
- throws CVSException {
-
- globalOptions = notNull(globalOptions);
-
- String[] gOptions1 = new String[globalOptions.length + 2];
- String[] gOptions2 = new String[globalOptions.length + 2];
-
- System.arraycopy(globalOptions,0,gOptions1,0,globalOptions.length);
- System.arraycopy(globalOptions,0,gOptions2,0,globalOptions.length);
-
- gOptions1[globalOptions.length] = gOptions2[globalOptions.length] = "-d";
- gOptions1[globalOptions.length + 1] = CompatibleTestSetup.REFERENCE_CLIENT_REPOSITORY;
- gOptions2[globalOptions.length + 1] = CompatibleTestSetup.ECLIPSE_CLIENT_REPOSITORY;
- execute(request,gOptions1,gOptions2,localOptions,arguments,rootExtention);
- }
-
/**
- * Acctally run the command in both folders. See doc above.
+ * Runs a command twice, once in the reference environments, once
+ * in the eclipse environment. Compares the resulting resources
+ * on disk, but not console output.
*/
- private void execute(String request,
- String[] globalOptions1,
- String[] globalOptions2,
- String[] localOptions,
- String[] arguments,
- String rootExtention)
- throws CVSException {
-
- assertNotNull(request);
- assertNotNull(globalOptions1);
- assertNotNull(globalOptions);
+ public void execute(String command,
+ String[] globalOptions, String[] localOptions, String[] arguments,
+ String pathRelativeToRoot) throws CVSException {
+ // run with reference client
boolean referenceClientException = false;
- boolean eclipseClientException = false;
-
- localOptions = notNull(localOptions);
- arguments = notNull(arguments);
- if (rootExtention == null || rootExtention.equals(".")) {
- rootExtention = "";
- }
-
try {
- ReferenceClient.execute(request,
- globalOptions1,
- localOptions,
- arguments,
- new File(referenceClientRoot,rootExtention),
- new NullProgressMonitor(),
- new PrintStream(new NullOutputStream()));
- } catch (ReferenceException e) {
- referenceClientException = true;
- if (!ignoreExceptions) {
- throw e;
+ File localRoot = referenceProject.getLocation().toFile();
+ if (pathRelativeToRoot.length() != 0) {
+ localRoot = new File(localRoot, pathRelativeToRoot);
+ }
+ CommandLineCVSClient.execute(
+ CompatibleTestSetup.referenceClientRepository.getLocation(),
+ localRoot, command, globalOptions, localOptions, arguments);
+ } catch (CVSClientException e) {
+ if (! ignoreExceptions) throw e;
+ referenceClientException = true;
+ } finally {
+ try {
+ referenceProject.refreshLocal(IResource.DEPTH_INFINITE, null);
+ EclipseSynchronizer.getInstance().flushAll(referenceProject, false); // remove me once refresh local fixed
+ } catch (CoreException e) {
+ fail("CoreException during refreshLocal: " + e.getMessage());
}
}
+ // run with Eclipse client
+ boolean eclipseClientException = false;
try {
- execute(request,
- globalOptions2,
- localOptions,
- arguments,
- new File(eclipseClientRoot,rootExtention),
- new NullProgressMonitor(),
- new PrintStream(new NullOutputStream()));
- } catch (CVSServerException e) {
- eclipseClientException = true;
- if (!ignoreExceptions) {
- throw e;
+ ICVSFolder localRoot = eclipseRoot;
+ IPath path = new Path(pathRelativeToRoot);
+ while (path.segmentCount() != 0) {
+ localRoot = localRoot.getFolder(path.segment(0));
+ path = path.removeFirstSegments(1);
}
+ EclipseCVSClient.execute(
+ CompatibleTestSetup.eclipseClientRepository, localRoot,
+ command, globalOptions, localOptions, arguments);
+ } catch (CVSClientException e) {
+ if (! ignoreExceptions) throw e;
+ eclipseClientException = true;
}
- if(ignoreExceptions) {
- assertEquals(referenceClientException == true, eclipseClientException == true);
- }
+ assertEquals(referenceClientException, eclipseClientException);
assertConsistent();
- }
+ }
/**
- * Checks whether the two directories inside the environment
- * are equal and therefore the state valid.
+ * Deletes files on the both of the cvs-servers.
*/
- public void assertConsistent() throws CVSException {
- ICVSFolder referenceFolder = Session.getManagedFolder(referenceClientRoot);
- ICVSFolder eclipseFolder = Session.getManagedFolder(eclipseClientRoot);
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)referenceFolder).getLocalFile(), new NullProgressMonitor());
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)eclipseFolder).getLocalFile(), new NullProgressMonitor());
- assertEquals(referenceFolder,eclipseFolder);
+ public void magicDeleteRemote(String remoteName) throws CVSException {
+ super.magicDeleteRemote(CompatibleTestSetup.referenceClientRepository, remoteName);
+ super.magicDeleteRemote(CompatibleTestSetup.eclipseClientRepository, remoteName);
}
/**
+ * Set up both of the repos on the cvs-server(s) with the standard
+ * file-structure:
+ * project
+ * a.txt
+ * f1
+ * b.txt
+ * c.txt
+ */
+ public void magicSetUpRepo(String projectName)
+ throws IOException, CoreException, CVSException {
+ magicSetUpRepo(projectName, new String[]{"a.txt","f1/b.txt","f1/c.txt"});
+ }
+
+ /**
+ * Set up both of the repos on the cvs-server(s) with a filestructre
+ * resulting for your input in the parameter createResources.
+ */
+ public void magicSetUpRepo(String projectName, String[] createResources)
+ throws IOException, CoreException, CVSException {
+ magicDeleteRemote(projectName);
+
+ IProject projectRoot = workspaceRoot.getProject(projectName + "-setup-tmp");
+ mkdirs(projectRoot);
+ createRandomFile(projectRoot, createResources);
+
+ String[] lOptions = new String[]{"-m","msg"};
+ String[] args = new String[]{projectName,"a","b"};
+
+ magicDeleteRemote(CompatibleTestSetup.referenceClientRepository, projectName);
+ EclipseCVSClient.execute(CompatibleTestSetup.referenceClientRepository, CVSWorkspaceRoot.getCVSFolderFor(projectRoot),
+ "import", EMPTY_ARGS, lOptions, args);
+
+ magicDeleteRemote(CompatibleTestSetup.eclipseClientRepository, projectName);
+ EclipseCVSClient.execute(CompatibleTestSetup.eclipseClientRepository, CVSWorkspaceRoot.getCVSFolderFor(projectRoot),
+ "import", EMPTY_ARGS, lOptions, args);
+
+ projectRoot.delete(false /*force*/, null);
+ }
+
+ /**
* Create a file with random-content in both, the reference client and
* the eclipse-client.
*
* @param relativeFileName is the relative path as allways in the
class used for access
*/
- public void createRandomFile(String relativeFileName) throws CVSException {
-
- String randomContent;
-
- randomContent = createRandomContent();
- try {
- writeToFile(relativeFileName,new String[]{randomContent});
- } catch (IOException e) {
- throw new CVSException("IOException while creating random content",e);
- }
+ public void createRandomFile(String relativeFileName)
+ throws IOException, CoreException {
+ String[] contents = new String[] { createRandomContent() };
+ writeToFile(relativeFileName, contents);
}
/**
@@ -270,18 +225,15 @@ public final class SameResultEnv extends JUnitTestCase {
*
* @see SameResultEnv#createRandomFile(String)
*/
- public void createRandomFile(String[] relativeFileNames, String rootExtention) throws CVSException {
-
- if (rootExtention == null || rootExtention.equals(".")) {
- rootExtention = "";
- }
-
- if (!rootExtention.equals("") && !rootExtention.startsWith("/")) {
- rootExtention = rootExtention + "/";
+ public void createRandomFile(String[] relativeFileNames,
+ String pathRelativeToRoot) throws CoreException, IOException {
+ if (pathRelativeToRoot == null) {
+ pathRelativeToRoot = "";
+ } else if (! pathRelativeToRoot.endsWith("/")) {
+ pathRelativeToRoot += "/";
}
-
- for (int i=0; i<relativeFileNames.length; i++) {
- createRandomFile(rootExtention + relativeFileNames[i]);
+ for (int i = 0; i < relativeFileNames.length; i++) {
+ createRandomFile(pathRelativeToRoot + relativeFileNames[i]);
}
}
@@ -289,91 +241,82 @@ public final class SameResultEnv extends JUnitTestCase {
* Read from the file (check that we have acctually got the same
* content in both versions
*/
- public String[] readFromFile(String relativeFileName) throws IOException {
-
- String[] content1;
- String[] content2;
-
- content1 = super.readFromFile(new File(referenceClientRoot,relativeFileName));
- content2 = super.readFromFile(new File(eclipseClientRoot,relativeFileName));
-
+ public String[] readFromFile(String relativeFileName)
+ throws IOException, CoreException {
+ IFile referenceFile = referenceProject.getFile(relativeFileName);
+ String[] content1 = super.readFromFile(referenceFile);
+ IFile eclipseFile = eclipseProject.getFile(relativeFileName);
+ String[] content2 = super.readFromFile(eclipseFile);
assertEqualsArrays(content1,content2);
-
return content1;
}
/**
- * Delete files from both of the directories
+ * Delete a file / folder from both directories.
*/
- public void deleteFile(String relativeFileName) throws CVSException {
-
- if (".".equals(relativeFileName)) {
- relativeFileName = "";
- }
-
- File file1 = new File(referenceClientRoot, relativeFileName);
- File file2 = new File(eclipseClientRoot, relativeFileName);
-
- assertEquals(file1.exists(),file2.exists());
-
- if (!file1.exists()) {
- return;
- }
-
- // Call the "clean-up-delete" that cares about deleting the
- // cache
- if (file1.isDirectory()) {
- delete(Session.getManagedFolder(file1));
- delete(Session.getManagedFolder(file2));
+ public void deleteFile(String relativeFileName) throws CoreException {
+ IResource referenceFile, eclipseFile;
+ if (relativeFileName.length() != 0) {
+ referenceFile = referenceProject.findMember(relativeFileName);
+ eclipseFile = eclipseProject.findMember(relativeFileName);
} else {
- delete(Session.getManagedFile(file1));
- delete(Session.getManagedFile(file2));
+ referenceFile = referenceProject;
+ eclipseFile = eclipseProject;
}
+ assertEquals(referenceFile != null, eclipseFile != null);
+ if (referenceFile == null) return;
+ assertEquals(referenceFile.exists(), eclipseFile.exists());
+ referenceFile.delete(true, null);
+ eclipseFile.delete(true, null);
}
/**
- * Create a folder and all the subfolders
- * in both of the directories
+ * Creates a folder (and its parents if needed) in both environments.
*/
- public void mkdirs(String folderName) {
- (new File(referenceClientRoot,folderName)).mkdirs();
- (new File(eclipseClientRoot,folderName)).mkdirs();
+ public void mkdirs(String relativeFolderName) throws CoreException {
+ IFolder referenceFolder = referenceProject.getFolder(relativeFolderName);
+ IFolder eclipseFolder = eclipseProject.getFolder(relativeFolderName);
+ assertEquals(referenceFolder.exists(), eclipseFolder.exists());
+ mkdirs(referenceFolder);
+ mkdirs(eclipseFolder);
}
/**
* Append a String to an file (acctally to both of the files, that are going
* to have the same content)
*/
- public void appendToFile(String relativeFileName, String txt) throws IOException {
- File file1 = new File(referenceClientRoot,relativeFileName);
- File file2 = new File(eclipseClientRoot,relativeFileName);
-
+ public void appendToFile(String relativeFileName, String[] contents)
+ throws IOException, CoreException {
// Wait a second so that the timestamp will change for sure
- waitMsec(2000);
-
- appendToFile(file1,txt);
- appendToFile(file2,txt);
+ waitMsec(1500);
+
+ IFile referenceFile = referenceProject.getFile(relativeFileName);
+ appendToFile(referenceFile, contents);
+ IFile eclipseFile = eclipseProject.getFile(relativeFileName);
+ appendToFile(eclipseFile, contents);
}
/**
* Write to the file (acctally to both of the files, that are going
* to have the same content)
- * Does create the underlying folder if they do not exist (the version
- * of JUnitTest does currently not)
*/
- public void writeToFile(String relativeFileName, String[] content) throws IOException {
-
- File file1 = new File(referenceClientRoot,relativeFileName);
- File file2 = new File(eclipseClientRoot,relativeFileName);
-
- file1.getParentFile().mkdirs();
- file2.getParentFile().mkdirs();
-
- writeToFile(file1,content);
- writeToFile(file2,content);
+ public void writeToFile(String relativeFileName, String[] contents)
+ throws IOException, CoreException {
+ IFile referenceFile = referenceProject.getFile(relativeFileName);
+ writeToFile(referenceFile, contents);
+ IFile eclipseFile = eclipseProject.getFile(relativeFileName);
+ writeToFile(eclipseFile, contents);
}
/**
+ * Checks whether the two directories inside the environment
+ * are equal and therefore the state valid.
+ */
+ public void assertConsistent() throws CVSException {
+ assertEquals(referenceRoot, eclipseRoot);
+ }
+
+ /**
* Deep compare of two ManagedResources (most likly folders).
* Passwords are ignored.
*
@@ -406,12 +349,12 @@ public final class SameResultEnv extends JUnitTestCase {
private static void assertEquals(ICVSFile mFile1, ICVSFile mFile2) throws CVSException {
// Check the permissions on disk
- assertEquals(getFile(mFile1).canWrite(), getFile(mFile2).canWrite());
+ assertEquals(mFile1.isReadOnly(), mFile2.isReadOnly());
// Compare the content of the files
try {
- InputStream in1 = new FileInputStream(getFile(mFile1));
- InputStream in2 = new FileInputStream(getFile(mFile2));
+ InputStream in1 = mFile1.getInputStream();
+ InputStream in2 = mFile2.getInputStream();
byte[] buffer1 = new byte[(int)mFile1.getSize()];
byte[] buffer2 = new byte[(int)mFile2.getSize()];
// This is not the right way to do it, because the Stream
@@ -487,8 +430,8 @@ public final class SameResultEnv extends JUnitTestCase {
assertEquals(mFolder1.isCVSFolder(),mFolder2.isCVSFolder());
if (mFolder1.isCVSFolder()) {
- String root1 = Util.removePassword(mFolder1.getFolderSyncInfo().getRoot());
- String root2 = Util.removePassword(mFolder2.getFolderSyncInfo().getRoot());
+ String root1 = removePassword(mFolder1.getFolderSyncInfo().getRoot());
+ String root2 = removePassword(mFolder2.getFolderSyncInfo().getRoot());
root1 = root1.substring(0,root1.lastIndexOf("@"));
root2 = root2.substring(0,root2.lastIndexOf("@"));
assertEquals(root1,root2);
@@ -541,4 +484,24 @@ public final class SameResultEnv extends JUnitTestCase {
public void setIgnoreExceptions(boolean ignoreExceptions) {
this.ignoreExceptions = ignoreExceptions;
}
+
+ /**
+ * returns ":pserver:nkrambro@fiji:/home/nkrambro/repo"
+ * when you insert ":pserver:nkrambro:password@fiji:/home/nkrambro/repo"
+ */
+ public static String removePassword(String root) {
+ StringTokenizer tok = new StringTokenizer(root, ":@", true);
+ StringBuffer filteredRoot = new StringBuffer();
+ int colonCounter = 3;
+ while (tok.hasMoreTokens()) {
+ String token = tok.nextToken();
+ if ("@".equals(token)) colonCounter = -1;
+ if (":".equals(token)) {
+ if (--colonCounter == 0) continue; // skip colon
+ }
+ if (colonCounter == 0) continue; // skip password
+ filteredRoot.append(token);
+ }
+ return filteredRoot.toString();
+ }
} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTests.java
index b2c6419d5..5ff88f091 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTests.java
@@ -16,11 +16,7 @@ public class AllTests extends EclipseTest {
public static Test suite() {
TestSuite suite = new TestSuite();
-
- suite.addTest(LocalFileTest.suite());
- suite.addTest(LocalFolderTest.suite());
suite.addTest(ResourceSyncInfoTest.suite());
- suite.addTest(SynchronizerTest.suite());
return suite;
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFileTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFileTest.java
deleted file mode 100644
index d7fcb0ebc..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFileTest.java
+++ /dev/null
@@ -1,220 +0,0 @@
-package org.eclipse.team.tests.ccvs.core.cvsresources;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-
-import junit.awtui.TestRunner;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
-
-
-public class LocalFileTest extends JUnitTestCase {
-
- ICVSFile file1;
- ICVSFile file1a;
- ICVSFile file2;
- ICVSFolder folder1;
-
- ResourceSyncInfo fileInfo1;
-
- File ioFile;
-
-
- public LocalFileTest(String arg) {
- super(arg);
- }
-
- public static void main(String[] args) {
- TestRunner.run(LocalFileTest.class);
- }
-
-
- public void setUp() throws CVSException {
-
- String tmpEntryLine1;
-
-
- String root = ":server:user:pwd@test:/home";
- String repo = "repository";
- folder1 = getManagedFolder("proj1");
- folder1.mkdir();
- folder1.setFolderSyncInfo(new FolderSyncInfo(repo,root,null,false));
-
- file1 = folder1.getFile("file1.txt");
- file1a = folder1.getFile("file1.txt");
- file2 = folder1.getFile("file2.txt");
-
- tmpEntryLine1 = "/.vcm_meta/1.1/Thu Sep 27 18:00:16 2001/-kb/TmyTag";
- fileInfo1 = new ResourceSyncInfo(tmpEntryLine1,null,null);
-
- ioFile = getFile("proj1/file1.txt");
-
- }
-
- public void tearDown() throws CVSException {
- folder1.delete();
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)folder1).getLocalFile(), new NullProgressMonitor());
- assertSynchronizerEmpty();
- assertTrue(!folder1.exists());
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(LocalFileTest.class);
- return suite;
- }
-
- public void testFileInfo() throws CVSException {
-
- String entryLine1;
- String entryLine2;
- String entryLine3;
- boolean fail=false;
-
- entryLine1 = "/.vcm_meta/1.1/27 Sep 2001 18:00:16/-kb/TmyTag";
- entryLine2 = "/file1.txt/1.1/27 Sep 2001 18:00:16/-kb/TmyTag";
- entryLine3 = "/file1.txt/1.2/27 Sep 2001 18:00:16/-kb/TmyTag";
-
- ResourceSyncInfo fileInfo1 = new ResourceSyncInfo(entryLine1,null,null);
- ResourceSyncInfo fileInfo2 = new ResourceSyncInfo(entryLine2,null,null);
- ResourceSyncInfo fileInfo3 = new ResourceSyncInfo(entryLine3,null,null);
-
- file1.setSyncInfo(fileInfo2);
-
- assertEquals(file1a.getSyncInfo(),fileInfo2);
-
- file1a.setSyncInfo(fileInfo3);
-
- assertEquals(file1.getSyncInfo(),fileInfo3);
- }
-
-// public void testSendReceive() throws Exception {
-//
-// String sendTxt;
-// String expectTxt;
-// InputStream in;
-//
-// sendTxt = "This is my text";
-// expectTxt = sendTxt.length() + "\n" + sendTxt;
-//
-// byte[] result = new byte[sendTxt.length()];
-//
-// PipedInputStream pIn;
-// PipedOutputStream pOut;
-//
-// pIn = new PipedInputStream();
-// pOut = new PipedOutputStream(pIn);
-//
-// in = new BufferedInputStream(pIn,sendTxt.length());
-//
-// pOut.write(sendTxt.getBytes());
-// file1.receiveFrom(in,sendTxt.length(),false,false, new NullProgressMonitor());
-// in.close();
-// pOut.close();
-//
-// result = new byte[expectTxt.length()];
-// pIn = new PipedInputStream();
-// pOut = new PipedOutputStream(pIn);
-//
-// in = new BufferedInputStream(pIn,sendTxt.length());
-// file1.sendTo(pOut,false, new NullProgressMonitor());
-// in.read(result);
-// in.close();
-// pOut.close();
-//
-// assertEquals(new String(result),expectTxt);
-// }
-
- public void testTimestamp() throws Exception {
-
- String timeStamp;
-
- ioFile.createNewFile();
- timeStamp = "Tue Oct 30 14:38:16 2001";
-
- file1.setTimeStamp(timeStamp);
- assertEquals(timeStamp, file1a.getTimeStamp());
-
- }
-
- public void testIsDirty() throws Exception {
-
- String timeStamp;
- String entryLine;
- ResourceSyncInfo fileInfo;
-
- ioFile.createNewFile();
- timeStamp = "Tue Oct 30 14:38:16 2001";
- entryLine = "/file1.txt/1.1/Tue Oct 30 14:38:16 2001/-kb/TmyTag";
-
- file1.setTimeStamp(timeStamp);
- timeStamp = file1.getTimeStamp();
-
- fileInfo = new ResourceSyncInfo(entryLine,null,timeStamp);
-
- file1.setSyncInfo(fileInfo);
-
- assertEquals(false, file1.isDirty());
-
- // touch the file
- writeToFile(ioFile,readFromFile(ioFile));
-
- assertEquals(true, file1.isDirty());
-
- file1.setTimeStamp(timeStamp);
-
- assertEquals(false, file1.isDirty());
- }
-
- // ---------------- Here the resource-tests start ---------------
-
- public void testExists() throws Exception {
-
- file1.delete();
- assertEquals(false, file1.exists());
- writeToFile(ioFile,new String[0]);
- assertEquals(true, file1.exists());
-
- }
-
- public void testGetName() {
- assertEquals("file1.txt", file1.getName());
- }
-
- public void testGetParent() {
- assertEquals(folder1,file1.getParent());
- }
-
- public void testGetRelativePath() throws CVSException {
- assertEquals("file1.txt", file1.getRelativePath(folder1));
- }
-
- public void testIsFolder() {
- assertEquals(false, file1.isFolder());
- }
-
- public void testIsManaged() throws CVSException {
-
- ResourceSyncInfo fileInfo2 = new ResourceSyncInfo("/file1.txt/1.1/27 Sep 2001 18:00:16/-kb/TmyTag",null,null);
-
- assertEquals(false, file1.isManaged());
- file1.setSyncInfo(fileInfo2);
- assertEquals(true, file1.isManaged());
-
- }
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFolderTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFolderTest.java
deleted file mode 100644
index 57913e7fb..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/LocalFolderTest.java
+++ /dev/null
@@ -1,446 +0,0 @@
-package org.eclipse.team.tests.ccvs.core.cvsresources;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import java.io.File;
-import java.io.IOException;
-
-import junit.awtui.TestRunner;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
-
-public class LocalFolderTest extends JUnitTestCase {
-
- ICVSFile file1;
- ICVSFile file1a;
- ICVSFile file2;
-
- ICVSFolder folder1;
- ICVSFolder folder1a;
- ICVSFolder folder2;
-
- String entryLine1;
- String entryLine2;
- String entryLineExtra1;
- String entryLineExtra2;
- String entryLineExtra3;
-
- String root;
- String repo;
- String root2;
- String repo2;
-
- ResourceSyncInfo fileInfo1;
-
- FolderSyncInfo folderInfo1;
- FolderSyncInfo folderInfo2;
-
- File ioFile1;
-
- public LocalFolderTest(String arg) {
- super(arg);
- }
-
- public static void main(String[] args) {
- TestRunner.run(LocalFolderTest.class);
- }
-
- /**
- * Leaves this file-structure:
- *
- * test (folder1, folder1a)
- * proj1 (folder2, ioFolder2) *** Does not exist ***
- * file1.txt (file1, file1a)
- * file2.txt (file2) *** Does not exist ***
- */
- public void setUp() throws CVSException, IOException {
-
- folder1 = getManagedFolder("test");
- folder1a = getManagedFolder("test");
- folder2 = folder1.getFolder("proj1");
- folder1.mkdir();
- assertTrue(folder1.exists());
-
- file1 = folder1.getFile("file1.txt");
- file1a = folder1.getFile("file1.txt");
- file2 = folder1.getFile("file2.txt");
-
- root = ":server:user:pwd@test:/home";
- repo = "repository";
- root2 = ":method:user:pwd@test2:/home/myFolder/repo";
- repo2 = "proj1/subdir";
-
- folderInfo1 = new FolderSyncInfo(repo,root,null,false);
- folderInfo2 = new FolderSyncInfo(repo2,root2,null,true);
-
- entryLine1 = "/.vcm_meta/1.1/27 Sep 2001 18:00:16/-kb/TmyTag";
- entryLine2 = "/file3.txt/1.1/27 Sep 2001 18:00:16/-kb/TmyTag";
- entryLineExtra1 = "/file1.txt/1.1/27 Sep 2001 18:00:16/-kb/TmyTag";
- entryLineExtra2 = "/file1.txt/1.2/27 Sep 2001 18:00:16/-kb/TmyTag";
- entryLineExtra3 = "/file2.txt/1.2/27 Sep 2001 18:00:16/-kb/TmyTag";
-
- folder1.setFolderSyncInfo(folderInfo1);
-
- fileInfo1 = new ResourceSyncInfo(entryLineExtra1,null,null);
- file1.setSyncInfo(fileInfo1);
-
- ioFile1 = getFile("test/file1.txt");
- ioFile1.createNewFile();
-
- }
-
- public void tearDown() throws CVSException {
- folder1.delete();
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)folder1).getLocalFile(), new NullProgressMonitor());
- assertSynchronizerEmpty();
- assertTrue(!folder1.exists());
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(LocalFolderTest.class);
- return suite;
- }
-
- public void testGetFolders() throws CVSException {
-
- // tests setFolderSyncInfo and getFolderSyncInfo as well
-
- boolean fail = false;
- ICVSFolder folder3;
- ICVSFolder tmpFolder;
- ICVSFolder[] resultFolders;
-
- folder3 = folder1.getFolder("folder3");
- folder3.mkdir();
-
- resultFolders = folder2.getFolders();
- assertEquals(0, resultFolders.length);
-
- // For the moment we assume, that seting a folderInfo
- // does not create the folder automatically but you
- // have to create it with mkdir.
- try {
- folder2.setFolderSyncInfo(folderInfo1);
- fail();
- } catch (Exception e) {
- }
-
- resultFolders = folder1.getFolders();
- assertEquals(1, resultFolders.length);
-
- folder2.mkdir();
-
- resultFolders = folder1.getFolders();
- assertEquals(2, resultFolders.length);
-
- folder2.delete();
-
- resultFolders = folder1.getFolders();
- assertEquals(1, resultFolders.length);
-
- folder2.mkdir();
- folder2.setFolderSyncInfo(folderInfo1);
-
- resultFolders = folder1.getFolders();
- assertEquals(2, resultFolders.length);
-
- folder2.delete();
-
- resultFolders = folder1.getFolders();
- assertEquals(2, resultFolders.length);
-
- tmpFolder = folder1.getFolder("proj1");
- assertEquals(false,tmpFolder.exists());
- assertEquals(true,tmpFolder.isManaged());
- }
-
- public void testGetFiles() throws Exception {
- // tests setFolderSyncInfo and getFolderSyncInfo as well
-
- boolean fail = false;
- ICVSFile[] resultFiles;
- ICVSFile file3;
- File ioFile3;
- ResourceSyncInfo fileInfo2;
-
- file3 = folder1.getFile("file3.txt");
- ioFile3 = getFile("test/file3.txt");
-
- // From here we check if the filelist does include files,
- // that are added locally but not as entries (and exclude them
- // again when we delete them)
- resultFiles = folder1.getFiles();
- assertEquals(1, resultFiles.length);
-
- ioFile3.createNewFile();
-
- resultFiles = folder1.getFiles();
- assertEquals(2, resultFiles.length);
-
- ioFile3.delete();
-
- resultFiles = folder1.getFiles();
- assertEquals(1, resultFiles.length);
-
- // Here is tested if we get files that do not exist locally but
- // in the entries
-
- // first we try a fileinfo with the wrong name
- try {
- file3.setSyncInfo(fileInfo1);
- } catch (Throwable e) {fail = true;}
- assertTrue(fail);
- fail = false;
-
- fileInfo2 = new ResourceSyncInfo(entryLine2,null,null);
-
- file3.setSyncInfo(fileInfo2);
-
- resultFiles = folder1.getFiles();
- assertEquals(2, resultFiles.length);
- assertEquals(false,file3.exists());
- assertEquals(true,file3.isManaged());
-
- file3.unmanage();
-
- resultFiles = folder1.getFiles();
- assertEquals(1, resultFiles.length);
- assertEquals(false,file3.exists());
- assertEquals(false,file3.isManaged());
- }
-
- public void testGetChild() throws CVSException {
-
- try {
- folder1.getChild("proj1");
- assertTrue(false);
- } catch (CVSException e) {}
-
- try {
- folder1.getChild("file2.txt");
- assertTrue(false);
- } catch (CVSException e) {}
-
- folder2.mkdir();
-
- assertEquals(true, folder1.getChild("proj1").isFolder());
- assertEquals("proj1", folder1.getChild("proj1").getName());
- assertEquals(false, folder1.getChild("file1.txt").isFolder());
-
- }
-
- // ---------------- Here the resource-tests start ---------------
-
- public void testExists() throws Exception {
- assertEquals(false, folder2.exists());
- folder2.mkdir();
- assertEquals(true, folder2.exists());
- folder2.delete();
- assertEquals(false, folder2.exists());
- }
-
- public void testGetName() throws CVSException {
- assertEquals("proj1", folder2.getName());
- folder2.mkdir();
- assertEquals("proj1", folder2.getName());
- }
-
- public void testGetParent() {
- assertEquals(folder1,folder2.getParent());
- }
-
- public void testGetRelativePath() throws CVSException {
- ICVSFolder subFolder1;
- ICVSFolder subFolder2;
- ICVSFolder subFolder3;
- String sep = "/";
-
- boolean fail = false;
-
- subFolder1 = folder1.getFolder("proj1");
- subFolder2 = subFolder1.getFolder("proj2");
- subFolder3 = subFolder2.getFolder("proj3");
-
- assertEquals("proj1", folder2.getRelativePath(folder1));
- assertEquals("testGetRelativeLocation.1","proj1", subFolder1.getRelativePath(folder1));
- assertEquals("testGetRelativeLocation.2","proj1" + sep + "proj2" + sep + "proj3", subFolder3.getRelativePath(folder1));
- assertEquals("testGetRelativeLocation.3","proj2", subFolder2.getRelativePath(subFolder1));
- assertEquals("testGetRelativeLocation.3a","", subFolder2.getRelativePath(subFolder2));
-
- try {
- subFolder1.getRelativePath(subFolder2);
- } catch (CVSException e) {fail = true;}
- assertTrue("testGetRelativeLocation.4",fail);
- fail = false;
-
- subFolder1.delete();
- }
-
- public void testIsFolder() {
- assertEquals(true, folder2.isFolder());
- }
-
- public void testFolderIsManaged() throws CVSException {
- ICVSFolder folder = getManagedFolder("testIsManaged");
- folder.mkdir();
- assertEquals(null, folder.getFolderSyncInfo());
-
- FolderSyncInfo info = new FolderSyncInfo("module", ":pserver:user@host:/home", null, false);
- folder.setFolderSyncInfo(info);
- assertTrue(folder.isCVSFolder() && !folder.isManaged());
- assertTrue(folder.getFolderSyncInfo().equals(info));
-
- folder.delete();
- reload(folder);
- }
-
- public void testFolderInfo() throws CVSException {
- FolderSyncInfo folderInfo2;
- FolderSyncInfo folderInfo3;
- String repo;
- String root;
-
- repo = "proj1/folder1";
- root = ":pserver:nkram:pwd@fiji:/home/nkrambro/repo";
-
- assertEquals(null, folder2.getFolderSyncInfo());
- assertEquals(false,folder2.isCVSFolder());
-
- folder1.setFolderSyncInfo(folderInfo1);
- folderInfo2 = folder1.getFolderSyncInfo();
-
- assertEquals(true,folder1.isCVSFolder());
- assertEquals(this.root,folderInfo2.getRoot());
- assertEquals(this.repo,folderInfo2.getRepository());
-
- folder1.unmanage();
-
- assertEquals(false,folder1.isCVSFolder());
- assertEquals(null,folder1.getFolderSyncInfo());
-
- folderInfo3 = new FolderSyncInfo(repo,root,folderInfo2.getTag(),false);
-
- folder1.setFolderSyncInfo(folderInfo3);
-
- assertEquals(root,folder1.getFolderSyncInfo().getRoot());
- assertEquals(repo,folder1.getFolderSyncInfo().getRepository());
- assertEquals("/home/repository",folderInfo2.getRemoteLocation());
- }
-
- public void testsetSyncInfo() throws CVSException {
- String entry1 = "/file1.txt/a/b/c/";
- String entry2 = "/file1.txt/b/b/c/";
- String entry3 = "/file2.txt/b/b/c/";
-
- ResourceSyncInfo info1 = new ResourceSyncInfo(entry1,null,null);
- ResourceSyncInfo info2 = new ResourceSyncInfo(entry2,null,null);
- ResourceSyncInfo info3 = new ResourceSyncInfo(entry3,null,null);
-
- ICVSFile file1 = this.file1;
- ICVSFile file2 = folder1.getFile("file2.txt");
-
- assertEquals(1,folder1.getFiles().length);
- file1.setSyncInfo(info1);
- assertEquals(1,folder1.getFiles().length);
- file1.setSyncInfo(info2);
- assertEquals(1,folder1.getFiles().length);
- file2.setSyncInfo(info3);
- assertEquals(2,folder1.getFiles().length);
-
- assertEquals(entry2,file1.getSyncInfo().getEntryLine(true));
- assertEquals(entry3,file2.getSyncInfo().getEntryLine(true));
-
- // The two files in the getFiles are acctually the files
- // we put in there
- assertTrue( ( folder1.getFiles()[0].equals(file1) ||
- folder1.getFiles()[0].equals(file2)) &&
- ( folder1.getFiles()[1].equals(file1) ||
- folder1.getFiles()[1].equals(file2)));
- }
-
- public void testSimpleGetFiles() throws CVSException {
- // When a file is added to the entries it should be in the list
- // of files afterwards ... this should be one of the current problems
- file2.setSyncInfo(new ResourceSyncInfo(entryLineExtra3,null,null));
- assertEquals(2,folder1.getFiles().length);
- file2.unmanage();
- assertEquals(1,folder1.getFiles().length);
- }
-
- public void testSimpleResourceSyncInfo() throws Exception {
-
- assertEquals(file1a.getSyncInfo(), fileInfo1);
-
- file1a.setSyncInfo(new ResourceSyncInfo(entryLineExtra2,null,null));
-
- assertEquals(file1.getSyncInfo().getEntryLine(true),entryLineExtra2);
-
- file1a.setSyncInfo(new ResourceSyncInfo(entryLineExtra1,null,null));
-
- assertEquals(file1.getSyncInfo().getEntryLine(true),entryLineExtra1);
-
- file1a.setSyncInfo(new ResourceSyncInfo(entryLineExtra2,null,null));
-
- assertEquals(file1.getSyncInfo().getEntryLine(true),entryLineExtra2);
- }
-
- public void testSimpleFolderSyncInfo() throws Exception {
- folder1.setFolderSyncInfo(folderInfo2);
- assertEquals(folder1.getFolderSyncInfo().getRepository(),repo2);
- assertEquals(folder1.getFolderSyncInfo().getRoot(),root2);
- assertEquals(folder1.getFolderSyncInfo().getIsStatic(),true);
-
- reload(folder1);
- assertEquals(folder1.getFolderSyncInfo().getRepository(),repo2);
- assertEquals(folder1.getFolderSyncInfo().getRoot(),root2);
- assertEquals(folder1.getFolderSyncInfo().getIsStatic(),true);
-
- folder1.setFolderSyncInfo(folderInfo1);
- assertEquals(folder1a.getFolderSyncInfo().getRepository(),repo);
- assertEquals(folder1a.getFolderSyncInfo().getRoot(),root);
- assertEquals(folder1a.getFolderSyncInfo().getIsStatic(),false);
- }
-
- public void testSyncIsCvsFolder() throws Exception {
-
- folder1.delete();
- reload(folder1);
- assertEquals(false,folder1.isCVSFolder());
-
- folder1.mkdir();
- assertEquals(false,folder1.isCVSFolder());
-
- folder1.setFolderSyncInfo(folderInfo1);
- assertEquals(true,folder1.isCVSFolder());
- assertEquals(false,folder1.isManaged());
-
- assertEquals(false,folder2.isCVSFolder());
-
- folder2.mkdir();
- assertEquals(false,folder2.isCVSFolder());
- assertEquals(false,folder2.isManaged());
-
- folder2.setFolderSyncInfo(folderInfo2);
- assertEquals(true,folder2.isCVSFolder());
- assertEquals(true,folder2.isManaged());
- }
-
- protected void reload(ICVSResource resource) throws CVSException {
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)resource).getLocalFile(), new NullProgressMonitor());
- }
-
- protected void save(ICVSResource resource) throws CVSException {
- CVSProviderPlugin.getSynchronizer().save(((LocalResource)resource).getLocalFile(), new NullProgressMonitor());
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/SynchronizerTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/SynchronizerTest.java
deleted file mode 100644
index f639f6318..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/SynchronizerTest.java
+++ /dev/null
@@ -1,253 +0,0 @@
-package org.eclipse.team.tests.ccvs.core.cvsresources;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-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.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.ccvs.core.CVSTag;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
-import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
-import org.eclipse.team.internal.ccvs.core.resources.LocalResource;
-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.SyncFileUtil;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-public class SynchronizerTest extends EclipseTest {
-
- public SynchronizerTest() {
- super();
- }
-
- public SynchronizerTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(SynchronizerTest.class);
- return new CVSTestSetup(suite);
- }
-
- protected File getSyncFile(File parent, String syncFileName) {
- return new File(SyncFileUtil.getCVSSubdirectory(parent), syncFileName);
- }
-
- protected void appendLineToFile(File file, String line) throws IOException {
-
- BufferedReader fileReader;
- List fileContentStore = new ArrayList();
-
- if (!file.exists()) {
- return;
- }
-
- String l;
- fileReader = new BufferedReader(new FileReader(file));
- while ((l = fileReader.readLine()) != null) {
- fileContentStore.add(l);
- }
- fileReader.close();
-
- String[] content = (String[]) fileContentStore.toArray(new String[fileContentStore.size()]);
- String[] newContent;
-
- newContent = new String[content.length + 1];
- System.arraycopy(content,0,newContent,0,content.length);
- newContent[content.length] = line;
-
- file.delete();
-
- BufferedWriter fileWriter;
-
- fileWriter = new BufferedWriter(new FileWriter(file));
- for (int i = 0; i<newContent.length; i++) {
- fileWriter.write(newContent[i]);
- fileWriter.newLine();
- }
- fileWriter.close();
- }
-
- public void testFolderSync() throws CoreException, CVSException {
- IProject project = getUniqueTestProject("testFolderSync");
- IResource[] resources = buildResources(project, new String[] {"a.txt", "folder1/", "folder1/b.txt", "folder2/", "folder2/c.txt"}, true);
- ensureExistsInFileSystem(resources);
- IFolder folder1 = project.getFolder("folder1");
- IFolder folder2 = project.getFolder("folder2");
- File folder1File = folder1.getLocation().toFile();
- File folder2File = folder2.getLocation().toFile();
- File projectFile = project.getLocation().toFile();
- ICVSResource cvsProject = new LocalFolder(projectFile);
-
- // 1.
-
- try {
- CVSProviderPlugin.getSynchronizer().setFolderSync(new File("dummy"), new FolderSyncInfo("repo", "root", null, false));
- fail();
- } catch(Exception e) {
- }
-
- // 2.
-
- FolderSyncInfo info = new FolderSyncInfo("repo", "root", null, false);
- CVSProviderPlugin.getSynchronizer().setFolderSync(projectFile, info);
- assertTrue(CVSProviderPlugin.getSynchronizer().getFolderSync(projectFile).equals(info));
- assertTrue(CVSProviderPlugin.getSynchronizer().members(projectFile).length == 0);
-
- // 3.
-
- info = new FolderSyncInfo("repo", "root", new CVSTag("v1", CVSTag.BRANCH), true);
- CVSProviderPlugin.getSynchronizer().setFolderSync(folder1File, info);
- assertTrue(CVSProviderPlugin.getSynchronizer().getFolderSync(folder1File).equals(info));
- assertTrue(CVSProviderPlugin.getSynchronizer().members(projectFile).length == 1);
-
- // 4.
-
- CVSProviderPlugin.getSynchronizer().setFolderSync(folder2File, info);
- assertTrue(CVSProviderPlugin.getSynchronizer().getFolderSync(folder2File).equals(info));
- assertTrue(CVSProviderPlugin.getSynchronizer().members(projectFile).length == 2);
- }
-
- public void testDeleteListener() throws CoreException, CVSException, TeamException {
- IProject project = createProject("testDeleteListener", new String[] {"a.txt", "folder1/", "folder1/b.txt"});
- IFolder folder1 = project.getFolder("folder1");
- IFile file1 = folder1.getFile("b.txt");
- ICVSFolder cvsFolder = new LocalFolder(folder1.getLocation().toFile());
- ICVSFolder cvsProject = new LocalFolder(project.getLocation().toFile());
- ICVSFile cvsfile = new LocalFile(file1.getLocation().toFile());
-
- // 1. delete of a folder deletes sync info deep
-
- FolderSyncInfo info = cvsFolder.getFolderSyncInfo();
- assertTrue(info!=null);
-
- folder1.delete(true, new NullProgressMonitor());
-
- assertTrue(cvsFolder.getFolderSyncInfo()==null);
- assertTrue(cvsfile.getSyncInfo()==null);
-
- // 2. rename of a project deletes cached sync info of source project
-
- project.move(new Path("movedProject"), true, new NullProgressMonitor());
-
- assertTrue(cvsProject.getFolderSyncInfo()==null);
- }
-
- public void testResourceSync() throws CVSException, CoreException, TeamException {
- IProject project = createProject("testResourceSync", new String[] {"a.txt", "folder1/", "folder1/b.txt"});
- IFolder folder1 = project.getFolder("folder1");
- IFile file1 = project.getFile("a.txt");
- IFile newFile = folder1.getFile("c.txt");
- IFolder newFolder = project.getFolder("folder2");
- ICVSFolder cvsFolder = new LocalFolder(folder1.getLocation().toFile());
- ICVSFolder cvsNewFolder = new LocalFolder(newFolder.getLocation().toFile());
- ICVSFile cvsFile = new LocalFile(file1.getLocation().toFile());
- ICVSFile cvsNewFile = new LocalFile(newFile.getLocation().toFile());
- ICVSFolder cvsProject = new LocalFolder(project.getLocation().toFile());
-
- // 1.
-
- assertTrue(!cvsProject.isManaged());
- assertTrue(cvsProject.isCVSFolder());
- assertTrue(cvsFile.getSyncInfo()!=null);
- assertTrue(cvsFolder.getSyncInfo()!=null);
-
- assertTrue(cvsNewFile.getSyncInfo()==null);
- assertTrue(cvsNewFolder.getSyncInfo()==null);
-
- // 2.
-
- ResourceSyncInfo folderInfo = new ResourceSyncInfo(cvsNewFolder.getName());
- ResourceSyncInfo fileInfo = new ResourceSyncInfo(cvsNewFile.getName(), "1.1", "timestamp", "-kb", null, null);
-
- cvsNewFile.setSyncInfo(fileInfo);
- cvsNewFolder.setSyncInfo(folderInfo);
-
- assertTrue(cvsNewFile.getSyncInfo().equals(fileInfo));
- assertTrue(cvsNewFolder.getSyncInfo().equals(folderInfo));
-
- save(cvsProject);
-
- assertTrue(cvsNewFile.getSyncInfo().equals(fileInfo));
- assertTrue(cvsNewFolder.getSyncInfo().equals(folderInfo));
- }
-
- public void testReload() throws CVSException, CoreException, TeamException, IOException {
- IProject project = createProject("testReload", new String[] {"a.txt", "folder1/", "folder1/b.txt", "folder2/", "folder2/folder2a/", "folder2/folder2a/b.txt", "folder3/b.txt"});
-
- File projectFile = project.getLocation().toFile();
- IFile newFile = project.getFile("b.txt");
- newFile.create(getRandomContents(), true, null);
- IFolder folder1 = project.getFolder("folder1");
- IFolder newFolder = project.getFolder("newFolder");
- newFolder.create(true, true, null);
- ICVSFolder cvsProject = new LocalFolder(project.getLocation().toFile());
- ICVSFile cvsNewFile = new LocalFile(newFile.getLocation().toFile());
- ICVSFolder cvsNewFolder = new LocalFolder(newFolder.getLocation().toFile());
- ICVSFolder cvsFolder = new LocalFolder(folder1.getLocation().toFile());
-
- // 1. update entry from outside of synchronizer then reload
- assertTrue(cvsNewFile.getSyncInfo()==null);
- assertTrue(cvsNewFolder.getSyncInfo()==null);
- assertTrue(cvsFolder.getFolderSyncInfo()!=null);
-
- ResourceSyncInfo fileInfo = new ResourceSyncInfo("/b.txt/1.1/Thu Aug 30 15:31:40 2001/-kb/", null, null);
- ResourceSyncInfo folderInfo = new ResourceSyncInfo("newFolder");
-
- folder1.delete(true, true, null);
-
- appendLineToFile(getSyncFile(project.getLocation().toFile(), SyncFileUtil.ENTRIES), fileInfo.getEntryLine(true));
- appendLineToFile(getSyncFile(project.getLocation().toFile(), SyncFileUtil.ENTRIES), folderInfo.getEntryLine(true));
-
- reload(cvsProject);
-
- assertTrue(cvsNewFile.getSyncInfo().equals(fileInfo));
- assertTrue(cvsNewFolder.getSyncInfo().equals(folderInfo));
- assertTrue(cvsFolder.getFolderSyncInfo()==null);
- assertTrue(new LocalFile(new File(folder1.getLocation().toFile(), "b.txt")).getSyncInfo()==null);
-
- // 2. delete multiple directory hierarchy and reload should delete everything from cache
- IFolder folder2 = project.getFolder("folder2");
- IFolder folder2a = folder2.getFolder("folder2a");
- ICVSFolder folder2aFile = new LocalFolder(folder2a.getLocation().toFile());
- ICVSFolder folder2File = new LocalFolder(folder2.getLocation().toFile());
-
- folder2File.unmanage();
- assertTrue(folder2File.exists());
- assertTrue(folder2File.getSyncInfo()==null);
- assertTrue(folder2aFile.getSyncInfo()==null);
- assertTrue(folder2File.getFolderSyncInfo()==null);
- assertTrue(folder2File.getFolderSyncInfo()==null);
- }
-
- protected void reload(ICVSResource resource) throws CVSException {
- CVSProviderPlugin.getSynchronizer().reload(((LocalResource)resource).getLocalFile(), new NullProgressMonitor());
- }
-
- protected void save(ICVSResource resource) throws CVSException {
- CVSProviderPlugin.getSynchronizer().save(((LocalResource)resource).getLocalFile(), new NullProgressMonitor());
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTests.java
index c8dbe6717..abcc3ef25 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTests.java
@@ -38,4 +38,4 @@ public class AllTests extends EclipseTest {
suite.addTest(SyncElementTest.suite());
return new CVSTestSetup(suite);
}
-}
+} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
index 451b2612e..03c3ddd4a 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
@@ -3,7 +3,6 @@ package org.eclipse.team.tests.ccvs.core.provider;
* (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import junit.framework.Test;
@@ -16,7 +15,6 @@ import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
import org.eclipse.team.tests.ccvs.core.EclipseTest;
import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
@@ -49,6 +47,7 @@ public class CVSProviderTest extends EclipseTest {
public void testAdd() throws TeamException, CoreException {
// Test add with cvsignores
+ /*
IProject project = createProject("testAdd", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
IFile file = project.getFile(".cvsignore");
file.create(new ByteArrayInputStream("ignored.txt".getBytes()), false, null);
@@ -65,13 +64,14 @@ public class CVSProviderTest extends EclipseTest {
getProvider(project).add(new IResource[] {project}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
- assertTrue( ! Session.getManagedResource(project.getFile("ignored.txt")).isManaged());
- assertTrue( ! Session.getManagedResource(project.getFile("folder1/ignored.txt")).isManaged());
+ assertTrue( ! CVSWorkspaceRoot.getCVSResourceFor(project.getFile("ignored.txt")).isManaged());
+ assertTrue( ! CVSWorkspaceRoot.getCVSResourceFor(project.getFile("folder1/ignored.txt")).isManaged());
- assertTrue(Session.getManagedResource(project.getFile("notignored.txt")).isManaged());
- assertTrue(Session.getManagedResource(project.getFile("folder1/notignored.txt")).isManaged());
- assertTrue(Session.getManagedResource(project.getFile(".cvsignore")).isManaged());
- assertTrue(Session.getManagedResource(project.getFile("folder1/.cvsignore")).isManaged());
+ assertTrue(CVSWorkspaceRoot.getCVSResourceFor(project.getFile("notignored.txt")).isManaged());
+ assertTrue(CVSWorkspaceRoot.getCVSResourceFor(project.getFile("folder1/notignored.txt")).isManaged());
+ assertTrue(CVSWorkspaceRoot.getCVSResourceFor(project.getFile(".cvsignore")).isManaged());
+ assertTrue(CVSWorkspaceRoot.getCVSResourceFor(project.getFile("folder1/.cvsignore")).isManaged());
+ */
}
public void testDelete() throws TeamException, CoreException {
@@ -218,6 +218,5 @@ public class CVSProviderTest extends EclipseTest {
getProvider(copy).get(new IResource[] {copy}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
assertEquals(project, copy);
}
-
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CommandsTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CommandsTest.java
deleted file mode 100644
index c637a694e..000000000
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CommandsTest.java
+++ /dev/null
@@ -1,513 +0,0 @@
-package org.eclipse.team.tests.ccvs.core.provider;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-import java.io.File;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.util.FileUtil;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
-
-/**
- * This class tests the basic functionality of the Eclipse CVS client
- * and can be used to test basic sanity.
- *
- * It does not run against another cvs client.
- */
-public class CommandsTest extends JUnitTestCase {
-
-
- static final String PLATFORM_NEWLINE = System.getProperty("line.separator");
-
- private File ioFolder1;
- private File ioFolder2;
- private File ioFolder3;
- private File ioFolder4;
-
- private String[] arguments;
-
- private boolean isSetUp = false;
-
- public static void main(String[] args) {
- run(CommandsTest.class);
- }
-
- public void setUp() throws Exception {
- if (!isSetUp) {
- try {
- createRemoteProject("proj1", new String[] { "folder1/c.txt", "folder1/d.txt", "folder2/test.flag"});
- } catch (Exception e) {
- System.err.println("Could not setup repository");
- }
- isSetUp = true;
- }
- ioFolder1 = getFile("test1");
- ioFolder2 = getFile("test2");
- ioFolder3 = getFile("test2/proj1");
- ioFolder4 = getFile("test2/proj1/folder1");
-
- FileUtil.deepDelete(ioFolder1);
- FileUtil.deepDelete(ioFolder2);
- ioFolder1.mkdir();
- ioFolder2.mkdir();
-
- }
-
- public void tearDown() throws CVSException {
- FileUtil.deepDelete(ioFolder1);
- FileUtil.deepDelete(ioFolder2);
- }
-
- public CommandsTest() {
- super("CommandsTest");
- arguments = new String[]{"proj1"};
- }
-
- public CommandsTest(String name) {
- super(name);
- arguments = new String[]{"proj1"};
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(CommandsTest.class);
- return new CVSTestSetup(suite);
- }
-
- /**
- * This should somehow create the following file-structure:
- *
- * temp
- * test1
- * proj1
- * CVS
- * folder1
- * CVS
- * c.txt
- * d.txt
- * folder2
- * CVS
- * test.flag
- * test2
- * proj1
- * CVS
- * folder1
- * CVS
- * c.txt
- * d.txt
- * folder2
- * CVS
- * test.flag
- *
- * where the cvs-folder contains the appropiate files including
- * the appropiated Entries-files
- */
- public void subTestCeckout() throws CVSException {
-
- execute("co",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder1,
- monitor,
- System.err);
-
- execute("co",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder2,
- monitor,
- System.err);
- }
-
- public void testCommitFiles() throws Exception {
- subTestCeckout();
- subTestCommitUpdate();
- }
-
- /**
- * Made for checking the ability of the client to cope with
- * multible folders and files as arguments
- */
- public void testDoubleRound() throws Exception {
-
- File folder1;
- File folder2;
-
- File file1a;
- File file2a;
- File file3a;
- File file4a;
-
- File file1b;
- File file2b;
- File file3b;
- File file4b;
-
- folder1 = ioFolder1;
- folder2 = ioFolder2;
-
- file1a = new File(folder1,"coProject1/a.txt");
- file2a = new File(folder1,"coProject2/a.txt");
- file3a = new File(folder2,"coProject1/a.txt");
- file4a = new File(folder2,"coProject2/a.txt");
-
- file1b = new File(folder1,"coProject1/f1/b.txt");
- file2b = new File(folder1,"coProject2/f1/b.txt");
- file3b = new File(folder2,"coProject1/f1/b.txt");
- file4b = new File(folder2,"coProject2/f1/b.txt");
-
-
- // Do the setup ...
- createRemoteProject("coProject1",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt"});
- createRemoteProject("coProject2",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt"});
-
- execute("co",
- globalOptions,
- EMPTY_ARGS,
- new String[]{"coProject1","coProject2"},
- folder1,
- monitor,
- System.err);
-
- execute("co",
- globalOptions,
- EMPTY_ARGS,
- new String[]{"coProject1","coProject2"},
- folder2,
- monitor,
- System.err);
-
- // Change the two projects
- appendToFile(file1a,"AppendIt The first");
- appendToFile(file2a,"AppendIt The second");
-
- appendToFile(file1b,"AppendIt The first");
- appendToFile(file2b,"AppendIt The second");
-
- // Send the two projects to the server
- execute("ci",
- globalOptions,
- new String[]{"-m","msg" + PLATFORM_NEWLINE + "second Line"},
- new String[]{"coProject1","coProject2"},
- folder1,
- monitor,
- System.err);
-
- execute("update",
- globalOptions,
- EMPTY_ARGS,
- new String[]{"coProject1","coProject2"},
- folder2,
- monitor,
- System.err);
-
- // Look if all the changes have been done allright
- assertEqualsArrays(readFromFile(file1a),readFromFile(file3a));
- assertEqualsArrays(readFromFile(file2a),readFromFile(file4a));
-
- assertEqualsArrays(readFromFile(file1b),readFromFile(file3b));
- assertEqualsArrays(readFromFile(file2b),readFromFile(file4b));
-
-
- // Now check if the programm works with single files
- appendToFile(file1a,"AppendIt The EXTRA");
- appendToFile(file1b,"AppendIt The EXTRA");
- execute("ci",
- globalOptions,
- new String[]{"-m","msg"},
- new String[]{"coProject1/a.txt"},
- folder1,
- monitor,
- System.err);
-
- execute("update",
- globalOptions,
- EMPTY_ARGS,
- new String[]{"coProject1/a.txt"},
- folder2,
- monitor,
- System.err);
-
- // It should have the 1a file updated but not the 1b file
- // because we did not upload and commit it
- assertEqualsArrays(readFromFile(file1a),readFromFile(file3a));
- try {
- assertEqualsArrays(readFromFile(file1b),readFromFile(file3b));
- throw new IllegalArgumentException("Fail-Statment");
- } catch (AssertionFailedError e) {}
- }
-
- /**
- * This TestCase should maybe become simpler.
- *
- * Anyway, it is about Up and downloading changes
- * without conflicts
- */
- public void subTestCommitUpdate() throws Exception {
-
- File file1;
- File file2;
- String[] fileContent1;
- // String[] fileContent2;
- boolean fail = false;
- GregorianCalendar calender;
-
- calender = new GregorianCalendar();
-
- fileContent1 = new String[]{"This is a ", "two-liner", calender.get(Calendar.MILLISECOND) + ""};
- // fileContent2 = new String[]{"This is a one-liner", calender.get(Calendar.MILLISECOND) + 10 + ""};
-
- file1 = getFile("test1/proj1/folder1/c.txt");
- file2 = getFile("test2/proj1/folder1/c.txt");
-
- // change something and commit the canges
- // in client1
- // writeToFile("test1/...", contents)
- writeToFile(file1,fileContent1);
-
- execute("ci",globalOptions,
- new String[]{"-m","TestMessage"},
- arguments,
- ioFolder1,
- monitor,
- System.err);
-
- // test that files in client1 and client2 are unequal before
- try {
- assertEqualsArrays(readFromFile(file1),readFromFile(file2));
- } catch (Throwable e) {
- fail = true;
- }
-
- assertTrue("subTestCommitUpdate.0a (This could happen by coincedence, try again) ",fail);
- fail = false;
-
- execute("update",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder2,
- monitor,
- System.err);
-
- assertEqualsArrays(fileContent1,readFromFile(file2));
-
- }
-
- public void testDifferentFolders() throws Exception {
-
- File file1;
- File file2;
- String[] fileContent1;
- String[] fileContent2;
- boolean fail = false;
- GregorianCalendar calender;
-
- calender = new GregorianCalendar();
-
- // Init the field
- subTestCeckout();
-
- file1 = getFile("test1/proj1/folder1/c.txt");
- file2 = getFile("test2/proj1/folder1/c.txt");
- fileContent1 = new String[]{"This is a ", "two-liner", calender.get(Calendar.MILLISECOND) + ""};
- fileContent2 = new String[]{"This is a one-liner", calender.get(Calendar.MILLISECOND) + 10 + ""};
-
- // First run
- writeToFile(file1,fileContent1);
-
-
- execute("ci",globalOptions,
- new String[]{"-m","TestMessage"},
- arguments,
- ioFolder1,
- monitor,
- System.err);
-
- try {
- assertEqualsArrays(readFromFile(file1),readFromFile(file2));
- } catch (Throwable e) {
- fail = true;
- }
-
- assertTrue("testDifferentFolders.1 (This could happen by coincedence, try again) ",fail);
- fail = false;
-
- // Should be able to set globalOptions to new String[0]
- execute("update",new String[0],
- EMPTY_ARGS,
- new String[0],
- ioFolder4,
- monitor,
- System.err);
-
- assertEqualsArrays(fileContent1,readFromFile(file2));
-
- // Seconde run
- //
- // wait a second to get a new timestamp and
- // check that the resource has acctually a new timestamp
- waitMsec(4000);
- writeToFile(file2,fileContent2);
- assertEquals(true, Session.getManagedFolder(ioFolder4).getFile("c.txt").isModified());
-
- // Should be able to set globalOptions to new String[0]
- execute("ci",new String[0],
- new String[]{"-m","TestMessage"},
- new String[0],
- ioFolder4,
- monitor,
- System.err);
-
- try {
- assertEqualsArrays(readFromFile(file1),readFromFile(file2));
- } catch (Throwable e) {
- fail = true;
- }
-
- assertTrue("testDifferentFolders.3 (This could happen by coincedence, try again) ",fail);
- fail = false;
-
- execute("update",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder1,
- monitor,
- System.err);
-
- assertEqualsArrays(fileContent2,readFromFile(file1));
-
- }
-
- public void testCommit() throws Exception {
-
- File ioFolder = ioFolder1;
-
- execute("co",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder,
- monitor,
- System.err);
-
- GregorianCalendar calender;
-
-
- calender = new GregorianCalendar();
-
- writeToFile(getFile("test1\\proj1\\folder1\\c.txt"), new String[]{"This is my","Test",calender.get(Calendar.MILLISECOND) +""});
-
- execute("ci",globalOptions,
- new String[]{"-m","TestMessage"},
- arguments,
- ioFolder,
- monitor,
- System.err);
- }
-
- public void testConnection() throws CVSException {
-
- File ioFolder = ioFolder1;
-
- execute("co",globalOptions,
- EMPTY_ARGS,
- new String[]{"proj1"},
- ioFolder,
- monitor,
- System.err);
- try {
- execute("co",globalOptions,
- EMPTY_ARGS,
- new String[]{"proj1XXX"},
- ioFolder,
- monitor,
- System.err);
- fail();
- } catch (CVSException e) {}
- }
-
- public void testDoubleCheckout() throws Exception {
-
- createRemoteProject("coProject1",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt"});
- createRemoteProject("coProject2",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt"});
- execute("co",
- globalOptions,
- EMPTY_ARGS,
- new String[]{"coProject1","coProject2"},
- workspaceRoot,
- monitor,
- System.err);
-
- assertTrue(getFile("coProject1/a.txt").exists());
- assertTrue(getFile("coProject1/f1/b.txt").exists());
- assertTrue(getFile("coProject2/a.txt").exists());
- assertTrue(getFile("coProject2/f1/b.txt").exists());
-
- FileUtil.deepDelete(getFile("coProject1"));
- FileUtil.deepDelete(getFile("coProject2"));
-
- }
-
- public void testImport() throws Exception {
- File ioFolder = ioFolder1;
- ICVSFolder mFolder = Session.getManagedFolder(ioFolder);
-
- String[] fileStructure = new String[]{"im/a.txt","im/f1/a.txt","im/f1/b.txt"};
- createRandomFile(ioFolder,fileStructure);
-
- deleteRemoteResource("im");
-
- execute("import",globalOptions,
- new String[]{"-m","Initial Release"},
- new String[]{"im","r1","r2"},
- getFile(mFolder.getFolder("im")),
- new NullProgressMonitor(),
- System.err);
-
- execute("co",globalOptions,
- EMPTY_ARGS,
- new String[]{"im"},
- getFile(mFolder),
- new NullProgressMonitor(),
- System.err);
- }
-
- public void testUpdate() throws CVSException {
-
- File ioFolder = ioFolder1;
-
- execute("co",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder,
- monitor,
- System.err);
-
- try {
- execute("update",globalOptions,
- EMPTY_ARGS,
- new String[0],
- ioFolder,
- monitor,
- System.err);
- fail();
- } catch (CVSException e) {}
-
- execute("update",globalOptions,
- EMPTY_ARGS,
- arguments,
- ioFolder,
- monitor,
- System.err);
- }
-}
-
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java
index f1c72e5b0..ca08933f7 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java
@@ -3,27 +3,35 @@ package org.eclipse.team.tests.ccvs.core.provider;
* (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.internal.plugins.PluginDescriptor;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+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.IPluginRegistry;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.ICVSResource;
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.Session;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
+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;
import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
@@ -85,19 +93,27 @@ public class ModuleTest extends EclipseTest {
isSetUp = true;
}
- protected void uploadProject(String projectName) throws TeamException, IOException {
- // upload the modules definitions file
- PluginDescriptor testPlugin = (PluginDescriptor)Platform.getPluginRegistry().getPluginDescriptor("org.eclipse.team.tests.cvs.core");
- String filePath = testPlugin.getLocation().concat(RESOURCE_PATH + projectName);
- URL url = null;
- try {
- url = new URL (filePath);
- } catch (java.net.MalformedURLException e) {
- assertTrue("Bad URL for " + filePath, true);
- }
+ protected void uploadProject(String projectName) throws TeamException, IOException, CoreException {
+ // locate the test case contents in the plugin resources
+ IPluginRegistry registry = Platform.getPluginRegistry();
+ IPluginDescriptor descriptor = registry.getPluginDescriptor("org.eclipse.team.tests.cvs.core");
+ URL baseURL = descriptor.getInstallURL();
+ URL url = new URL(baseURL, RESOURCE_PATH + projectName);
+ url = Platform.resolve(url);
+ Assert.assertTrue(url.getProtocol().equals("file"));
+ IPath path = new Path(url.getPath());
- // Import the project into CVS
- Session s = new Session(getRepository(), Session.getManagedFolder(new File(url.getPath())));
+ // create a project rooted there
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot workspaceRoot = workspace.getRoot();
+ IProject project = workspaceRoot.getProject(projectName);
+ IProjectDescription projectDescription = workspace.newProjectDescription(projectName);
+ projectDescription.setLocation(path);
+ project.create(projectDescription, null);
+ project.open(null);
+
+ // import the project into CVS
+ Session s = new Session(getRepository(), CVSWorkspaceRoot.getCVSFolderFor(project));
s.open(DEFAULT_MONITOR);
try {
Command.IMPORT.execute(s, Command.NO_GLOBAL_OPTIONS,
@@ -108,13 +124,16 @@ public class ModuleTest extends EclipseTest {
} finally {
s.close();
}
+
+ // delete the project locally
+ project.delete(false /*deleteContent*/, false /*force*/, null);
}
// XXX Temporary method of checkout (i.e. with vcm_meta
protected IProject checkoutProject(String projectName, CVSTag tag) throws TeamException {
IProject project = super.checkoutProject(getWorkspace().getRoot().getProject(projectName), null, tag);
- ICVSFolder parent = (ICVSFolder)Session.getManagedResource(project);
- ICVSResource vcmmeta = Session.getManagedResource(project.getFile(".vcm_meta"));
+ ICVSFolder parent = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project);
+ ICVSResource vcmmeta = CVSWorkspaceRoot.getCVSResourceFor(project.getFile(".vcm_meta"));
if ( ! vcmmeta.isManaged() && ! parent.getFolderSyncInfo().getIsStatic()) {
getProvider(project).add(new IResource[] {project.getFile(".vcm_meta")}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
waitMsec(1000);
@@ -143,8 +162,8 @@ public class ModuleTest extends EclipseTest {
public void testSelfReferencingModule() throws TeamException, CoreException, IOException {
uploadProject("project1");
IProject project1 = checkoutProject("project1", null);
- IRemoteSyncElement tree = getProvider(project1).getRemoteSyncTree(project1, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, Session.getManagedResource(project1), (ICVSResource)tree.getRemote(), false, false);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project1, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project1), (ICVSResource)tree.getRemote(), false, false);
RemoteModule module = getRemoteModule("project1");
assertEquals(Path.EMPTY, (RemoteFolder)tree.getRemote(), module, false);
}
@@ -159,14 +178,14 @@ public class ModuleTest extends EclipseTest {
public void testFlattenedStructure() throws TeamException, CoreException, IOException {
IProject docs = checkoutProject("docs", null);
- IRemoteSyncElement tree = getProvider(docs).getRemoteSyncTree(docs, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, Session.getManagedResource(docs), (ICVSResource)tree.getRemote(), false, false);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(docs, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(docs), (ICVSResource)tree.getRemote(), false, false);
RemoteModule module = getRemoteModule("docs");
assertEquals(Path.EMPTY, (RemoteFolder)tree.getRemote(), module, false);
IProject macros = checkoutProject("macros", null);
- tree = getProvider(macros).getRemoteSyncTree(macros, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, Session.getManagedResource(macros), (ICVSResource)tree.getRemote(), false, false);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(macros, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(macros), (ICVSResource)tree.getRemote(), false, false);
module = getRemoteModule("macros");
assertEquals(Path.EMPTY, (RemoteFolder)tree.getRemote(), module, false);
@@ -183,15 +202,15 @@ public class ModuleTest extends EclipseTest {
public void testIncludeAndExcludeDocs() throws TeamException, CoreException, IOException {
uploadProject("project2");
IProject project2 = checkoutProject("project2", null);
- IRemoteSyncElement tree = getProvider(project2).getRemoteSyncTree(project2, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, Session.getManagedResource(project2), (ICVSResource)tree.getRemote(), false, false);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project2, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project2), (ICVSResource)tree.getRemote(), false, false);
RemoteModule module = getRemoteModule("project2");
assertEquals(Path.EMPTY, (RemoteFolder)tree.getRemote(), module, false);
project2 = checkoutProject("project2-only", null);
- tree = getProvider(project2).getRemoteSyncTree(project2, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, Session.getManagedResource(project2), (ICVSResource)tree.getRemote(), false, false);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project2, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project2), (ICVSResource)tree.getRemote(), false, false);
module = getRemoteModule("project2-only");
assertEquals(Path.EMPTY, (RemoteFolder)tree.getRemote(), module, false);
@@ -209,15 +228,15 @@ public class ModuleTest extends EclipseTest {
public void testAliasForFiles() throws TeamException, CoreException, IOException {
uploadProject("project3");
IProject project3 = checkoutProject("project3-sub", null);
- IRemoteSyncElement tree = getProvider(project3).getRemoteSyncTree(project3, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project3, CVSTag.DEFAULT, DEFAULT_MONITOR);
// assertEquals("Local does not match remote", Session.getManagedResource(project3), (ICVSResource)tree.getRemote(), false, false);
project3 = checkoutProject("project3-src", null);
- tree = getProvider(project3).getRemoteSyncTree(project3, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project3, CVSTag.DEFAULT, DEFAULT_MONITOR);
// assertEquals("Local does not match remote", Session.getManagedResource(project3), (ICVSResource)tree.getRemote(), false, false);
project3 = checkoutProject("project3-src_file", null);
- tree = getProvider(project3).getRemoteSyncTree(project3, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project3, CVSTag.DEFAULT, DEFAULT_MONITOR);
// assertEquals("Local does not match remote", Session.getManagedResource(project3), (ICVSResource)tree.getRemote(), false, false);
}
@@ -232,15 +251,15 @@ public class ModuleTest extends EclipseTest {
public void testAliases() throws TeamException, CoreException, IOException {
uploadProject("project7");
IProject project7 = checkoutProject("project7-common", null);
- IRemoteSyncElement tree = getProvider(project7).getRemoteSyncTree(project7, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project7, CVSTag.DEFAULT, DEFAULT_MONITOR);
// assertEquals("Local does not match remote", Session.getManagedResource(project7), (ICVSResource)tree.getRemote(), false, false);
project7 = checkoutProject("project7-pc", null);
- tree = getProvider(project7).getRemoteSyncTree(project7, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project7, CVSTag.DEFAULT, DEFAULT_MONITOR);
// assertEquals("Local does not match remote", Session.getManagedResource(project7), (ICVSResource)tree.getRemote(), false, false);
project7 = checkoutProject("project7-linux", null);
- tree = getProvider(project7).getRemoteSyncTree(project7, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project7, CVSTag.DEFAULT, DEFAULT_MONITOR);
// assertEquals("Local does not match remote", Session.getManagedResource(project7), (ICVSResource)tree.getRemote(), false, false);
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java
index 662fc3326..28fc6f6f3 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java
@@ -15,21 +15,24 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
import org.eclipse.team.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.ccvs.core.ILogEntry;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteResource;
import org.eclipse.team.core.sync.IRemoteSyncElement;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
+import org.eclipse.team.internal.ccvs.core.resources.*;
+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.RemoteFolderTree;
-import org.eclipse.team.internal.ccvs.core.util.RemoteFolderTreeBuilder;
+import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTreeBuilder;
import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
import org.eclipse.team.tests.ccvs.core.EclipseTest;
import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
@@ -51,7 +54,7 @@ public class RemoteResourceTest extends EclipseTest {
}
protected void assertRemoteMatchesLocal(String message, RemoteFolder remote, IContainer container) throws CVSException, IOException, CoreException {
- assertEquals(Path.EMPTY, (ICVSResource)remote, Session.getManagedFolder(container.getLocation().toFile()), false, false);
+ assertEquals(Path.EMPTY, (ICVSResource)remote, CVSWorkspaceRoot.getCVSFolderFor(container), false, false);
}
protected void getMembers(ICVSRemoteFolder folder, boolean deep) throws TeamException {
@@ -108,7 +111,7 @@ public class RemoteResourceTest extends EclipseTest {
*/
public void testGetBase() throws TeamException, CoreException, IOException {
IProject project = createProject("testGetBase", new String[] { "file1.txt", "file2.txt", "folder1/a.txt", "folder2/folder3/b.txt"});
- RemoteFolderTree tree = RemoteFolderTreeBuilder.buildBaseTree(getRepository(), Session.getManagedFolder(project.getLocation().toFile()), CVSTag.DEFAULT, DEFAULT_MONITOR);
+ RemoteFolderTree tree = RemoteFolderTreeBuilder.buildBaseTree(getRepository(), CVSWorkspaceRoot.getCVSFolderFor(project), CVSTag.DEFAULT, DEFAULT_MONITOR);
assertRemoteMatchesLocal("testGetBase", tree, project);
}
@@ -164,10 +167,10 @@ public class RemoteResourceTest extends EclipseTest {
*/
public void testGetRemoteResource() throws CoreException, TeamException, IOException {
IProject project = createProject("testGetRemoteResource", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/a.txt", "folder2/folder3/", "folder2/folder3/b.txt", "folder2/folder3/c.txt"});
- ICVSRemoteResource file = getProvider(project).getRemoteResource(project.getFile("folder1/a.txt"));
+ ICVSRemoteResource file = CVSWorkspaceRoot.getRemoteResourceFor(project.getFile("folder1/a.txt"));
assertTrue("File should exist remotely", file.exists());
- assertEquals(Path.EMPTY, (ICVSResource)file, (ICVSResource)Session.getManagedFile(project.getFile("folder1/a.txt").getLocation().toFile()), false, false);
- ICVSRemoteResource folder = getProvider(project).getRemoteResource(project.getFolder("folder2/folder3/"));
+ assertEquals(Path.EMPTY, (ICVSResource)file, (ICVSResource)CVSWorkspaceRoot.getRemoteResourceFor(project.getFile("folder1/a.txt")), false, false);
+ ICVSRemoteResource folder = CVSWorkspaceRoot.getRemoteResourceFor(project.getFolder("folder2/folder3/"));
getMembers((ICVSRemoteFolder)folder, true);
assertTrue("Folder should exist remotely", folder.exists());
// XXX this didn't work right. I'll need to check into it later
@@ -191,13 +194,13 @@ public class RemoteResourceTest extends EclipseTest {
getProvider(project).checkin(new IResource[] {project}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
// Fetch the remote tree for the version
- IRemoteSyncElement tree = getProvider(project).getRemoteSyncTree(project, v1Tag, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, v1Tag, DEFAULT_MONITOR);
// Check out the project version
project = checkoutCopy(project, v1Tag);
// Compare the two
- assertEquals(Path.EMPTY, (ICVSResource)tree.getRemote(), (ICVSResource)Session.getManagedResource(project), false, false);
+ assertEquals(Path.EMPTY, (ICVSResource)tree.getRemote(), (ICVSResource)CVSWorkspaceRoot.getCVSResourceFor(project), false, false);
}
/*
@@ -212,7 +215,7 @@ public class RemoteResourceTest extends EclipseTest {
file.setContents(new ByteArrayInputStream(new byte[0]), false, false, DEFAULT_MONITOR);
commitResources(project, new String[] {"file.txt"});
- ICVSRemoteResource remote = getProvider(project).getRemoteResource(file);
+ ICVSRemoteResource remote = CVSWorkspaceRoot.getRemoteResourceFor(file);
InputStream in = remote.getContents(DEFAULT_MONITOR);
int count = 0;
while(in.read() != -1) {
@@ -236,7 +239,7 @@ public class RemoteResourceTest extends EclipseTest {
file.setContents(new ByteArrayInputStream("bye there".getBytes()), false, false, DEFAULT_MONITOR);
commitResources(project, new String[] {"file.txt"});
- ICVSRemoteFile remote = (ICVSRemoteFile)getProvider(project).getRemoteResource(file);
+ ICVSRemoteFile remote = (ICVSRemoteFile)CVSWorkspaceRoot.getRemoteResourceFor(file);
ILogEntry[] entries = remote.getLogEntries(DEFAULT_MONITOR);
for (int i=0;i<entries.length;i++) {
InputStream in = entries[i].getRemoteFile().getContents(DEFAULT_MONITOR);
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/SyncElementTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/SyncElementTest.java
index c9fa87ba4..39d3aa69a 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/SyncElementTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/SyncElementTest.java
@@ -16,7 +16,9 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.team.ccvs.core.*;
import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.ILocalSyncElement;
import org.eclipse.team.core.sync.IRemoteResource;
@@ -25,7 +27,7 @@ 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.resources.CVSRemoteSyncElement;
-import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
import org.eclipse.team.tests.ccvs.core.EclipseTest;
import org.eclipse.team.tests.ccvs.core.JUnitTestCase;
@@ -141,7 +143,7 @@ public class SyncElementTest extends EclipseTest {
getProvider(copy).checkin(new IResource[] {copy}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
// Get the sync tree for the project
- IRemoteSyncElement tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testIncomingChanges", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
new int[] {
@@ -159,7 +161,7 @@ public class SyncElementTest extends EclipseTest {
updateResources(project, new String[] {"folder1/a.txt", "folder1/b.txt", /* "folder2/", "folder2/folder3/", */ "folder2/folder3/add.txt"}, false);
// Verify that we are in sync (except for "folder1/b.txt", which was deleted)
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testIncomingChanges", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
new int[] {
@@ -192,7 +194,7 @@ public class SyncElementTest extends EclipseTest {
deleteResources(project, new String[] {"folder1/b.txt"}, false);
// Get the sync tree for the project
- IRemoteSyncElement tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testOutgoingChanges", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
new int[] {
@@ -208,7 +210,7 @@ public class SyncElementTest extends EclipseTest {
commitResources(project, new String[] {"folder1/a.txt", "folder1/b.txt", "folder2/folder3/add.txt"});
// Ensure we're in sync
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testOutgoingChanges", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
new int[] {
@@ -236,7 +238,7 @@ public class SyncElementTest extends EclipseTest {
file.delete(true, DEFAULT_MONITOR);
// Get the sync tree for the project
- IRemoteSyncElement tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testOutgoingQuestionables", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
new int[] {
@@ -255,7 +257,7 @@ public class SyncElementTest extends EclipseTest {
commitResources(project, new String[] {"folder1/b.txt", "folder2/folder3/add.txt"});
// Ensure we are in sync
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testOutgoingQuestionables", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"},
new int[] {
@@ -295,7 +297,7 @@ public class SyncElementTest extends EclipseTest {
file.setContents(getRandomContents(), false, false, null); // This will test conflicts (C)
// Get the sync tree for the project
- IRemoteSyncElement tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testFileConflict", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt"},
new int[] {
@@ -307,7 +309,7 @@ public class SyncElementTest extends EclipseTest {
getProvider(project).update(new IResource[] {project.getFile("file1.txt")},
new Command.LocalOption[] {Update.IGNORE_LOCAL_CHANGES, Command.DO_NOT_RECURSE},
null, null, DEFAULT_MONITOR);
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testFileConflict", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt"},
new int[] {
@@ -317,7 +319,7 @@ public class SyncElementTest extends EclipseTest {
// Release the folder1/a.txt conflict by merging and then committing
makeOutgoing(tree, new String[] {"folder1/a.txt"});
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testFileConflict", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt"},
new int[] {
@@ -325,7 +327,7 @@ public class SyncElementTest extends EclipseTest {
IRemoteSyncElement.IN_SYNC,
IRemoteSyncElement.OUTGOING | IRemoteSyncElement.CHANGE });
getProvider(project).checkin(new IResource[] {project.getFile("folder1/a.txt")}, IResource.DEPTH_ZERO, DEFAULT_MONITOR);
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testFileConflict", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt"},
new int[] {
@@ -361,7 +363,7 @@ public class SyncElementTest extends EclipseTest {
deleteResources(copy, new String[] { "add3.txt"}, true);
// Get the sync tree for the project
- IRemoteSyncElement tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testAdditionConflicts", tree,
new String[] { "file.txt", "add1a.txt", "add1b.txt", "add2a.txt", "add2b.txt", "add3.txt"},
new int[] {
@@ -374,7 +376,7 @@ public class SyncElementTest extends EclipseTest {
// Release the conflict cases (MERGE is not required for add3.txt but we do it anyway to ensure it doesn't cause problems)
makeOutgoing(tree, new String[]{"add1b.txt", "add2b.txt", "add3.txt"});
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testAdditionConflicts", tree,
new String[] { "file.txt", "add1b.txt", "add2b.txt", "add3.txt"},
new int[] {
@@ -383,7 +385,7 @@ public class SyncElementTest extends EclipseTest {
IRemoteSyncElement.OUTGOING | IRemoteSyncElement.CHANGE,
IRemoteSyncElement.OUTGOING | IRemoteSyncElement.ADDITION });
getProvider(project).checkin(new IResource[] {project.getFile("add1b.txt"), project.getFile("add2b.txt"), project.getFile("add3.txt")}, IResource.DEPTH_ZERO, DEFAULT_MONITOR);
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testAdditionConflicts", tree,
new String[] { "file.txt", "add1b.txt", "add2b.txt", "add3.txt"},
new int[] {
@@ -398,7 +400,7 @@ public class SyncElementTest extends EclipseTest {
getProvider(project).update(new IResource[] {project.getFile("add1a.txt"), project.getFile("add2a.txt")},
new Command.LocalOption[] {Command.DO_NOT_RECURSE},
null, null, DEFAULT_MONITOR);
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testAdditionConflicts", tree,
new String[] { "add1a.txt", "add2a.txt"},
new int[] {
@@ -454,7 +456,7 @@ public class SyncElementTest extends EclipseTest {
// Get the sync tree for the project
- IRemoteSyncElement tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testDeletionConflictsA", tree,
new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt"},
new int[] {
@@ -473,7 +475,7 @@ public class SyncElementTest extends EclipseTest {
makeIncoming(tree, new String[] {"delete3.txt"});
project.getFile("delete3.txt").delete(false, DEFAULT_MONITOR);
updateResources(project, new String[] {"delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt"}, true);
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testDeletionConflictsA", tree,
new String[] { "delete1.txt", "delete2.txt"},
new int[] {
@@ -508,7 +510,7 @@ public class SyncElementTest extends EclipseTest {
// Get the sync tree for the project
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testDeletionConflictsB", tree,
new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt"},
new int[] {
@@ -524,7 +526,7 @@ public class SyncElementTest extends EclipseTest {
// XXX SPECIAL CASE: "delete4.txt" and "delete5.txt" must be unmanaged
unmanageResources(project, new String[]{"delete4.txt", "delete5.txt"});
commitResources(project, new String[] { "delete1.txt", "delete2.txt", "delete3.txt", "delete4.txt", "delete5.txt"});
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testDeletionConflictsB", tree,
new String[] { "delete3.txt"},
new int[] {
@@ -572,7 +574,7 @@ public class SyncElementTest extends EclipseTest {
IResource[] resources = buildResources(project, new String[] {"folder1/"});
((IFolder)resources[0]).create(false, true, DEFAULT_MONITOR);
- IRemoteSyncElement tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testFolderConflict", tree,
new String[] { "file.txt", "folder1/", "folder1/file.txt", "folder2/", "folder2/file.txt"},
new int[] {
@@ -583,7 +585,7 @@ public class SyncElementTest extends EclipseTest {
IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION});
makeInSync(tree, new String[] {"folder1/"});
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testFolderConflict", tree,
new String[] { "file.txt", "folder1/", "folder1/file.txt", "folder2/", "folder2/file.txt"},
new int[] {
@@ -607,7 +609,7 @@ public class SyncElementTest extends EclipseTest {
file.delete(true, DEFAULT_MONITOR); // WARNING: As of 2002/03/05, this is equivalent to a cvs remove
// Get the sync tree for the project
- IRemoteSyncElement tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testOutgoingDeletion", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"},
new int[] {
@@ -620,7 +622,7 @@ public class SyncElementTest extends EclipseTest {
getProvider(file).checkin(new IResource[] {file}, IResource.DEPTH_ZERO, DEFAULT_MONITOR);
// Get the sync tree again for the project and ensure others aren't effected
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testOutgoingDeletion", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt"},
new int[] {
@@ -644,7 +646,7 @@ public class SyncElementTest extends EclipseTest {
addResources(copy, new String[] { "folder1/add.txt" }, true);
// Get the sync tree for the project
- IRemoteSyncElement tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testIncomingAddition", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/add.txt"},
new int[] {
@@ -661,7 +663,7 @@ public class SyncElementTest extends EclipseTest {
null, null, DEFAULT_MONITOR);
// Get the sync tree again for the project and ensure the added resource is in sync
- tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testIncomingAddition", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/add.txt"},
new int[] {
@@ -695,7 +697,7 @@ public class SyncElementTest extends EclipseTest {
file.setContents(new ByteArrayInputStream("unique text".getBytes()), false, false, null);
// Get the sync tree for the project
- IRemoteSyncElement tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
assertSyncEquals("testGranularityContents", tree,
new String[] { "file1.txt", "folder1/", "folder1/a.txt"},
new int[] {
@@ -720,8 +722,8 @@ public class SyncElementTest extends EclipseTest {
deleteResources(project, new String[] {"folder1/b.txt"}, false);
// Get the sync tree for the project
- IRemoteSyncElement tree = getProvider(project).getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, (ICVSResource)tree.getBase(), Session.getManagedResource(copy), false, false);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, CVSTag.DEFAULT, DEFAULT_MONITOR);
+ assertEquals(Path.EMPTY, (ICVSResource)tree.getBase(), CVSWorkspaceRoot.getCVSResourceFor(copy), false, false);
}
@@ -747,8 +749,8 @@ public class SyncElementTest extends EclipseTest {
changeResources(project, new String[] {"file2.txt"}, false);
changeResources(project, new String[] {"file3.txt"}, true);
- IRemoteResource base = getProvider(project).getRemoteTree(project, new CVSTag("v1", CVSTag.VERSION), DEFAULT_MONITOR);
- IRemoteResource remote = getProvider(project).getRemoteTree(project, new CVSTag("branch1", CVSTag.BRANCH), DEFAULT_MONITOR);
+ IRemoteResource base = CVSWorkspaceRoot.getRemoteTree(project, new CVSTag("v1", CVSTag.VERSION), DEFAULT_MONITOR);
+ IRemoteResource remote = CVSWorkspaceRoot.getRemoteTree(project, new CVSTag("branch1", CVSTag.BRANCH), DEFAULT_MONITOR);
IRemoteSyncElement tree = new CVSRemoteSyncElement(false, project, base, remote);
// watch for empty directories and the prune option!!!
@@ -779,7 +781,7 @@ public class SyncElementTest extends EclipseTest {
changeResources(copy, new String[] {"file1.txt", "file2.txt"}, true);
// Sync on the original and assert the result equals the copy
- IRemoteSyncElement tree = getProvider(project).getRemoteSyncTree(project, null, DEFAULT_MONITOR);
- assertEquals(Path.EMPTY, (ICVSResource)tree.getRemote(), Session.getManagedResource(copy), false, false);
+ IRemoteSyncElement tree = CVSWorkspaceRoot.getRemoteSyncTree(project, null, DEFAULT_MONITOR);
+ assertEquals(Path.EMPTY, (ICVSResource)tree.getRemote(), CVSWorkspaceRoot.getCVSResourceFor(copy), false, false);
}
} \ No newline at end of file

Back to the top