Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.cvs.core')
-rw-r--r--bundles/org.eclipse.team.cvs.core/.classpath7
-rw-r--r--bundles/org.eclipse.team.cvs.core/.cvsignore1
-rw-r--r--bundles/org.eclipse.team.cvs.core/.options18
-rw-r--r--bundles/org.eclipse.team.cvs.core/.project28
-rw-r--r--bundles/org.eclipse.team.cvs.core/.settings/org.eclipse.jdt.core.prefs62
-rw-r--r--bundles/org.eclipse.team.cvs.core/.settings/org.eclipse.jdt.ui.prefs7
-rw-r--r--bundles/org.eclipse.team.cvs.core/META-INF/MANIFEST.MF29
-rw-r--r--bundles/org.eclipse.team.cvs.core/about.html48
-rw-r--r--bundles/org.eclipse.team.cvs.core/about_files/NOTICE15
-rw-r--r--bundles/org.eclipse.team.cvs.core/about_files/asl-v20.txt202
-rw-r--r--bundles/org.eclipse.team.cvs.core/build.properties20
-rw-r--r--bundles/org.eclipse.team.cvs.core/doc/hglegal.htm14
-rw-r--r--bundles/org.eclipse.team.cvs.core/doc/ngibmcpy.gifbin1045 -> 0 bytes
-rw-r--r--bundles/org.eclipse.team.cvs.core/doc/org_eclipse_team_cvs_core.html15
-rw-r--r--bundles/org.eclipse.team.cvs.core/plugin.properties19
-rw-r--r--bundles/org.eclipse.team.cvs.core/plugin.xml243
-rw-r--r--bundles/org.eclipse.team.cvs.core/schema/authenticator.exsd97
-rw-r--r--bundles/org.eclipse.team.cvs.core/schema/connectionmethods.exsd146
-rw-r--r--bundles/org.eclipse.team.cvs.core/schema/filemodificationvalidator.exsd97
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSAnnotateBlock.java132
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCompareSubscriber.java279
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCoreFileModificationValidator.java242
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java83
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java355
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSyncInfo.java62
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMessages.java266
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java775
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java737
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSResourceRuleFactory.java26
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java92
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java170
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java367
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java161
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTag.java139
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java872
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java200
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java443
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/EditorsInfo.java95
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSDecoratorEnablementListener.java30
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java199
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFileModificationValidator.java29
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java181
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSListener.java19
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java58
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java57
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java88
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java158
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java173
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java23
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java42
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSStorage.java57
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IConnectionMethod.java52
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ILogEntry.java66
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IResourceStateChangeListener.java97
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IServerConnection.java48
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java152
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserInfo.java40
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java106
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java36
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java300
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java97
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java63
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Admin.java22
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Annotate.java32
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ByteCountOutputStream.java25
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java99
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java55
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java183
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckoutWithOverwrite.java64
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java834
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CommandOutputListener.java71
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java136
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ConsoleListeners.java131
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java59
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java76
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java52
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Editors.java37
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java31
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java121
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java64
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java133
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java42
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java105
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java51
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModifiedFileSender.java54
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModuleExpansionHandler.java35
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPCommand.java59
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPVisitor.java44
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java56
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NotifiedHandler.java55
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java106
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RDiff.java46
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RLog.java127
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java110
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java73
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java36
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java60
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java80
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Replace.java85
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java247
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java187
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java1038
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java77
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Status.java21
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java86
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/SyncUpdate.java50
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java107
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java49
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java110
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java206
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java165
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java160
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java28
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequestsHandler.java43
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java99
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java125
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java113
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java75
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/EditorsListener.java104
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java72
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java47
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ILogEntryListener.java26
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IMessagePatterns.java38
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java27
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java51
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java137
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java330
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java71
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/RDiffSummaryListener.java144
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ServerMessageLineMatcher.java99
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java77
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java64
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java294
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException.java84
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException.java89
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java1258
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java64
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java236
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java114
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java36
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java307
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnectionMethod.java38
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/UserInfo.java64
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileHistory.java350
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileHistoryProvider.java103
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileRevision.java116
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSLocalFileRevision.java45
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSResourceVariantFileRevision.java45
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSFileStore.java186
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSFileSystem.java80
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSFileTree.java146
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSURI.java308
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/LogEntryCache.java210
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/RLogTreeBuilder.java118
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/RemoteLogger.java148
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/CVSActiveChangeSet.java22
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/CVSActiveChangeSetCollector.java34
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/CVSCheckedInChangeSet.java47
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/ChangeSetAdapterFactory.java38
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/ChangeSetModelProvider.java37
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/ChangeSetResourceMapping.java60
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/UnassignedDiffChangeSet.java21
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties262
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSEntryLineTag.java130
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java269
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java633
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java414
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java275
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java1932
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileContentCachingService.java137
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileModificationManager.java162
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java680
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java598
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderMemberFetcher.java318
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderSandbox.java125
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java75
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java822
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java385
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java229
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SessionPropertySyncInfoCache.java489
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SyncInfoCache.java145
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java420
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/UpdateContentCachingService.java303
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaserevInfo.java90
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSBaseResourceVariantTree.java66
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSDescendantResourceVariantByteStore.java135
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSResourceVariantTree.java402
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java154
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java328
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MultiTagResourceVariantTree.java44
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableFolderSyncInfo.java58
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableResourceSyncInfo.java135
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/NotifyInfo.java186
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ReentrantLock.java75
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java923
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/BuildCleanupListener.java157
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java101
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileNameMatcher.java74
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java292
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/MoveDeleteHook.java323
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java190
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceStateChangeListeners.java155
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResponsiveSocketFactory.java180
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/StringMatcher.java450
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java278
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java750
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java532
207 files changed, 0 insertions, 36036 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/.classpath b/bundles/org.eclipse.team.cvs.core/.classpath
deleted file mode 100644
index ce7393340..000000000
--- a/bundles/org.eclipse.team.cvs.core/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.team.cvs.core/.cvsignore b/bundles/org.eclipse.team.cvs.core/.cvsignore
deleted file mode 100644
index c5e82d745..000000000
--- a/bundles/org.eclipse.team.cvs.core/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/.options b/bundles/org.eclipse.team.cvs.core/.options
deleted file mode 100644
index 24500e974..000000000
--- a/bundles/org.eclipse.team.cvs.core/.options
+++ /dev/null
@@ -1,18 +0,0 @@
-# Debugging options for the org.eclipse.team.cvs.core plugin.
-
-# Turn on debugging for the plugin.
-org.eclipse.team.cvs.core/debug=false
-
-# Shows when meta-files are modified by a 3rd party
-org.eclipse.team.cvs.core/metafiles=false
-
-# Shows cvs client/server protocol
-org.eclipse.team.cvs.core/cvsprotocol=true
-# Shows stream debugging information
-org.eclipse.team.cvs.core/threading=false
-
-# Shows dirty state caching debugging information
-org.eclipse.team.cvs.core/dirtycaching=false
-
-# Shows dirty state caching debugging information
-org.eclipse.team.cvs.core/syncchangeevents=false \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/.project b/bundles/org.eclipse.team.cvs.core/.project
deleted file mode 100644
index 5ea5b7f98..000000000
--- a/bundles/org.eclipse.team.cvs.core/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.team.cvs.core</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/bundles/org.eclipse.team.cvs.core/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.team.cvs.core/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index c1321545e..000000000
--- a/bundles/org.eclipse.team.cvs.core/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,62 +0,0 @@
-#Thu Jun 29 09:04:19 EDT 2006
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=error
-org.eclipse.jdt.core.compiler.problem.unusedLocal=error
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.3
-org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled
-org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL
-org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX
diff --git a/bundles/org.eclipse.team.cvs.core/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.team.cvs.core/.settings/org.eclipse.jdt.ui.prefs
deleted file mode 100644
index c67280f97..000000000
--- a/bundles/org.eclipse.team.cvs.core/.settings/org.eclipse.jdt.ui.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-#Wed Mar 15 15:55:40 EST 2006
-eclipse.preferences.version=1
-internal.default.compliance=user
-org.eclipse.jdt.ui.ignorelowercasenames=true
-org.eclipse.jdt.ui.importorder=java;javax;org;com;
-org.eclipse.jdt.ui.ondemandthreshold=3
-org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">/*******************************************************************************\r\n * Copyright (c) ${year} IBM Corporation and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n *\r\n * Contributors\:\r\n * IBM Corporation - initial API and implementation\r\n *******************************************************************************/\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
diff --git a/bundles/org.eclipse.team.cvs.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.team.cvs.core/META-INF/MANIFEST.MF
deleted file mode 100644
index 41b2342db..000000000
--- a/bundles/org.eclipse.team.cvs.core/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,29 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.team.cvs.core; singleton:=true
-Bundle-Version: 3.3.100.qualifier
-Bundle-Activator: org.eclipse.team.internal.ccvs.core.CVSProviderPlugin
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
-Export-Package: org.eclipse.team.internal.ccvs.core;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
- org.eclipse.team.internal.ccvs.core.client;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
- org.eclipse.team.internal.ccvs.core.client.listeners;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
- org.eclipse.team.internal.ccvs.core.connection;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
- org.eclipse.team.internal.ccvs.core.filehistory;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
- org.eclipse.team.internal.ccvs.core.filesystem;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
- org.eclipse.team.internal.ccvs.core.mapping;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
- org.eclipse.team.internal.ccvs.core.resources;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
- org.eclipse.team.internal.ccvs.core.syncinfo;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
- org.eclipse.team.internal.ccvs.core.util;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui"
-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.core.resources;bundle-version="[3.3.0,4.0.0)",
- org.eclipse.team.core;bundle-version="[3.3.0,4.0.0)",
- org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)",
- com.jcraft.jsch;bundle-version="[0.1.27,2.0.0)",
- org.eclipse.jsch.core;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.core.net;bundle-version="[1.0.0,2.0.0)"
-Eclipse-LazyStart: true
-Import-Package: com.ibm.icu.text,
- com.ibm.icu.util
-Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/bundles/org.eclipse.team.cvs.core/about.html b/bundles/org.eclipse.team.cvs.core/about.html
deleted file mode 100644
index 071d9d480..000000000
--- a/bundles/org.eclipse.team.cvs.core/about.html
+++ /dev/null
@@ -1,48 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 7, 2007</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-<h3>Third Party Content</h3>
-
-<p>The Content includes items that have been sourced from third parties as set out below. If you
-did not receive this Content directly from the Eclipse Foundation, the following is provided
-for informational purposes only, and you should look to the Redistributor&rsquo;s license for
-terms and conditions of use.</p>
-
-<h4>Ant 1.7.0</h4>
-<p>The plug-in is based on software developed by The Apache Software Foundation as part of the Ant project.</p>
-
-<p>The class org.eclipse.team.internal.ccvs.core.connection.PServerConnection (&quot;Ant-Derived Work&quot;) in the plug-in JAR is based on Ant code from the file CVSPass.java in the package org.apache.tools.ant.taskdefs.</p>
-
-<p>Your use of the Ant-Derived Work is subject to the terms and conditions of the Apache Software License 2.0. A copy of the license is contained
-in the file <a href="about_files/asl-v20.txt" target="_blank">asl-v20.txt</a> and is also available at <a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>.
-
-<p>The names &quot;Ant&quot; and &quot;Apache Software Foundation&quot; must not be used to endorse or promote products derived from this
-software without prior written permission. For written permission, please contact <a href="mailto:apache@apache.org">apache@apache.org</a>.</p>
-
-<p>The Apache attribution <a href="about_files/NOTICE" target="_blank">NOTICE</a> file is included with the Content in accordance with 4d of the Apache License, Version 2.0.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/about_files/NOTICE b/bundles/org.eclipse.team.cvs.core/about_files/NOTICE
deleted file mode 100644
index 1fb6dde47..000000000
--- a/bundles/org.eclipse.team.cvs.core/about_files/NOTICE
+++ /dev/null
@@ -1,15 +0,0 @@
- =========================================================================
- == NOTICE file corresponding to the section 4 d of ==
- == the Apache License, Version 2.0, ==
- == in this case for the Apache Ant distribution. ==
- =========================================================================
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- This product includes also software developed by :
- - the W3C consortium (http://www.w3c.org) ,
- - the SAX project (http://www.saxproject.org)
-
- Please read the different LICENSE files present in the root directory of
- this distribution.
diff --git a/bundles/org.eclipse.team.cvs.core/about_files/asl-v20.txt b/bundles/org.eclipse.team.cvs.core/about_files/asl-v20.txt
deleted file mode 100644
index d64569567..000000000
--- a/bundles/org.eclipse.team.cvs.core/about_files/asl-v20.txt
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/bundles/org.eclipse.team.cvs.core/build.properties b/bundles/org.eclipse.team.cvs.core/build.properties
deleted file mode 100644
index 159ea5d0d..000000000
--- a/bundles/org.eclipse.team.cvs.core/build.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2006 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# Eclipse build contribution
-bin.includes = about.html,\
- about_files/,\
- plugin.xml,\
- plugin.properties,\
- .,\
- .options,\
- META-INF/
-source..=src/
-src.includes=about.html
diff --git a/bundles/org.eclipse.team.cvs.core/doc/hglegal.htm b/bundles/org.eclipse.team.cvs.core/doc/hglegal.htm
deleted file mode 100644
index c59811321..000000000
--- a/bundles/org.eclipse.team.cvs.core/doc/hglegal.htm
+++ /dev/null
@@ -1,14 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.73 [en] (Win98; U) [Netscape]">
- <title>Legal Notices</title>
-</head>
-<body>
-
-<h3>
-<a NAME="Notices"></a>Notices</h3>
-(c) Copyright IBM Corp. 2000, 2001. All Rights Reserved.
-</body>
-</html>
diff --git a/bundles/org.eclipse.team.cvs.core/doc/ngibmcpy.gif b/bundles/org.eclipse.team.cvs.core/doc/ngibmcpy.gif
deleted file mode 100644
index 61cef4852..000000000
--- a/bundles/org.eclipse.team.cvs.core/doc/ngibmcpy.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.team.cvs.core/doc/org_eclipse_team_cvs_core.html b/bundles/org.eclipse.team.cvs.core/doc/org_eclipse_team_cvs_core.html
deleted file mode 100644
index 5426e6995..000000000
--- a/bundles/org.eclipse.team.cvs.core/doc/org_eclipse_team_cvs_core.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="Build">
- <title>Eclipse CVS Core Extension Points</title>
-</head>
-<body link="#0000FF" vlink="#800080">
-
-<center><h1>Eclipse CVS Core</h1></center>
-The extension points declared by this plug-in are for internal use only.
-
-<p><a href="hglegal.htm"><img SRC="ngibmcpy.gif" ALT="Copyright IBM Corp. 2000, 2002. All Rights Reserved." BORDER=0></a>
-</body>
-</html>
diff --git a/bundles/org.eclipse.team.cvs.core/plugin.properties b/bundles/org.eclipse.team.cvs.core/plugin.properties
deleted file mode 100644
index bed5d0913..000000000
--- a/bundles/org.eclipse.team.cvs.core/plugin.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2006 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-providerName=Eclipse.org
-pluginName=CVS Team Provider Core
-cvsNature=CVS Team Nature
-
-# The following 3 strings do not require translation
-Authenticator=Authenticator
-ConnectionMethods=ConnectionMethods
-FileModificationValidator=FileModificationValidator
-ChangeSets=Change Sets
diff --git a/bundles/org.eclipse.team.cvs.core/plugin.xml b/bundles/org.eclipse.team.cvs.core/plugin.xml
deleted file mode 100644
index f563ca4a7..000000000
--- a/bundles/org.eclipse.team.cvs.core/plugin.xml
+++ /dev/null
@@ -1,243 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin>
-
-
-<!-- *************** Extension Points **************** -->
- <extension-point id="authenticator" name="%Authenticator" schema="schema/authenticator.exsd"/>
- <extension-point id="connectionmethods" name="%ConnectionMethods" schema="schema/connectionmethods.exsd"/>
- <extension-point id="filemodificationvalidator" name="%FileModificationValidator" schema="schema/filemodificationvalidator.exsd"/>
-
-<!-- *************** Connection Methods **************** -->
- <extension
- id="pserver"
- point="org.eclipse.team.cvs.core.connectionmethods">
- <adapter>
- <run
- class="org.eclipse.team.internal.ccvs.core.connection.PServerConnectionMethod">
- <parameter
- name="trace"
- value="false">
- </parameter>
- </run>
- </adapter>
- </extension>
- <extension
- id="ext"
- point="org.eclipse.team.cvs.core.connectionmethods">
- <adapter>
- <run
- class="org.eclipse.team.internal.ccvs.core.connection.ExtConnectionMethod">
- <parameter
- name="trace"
- value="false">
- </parameter>
- </run>
- </adapter>
- </extension>
-<!-- *************** Repository Provider **************** -->
- <extension
- point="org.eclipse.team.core.repository">
- <repository
- class="org.eclipse.team.internal.ccvs.core.CVSTeamProvider"
- fileSystemScheme="cvs"
- id="org.eclipse.team.cvs.core.cvsnature"
- metaFilePaths="CVS/Root,CVS/Repository"
- typeClass="org.eclipse.team.internal.ccvs.core.CVSTeamProviderType">
- </repository>
- </extension>
-<!-- *************** Resource patterns ignored by CVS **************** -->
- <extension
- point="org.eclipse.team.core.ignore">
- <ignore
- enabled="true"
- pattern="RCS">
- </ignore>
- <ignore
- enabled="true"
- pattern="RCSLOG">
- </ignore>
- <ignore
- enabled="true"
- pattern="SCCS">
- </ignore>
- <ignore
- enabled="true"
- pattern="CVS.adm">
- </ignore>
- <ignore
- enabled="false"
- pattern="tags">
- </ignore>
- <ignore
- enabled="false"
- pattern="TAGS">
- </ignore>
- <ignore
- enabled="true"
- pattern=".make.state">
- </ignore>
- <ignore
- enabled="true"
- pattern=".nse_depinfo">
- </ignore>
- <ignore
- enabled="true"
- pattern="*~">
- </ignore>
- <ignore
- enabled="true"
- pattern="#*">
- </ignore>
- <ignore
- enabled="true"
- pattern=".#*">
- </ignore>
- <ignore
- enabled="true"
- pattern=",*">
- </ignore>
- <ignore
- enabled="true"
- pattern="_$*">
- </ignore>
- <ignore
- enabled="true"
- pattern="*$">
- </ignore>
- <ignore
- enabled="true"
- pattern="*.old">
- </ignore>
- <ignore
- enabled="true"
- pattern="*.bak">
- </ignore>
- <ignore
- enabled="true"
- pattern="*.BAK">
- </ignore>
- <ignore
- enabled="true"
- pattern="*.orig">
- </ignore>
- <ignore
- enabled="true"
- pattern="*.rej">
- </ignore>
- <ignore
- enabled="true"
- pattern=".del-*">
- </ignore>
- <ignore
- enabled="false"
- pattern="*.a">
- </ignore>
- <ignore
- enabled="true"
- pattern="*.olb">
- </ignore>
- <ignore
- enabled="true"
- pattern="*.obj">
- </ignore>
- <ignore
- enabled="true"
- pattern="*.o">
- </ignore>
- <ignore
- enabled="false"
- pattern="*.so">
- </ignore>
- <ignore
- enabled="false"
- pattern="*.exe">
- </ignore>
- <ignore
- enabled="true"
- pattern="*.Z">
- </ignore>
- <ignore
- enabled="true"
- pattern="*.elc">
- </ignore>
- <ignore
- enabled="true"
- pattern="*.ln">
- </ignore>
- <ignore
- enabled="true"
- pattern=".DS_Store">
- </ignore>
- <ignore
- enabled="false"
- pattern="core">
- </ignore>
- <ignore
- enabled="false"
- pattern="*.jnilib"/>
- <ignore
- enabled="false"
- pattern="*.sl"/>
- <ignore
- enabled="false"
- pattern="*.dll"/>
- <ignore
- enabled="false"
- pattern="*.bat"/>
- <ignore
- enabled="false"
- pattern="*.com"/>
- <ignore
- enabled="true"
- pattern="*.log"/>
- <ignore
- enabled="false"
- pattern="*.zip"/>
- <ignore
- enabled="false"
- pattern="*.gz"/>
- </extension>
-
-<!-- ************ File Types *************** -->
- <extension
- point="org.eclipse.team.core.fileTypes">
- <fileTypes
- type="text"
- extension="cvsignore">
- </fileTypes>
- </extension>
- <extension
- point="org.eclipse.core.filesystem.filesystems">
- <filesystem scheme="cvs">
- <run class="org.eclipse.team.internal.ccvs.core.filesystem.CVSFileSystem"/>
- </filesystem>
- </extension>
- <extension
- id="changeSetModel"
- name="%ChangeSets"
- point="org.eclipse.core.resources.modelProviders">
- <modelProvider
- class="org.eclipse.team.internal.ccvs.core.mapping.ChangeSetModelProvider"/>
- <extends-model id="org.eclipse.core.resources.modelProvider"/>
- </extension>
- <extension
- point="org.eclipse.core.runtime.adapters">
- <factory
- adaptableType="org.eclipse.team.internal.ccvs.core.mapping.CVSActiveChangeSet"
- class="org.eclipse.team.internal.ccvs.core.mapping.ChangeSetAdapterFactory">
- <adapter type="org.eclipse.core.resources.mapping.ResourceMapping"/>
- </factory>
- <factory
- adaptableType="org.eclipse.team.internal.ccvs.core.mapping.CVSCheckedInChangeSet"
- class="org.eclipse.team.internal.ccvs.core.mapping.ChangeSetAdapterFactory">
- <adapter type="org.eclipse.core.resources.mapping.ResourceMapping"/>
- </factory>
- <factory
- adaptableType="org.eclipse.team.internal.ccvs.core.mapping.UnassignedDiffChangeSet"
- class="org.eclipse.team.internal.ccvs.core.mapping.ChangeSetAdapterFactory">
- <adapter type="org.eclipse.core.resources.mapping.ResourceMapping"/>
- </factory>
- </extension>
-
-</plugin>
diff --git a/bundles/org.eclipse.team.cvs.core/schema/authenticator.exsd b/bundles/org.eclipse.team.cvs.core/schema/authenticator.exsd
deleted file mode 100644
index 7f2bdb1c6..000000000
--- a/bundles/org.eclipse.team.cvs.core/schema/authenticator.exsd
+++ /dev/null
@@ -1,97 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.team.cvs.core">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.team.cvs.core" id="authenticator" name="Authenticator"/>
- </appInfo>
- <documentation>
- This extension point is internal use only
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="authenticator"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="authenticator">
- <complexType>
- <sequence>
- <element ref="run"/>
- </sequence>
- </complexType>
- </element>
-
- <element name="run">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 1.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- This extension point is for internal use only
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2004 IBM Corporation and others.
-All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/bundles/org.eclipse.team.cvs.core/schema/connectionmethods.exsd b/bundles/org.eclipse.team.cvs.core/schema/connectionmethods.exsd
deleted file mode 100644
index 95dfea0bb..000000000
--- a/bundles/org.eclipse.team.cvs.core/schema/connectionmethods.exsd
+++ /dev/null
@@ -1,146 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.team.cvs.core">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.team.cvs.core" id="connectionmethods" name="ConnectionMethods"/>
- </appInfo>
- <documentation>
- This extension point allows additional CVS connection methods to be pluged in. It is for internal use.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="adapter"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="adapter">
- <complexType>
- <sequence>
- <element ref="run"/>
- </sequence>
- </complexType>
- </element>
-
- <element name="run">
- <complexType>
- <sequence>
- <element ref="parameter" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- An implementation of &lt;samp&gt;IConnectionMethod&lt;/samp&gt;
- </documentation>
- <appInfo>
- <meta.attribute kind="java"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="parameter">
- <complexType>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
- This extension point is internal use only
- </documentation>
- </annotation>
- </attribute>
- <attribute name="value" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 1.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- Following is an example of a connectionmethods extension:
-
-&lt;p&gt;
-&lt;pre&gt;
- &lt;extension id=&quot;pserver&quot; point=&quot;org.eclipse.team.cvs.core.connectionmethods&quot;&gt;
- &lt;adapter&gt;
- &lt;run class=&quot;org.eclipse.team.internal.ccvs.core.connection.PServerConnectionMethod&quot;&gt;
- &lt;parameter name=&quot;trace&quot; value=&quot;false&quot;&gt;
- &lt;/parameter&gt;
- &lt;/run&gt;
- &lt;/adapter&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- This extension point is internal use only
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2004 IBM Corporation and others.
-All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/bundles/org.eclipse.team.cvs.core/schema/filemodificationvalidator.exsd b/bundles/org.eclipse.team.cvs.core/schema/filemodificationvalidator.exsd
deleted file mode 100644
index 250ce3df2..000000000
--- a/bundles/org.eclipse.team.cvs.core/schema/filemodificationvalidator.exsd
+++ /dev/null
@@ -1,97 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.team.cvs.core">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.team.cvs.core" id="filemodificationvalidator" name="FileModificationValidator"/>
- </appInfo>
- <documentation>
- This extension point is for internal use only
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="validator"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="validator">
- <complexType>
- <sequence>
- <element ref="run"/>
- </sequence>
- </complexType>
- </element>
-
- <element name="run">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 2.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- This extension point is for internal use only
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2004 IBM Corporation and others.
-All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSAnnotateBlock.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSAnnotateBlock.java
deleted file mode 100644
index addfbce4a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSAnnotateBlock.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Model for a CVS Annotate block.
- */
-public class CVSAnnotateBlock {
-
- String revision = ""; //$NON-NLS-1$
- String user = ""; //$NON-NLS-1$
- int startLine = 0;
- int endLine = 0;
- int sourceOffset = 0;
- boolean valid = false;
-
- /**
- * @return
- */
- public boolean isValid() {
- return valid;
- }
-
- /**
- * @return index of line where source starts.
- */
- public int getSourceOffset() {
- return sourceOffset;
- }
-
- /**
- * @return int the last source line of the receiver
- */
- public int getEndLine() {
- return endLine;
- }
-
- /**
- * @param line
- */
- public void setEndLine(int line) {
- endLine = line;
- }
-
- /**
- * @return the revision the receiver occured in.
- */
- public String getRevision() {
- return revision;
- }
-
- /**
- * @return the first source line number of the receiver
- */
- public int getStartLine() {
- return startLine;
- }
-
-
- /**
- * Parase a CVS Annotate output line and instantiate the receiver
- * @param line a CVS Annotate output line
- */
- public CVSAnnotateBlock(String line, int lineNumber) {
- super();
-
- startLine = lineNumber;
- endLine = lineNumber;
-
- int index = line.indexOf(' ');
- if (index == -1) {
- return;
- }
- revision = line.substring(0, index);
-
- index = line.indexOf("(", index); //$NON-NLS-1$
- if (index == -1) {
- return;
- }
-
- int index2 = line.indexOf(' ', index);
- if (index2 == -1) {
- return;
- }
-
- user = line.substring(index + 1, index2);
-
- index = line.indexOf(":", index2); //$NON-NLS-1$
- if (index == -1) {
- return;
- }
-
- sourceOffset = index + 2;
- valid = true;
- }
-
- /**
- * Used by the default LabelProvider to display objects in a List View
- */
- public String toString() {
- int delta = endLine - startLine + 1;
- String line = CVSMessages.CVSAnnotateBlock_4;
- if (delta == 1) {
- line = CVSMessages.CVSAnnotateBlock_5;
- }
- return NLS.bind(CVSMessages.CVSAnnotateBlock_6, (new Object[] {
- user,
- revision,
- String.valueOf(delta),
- line
- }));
- }
-
- /**
- * Answer true if the receiver contains the given line number, false otherwse.
- * @param i a line number
- * @return true if receiver contains a line number.
- */
- public boolean contains(int i) {
- return (i >= startLine && i <= endLine);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCompareSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCompareSubscriber.java
deleted file mode 100644
index 42e7b7cdd..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCompareSubscriber.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.subscribers.*;
-import org.eclipse.team.core.variants.IResourceVariantTree;
-import org.eclipse.team.core.variants.SessionResourceVariantByteStore;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MultiTagResourceVariantTree;
-
-/**
- * This subscriber is used when comparing the local workspace with its
- * corresponding remote.
- */
-public class CVSCompareSubscriber extends CVSSyncTreeSubscriber implements ISubscriberChangeListener {
-
- public static final String ID = "org.eclipse.team.cvs.ui.compare-participant"; //$NON-NLS-1$
- public static final String ID_MODAL = "org.eclipse.team.cvs.ui.compare-participant-modal"; //$NON-NLS-1$
-
- public static final String QUALIFIED_NAME = CVSProviderPlugin.ID + ".compare"; //$NON-NLS-1$
- private static final String UNIQUE_ID_PREFIX = "compare-"; //$NON-NLS-1$
-
- private IResource[] resources;
- private CVSResourceVariantTree tree;
-
- public CVSCompareSubscriber(IResource[] resources, CVSTag tag) {
- super(getUniqueId(), NLS.bind(CVSMessages.CVSCompareSubscriber_2, new String[] { tag.getName() })); //
- this.resources = resources;
- tree = new CVSResourceVariantTree(new SessionResourceVariantByteStore(), tag, getCacheFileContentsHint());
- initialize();
- }
-
- public CVSCompareSubscriber(IResource[] resources, CVSTag[] tags, String name) {
- super(getUniqueId(), NLS.bind(CVSMessages.CVSCompareSubscriber_2, new String[] { name })); //
- resetRoots(resources, tags);
- initialize();
- }
-
- /**
- * @param resources
- * @param tags
- */
- public void resetRoots(IResource[] resources, CVSTag[] tags) {
- if (this.resources != null) {
- List removed = new ArrayList();
- for (int i = 0; i < this.resources.length; i++) {
- IResource resource = this.resources[i];
- removed.add(new SubscriberChangeEvent(this, ISubscriberChangeEvent.ROOT_REMOVED, resource));
- }
- this.resources = new IResource[0];
- fireTeamResourceChange((ISubscriberChangeEvent[]) removed.toArray(new ISubscriberChangeEvent[removed.size()]));
- if (tree != null) {
- tree.dispose();
- tree = null;
- }
- }
- this.resources = resources;
- MultiTagResourceVariantTree multiTree = new MultiTagResourceVariantTree(new SessionResourceVariantByteStore(), getCacheFileContentsHint());
- for (int i = 0; i < tags.length; i++) {
- multiTree.addResource(resources[i], tags[i]);
- }
- tree = multiTree;
- }
-
- private void initialize() {
- CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().addListener(this);
- }
-
- public void dispose() {
- CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().removeListener(this);
- tree.dispose();
- }
-
- private static QualifiedName getUniqueId() {
- String uniqueId = Long.toString(System.currentTimeMillis());
- return new QualifiedName(QUALIFIED_NAME, UNIQUE_ID_PREFIX + uniqueId);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getBaseSynchronizationCache()
- */
- protected IResourceVariantTree getBaseTree() {
- // No base cache needed since it's a two way compare
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getRemoteSynchronizationCache()
- */
- protected IResourceVariantTree getRemoteTree() {
- return tree;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.TeamSubscriber#isThreeWay()
- */
- public boolean isThreeWay() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.TeamSubscriber#roots()
- */
- public IResource[] roots() {
- return resources;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.ITeamResourceChangeListener#teamResourceChanged(org.eclipse.team.core.subscribers.TeamDelta[])
- */
- public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas) {
- List outgoingDeltas = new ArrayList(deltas.length);
- for (int i = 0; i < deltas.length; i++) {
- ISubscriberChangeEvent delta = deltas[i];
- if ((delta.getFlags() & ISubscriberChangeEvent.ROOT_REMOVED) != 0) {
- IResource resource = delta.getResource();
- outgoingDeltas.addAll(Arrays.asList(handleRemovedRoot(resource)));
- } else if ((delta.getFlags() & ISubscriberChangeEvent.SYNC_CHANGED) != 0) {
- IResource resource = delta.getResource();
- try {
- if (isSupervised(resource)) {
- outgoingDeltas.add(new SubscriberChangeEvent(this, delta.getFlags(), resource));
- }
- } catch (TeamException e) {
- // Log and ignore
- CVSProviderPlugin.log(e);
- }
- }
- }
-
- fireTeamResourceChange((SubscriberChangeEvent[]) outgoingDeltas.toArray(new SubscriberChangeEvent[outgoingDeltas.size()]));
- }
-
- private SubscriberChangeEvent[] handleRemovedRoot(IResource removedRoot) {
- // Determine if any of the roots of the compare are affected
- List removals = new ArrayList(resources.length);
- for (int j = 0; j < resources.length; j++) {
- IResource root = resources[j];
- if (removedRoot.getFullPath().isPrefixOf(root.getFullPath())) {
- // The root is no longer managed by CVS
- removals.add(root);
- try {
- tree.flushVariants(root, IResource.DEPTH_INFINITE);
- } catch (TeamException e) {
- CVSProviderPlugin.log(e);
- }
- }
- }
- if (removals.isEmpty()) {
- return new SubscriberChangeEvent[0];
- }
-
- // Adjust the roots of the subscriber
- List newRoots = new ArrayList(resources.length);
- newRoots.addAll(Arrays.asList(resources));
- newRoots.removeAll(removals);
- resources = (IResource[]) newRoots.toArray(new IResource[newRoots.size()]);
-
- // Create the deltas for the removals
- SubscriberChangeEvent[] deltas = new SubscriberChangeEvent[removals.size()];
- for (int i = 0; i < deltas.length; i++) {
- deltas[i] = new SubscriberChangeEvent(this, ISubscriberChangeEvent.ROOT_REMOVED, (IResource)removals.get(i));
- }
- return deltas;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.TeamSubscriber#isSupervised(org.eclipse.core.resources.IResource)
- */
- public boolean isSupervised(IResource resource) throws TeamException {
- if (super.isSupervised(resource)) {
- if (!resource.exists() && !getRemoteTree().hasResourceVariant(resource)) {
- // Exclude conflicting deletions
- return false;
- }
- for (int i = 0; i < resources.length; i++) {
- IResource root = resources[i];
- if (root.getFullPath().isPrefixOf(resource.getFullPath())) {
- return true;
- }
- }
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getCacheFileContentsHint()
- */
- protected boolean getCacheFileContentsHint() {
- return true;
- }
-
- public CVSTag getTag() {
- return tree.getTag(ResourcesPlugin.getWorkspace().getRoot());
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object other) {
- if(this == other) return true;
- if(! (other instanceof CVSCompareSubscriber)) return false;
- CVSCompareSubscriber s = (CVSCompareSubscriber)other;
- CVSResourceVariantTree tree1 = (CVSResourceVariantTree)getRemoteTree();
- CVSResourceVariantTree tree2 = (CVSResourceVariantTree)s.getRemoteTree();
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- CVSTag tag1 = tree1.getTag(root);
- CVSTag tag2 = tree2.getTag(root);
- if (tag1 == null || tag2 == null) return false;
- return tag1.equals(tag2) && rootsEqual(s);
- }
-
- /**
- * Prime the remote tree with the sync info from the local workspace.
- * This is done to ensure that we don't get a huge nimber of outgoing
- * changes before the first refresh.
- *
- */
- public void primeRemoteTree() throws CVSException {
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- cvsResource.accept(new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {
- byte[] bytes = file.getSyncBytes();
- if (bytes != null) {
- try {
- tree.getByteStore().setBytes(file.getIResource(), bytes);
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- }
- }
- }
- public void visitFolder(ICVSFolder folder) throws CVSException {
- // No need to copy sync info for folders since
- // CVS resource variant tree will get missing
- // folder info from the local resources
- folder.acceptChildren(this);
- }
- });
- }
- }
-
- /**
- * Return the tag associated with the given root resource
- * or <code>null</code> if there is only a single tag
- * for the subscriber.
- * @param root the root resource
- * @return the tag associated with the given root resource
- */
- public CVSTag getTag(IResource root) {
- return tree.getTag(root);
- }
-
- /**
- * Return <code>true</code> if the tag against which each
- * root is compared may differ.
- * @return whether the tag on each root may differ.
- */
- public boolean isMultipleTagComparison() {
- return getTag() == null;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCoreFileModificationValidator.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCoreFileModificationValidator.java
deleted file mode 100644
index 1d5e6a3c2..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSCoreFileModificationValidator.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.resources.team.FileModificationValidationContext;
-import org.eclipse.core.resources.team.FileModificationValidator;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-
-/**
- * Core validator that will load the UI validator only if a prompt is needed
- */
-public class CVSCoreFileModificationValidator extends FileModificationValidator implements ICVSFileModificationValidator {
-
- FileModificationValidator uiValidator;
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.team.FileModificationValidator#validateEdit(org.eclipse.core.resources.IFile[], org.eclipse.core.resources.team.FileModificationValidationContext)
- */
- public IStatus validateEdit(IFile[] files, FileModificationValidationContext context) {
- IFile[] unmanagedReadOnlyFiles = getUnmanagedReadOnlyFiles(files);
- if (unmanagedReadOnlyFiles.length > 0) {
- IStatus status = setWritable(unmanagedReadOnlyFiles);
- if (!status.isOK()) {
- return status;
- }
- }
- IFile[] readOnlyFiles = getManagedReadOnlyFiles(files);
- if (readOnlyFiles.length == 0) return Status.OK_STATUS;
- return edit(readOnlyFiles, context);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IFileModificationValidator#validateSave(org.eclipse.core.resources.IFile)
- */
- public IStatus validateSave(IFile file) {
- if (!needsCheckout(file)) {
- if (file.isReadOnly()) {
- setWritable(new IFile[] { file } );
- }
- return Status.OK_STATUS;
- }
- return edit(new IFile[] {file}, (FileModificationValidationContext)null);
- }
-
- /**
- * Method for editing a set of files. Is overriden by the
- * UI to prompt the user. Default behavior is to try and load the
- * UI validator and, failing that, to edit without
- * prompting.
- * @param readOnlyFiles
- * @param context
- * @return
- */
- protected IStatus edit(IFile[] readOnlyFiles, FileModificationValidationContext context) {
- FileModificationValidator override = getUIValidator();
- if (override != null) {
- return override.validateEdit(readOnlyFiles, context);
- } else {
- performEdit(readOnlyFiles);
- return Status.OK_STATUS;
- }
- }
-
- private FileModificationValidator getUIValidator() {
- synchronized(this) {
- if (uiValidator == null) {
- uiValidator = getPluggedInValidator();
- }
- }
- return uiValidator;
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFileModificationValidator#validateMoveDelete(org.eclipse.core.resources.IFile[], org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus validateMoveDelete(IFile[] files, IProgressMonitor monitor) {
- IFile[] readOnlyFiles = getManagedReadOnlyFiles(files);
- if (readOnlyFiles.length == 0) return Status.OK_STATUS;
-
- performEdit(readOnlyFiles);
- return Status.OK_STATUS;
- }
-
- /*
- * Perform the headless edit check in the background.
- * The user will be notified of any errors that occurred.
- */
- protected void performEdit(final IFile[] readOnlyFiles) {
- setWritable(readOnlyFiles);
- Job job = new Job(CVSMessages.CVSCoreFileModificationValidator_editJob) {
- protected IStatus run(IProgressMonitor monitor) {
- try {
- performEdit(readOnlyFiles, monitor);
- } catch (CVSException e) {
- return e.getStatus();
- }
- return Status.OK_STATUS;
- }
- };
- scheduleEditJob(job);
- }
-
- protected void scheduleEditJob(Job job) {
- job.schedule();
- }
-
- protected CVSTeamProvider getProvider(IFile[] files) {
- CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(files[0].getProject(), CVSProviderPlugin.getTypeId());
- return provider;
- }
-
- protected void performEdit(IFile[] files, IProgressMonitor monitor) throws CVSException {
- getProvider(files).edit(files, false /* recurse */, true /* notify server */, true /* notify for writtable files */, ICVSFile.NO_NOTIFICATION, monitor);
- }
-
- private boolean needsCheckout(IFile file) {
- try {
- if (file.isReadOnly()) {
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file);
- boolean managed = cvsFile.isManaged();
- return managed;
- }
- } catch (CVSException e) {
- // Log the exception and assume we don't need a checkout
- CVSProviderPlugin.log(e);
- }
- return false;
- }
-
- protected IStatus setWritable(final IFile[] files) {
- for (int i = 0; i < files.length; i++) {
- IFile file = files[i];
- ResourceAttributes attributes = file.getResourceAttributes();
- if (attributes != null) {
- attributes.setReadOnly(false);
- }
- try {
- file.setResourceAttributes(attributes);
- } catch (CoreException e) {
- return CVSException.wrapException(e).getStatus();
- }
- }
- return Status.OK_STATUS;
- }
-
- private IFile[] getManagedReadOnlyFiles(IFile[] files) {
- List readOnlys = new ArrayList();
- for (int i = 0; i < files.length; i++) {
- IFile iFile = files[i];
- if (needsCheckout(iFile)) {
- readOnlys.add(iFile);
- }
- }
- return (IFile[]) readOnlys.toArray(new IFile[readOnlys.size()]);
- }
-
- protected IFile[] getUnmanagedReadOnlyFiles(IFile[] files) {
- List readOnlys = new ArrayList();
- for (int i = 0; i < files.length; i++) {
- IFile iFile = files[i];
- if (iFile.isReadOnly() && !needsCheckout(iFile)) {
- readOnlys.add(iFile);
- }
- }
- return (IFile[]) readOnlys.toArray(new IFile[readOnlys.size()]);
- }
-
- private static FileModificationValidator getPluggedInValidator() {
- IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(CVSProviderPlugin.ID, CVSProviderPlugin.PT_FILE_MODIFICATION_VALIDATOR).getExtensions();
- if (extensions.length == 0)
- return null;
- IExtension extension = extensions[0];
- IConfigurationElement[] configs = extension.getConfigurationElements();
- if (configs.length == 0) {
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("The CVS file modification validator is missing from extension {0}", (new Object[] {extension.getUniqueIdentifier()})), null);//$NON-NLS-1$
- return null;
- }
- try {
- IConfigurationElement config = configs[0];
- return (FileModificationValidator) config.createExecutableExtension("run");//$NON-NLS-1$
- } catch (CoreException ex) {
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("The CVS file modification validator registered as ID {0} could not be instantiated", (new Object[] {extension.getUniqueIdentifier()})), ex);//$NON-NLS-1$
- return null;
- }
- }
-
- public ISchedulingRule validateEditRule(CVSResourceRuleFactory factory, IResource[] resources) {
- FileModificationValidator override = getUIValidator();
- if (override instanceof CVSCoreFileModificationValidator && override != this) {
- CVSCoreFileModificationValidator ui = (CVSCoreFileModificationValidator) override;
- return ui.validateEditRule(factory, resources);
- }
- return internalValidateEditRule(factory, resources);
- }
-
- protected final ISchedulingRule internalValidateEditRule(CVSResourceRuleFactory factory, IResource[] resources) {
- if (resources.length == 0)
- return null;
- //optimize rule for single file
- if (resources.length == 1)
- return isReadOnly(resources[0]) ? factory.getParent(resources[0]) : null;
- //need a lock on the parents of all read-only files
- HashSet rules = new HashSet();
- for (int i = 0; i < resources.length; i++)
- if (isReadOnly(resources[i]))
- rules.add(factory.getParent(resources[i]));
- return createSchedulingRule(rules);
- }
-
- protected ISchedulingRule createSchedulingRule(Set rules) {
- if (rules.isEmpty())
- return null;
- if (rules.size() == 1)
- return (ISchedulingRule) rules.iterator().next();
- ISchedulingRule[] ruleArray = (ISchedulingRule[]) rules
- .toArray(new ISchedulingRule[rules.size()]);
- return new MultiRule(ruleArray);
- }
-
- protected final boolean isReadOnly(IResource resource) {
- ResourceAttributes a = resource.getResourceAttributes();
- if (a != null) {
- return a.isReadOnly();
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java
deleted file mode 100644
index 3bd196644..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.TeamException;
-
-/**
- * A checked expection representing a failure in the CVS plugin.
- * <p>
- * CVS exceptions contain a status object describing the cause of
- * the exception.
- * </p>
- *
- * @see IStatus
- */
-public class CVSException extends TeamException {
-
- private static final long serialVersionUID = 1L;
-
- public CVSException(CoreException e) {
- super(e);
- }
-
- public CVSException(String message) {
- this(new CVSStatus(IStatus.ERROR, message));
- }
-
- public CVSException(IStatus status) {
- super(status);
- }
-
- /*
- * Static helper methods for creating exceptions
- */
- public static CVSException wrapException(IResource resource, String message, IOException e) {
- return new CVSException(new CVSStatus(IStatus.ERROR, IO_FAILED, message, e, resource));
- }
-
- /*
- * Static helper methods for creating exceptions
- */
- public static CVSException wrapException(IResource resource, String message, CoreException e) {
- return new CVSException(new CVSStatus(IStatus.ERROR, e.getStatus().getCode(), message, e, resource));
- }
-
- /*
- * Static helper methods for creating exceptions
- */
- public static CVSException wrapException(Exception e) {
- Throwable t = e;
- if (e instanceof InvocationTargetException) {
- Throwable target = ((InvocationTargetException) e).getTargetException();
- if (target instanceof CVSException) {
- return (CVSException) target;
- }
- t = target;
- }
- //TODO: fix the caller to include a resource
- //TODO: fix the caller to setup the error code
- return new CVSException(new CVSStatus(IStatus.ERROR, UNABLE, t.getMessage() != null ? t.getMessage() : "", t, (IResource)null)); //$NON-NLS-1$
- }
-
- public static CVSException wrapException(CoreException e) {
- if (e instanceof CVSException) {
- return (CVSException)e;
- }
- return new CVSException(e);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java
deleted file mode 100644
index ca5268763..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.subscribers.*;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.synchronize.SyncInfoFilter;
-import org.eclipse.team.core.variants.*;
-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.syncinfo.CVSResourceVariantTree;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * A CVSMergeSubscriber is responsible for maintaining the remote trees for a merge into
- * the workspace. The remote trees represent the CVS revisions of the start and end
- * points (version or branch) of the merge.
- *
- * This subscriber stores the remote handles in the resource tree sync info slot. When
- * the merge is cancelled this sync info is cleared.
- *
- * A merge can persist between workbench sessions and thus can be used as an
- * ongoing merge.
- *
- * TODO: Is the merge subscriber interested in workspace sync info changes?
- * TODO: Do certain operations (e.g. replace with) invalidate a merge subscriber?
- * TODO: How to ensure that sync info is flushed when merge roots are deleted?
- */
-public class CVSMergeSubscriber extends CVSSyncTreeSubscriber implements IResourceChangeListener, ISubscriberChangeListener {
-
- private final class MergeBaseTree extends CVSResourceVariantTree {
- // The merge synchronizer has been kept so that those upgrading
- // from 3.0 M8 to 3.0 M9 so not lose there ongoing merge state
- private PersistantResourceVariantByteStore mergedSynchronizer;
- private MergeBaseTree(ResourceVariantByteStore cache, CVSTag tag, boolean cacheFileContentsHint, String syncKeyPrefix) {
- super(cache, tag, cacheFileContentsHint);
- mergedSynchronizer = new PersistantResourceVariantByteStore(new QualifiedName(SYNC_KEY_QUALIFIER, syncKeyPrefix + "0merged")); //$NON-NLS-1$
- }
- public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
- // Only refresh the base of a resource once as it should not change
- List unrefreshed = new ArrayList();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if (!hasResourceVariant(resource)) {
- unrefreshed.add(resource);
- }
- }
- if (unrefreshed.isEmpty()) {
- monitor.done();
- return new IResource[0];
- }
- IResource[] refreshed = super.refresh((IResource[]) unrefreshed.toArray(new IResource[unrefreshed.size()]), depth, monitor);
- return refreshed;
- }
- public IResourceVariant getResourceVariant(IResource resource) throws TeamException {
- // Use the merged bytes for the base if there are some
- byte[] mergedBytes = mergedSynchronizer.getBytes(resource);
- if (mergedBytes != null) {
- byte[] parentBytes = getByteStore().getBytes(resource.getParent());
- if (parentBytes != null) {
- return RemoteFile.fromBytes(resource, mergedBytes, parentBytes);
- }
- }
- return super.getResourceVariant(resource);
- }
-
- /**
- * Mark the resource as merged by making it's base equal the remote
- */
- public void merged(IResource resource, byte[] remoteBytes) throws TeamException {
- if (remoteBytes == null) {
- getByteStore().deleteBytes(resource);
- } else {
- getByteStore().setBytes(resource, remoteBytes);
- }
- }
-
- /**
- * Return true if the remote has already been merged
- * (i.e. the base equals the remote).
- */
- public boolean isMerged(IResource resource, byte[] remoteBytes) throws TeamException {
- byte[] mergedBytes = getByteStore().getBytes(resource);
- return Util.equals(mergedBytes, remoteBytes);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree#dispose()
- */
- public void dispose() {
- mergedSynchronizer.dispose();
- super.dispose();
- }
- }
-
- public static final String ID = "org.eclipse.team.cvs.ui.cvsmerge-participant"; //$NON-NLS-1$
- public static final String ID_MODAL = "org.eclipse.team.cvs.ui.cvsmerge-participant-modal"; //$NON-NLS-1$
- private static final String UNIQUE_ID_PREFIX = "merge-"; //$NON-NLS-1$
-
- private CVSTag start, end;
- private List roots;
- private CVSResourceVariantTree remoteTree;
- private MergeBaseTree baseTree;
-
- public CVSMergeSubscriber(IResource[] roots, CVSTag start, CVSTag end) {
- this(getUniqueId(), roots, start, end);
- }
-
- private static QualifiedName getUniqueId() {
- String uniqueId = Long.toString(System.currentTimeMillis());
- return new QualifiedName(ID, "CVS" + UNIQUE_ID_PREFIX + uniqueId); //$NON-NLS-1$
- }
-
- public CVSMergeSubscriber(QualifiedName id, IResource[] roots, CVSTag start, CVSTag end) {
- super(id, NLS.bind(CVSMessages.CVSMergeSubscriber_2, new String[] { start.getName(), end.getName() }));
- this.start = start;
- this.end = end;
- this.roots = new ArrayList(Arrays.asList(roots));
- initialize();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.CVSWorkspaceSubscriber#initialize()
- */
- private void initialize() {
- QualifiedName id = getId();
- String syncKeyPrefix = id.getLocalName();
- PersistantResourceVariantByteStore remoteSynchronizer = new PersistantResourceVariantByteStore(new QualifiedName(SYNC_KEY_QUALIFIER, syncKeyPrefix + end.getName()));
- remoteTree = new CVSResourceVariantTree(remoteSynchronizer, getEndTag(), getCacheFileContentsHint()) {
- public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
- // Override refresh to compare file contents
- monitor.beginTask(null, 100);
- try {
- IResource[] refreshed = super.refresh(resources, depth, monitor);
- compareWithRemote(refreshed, Policy.subMonitorFor(monitor, 50));
- return refreshed;
- } finally {
- monitor.done();
- }
- }
- };
- PersistantResourceVariantByteStore baseSynchronizer = new PersistantResourceVariantByteStore(new QualifiedName(SYNC_KEY_QUALIFIER, syncKeyPrefix + start.getName()));
- baseTree = new MergeBaseTree(baseSynchronizer, getStartTag(), getCacheFileContentsHint(), syncKeyPrefix);
-
- ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
- CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().addListener(this);
- }
-
- protected SyncInfo getSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote) throws TeamException {
- CVSMergeSyncInfo info = new CVSMergeSyncInfo(local, base, remote, this);
- info.init();
- return info;
- }
-
- public void merged(IResource[] resources) throws TeamException {
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- internalMerged(resource);
- }
- fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, resources));
- }
-
- private void internalMerged(IResource resource) throws TeamException {
- byte[] remoteBytes = getRemoteByteStore().getBytes(resource);
- baseTree.merged(resource, remoteBytes);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.TeamSubscriber#cancel()
- */
- public void cancel() {
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
- remoteTree.dispose();
- baseTree.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.TeamSubscriber#roots()
- */
- public IResource[] roots() {
- return (IResource[]) roots.toArray(new IResource[roots.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.TeamSubscriber#isSupervised(org.eclipse.core.resources.IResource)
- */
- public boolean isSupervised(IResource resource) throws TeamException {
- return getBaseTree().hasResourceVariant(resource) || getRemoteTree().hasResourceVariant(resource);
- }
-
- public CVSTag getStartTag() {
- return start;
- }
-
- public CVSTag getEndTag() {
- return end;
- }
-
- /*
- * What to do when a root resource for this merge changes?
- * Deleted, Move, Copied
- * Changed in a CVS way (tag changed, revision changed...)
- * Contents changed by user
- * @see IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- try {
- IResourceDelta delta = event.getDelta();
- if(delta != null) {
- delta.accept(new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource resource = delta.getResource();
-
- if (resource.getType()==IResource.PROJECT) {
- IProject project = (IProject)resource;
- if (!project.isAccessible()) {
- return false;
- }
- if ((delta.getFlags() & IResourceDelta.OPEN) != 0) {
- return false;
- }
- if (RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()) == null) {
- return false;
- }
- }
-
- if (roots.contains(resource)) {
- if (delta.getKind() == IResourceDelta.REMOVED || delta.getKind() == IResourceDelta.MOVED_TO) {
- cancel();
- }
- // stop visiting children
- return false;
- }
- // keep visiting children
- return true;
- }
- });
- }
- } catch (CoreException e) {
- CVSProviderPlugin.log(e.getStatus());
- }
- }
-
- /**
- * Return whether the given resource has been merged with its
- * corresponding remote.
- * @param resource the local resource
- * @return boolean
- * @throws TeamException
- */
- public boolean isMerged(IResource resource) throws TeamException {
- byte[] remoteBytes = getRemoteByteStore().getBytes(resource);
- return baseTree.isMerged(resource, remoteBytes);
- }
-
- /*
- * Currently only the workspace subscriber knows when a project has been deconfigured. We will listen for these events
- * and remove the root then forward to merge subscriber listeners.
- * (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.ITeamResourceChangeListener#teamResourceChanged(org.eclipse.team.core.subscribers.TeamDelta[])
- */
- public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas) {
- for (int i = 0; i < deltas.length; i++) {
- ISubscriberChangeEvent delta = deltas[i];
- switch(delta.getFlags()) {
- case ISubscriberChangeEvent.ROOT_REMOVED:
- IResource resource = delta.getResource();
- if(roots.remove(resource)) {
- fireTeamResourceChange(new ISubscriberChangeEvent[] {delta});
- }
- break;
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getBaseSynchronizationCache()
- */
- protected IResourceVariantTree getBaseTree() {
- return baseTree;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getRemoteSynchronizationCache()
- */
- protected IResourceVariantTree getRemoteTree() {
- return remoteTree;
- }
-
- protected boolean getCacheFileContentsHint() {
- return true;
- }
-
- /*
- * Mark as merged any local resources whose contents match that of the remote resource.
- */
- private void compareWithRemote(IResource[] refreshed, IProgressMonitor monitor) throws CVSException, TeamException {
- // For any remote changes, if the revision differs from the local, compare the contents.
- if (refreshed.length == 0) return;
- SyncInfoFilter.ContentComparisonSyncInfoFilter contentFilter =
- new SyncInfoFilter.ContentComparisonSyncInfoFilter();
- monitor.beginTask(null, refreshed.length * 100);
- for (int i = 0; i < refreshed.length; i++) {
- IResource resource = refreshed[i];
- if (resource.getType() == IResource.FILE) {
- ICVSFile local = CVSWorkspaceRoot.getCVSFileFor((IFile)resource);
- byte[] localBytes = local.getSyncBytes();
- byte[] remoteBytes = getRemoteByteStore().getBytes(resource);
- if (remoteBytes != null
- && localBytes != null
- && local.exists()
- && !ResourceSyncInfo.getRevision(remoteBytes).equals(ResourceSyncInfo.getRevision(localBytes))
- && contentFilter.select(getSyncInfo(resource), Policy.subMonitorFor(monitor, 100))) {
- // The contents are equals so mark the file as merged
- internalMerged(resource);
- }
- }
- }
- monitor.done();
- }
-
-
- private PersistantResourceVariantByteStore getRemoteByteStore() {
- return (PersistantResourceVariantByteStore)((CVSResourceVariantTree)getRemoteTree()).getByteStore();
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object other) {
- if(this == other) return true;
- if(! (other instanceof CVSMergeSubscriber)) return false;
- CVSMergeSubscriber s = (CVSMergeSubscriber)other;
- return getEndTag().equals(s.getEndTag()) &&
- getStartTag().equals(s.getStartTag()) && rootsEqual(s);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSyncInfo.java
deleted file mode 100644
index 1662c2ebc..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSyncInfo.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.subscribers.*;
-import org.eclipse.team.core.synchronize.*;
-import org.eclipse.team.core.variants.*;
-
-public class CVSMergeSyncInfo extends CVSSyncInfo {
-
- public CVSMergeSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote, Subscriber subscriber) {
- super(local, base, remote, subscriber);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.CVSSyncInfo#handleDeletionConflicts(int)
- */
- protected int handleDeletionConflicts(int kind) {
- // (see bug 40053).
- if(kind == (SyncInfo.CONFLICTING | SyncInfo.DELETION | SyncInfo.PSEUDO_CONFLICT)) {
- return SyncInfo.IN_SYNC;
- }
- return kind;
- }
-
- protected int calculateKind() throws TeamException {
- // Report merged resources as in-sync
- if (((CVSMergeSubscriber)getSubscriber()).isMerged(getLocal())) {
- return IN_SYNC;
- }
-
- int kind = super.calculateKind();
-
- // Report outgoing resources as in-sync
- if((kind & DIRECTION_MASK) == OUTGOING) {
- return IN_SYNC;
- }
-
- return kind;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.CVSSyncInfo#makeOutgoing(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus makeOutgoing(IProgressMonitor monitor) throws TeamException {
- // Make the resource outgoing by marking it as merged with the subscriber
- CVSMergeSubscriber subscriber = (CVSMergeSubscriber)getSubscriber();
- subscriber.merged(new IResource[] {getLocal() });
- return Status.OK_STATUS;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMessages.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMessages.java
deleted file mode 100644
index 9397ebc7c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMessages.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import org.eclipse.osgi.util.NLS;
-
-public class CVSMessages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.team.internal.ccvs.core.messages";//$NON-NLS-1$
- public static String CVSResourceVariantTree_GettingSyncInfoError;
- public static String FolderSyncInfo_InvalidSyncInfoBytes;
- public static String LogEntry_0;
- public static String ok;
- public static String AbstractStructureVisitor_sendingFolder;
- public static String AbstractStructureVisitor_sendingFile;
- public static String AbstractStructureVisitor_noRemote;
-
- public static String CVSAuthenticationException_detail;
- public static String CVSCommunicationException_io;
- public static String CVSCommunicationException_interruptCause;
- public static String CVSCommunicationException_interruptSolution;
- public static String CVSCommunicationException_alternateInterruptCause;
- public static String CVSCommunicationException_alternateInterruptSolution;
- public static String CVSStatus_messageWithRoot;
-
- public static String CVSTag_nullName;
- public static String CVSTag_emptyName;
- public static String CVSTag_beginName;
- public static String CVSTag_badCharName;
-
- public static String CVSWorkspaceRoot_notCVSFolder;
-
- public static String java_io_IOException;
- public static String java_io_EOFException;
- public static String java_io_FileNotFoundException;
- public static String java_io_InterruptedIOException;
- public static String java_net_UnknownHostException;
- public static String java_net_ConnectException;
- public static String java_net_SocketException;
- public static String java_net_NoRouteToHostException;
-
- public static String Connection_cannotClose;
- public static String Connection_readUnestablishedConnection;
- public static String Connection_writeUnestablishedConnection;
- public static String Connection_0;
- public static String PrepareForReplaceVisitor_DeletedFileWithoutHistoryCannotBeRestoredWhileRevertToBase;
- public static String PrepareForReplaceVisitor_FileCannotBeReplacedWithBase;
-
- public static String PServerConnection_invalidChars;
- public static String PServerConnection_loginRefused;
- public static String PServerConnection_invalidUser;
- public static String PServerConnection_socket;
- public static String PServerConnection_connectionRefused;
- public static String PServerConnection_noResponse;
- public static String PServerConnection_authenticating;
-
- public static String CVSProviderPlugin_unknownStateFileVersion;
-
- public static String CVSProvider_ioException;
- public static String CVSProvider_errorLoading;
- public static String CVSProvider_infoMismatch;
-
- public static String CVSTeamProvider_noFolderInfo;
- public static String CVSTeamProvider_invalidResource;
- public static String CVSTeamProvider_typesDiffer;
- public static String CVSTeamProvider_settingKSubst;
- public static String CVSTeamProvider_cleanLineDelimitersException;
- public static String CVSTeamProvider_changingKeywordComment;
- public static String CVSTeamProvider_errorGettingFetchProperty;
- public static String CVSTeamProvider_errorSettingFetchProperty;
- public static String CVSTeamProvider_overlappingRemoteFolder;
- public static String CVSTeamProvider_overlappingFileDeletion;
- public static String CVSTeamProvider_errorGettingWatchEdit;
- public static String CVSTeamProvider_errorSettingWatchEdit;
- public static String CVSTeamProvider_errorAddingFileToDiff;
- public static String CVSTeamProvider_updatingFolder;
- public static String CVSCoreFileModificationValidator_editJob;
-
- public static String ResourceDeltaVisitor_visitError;
-
- public static String EclipseResource_invalidResourceClass;
-
- public static String RemoteResource_invalidOperation;
- public static String RemoteFolder_invalidChild;
- public static String RemoteFolder_errorFetchingRevisions;
- public static String RemoteFolder_errorFetchingMembers;
- public static String RemoteFolder_doesNotExist;
-
- public static String RemoteFolderTreeBuilder_buildingBase;
- public static String RemoteFolderTreeBuilder_0;
- public static String RemoteFolderTreeBuilder_receivingDelta;
- public static String RemoteFolderTreeBuilder_receivingRevision;
- public static String RemoteFolderTreeBuilder_missingParent;
- public static String RemoteFolderTreeBuild_folderDeletedFromServer;
-
- public static String Session_badInt;
- public static String Session_receiving;
- public static String Session_transfer;
- public static String Session_transferNoSize;
- public static String Session_calculatingCompressedSize;
- public static String Session_0;
- public static String Session_sending;
-
- public static String Command_receivingResponses;
- public static String Command_warnings;
- public static String Command_serverError;
- public static String Command_noMoreInfoAvailable;
- public static String Command_unsupportedResponse;
- public static String Command_argumentNotManaged;
- public static String Command_invalidTag;
- public static String Command_noOpenSession;
- public static String Command_seriousServerError;
-
- public static String Add_invalidParent;
-
- public static String Commit_syncInfoMissing;
- public static String Commit_timestampReset;
-
- public static String Diff_serverError;
-
- public static String Tag_notVersionOrBranchError;
-
- public static String ModTimeHandler_invalidFormat;
- public static String UpdateListener_0;
- public static String RemovedHandler_invalid;
- public static String RemovedHandler_0;
- public static String CheckInHandler_checkedIn;
-
- public static String KSubstOption__kb_short;
- public static String KSubstOption__kb_long;
- public static String KSubstOption__ko_short;
- public static String KSubstOption__ko_long;
- public static String KSubstOption__kkv_short;
- public static String KSubstOption__kkv_long;
- public static String KSubstOption__kkvl_short;
- public static String KSubstOption__kkvl_long;
- public static String KSubstOption__kv_short;
- public static String KSubstOption__kv_long;
- public static String KSubstOption__kk_short;
- public static String KSubstOption__kk_long;
- public static String KSubstOption_unknown_short;
- public static String KSubstOption_unknown_long;
-
- public static String AdminKSubstListener_expectedRCSFile;
- public static String AdminKSubstListener_commandRootNotManaged;
- public static String AdminKSubstListener_expectedChildOfCommandRoot;
- public static String CVSRepositoryLocation_locationForm;
- public static String CVSRepositoryLocation_methods;
- public static String CVSRepositoryLocation_parsingMethod;
- public static String CVSRepositoryLocation_parsingUser;
- public static String CVSRepositoryLocation_parsingPassword;
- public static String CVSRepositoryLocation_parsingHost;
- public static String CVSRepositoryLocation_parsingPort;
- public static String CVSRepositoryLocation_parsingRoot;
- public static String CVSRepositoryLocation_invalidFormat;
- public static String CVSRepositoryLocation_openingConnection;
- public static String CVSRepositoryLocation_usernameRequired;
- public static String CVSRepositoryLocation_hostRequired;
- public static String CVSRepositoryLocation_rootRequired;
- public static String CVSRepositoryLocation_noAuthenticator;
-
- public static String Util_timeout;
- public static String Util_processTimeout;
- public static String Util_truncatedPath;
-
- public static String ResourceSyncInfo_malformedSyncBytes;
- public static String Malformed_entry_line___11;
- public static String Malformed_entry_line__missing_name___12;
- public static String Malformed_entry_line__missing_revision___13;
- public static String FolderSyncInfo_Maleformed_root_4;
- public static String SyncFileWriter_baseNotAvailable;
- public static String BaseRevInfo_malformedEntryLine;
-
- public static String EXTServerConnection_invalidPort;
- public static String EXTServerConnection_varsNotSet;
- public static String CVSRemoteSyncElement_rootDiffers;
- public static String CVSRemoteSyncElement_repositoryDiffers;
- public static String Util_Internal_error__resource_does_not_start_with_root_3;
-
- public static String CVSProvider_Scrubbing_local_project_1;
- public static String CVSProvider_Scrubbing_projects_1;
- public static String CVSProvider_Creating_projects_2;
-
- public static String EclipseFile_Problem_deleting_resource;
- public static String EclipseFile_Problem_accessing_resource;
- public static String EclipseFile_Problem_writing_resource;
- public static String EclipseFolder_problem_creating;
- public static String EclipseFolder_isModifiedProgress;
- public static String EclipseFolder_0;
-
- public static String EclipseSynchronizer_UpdatingSyncEndOperation;
- public static String EclipseSynchronizer_UpdatingSyncEndOperationCancelled;
- public static String EclipseSynchronizer_NotifyingListeners;
- public static String EclipseSynchronizer_ErrorSettingFolderSync;
- public static String EclipseSynchronizer_ErrorSettingResourceSync;
- public static String EclipseSynchronizer_ErrorSettingIgnorePattern;
- public static String EclipseSynchronizer_ErrorCommitting;
- public static String EclipseSynchronizer_folderSyncInfoMissing;
- public static String SyncFileChangeListener_errorSettingTeamPrivateFlag;
-
- public static String RemoteFile_getContents;
- public static String RemoteFile_getLogEntries;
- public static String RemoteFolder_exists;
- public static String RemoteFolder_getMembers;
- public static String RemoteModule_getRemoteModules;
- public static String RemoteModule_invalidDefinition;
-
- public static String Version_unsupportedVersion;
- public static String Version_unknownVersionFormat;
- public static String Version_versionNotValidRequest;
-
- public static String LogListener_invalidRevisionFormat;
- public static String NotifyInfo_MalformedLine;
- public static String NotifyInfo_MalformedNotificationType;
- public static String NotifyInfo_MalformedNotifyDate;
-
- public static String ResourceSynchronizer_missingParentBytesOnGet;
- public static String ResourceSynchronizer_missingParentBytesOnSet;
- public static String CVSAnnotateBlock_4;
- public static String CVSAnnotateBlock_5;
- public static String CVSAnnotateBlock_6;
- public static String CVSMergeSubscriber_2;
- public static String CVSProviderPlugin_20;
- public static String CRLFDetectInputStream_0;
- public static String DeferredResourceChangeHandler_0;
- public static String DeferredResourceChangeHandler_1;
- public static String CVSWorkspaceRoot_11;
- public static String RemoveEntryHandler_2;
- public static String ServerMessageLineMatcher_5;
- public static String ServerMessageLineMatcher_6;
- public static String ServerMessageLineMatcher_7;
- public static String CVSSyncInfo_7;
- public static String CVSSyncInfo_8;
- public static String CVSSyncInfo_9;
- public static String CVSSyncInfo_10;
- public static String CVSCompareSubscriber_2;
- public static String AnnotateListener_3;
- public static String AnnotateListener_4;
- public static String CVSWorkspaceSubscriber_1;
- public static String CVSWorkspaceSubscriber_2;
- public static String KnownRepositories_0;
- public static String CVSRepositoryLocation_72;
- public static String CVSRepositoryLocation_73;
- public static String CVSRepositoryLocation_74;
- public static String CVSRepositoryLocation_75;
- public static String SyncFileWriter_0;
- public static String ResponseHandler_0;
-
- public static String CVSTeamProviderType_0;
- public static String CVSFileSystem_FetchTree;
- public static String CVSURI_InvalidURI;
-
- static {
- // load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, CVSMessages.class);
- }
-
- public static String CVSFileHistory_0;
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java
deleted file mode 100644
index 1cc4de6a8..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java
+++ /dev/null
@@ -1,775 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Dan Rubel - initial API and implementation
- * IBM Corporation - maintenance and modifications
- *******************************************************************************/
-
-package org.eclipse.team.internal.ccvs.core;
-
-import java.io.File;
-import java.net.URI;
-import java.util.*;
- import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.MultiRule;
-import org.eclipse.team.core.*;
-import org.eclipse.team.internal.ccvs.core.client.*;
-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.filesystem.CVSURI;
-import org.eclipse.team.internal.ccvs.core.resources.*;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.KnownRepositories;
-
-/**
- * An object for serializing and deserializing
- * of references to CVS based projects. Given a project, it can produce a
- * UTF-8 encoded String which can be stored in a file.
- * Given this String, it can load a project into the workspace.
- *
- * @since 3.0
- */
-public class CVSProjectSetCapability extends ProjectSetCapability {
-
- /**
- * Override superclass implementation to return an array of project references.
- *
- * @see ProjectSetSerializer#asReference(IProject[], ProjectSetSerializationContext, IProgressMonitor)
- */
- public String[] asReference(
- IProject[] projects,
- ProjectSetSerializationContext context,
- IProgressMonitor monitor)
- throws TeamException {
-
- String[] result = new String[projects.length];
- for (int i = 0; i < projects.length; i++)
- result[i] = asReference(projects[i]);
- return result;
- }
-
- /**
- * Answer a string representing the specified project
- *
- * @param project the project (not <code>null</code>)
- * @return the project reference (not <code>null</code>)
- * @throws CVSException
- */
- private String asReference(IProject project) throws TeamException {
- CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(project);
- CVSWorkspaceRoot root = provider.getCVSWorkspaceRoot();
- CVSRepositoryLocation location = CVSRepositoryLocation.fromString(root.getRemoteLocation().getLocation(false));
- location.setUserMuteable(true);
- ICVSFolder folder = root.getLocalRoot();
- return asReference(location, folder, project);
- }
-
- private String asReference(CVSRepositoryLocation location, ICVSFolder folder, IProject project) throws TeamException {
- StringBuffer buffer = new StringBuffer();
- buffer.append("1.0,"); //$NON-NLS-1$
-
- String repoLocation = location.getLocation();
- buffer.append(repoLocation);
- buffer.append(","); //$NON-NLS-1$
-
- FolderSyncInfo syncInfo = folder.getFolderSyncInfo();
- String module = syncInfo.getRepository();
- buffer.append(module);
- buffer.append(","); //$NON-NLS-1$
-
- String projectName = project.getName();
- buffer.append(projectName);
- CVSTag tag = syncInfo.getTag();
- if (tag != null) {
- if (tag.getType() != CVSTag.DATE) {
- buffer.append(","); //$NON-NLS-1$
- String tagName = tag.getName();
- buffer.append(tagName);
- }
- }
- return buffer.toString();
- }
-
- /**
- * Override superclass implementation to load the referenced projects into the workspace.
- *
- * @see org.eclipse.team.core.ProjectSetSerializer#addToWorkspace(java.lang.String[], org.eclipse.team.core.ProjectSetSerializationContext, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IProject[] addToWorkspace(
- String[] referenceStrings,
- ProjectSetSerializationContext context,
- IProgressMonitor monitor)
- throws TeamException {
-
- monitor = Policy.monitorFor(monitor);
- Policy.checkCanceled(monitor);
-
- // Confirm the projects to be loaded
- Map infoMap = new HashMap(referenceStrings.length);
- IProject[] projects = asProjects(referenceStrings, infoMap);
-
- projects = confirmOverwrite(context, projects);
- if (projects == null)
- return new IProject[0];
-
- Map alternativeMap = isAdditionalRepositoryInformationRequired(projects, infoMap);
- if (!alternativeMap.isEmpty()) {
- // display the dialog
- Map alternativeRespositoriesMap = promptForAdditionRepositoryInformation(alternativeMap);
- // replace repository location from a project load info with one from the prompter
- if (alternativeRespositoriesMap != null) {
- for (Iterator iterator = infoMap.values().iterator(); iterator
- .hasNext();) {
- LoadInfo loadInfoForProject = (LoadInfo) iterator.next();
- ICVSRepositoryLocation selectedAlternativeRepository = (ICVSRepositoryLocation) alternativeRespositoriesMap
- .get(loadInfoForProject.repositoryLocation);
- // TODO: final modifier removed for LoadInfo.repositoryLocation
- // another solution is to create a copy (clone) of LoadInfo, and replace the whole object
- loadInfoForProject.repositoryLocation = selectedAlternativeRepository;
- }
- } else {
- // operation canceled
- return new IProject[0];
- }
- }
-
- // Load the projects
- return checkout(projects, infoMap, monitor);
-
- }
-
- /**
- * Translate the reference strings into projects to be loaded
- * and build a mapping of project to project load information.
- *
- * @param referenceStrings project references
- * @param infoMap a mapping of project to project load information
- * @return the projects to be loaded
- */
- private IProject[] asProjects(String[] referenceStrings, Map infoMap) throws CVSException {
- Collection result = new ArrayList();
- for (int i = 0; i < referenceStrings.length; i++) {
- StringTokenizer tokenizer = new StringTokenizer(referenceStrings[i], ","); //$NON-NLS-1$
- String version = tokenizer.nextToken();
- // If this is a newer version, then ignore it
- if (!version.equals("1.0")) //$NON-NLS-1$
- continue;
- LoadInfo info = new LoadInfo(tokenizer, false, false);
- IProject proj = info.getProject();
- result.add(proj);
- infoMap.put(proj, info);
- }
- return (IProject[]) result.toArray(new IProject[result.size()]);
- }
-
- /**
- * Checkout projects from the CVS repository
- *
- * @param projects the projects to be loaded from the repository
- * @param infoMap a mapping of project to project load information
- * @param monitor the progress monitor (not <code>null</code>)
- */
- private IProject[] checkout(
- final IProject[] projects,
- final Map infoMap,
- IProgressMonitor monitor)
- throws TeamException {
-
- final List result = new ArrayList();
- try {
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("", 1000 * projects.length); //$NON-NLS-1$
- try {
- for (int i = 0; i < projects.length; i++) {
- if (monitor.isCanceled())
- break;
- IProject project = projects[i];
- LoadInfo info = (LoadInfo) infoMap.get(project);
- if (info != null && info.checkout(new SubProgressMonitor(monitor, 1000)))
- result.add(project);
- }
- }
- finally {
- monitor.done();
- }
- }
- }, getCheckoutRule(projects), IResource.NONE, monitor);
- } catch (CoreException e) {
- throw TeamException.asTeamException(e);
- }
- return (IProject[])result.toArray(new IProject[result.size()]);
- }
-
- /**
- * Internal class for adding projects to the workspace
- */
- class LoadInfo {
- // TODO: final modifier removed in order to replace a repository location before check out
- private ICVSRepositoryLocation repositoryLocation;
- private final String module;
- private final IProject project;
- private final CVSTag tag;
-
- /**
- * Construct a new instance wrapping the specified project reference
- *
- * @param tokenizer the StringTokenizer from which all data are extracted
- */
- LoadInfo(StringTokenizer tokenizer,boolean useKnown, boolean addIfNotFound) throws CVSException {
- String repo = tokenizer.nextToken();
- repositoryLocation = getRepositoryLocationFromString(repo,useKnown,addIfNotFound);
- module = tokenizer.nextToken();
- String projectName = tokenizer.nextToken();
- project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- if (tokenizer.hasMoreTokens()) {
- String tagName = tokenizer.nextToken();
- tag = new CVSTag(tagName, CVSTag.BRANCH);
- }
- else {
- tag = null;
- }
- }
-
- LoadInfo(StringTokenizer tokenizer) throws CVSException {
- this(tokenizer, true, true);
- }
-
- /**
- * Answer the project referenced by this object.
- * The project may or may not already exist.
- *
- * @return the project (not <code>null</code>)
- */
- private IProject getProject() {
- return project;
- }
-
- /**
- * Checkout the project specified by this reference.
- *
- * @param monitor project monitor
- * @return true if loaded, else false
- * @throws TeamException
- */
- boolean checkout(IProgressMonitor monitor) throws TeamException {
- if (repositoryLocation == null)
- return false;
- CVSProjectSetCapability.checkout(
- repositoryLocation,
- project,
- module,
- tag,
- monitor);
- return true;
- }
- }
-
- /**
- * Extract the CVS repository location information from the specified string
- *
- * @param repo the repository location as a string
- * @param use a known repository which matches the one from the repo string
- * @param addIfNotFound add newLocation to the list of known repositories
- * @return the CVS repository information
- * @throws CVSException
- */
- private static ICVSRepositoryLocation getRepositoryLocationFromString(String repo, boolean useKnown, boolean addIfNotFound) throws CVSException {
- // create the new location
- ICVSRepositoryLocation newLocation = CVSRepositoryLocation.fromString(repo);
- if (useKnown && (newLocation.getUsername() == null || newLocation.getUsername().length() == 0)) {
- // look for an existing location that matched
- ICVSRepositoryLocation[] locations = CVSProviderPlugin.getPlugin().getKnownRepositories();
- for (int i = 0; i < locations.length; i++) {
- ICVSRepositoryLocation location = locations[i];
- if (isMatching(newLocation, location))
- return location;
- }
- }
- // No existing location was found so add this location to the list of known repositories
- if (addIfNotFound)
- KnownRepositories.getInstance().addRepository(newLocation, true);
- return newLocation;
- }
-
- /**
- * Checkout a CVS module.
- *
- * The provided project represents the target project. Any existing contents
- * may or may not get overwritten. If project is <code>null</code> then a project
- * will be created based on the provided sourceModule. If soureModule is null,
- * then the project name will be used as the module to
- * check out. If both are absent, an exception is thrown.
- *
- * Resources existing in the local file system at the target project location but now
- * known to the workbench will be overwritten.
- *
- * After the successful completion of this method, the project will exist
- * and be open.
- */
- public static void checkout(
- ICVSRepositoryLocation repository,
- IProject project,
- String sourceModule,
- CVSTag tag,
- IProgressMonitor monitor)
- throws TeamException {
-
- if (sourceModule == null)
- sourceModule = project.getName();
- checkout(new ICVSRemoteFolder[] { new RemoteFolder(null, repository, sourceModule, tag)},
- new IProject[] { project }, monitor);
- }
-
- /**
- * Checkout the remote resources into the local workspace. Each resource will
- * be checked out into the corresponding project. If the corresponding project is
- * null or if projects is null, the name of the remote resource is used as the name of the project.
- *
- * Resources existing in the local file system at the target project location but now
- * known to the workbench will be overwritten.
- */
- public static void checkout(final ICVSRemoteFolder[] resources, final IProject[] projects, final IProgressMonitor monitor) throws TeamException {
- final TeamException[] eHolder = new TeamException[1];
- try {
- IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor pm) throws CoreException {
- try {
- pm.beginTask(null, 1000 * resources.length);
-
- // Get the location of the workspace root
- ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot());
-
- for (int i=0;i<resources.length;i++) {
- IProject project = null;
- RemoteFolder resource = (RemoteFolder)resources[i];
-
- // Determine the provided target project if there is one
- if (projects != null)
- project = projects[i];
-
- // Determine the remote module to be checked out
- String moduleName;
- if (resource instanceof RemoteModule) {
- moduleName = ((RemoteModule)resource).getName();
- } else {
- moduleName = resource.getRepositoryRelativePath();
- }
-
- // Open a connection session to the repository
- ICVSRepositoryLocation repository = resource.getRepository();
- Session session = new Session(repository, root);
- try {
- session.open(Policy.subMonitorFor(pm, 50), false /* read-only */);
-
- // Determine the local target projects (either the project provider or the module expansions)
- final Set targetProjects = new HashSet();
- if (project == null) {
-
- // Fetch the module expansions
- IStatus status = Request.EXPAND_MODULES.execute(session, new String[] {moduleName}, Policy.subMonitorFor(pm, 50));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
-
- // Convert the module expansions to local projects
- String[] expansions = session.getModuleExpansions();
- for (int j = 0; j < expansions.length; j++) {
- targetProjects.add(ResourcesPlugin.getWorkspace().getRoot().getProject(new Path(null, expansions[j]).segment(0)));
- }
-
- } else {
- targetProjects.add(project);
- }
-
- // Prepare the target projects to receive resources
- root.run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- scrubProjects((IProject[]) targetProjects.toArray(new IProject[targetProjects.size()]), monitor);
- }
- }, Policy.subMonitorFor(pm, 100));
-
- // Build the local options
- List localOptions = new ArrayList();
- // Add the option to load into the target project if one was supplied
- if (project != null) {
- localOptions.add(Checkout.makeDirectoryNameOption(project.getName()));
- }
- // Prune empty directories if pruning enabled
- if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories())
- localOptions.add(Command.PRUNE_EMPTY_DIRECTORIES);
- // Add the options related to the CVSTag
- CVSTag tag = resource.getTag();
- if (tag == null) {
- // A null tag in a remote resource indicates HEAD
- tag = CVSTag.DEFAULT;
- }
- localOptions.add(Update.makeTagOption(tag));
-
- // Perform the checkout
- IStatus status = Command.CHECKOUT.execute(session,
- Command.NO_GLOBAL_OPTIONS,
- (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]),
- new String[]{moduleName},
- null,
- Policy.subMonitorFor(pm, 800));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- // XXX Should we cleanup any partially checked out projects?
- throw new CVSServerException(status);
- }
-
- // Bring the project into the workspace
- refreshProjects((IProject[])targetProjects.toArray(new IProject[targetProjects.size()]), Policy.subMonitorFor(pm, 100));
-
- } finally {
- session.close();
- }
- }
- }
- catch (TeamException e) {
- // Pass it outside the workspace runnable
- eHolder[0] = e;
- } finally {
- pm.done();
- }
- // CoreException and OperationCanceledException are propagated
- }
- };
- ResourcesPlugin.getWorkspace().run(workspaceRunnable, getCheckoutRule(projects), 0, monitor);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- monitor.done();
- }
- // Re-throw the TeamException, if one occurred
- if (eHolder[0] != null) {
- throw eHolder[0];
- }
- }
-
- private static ISchedulingRule getCheckoutRule(final IProject[] projects) {
- if (projects.length == 1) {
- return ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(projects[0]);
- } else {
- Set rules = new HashSet();
- for (int i = 0; i < projects.length; i++) {
- ISchedulingRule modifyRule = ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(projects[i]);
- if (modifyRule instanceof IResource && ((IResource)modifyRule).getType() == IResource.ROOT) {
- // One of the projects is mapped to a provider that locks the workspace.
- // Just return the workspace root rule
- return modifyRule;
- }
- rules.add(modifyRule);
- }
- return new MultiRule((ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules.size()]));
- }
- }
- /*
- * Bring the provied projects into the workspace
- */
- /* internal use only */ static void refreshProjects(IProject[] projects, IProgressMonitor monitor) throws CoreException, TeamException {
- monitor.beginTask(CVSMessages.CVSProvider_Creating_projects_2, projects.length * 100);
- try {
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- // Register the project with Team
- RepositoryProvider.map(project, CVSProviderPlugin.getTypeId());
- CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId());
- provider.setWatchEditEnabled(CVSProviderPlugin.getPlugin().isWatchEditEnabled());
- }
-
- } finally {
- monitor.done();
- }
- }
-
- /*
- * Delete the target projects before checking out
- */
- /* internal use only */ static void scrubProjects(IProject[] projects, IProgressMonitor monitor) throws CVSException {
- if (projects == null) {
- monitor.done();
- return;
- }
- monitor.beginTask(CVSMessages.CVSProvider_Scrubbing_projects_1, projects.length * 100);
- try {
- for (int i=0;i<projects.length;i++) {
- IProject project = projects[i];
- if (project != null && project.exists()) {
- if(!project.isOpen()) {
- project.open(Policy.subMonitorFor(monitor, 10));
- }
- // We do not want to delete the project to avoid a project deletion delta
- // We do not want to delete the .project to avoid core exceptions
- monitor.subTask(CVSMessages.CVSProvider_Scrubbing_local_project_1);
- // unmap the project from any previous repository provider
- if (RepositoryProvider.getProvider(project) != null)
- RepositoryProvider.unmap(project);
- IResource[] children = project.members(IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
- IProgressMonitor subMonitor = Policy.subMonitorFor(monitor, 80);
- subMonitor.beginTask(null, children.length * 100);
- try {
- for (int j = 0; j < children.length; j++) {
- if ( ! children[j].getName().equals(".project")) {//$NON-NLS-1$
- children[j].delete(true /*force*/, Policy.subMonitorFor(subMonitor, 100));
- }
- }
- } finally {
- subMonitor.done();
- }
- } else if (project != null) {
- // Make sure there is no directory in the local file system.
- File location = new File(project.getParent().getLocation().toFile(), project.getName());
- if (location.exists()) {
- deepDelete(location);
- }
- }
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- monitor.done();
- }
- }
-
- private static void deepDelete(File resource) {
- if (resource.isDirectory()) {
- File[] fileList = resource.listFiles();
- for (int i = 0; i < fileList.length; i++) {
- deepDelete(fileList[i]);
- }
- }
- resource.delete();
- }
-
- public String getProject(String referenceString) {
- //team provider, cvs folder, project name
- StringTokenizer tokenizer = new StringTokenizer(referenceString, ","); //$NON-NLS-1$
- String version = tokenizer.nextToken();
- // If this is a newer version, then ignore it
- if (!version.equals("1.0")) //$NON-NLS-1$
- return null;
- try {
- LoadInfo info = new LoadInfo(tokenizer);
- return info.getProject().getName();
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- return null;
- }
- }
-
- public URI getURI(String referenceString) {
- //team provider, cvs folder, project name
- StringTokenizer tokenizer = new StringTokenizer(referenceString, ","); //$NON-NLS-1$
- String version = tokenizer.nextToken();
- // If this is a newer version, then ignore it
- if (!version.equals("1.0")) //$NON-NLS-1$
- return null;
- try {
- LoadInfo info = new LoadInfo(tokenizer);
- CVSURI cvsURI = new CVSURI(info.repositoryLocation,new Path(info.module),info.tag);
- return cvsURI.toURI();
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.ProjectSetCapability#asReference(java.net.URI, java.lang.String)
- */
- public String asReference(URI uri, String projectName) {
- try {
- CVSURI cvsURI = CVSURI.fromUri(uri);
- ICVSRepositoryLocation location = cvsURI.getRepository();
- ICVSFolder folder = cvsURI.toFolder();
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- return asReference((CVSRepositoryLocation)location, folder, project);
- } catch (TeamException e) {
- CVSProviderPlugin.log(e);
- return null;
- }
- }
-
- /**
- * Checks whether a dialog prompting for an addition repository location is
- * required.
- *
- * @see org.eclipse.team.internal.ccvs.ui.AlternativeRepositoryDialog
- * @see org.eclipse.team.internal.ccvs.ui.AlternativeRepositoryTable
- *
- * @param projects
- * an array of project to check out a mapping of project to
- * project load information
- *
- * @return a mapping of project to project load information
- *
- *
- * When non-empty map is returned it will contain a mapping of a repository
- * location (<code>ICVSRepositoryLocation</code>) from the project set
- * to a list of suggested, known repositories locations (<code>ICVSRepositoryLocation</code>)
- * to use. The list contains at least one element - a default location (same
- * as in the project set). It's always on the first position in the list.
- * It's possible that the repository location is known, but even then we
- * still allow user to select a different location. So, the default location
- * is optionally followed by compatible locations found. Finally, the last
- * positions are held by the rest of known locations.
- *
- * <p>
- * The order in which items are kept in a list also reflects the way a combo
- * box from the Alternative Repository dialog will look like.
- * </p>
- * <p>
- * Structure of the list:
- * <ul>
- * <li>default location form the project set</li>
- * <li>compatible locations (if found) - no particular order here</li>
- * <li>other known locations - no particular order here neither</li>
- * </ul>
- * </p>
- * An empty map is returned when the project set file contains all required
- * information.
- */
- private static Map isAdditionalRepositoryInformationRequired(
- IProject[] projects, final Map infoMap) {
-
- List confirmedProjectsList = Arrays.asList(projects);
-
- if (infoMap == null)
- return Collections.EMPTY_MAP;
-
- Set projectSetRepositoryLocations = new HashSet();
- for (Iterator iterator = infoMap.keySet().iterator(); iterator
- .hasNext();) {
- IProject project = (IProject) iterator.next();
- if (confirmedProjectsList.contains(project)) {
- LoadInfo loadInfo = (LoadInfo) infoMap.get(project);
- projectSetRepositoryLocations.add(loadInfo.repositoryLocation);
- }
- }
-
- // none of projects from project sets is confirmed to overwrite
- if (projectSetRepositoryLocations.isEmpty()) {
- return Collections.EMPTY_MAP;
- }
-
- List knownRepositories = Arrays.asList(KnownRepositories.getInstance()
- .getRepositories());
-
- Map resultMap = new HashMap();
-
- if (knownRepositories.isEmpty()) {
- // there are no known repositories so use repository location from
- // the project set
- for (Iterator iterator = projectSetRepositoryLocations.iterator(); iterator
- .hasNext();) {
- ICVSRepositoryLocation projectSetRepositoryLocation = (ICVSRepositoryLocation) iterator
- .next();
- ArrayList alternativeList = new ArrayList(1);
- alternativeList.add(projectSetRepositoryLocation);
- resultMap.put(projectSetRepositoryLocation,
- alternativeList);
- }
- } else if (!knownRepositories.containsAll(projectSetRepositoryLocations)) {
- // not all repositories from the project set are known
-
- for (Iterator iterator = projectSetRepositoryLocations.iterator(); iterator
- .hasNext();) {
- ICVSRepositoryLocation projectSetRepositoryLocation = (ICVSRepositoryLocation) iterator
- .next();
-
- List alternativeList = new ArrayList();
- List matchingList = new ArrayList();
- List compatibleList = new ArrayList();
- for (Iterator iterator2 = knownRepositories.iterator(); iterator2
- .hasNext();) {
- ICVSRepositoryLocation knownRepositoryLocation = (ICVSRepositoryLocation) iterator2
- .next();
- if (isMatching(projectSetRepositoryLocation,
- knownRepositoryLocation)) {
- matchingList.add(knownRepositoryLocation);
- } else if (isCompatible(knownRepositoryLocation,
- projectSetRepositoryLocation)) {
- compatibleList.add(knownRepositoryLocation);
- } else {
- alternativeList.add(knownRepositoryLocation);
- }
- }
-
- // comparator identical with the one from
- // org.eclipse.team.internal.ccvs.ui.repo.RepositoryComparator
- Comparator comparator = new Comparator() {
- public int compare(Object o1, Object o2) {
- if (o1 instanceof ICVSRepositoryLocation
- && o2 instanceof ICVSRepositoryLocation) {
- return ((ICVSRepositoryLocation) o1).getLocation(
- false).compareTo(
- ((ICVSRepositoryLocation) o2)
- .getLocation(false));
- }
- return 0;
- }
- };
-
- Collections.sort(alternativeList, comparator);
-
- Collections.sort(compatibleList, comparator);
- // add compatible repos before others
- alternativeList.addAll(0, compatibleList);
-
- // if matching repos found add them first instead of the
- // repository location from the project set
- if (matchingList.isEmpty()) {
- alternativeList.add(0, projectSetRepositoryLocation);
- } else {
- Collections.sort(matchingList, comparator);
- alternativeList.addAll(0, matchingList);
- }
-
- resultMap.put(projectSetRepositoryLocation,
- alternativeList);
- }
- } // else { all repositories are known, we don't need to prompt for
- // additional information }
-
- return resultMap;
- }
-
- /**
- * Same test as in org.eclipse.team.internal.ccvs.ui.CVSProjectPropertiesPage
- *
- * @see org.eclipse.team.internal.ccvs.ui.CVSProjectPropertiesPage#isCompatible
- *
- * @param location A location from known repositories collection
- * @param oldLocation A location to check c
- * @return Are given locations compatible
- */
- public static boolean isCompatible(ICVSRepositoryLocation location, ICVSRepositoryLocation oldLocation) {
- if (!location.getHost().equals(oldLocation.getHost())) return false;
- if (!location.getRootDirectory().equals(oldLocation.getRootDirectory())) return false;
- if (location.equals(oldLocation)) return false;
- return true;
- }
-
- private static boolean isMatching(ICVSRepositoryLocation newLocation, ICVSRepositoryLocation oldLocation) {
- if (oldLocation.getMethod() == newLocation.getMethod()
- && oldLocation.getHost().equals(newLocation.getHost())
- && oldLocation.getPort() == newLocation.getPort()
- && oldLocation.getRootDirectory().equals(newLocation.getRootDirectory()))
- return true;
- return false;
- }
-
- private Map promptForAdditionRepositoryInformation(Map alternativeMap) {
- IUserAuthenticator authenticator = CVSRepositoryLocation.getAuthenticator();
- return authenticator.promptToConfigureRepositoryLocations(alternativeMap);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java
deleted file mode 100644
index 2dd5ceae0..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java
+++ /dev/null
@@ -1,737 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jsch.core.IJSchService;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.Team;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.ConsoleListeners;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption;
-import org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener;
-import org.eclipse.team.internal.ccvs.core.mapping.CVSActiveChangeSetCollector;
-import org.eclipse.team.internal.ccvs.core.resources.FileModificationManager;
-import org.eclipse.team.internal.ccvs.core.util.*;
-import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class CVSProviderPlugin extends Plugin {
-
- // preference names
- public static final String READ_ONLY = "cvs.read.only"; //$NON-NLS-1$
- public static final String ENABLE_WATCH_ON_EDIT = "cvs.watch.on.edit"; //$NON-NLS-1$
-
- // external command to run for ext connection method
- public static final String DEFAULT_CVS_RSH = "ssh"; //$NON-NLS-1$
- // external command parameters
- public static final String DEFAULT_CVS_RSH_PARAMETERS = "-l {user} {host}"; //$NON-NLS-1$
- // remote command to run for ext connection method
- public static final String DEFAULT_CVS_SERVER = "cvs"; //$NON-NLS-1$
- // determines if empty directories received from the server should be pruned.
- public static final boolean DEFAULT_PRUNE = true;
- // determines if the user is prompted for confirmation before moving tags during a tag operation.
- public static final boolean DEFAULT_CONFIRM_MOVE_TAG = true;
- // determines if new directories should be discovered during update.
- public static final boolean DEFAULT_FETCH = true;
- // communication timeout with the server
- public static final int DEFAULT_TIMEOUT = 60;
- // file transfer compression level (0 - 9)
- public static final int DEFAULT_COMPRESSION_LEVEL = 0;
- // default text keyword substitution mode
- public static final KSubstOption DEFAULT_TEXT_KSUBST_OPTION = Command.KSUBST_TEXT_EXPAND;
-
- // cvs plugin extension points and ids
- public static final String ID = "org.eclipse.team.cvs.core"; //$NON-NLS-1$
-
- public static final QualifiedName CVS_WORKSPACE_SUBSCRIBER_ID = new QualifiedName("org.eclipse.team.cvs.ui.cvsworkspace-participant", "syncparticipant"); //$NON-NLS-1$ //$NON-NLS-2$
- public static final String PT_AUTHENTICATOR = "authenticator"; //$NON-NLS-1$
- public static final String PT_CONNECTIONMETHODS = "connectionmethods"; //$NON-NLS-1$
- public static final String PT_FILE_MODIFICATION_VALIDATOR = "filemodificationvalidator"; //$NON-NLS-1$
-
- private QuietOption quietness;
- private int compressionLevel = DEFAULT_COMPRESSION_LEVEL;
- private KSubstOption defaultTextKSubstOption = DEFAULT_TEXT_KSUBST_OPTION;
- private boolean usePlatformLineend = true;
- private int communicationsTimeout = DEFAULT_TIMEOUT;
- private boolean pruneEmptyDirectories = DEFAULT_PRUNE;
- private boolean fetchAbsentDirectories = DEFAULT_FETCH;
- private boolean replaceUnmanaged = true;
- private boolean repositoriesAreBinary = false;
- private String cvsRshCommand = DEFAULT_CVS_RSH;
- private String cvsRshParameters = DEFAULT_CVS_RSH_PARAMETERS;
- private String cvsServer = DEFAULT_CVS_SERVER;
- private boolean determineVersionEnabled = true;
-
- private static volatile CVSProviderPlugin instance;
-
- // CVS specific resource delta listeners
- private BuildCleanupListener addDeleteMoveListener;
- private FileModificationManager fileModificationManager;
- private SyncFileChangeListener metaFileSyncListener;
-
- private static final String REPOSITORIES_STATE_FILE = ".cvsProviderState"; //$NON-NLS-1$
- // version numbers for the state file (a positive number indicates version 1)
- private static final int REPOSITORIES_STATE_FILE_VERSION_2 = -1;
- private static List decoratorEnablementListeners = new ArrayList();
-
- private CVSWorkspaceSubscriber cvsWorkspaceSubscriber;
-
- /**
- * The identifier for the CVS nature
- * (value <code>"org.eclipse.team.cvs.core.nature"</code>).
- * The presence of this nature on a project indicates that it is
- * CVS-capable.
- *
- * @see org.eclipse.core.resources.IProject#hasNature
- */
- private static final String NATURE_ID = ID + ".cvsnature"; //$NON-NLS-1$
-
- // File used to idicate if the workbench was shut down properly or not
- private static final String CRASH_INDICATION_FILE = ".running"; //$NON-NLS-1$
- private boolean crash;
-
- private boolean autoShareOnImport;
- private boolean useProxy;
-
- public static final String PROXY_TYPE_HTTP = "HTTP"; //$NON-NLS-1$
- public static final String PROXY_TYPE_SOCKS5 = "SOCKS5"; //$NON-NLS-1$
- public static final String HTTP_DEFAULT_PORT = "80"; //$NON-NLS-1$
- public static final String SOCKS5_DEFAULT_PORT = "1080"; //$NON-NLS-1$
-
- private String proxyType;
- private String proxyHost;
- private String proxyPort;
- private boolean useProxyAuth;
-
- private CVSActiveChangeSetCollector changeSetManager;
- private ServiceTracker tracker;
-
- private static final String INFO_PROXY_USER = "org.eclipse.team.cvs.core.proxy.user"; //$NON-NLS-1$
- private static final String INFO_PROXY_PASS = "org.eclipse.team.cvs.core.proxy.pass"; //$NON-NLS-1$
-
- private static final URL FAKE_URL;
- static {
- URL temp = null;
- try {
- temp = new URL("http://org.eclipse.team.cvs.proxy.auth");//$NON-NLS-1$
- } catch (MalformedURLException e) {
- // Should never fail
- }
- FAKE_URL = temp;
- }
-
-
- public synchronized CVSWorkspaceSubscriber getCVSWorkspaceSubscriber() {
- if (cvsWorkspaceSubscriber == null) {
- cvsWorkspaceSubscriber = new CVSWorkspaceSubscriber(
- CVS_WORKSPACE_SUBSCRIBER_ID,
- CVSMessages.CVSProviderPlugin_20);
- }
- return cvsWorkspaceSubscriber;
- }
-
- /**
- * Constructor for CVSProviderPlugin.
- * @param descriptor
- */
- public CVSProviderPlugin() {
- super();
- instance = this;
- }
-
- /**
- * Convenience method for logging CoreExceptions to the plugin log
- */
- public static void log(CoreException e) {
- log(e.getStatus().getSeverity(), e.getMessage(), e);
- }
-
- /**
- * Log the given exception along with the provided message and severity indicator
- */
- public static void log(int severity, String message, Throwable e) {
- log(new Status(severity, ID, 0, message, e));
- }
-
- /**
- * Log the given status. Do not use this method for the IStatus from a CoreException.
- * Use<code>log(CoreException)</code> instead so the stack trace is not lost.
- */
- public static void log(IStatus status) {
- getPlugin().getLog().log(status);
- }
-
- /**
- * Returns the singleton plug-in instance.
- *
- * @return the plugin instance
- */
- public static CVSProviderPlugin getPlugin() {
- return instance;
- }
-
- /**
- * Answers the repository provider type id for the cvs plugin
- */
- public static String getTypeId() {
- return NATURE_ID;
- }
-
- /**
- * Sets the file transfer compression level. (if supported)
- * Valid levels are: 0 (disabled), 1 (worst/fastest) - 9 (best/slowest)
- */
- public void setCompressionLevel(int level) {
- compressionLevel = level;
- }
-
- /**
- * Gets the file transfer compression level.
- */
- public int getCompressionLevel() {
- return compressionLevel;
- }
-
- /**
- * Sets the default keyword substitution mode for text files.
- */
- public void setDefaultTextKSubstOption(KSubstOption ksubst) {
- defaultTextKSubstOption = ksubst;
- }
-
-
- /**
- * Gets the default keyword substitution mode for text files.
- */
- public KSubstOption getDefaultTextKSubstOption() {
- return defaultTextKSubstOption;
- }
-
- /**
- * Should the CVS adapter prune empty directories
- */
- public boolean getPruneEmptyDirectories() {
- return pruneEmptyDirectories;
- }
-
- /**
- * Set whether the CVS adapter should prune empty directories
- */
- public void setPruneEmptyDirectories(boolean prune) {
- pruneEmptyDirectories = prune;
- }
-
- /**
- * Get the communications timeout value in seconds
- */
- public int getTimeout() {
- return communicationsTimeout;
- }
-
- /**
- * Set the timeout value for communications to a value in seconds.
- * The value must be greater than or equal 0. If is it 0, there is no timeout.
- */
- public void setTimeout(int timeout) {
- this.communicationsTimeout = Math.max(0, timeout);
- }
-
- /**
- * Set the quietness option to use with cvs commands.
- * Can be "", "-q" or "-Q"
- */
- public void setQuietness(QuietOption option) {
- this.quietness = option;
- }
-
- /**
- * Get the quietness option for commands
- */
- public QuietOption getQuietness() {
- return quietness;
- }
-
- /**
- * Set the console listener for commands.
- * @param consoleListener the listener
- */
- public void setConsoleListener(IConsoleListener consoleListener) {
- ConsoleListeners.getInstance().addListener(consoleListener);
- }
-
- /**
- * @see Plugin#start(BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
-
- // load the state which includes the known repositories
- loadOldState();
- crash = createCrashFile();
-
- // Initialize CVS change listeners. Note that the report type is important.
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- addDeleteMoveListener = new BuildCleanupListener();
- fileModificationManager = new FileModificationManager();
- metaFileSyncListener = new SyncFileChangeListener();
- workspace.addResourceChangeListener(addDeleteMoveListener, IResourceChangeEvent.POST_BUILD);
- workspace.addResourceChangeListener(metaFileSyncListener, IResourceChangeEvent.POST_CHANGE);
- workspace.addResourceChangeListener(fileModificationManager, IResourceChangeEvent.POST_CHANGE);
-
- getCVSWorkspaceSubscriber();
-
- // Must load the change set manager on startup since it listens to deltas
- getChangeSetManager();
-
- tracker = new ServiceTracker(getBundle().getBundleContext(), IJSchService.class.getName(), null);
- tracker.open();
- }
-
- /**
- * @see Plugin#stop(BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- try {
- savePluginPreferences();
-
- // remove listeners
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- workspace.removeResourceChangeListener(metaFileSyncListener);
- workspace.removeResourceChangeListener(fileModificationManager);
- workspace.removeResourceChangeListener(addDeleteMoveListener);
-
- // remove all of this plugin's save participants. This is easier than having
- // each class that added itself as a participant to have to listen to shutdown.
- workspace.removeSaveParticipant(this);
-
- getChangeSetManager().dispose();
-
- tracker.close();
-
- deleteCrashFile();
- } finally {
- super.stop(context);
- }
- }
-
- /**
- * @see org.eclipse.core.runtime.Plugin#initializeDefaultPluginPreferences()
- */
- protected void initializeDefaultPluginPreferences(){
- Preferences store = getPluginPreferences();
- store.setDefault(READ_ONLY, false);
- store.setDefault(ENABLE_WATCH_ON_EDIT, false);
- }
-
- /**
- * Gets the cvsRshCommand.
- * @return Returns a String
- */
- public String getCvsRshCommand() {
- return cvsRshCommand;
- }
-
- /**
- * Sets the cvsRshCommand.
- * @param cvsRshCommand The cvsRshCommand to set
- */
- public void setCvsRshCommand(String cvsRshCommand) {
- this.cvsRshCommand = cvsRshCommand;
- }
-
- /**
- * Returns the cvsRshParameters.
- * @return String
- */
- public String getCvsRshParameters() {
- return cvsRshParameters;
- }
-
- /**
- * Sets the cvsRshParameters.
- * @param cvsRshParameters The cvsRshParameters to set
- */
- public void setCvsRshParameters(String cvsRshParameters) {
- this.cvsRshParameters = cvsRshParameters;
- }
-
- /**
- * Gets the cvsServer.
- * @return Returns a String
- */
- public String getCvsServer() {
- return cvsServer;
- }
-
- /**
- * Sets the cvsServer.
- * @param cvsServer The cvsServer to set
- */
- public void setCvsServer(String cvsServer) {
- this.cvsServer = cvsServer;
- }
-
- /**
- * Gets the etchAbsentDirectories.
- * @return Returns a boolean
- */
- public boolean getFetchAbsentDirectories() {
- return fetchAbsentDirectories;
- }
-
- public boolean getRepositoriesAreBinary() {
- return repositoriesAreBinary;
- }
-
- /**
- * Sets the fetchAbsentDirectories.
- * @param etchAbsentDirectories The etchAbsentDirectories to set
- */
- public void setFetchAbsentDirectories(boolean fetchAbsentDirectories) {
- this.fetchAbsentDirectories = fetchAbsentDirectories;
- }
-
- public void setRepositoriesAreBinary(boolean binary) {
- repositoriesAreBinary = binary;
- }
-
- public static void broadcastDecoratorEnablementChanged(final boolean enabled) {
- ICVSDecoratorEnablementListener[] listeners;
- synchronized(decoratorEnablementListeners) {
- listeners = (ICVSDecoratorEnablementListener[]) decoratorEnablementListeners.toArray(new ICVSDecoratorEnablementListener[decoratorEnablementListeners.size()]);
- }
- for (int i = 0; i < listeners.length; i++) {
- final ICVSDecoratorEnablementListener listener = listeners[i];
- ISafeRunnable code = new ISafeRunnable() {
- public void run() throws Exception {
- listener.decoratorEnablementChanged(enabled);
- }
- public void handleException(Throwable e) {
- // don't log the exception....it is already being logged in Platform#run
- }
- };
- Platform.run(code);
- }
- }
-
- /**
- * Gets the replaceUnmanaged.
- * @return Returns a boolean
- */
- public boolean isReplaceUnmanaged() {
- return replaceUnmanaged;
- }
-
- /**
- * Sets the replaceUnmanaged.
- * @param replaceUnmanaged The replaceUnmanaged to set
- */
- public void setReplaceUnmanaged(boolean replaceUnmanaged) {
- this.replaceUnmanaged = replaceUnmanaged;
- }
-
-
- /**
- * Register to receive notification of repository creation and disposal
- */
- public void addRepositoryListener(ICVSListener listener) {
- KnownRepositories.getInstance().addRepositoryListener(listener);
- }
-
- /**
- * Register to receive notification of enablement of sync info decoration requirements. This
- * can be useful for providing lazy initialization of caches that are only required for decorating
- * resource with CVS information.
- */
- public void addDecoratorEnablementListener(ICVSDecoratorEnablementListener listener) {
- synchronized(decoratorEnablementListeners) {
- decoratorEnablementListeners.add(listener);
- }
- }
-
- /**
- * De-register a listener
- */
- public void removeRepositoryListener(ICVSListener listener) {
- KnownRepositories.getInstance().removeRepositoryListener(listener);
- }
-
- /**
- * De-register the decorator enablement listener.
- */
- public void removeDecoratorEnablementListener(ICVSDecoratorEnablementListener listener) {
- synchronized(decoratorEnablementListeners) {
- decoratorEnablementListeners.remove(listener);
- }
- }
-
- /**
- * Return a list of the know repository locations. This is left
- * here to isolate the RelEng tools plugin from changes in CVS core.
- */
- public ICVSRepositoryLocation[] getKnownRepositories() {
- return KnownRepositories.getInstance().getRepositories();
- }
-
- private void loadOldState() {
- try {
- IPath pluginStateLocation = CVSProviderPlugin.getPlugin().getStateLocation().append(REPOSITORIES_STATE_FILE);
- File file = pluginStateLocation.toFile();
- if (file.exists()) {
- try {
- DataInputStream dis = new DataInputStream(new FileInputStream(file));
- readOldState(dis);
- dis.close();
- // The file is no longer needed as the state is
- // persisted in the user settings
- file.delete();
- } catch (IOException e) {
- throw new TeamException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, CVSMessages.CVSProvider_ioException, e));
- }
- }
- } catch (TeamException e) {
- Util.logError(CVSMessages.CVSProvider_errorLoading, e);
- }
- }
-
- private void readOldState(DataInputStream dis) throws IOException, CVSException {
- KnownRepositories instance = KnownRepositories.getInstance();
- int count = dis.readInt();
- if (count >= 0) {
- // this is the version 1 format of the state file
- for (int i = 0; i < count; i++) {
- ICVSRepositoryLocation location = instance.getRepository(dis.readUTF());
- instance.addRepository(location, false /* no need to broadcast on startup */);
- }
- } else if (count == REPOSITORIES_STATE_FILE_VERSION_2) {
- count = dis.readInt();
- for (int i = 0; i < count; i++) {
- ICVSRepositoryLocation location = instance.getRepository(dis.readUTF());
- instance.addRepository(location, false /* no need to broadcast on startup */);
- // Read the next field which is no longer used
- dis.readUTF();
- }
- } else {
- Util.logError(NLS.bind(CVSMessages.CVSProviderPlugin_unknownStateFileVersion, new String[] { new Integer(count).toString() }), null);
- }
- }
-
- public static boolean isText(IFile file) {
- if (CVSProviderPlugin.getPlugin().getRepositoriesAreBinary()) return false;
- return Team.getFileContentManager().getType(file) == Team.TEXT;
- }
-
- /**
- * Gets the determineVersionEnabled.
- * @return boolean
- */
- public boolean isDetermineVersionEnabled() {
- return determineVersionEnabled;
- }
-
- /**
- * Sets the determineVersionEnabled.
- * @param determineVersionEnabled The determineVersionEnabled to set
- */
- public void setDetermineVersionEnabled(boolean determineVersionEnabled) {
- this.determineVersionEnabled = determineVersionEnabled;
- }
-
- /**
- * Returns the fileModificationManager.
- * @return FileModificationManager
- */
- public FileModificationManager getFileModificationManager() {
- return fileModificationManager;
- }
-
- /**
- * @return boolean
- */
- public boolean isWatchEditEnabled() {
- return getPluginPreferences().getBoolean(CVSProviderPlugin.READ_ONLY);
- }
-
- public void setDebugProtocol(boolean value) {
- Policy.DEBUG_CVS_PROTOCOL = value;
- }
-
- public boolean isDebugProtocol() {
- return Policy.DEBUG_CVS_PROTOCOL;
- }
-
- /*
- * Create the crash indicator file. This method returns true if the file
- * already existed, indicating that a crash occurred on the last invokation of
- * the platform.
- */
- private boolean createCrashFile() {
- IPath pluginStateLocation = CVSProviderPlugin.getPlugin().getStateLocation();
- File crashFile = pluginStateLocation.append(CRASH_INDICATION_FILE).toFile();
- if (crashFile.exists()) {
- return true;
- }
- try {
- crashFile.createNewFile();
- } catch (IOException e) {
- CVSProviderPlugin.log(IStatus.ERROR, e.getMessage(), e);
- }
- return false;
- }
-
- private void deleteCrashFile() {
- IPath pluginStateLocation = CVSProviderPlugin.getPlugin().getStateLocation();
- File crashFile = pluginStateLocation.append(CRASH_INDICATION_FILE).toFile();
- crashFile.delete();
- }
-
- public boolean crashOnLastRun() {
- return crash;
- }
-
- /**
- * Return the CVS preferences node in the instance scope
- */
- public org.osgi.service.prefs.Preferences getInstancePreferences() {
- return new InstanceScope().getNode(getBundle().getSymbolicName());
- }
-
- /**
- * @return Returns the usePlatformLineend.
- */
- public boolean isUsePlatformLineend() {
- return usePlatformLineend;
- }
- /**
- * @param usePlatformLineend The usePlatformLineend to set.
- */
- public void setUsePlatformLineend(boolean usePlatformLineend) {
- this.usePlatformLineend = usePlatformLineend;
- }
-
- public void setAutoshareOnImport(boolean autoShareOnImport) {
- this.autoShareOnImport = autoShareOnImport;
- }
-
- public boolean isAutoshareOnImport() {
- return autoShareOnImport;
- }
-
- /**
- * @return Returns the watchOnEdit.
- */
- public boolean isWatchOnEdit() {
- return getPluginPreferences().getBoolean(CVSProviderPlugin.ENABLE_WATCH_ON_EDIT);
- }
-
- // proxy configuration
-
- public void setUseProxy(boolean useProxy) {
- this.useProxy = useProxy;
- }
-
- public boolean isUseProxy() {
- return this.useProxy;
- }
-
- public void setProxyType(String proxyType) {
- this.proxyType = proxyType;
- }
-
- public String getProxyType() {
- return this.proxyType;
- }
-
- public void setProxyHost(String proxyHost) {
- this.proxyHost = proxyHost;
- }
-
- public String getProxyHost() {
- return this.proxyHost;
- }
-
- public void setProxyPort(String proxyPort) {
- this.proxyPort = proxyPort;
- }
-
- public String getProxyPort() {
- return this.proxyPort;
- }
-
- public void setUseProxyAuth(boolean useProxyAuth) {
- this.useProxyAuth = useProxyAuth;
- }
-
- public boolean isUseProxyAuth() {
- return this.useProxyAuth;
- }
-
- public String getProxyUser() {
- Object user = getAuthInfo().get(INFO_PROXY_USER);
- return user==null ? "" : (String) user; //$NON-NLS-1$
- }
-
- public String getProxyPassword() {
- Object pass = getAuthInfo().get(INFO_PROXY_PASS);
- return pass==null ? "" : (String) pass; //$NON-NLS-1$
- }
-
- private Map getAuthInfo() {
- // Retrieve username and password from keyring.
- Map authInfo = Platform.getAuthorizationInfo(FAKE_URL, "proxy", ""); //$NON-NLS-1$ //$NON-NLS-2$
- return authInfo!=null ? authInfo : Collections.EMPTY_MAP;
- }
-
- public void setProxyAuth(String proxyUser, String proxyPass) {
- Map authInfo = getAuthInfo();
- if (authInfo.size()==0) {
- authInfo = new java.util.HashMap(4);
- }
- if (proxyUser != null) {
- authInfo.put(INFO_PROXY_USER, proxyUser);
- }
- if (proxyPass != null) {
- authInfo.put(INFO_PROXY_PASS, proxyPass);
- }
- try {
- Platform.addAuthorizationInfo(FAKE_URL, "proxy", "", authInfo); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (CoreException e) {
- // We should probably wrap the CoreException here!
- CVSProviderPlugin.log(e);
- }
- }
-
- public synchronized ActiveChangeSetManager getChangeSetManager() {
- if (changeSetManager == null) {
- changeSetManager = new CVSActiveChangeSetCollector(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber());
- }
- return changeSetManager;
- }
-
- public IJSchService getJSchService() {
- return (IJSchService)tracker.getService();
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSResourceRuleFactory.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSResourceRuleFactory.java
deleted file mode 100644
index d1d31f888..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSResourceRuleFactory.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.team.ResourceRuleFactory;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-
-public class CVSResourceRuleFactory extends ResourceRuleFactory {
- public ISchedulingRule validateEditRule(IResource[] resources) {
- return CVSTeamProvider.internalGetFileModificationValidator().validateEditRule(this, resources);
- }
-
- public ISchedulingRule getParent(IResource resource) {
- return parent(resource);
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java
deleted file mode 100644
index e26599f02..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.core.variants.IResourceVariantComparator;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * CVSRevisionNumberCompareCriteria
- */
- public class CVSRevisionNumberCompareCriteria implements IResourceVariantComparator {
-
- private boolean isThreeWay;
-
- public CVSRevisionNumberCompareCriteria(boolean isThreeWay) {
- this.isThreeWay = isThreeWay;
- }
-
- /**
- * @see RemoteSyncElement#timestampEquals(IResourceVariant, IResourceVariant)
- */
- protected boolean compare(ICVSRemoteResource e1, ICVSRemoteResource e2) {
- if(e1.isContainer()) {
- if(e2.isContainer()) {
- return true;
- }
- return false;
- }
- return e1.equals(e2);
- }
-
- /**
- * @see RemoteSyncElement#timestampEquals(IResource, IResourceVariant)
- */
- protected boolean compare(IResource e1, ICVSRemoteResource e2) {
- if(e1.getType() != IResource.FILE) {
- if(e2.isContainer()) {
- return true;
- }
- return false;
- }
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)e1);
- try {
- byte[] syncBytes1 = cvsFile.getSyncBytes();
- byte[] syncBytes2 = ((ICVSRemoteFile)e2).getSyncBytes();
-
- if(syncBytes1 != null) {
- if(ResourceSyncInfo.isDeletion(syncBytes1) || ResourceSyncInfo.isMerge(syncBytes1) || cvsFile.isModified(null)) {
- return false;
- }
- return ResourceSyncInfo.getRevision(syncBytes1).equals(ResourceSyncInfo.getRevision(syncBytes2));
- }
- return false;
- } catch(CVSException e) {
- CVSProviderPlugin.log(e);
- return false;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.IComparisonCriteria#compare(org.eclipse.core.resources.IResource, org.eclipse.team.core.subscribers.ISubscriberResource)
- */
- public boolean compare(IResource local, IResourceVariant remote) {
- return compare(local, (ICVSRemoteResource)remote);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.IComparisonCriteria#compare(org.eclipse.team.core.subscribers.ISubscriberResource, org.eclipse.team.core.subscribers.ISubscriberResource)
- */
- public boolean compare(IResourceVariant base, IResourceVariant remote) {
- return compare((ICVSRemoteResource)base, (ICVSRemoteResource)remote);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.ISubscriberResourceComparator#isThreeWay()
- */
- public boolean isThreeWay() {
- return isThreeWay;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java
deleted file mode 100644
index a5309084b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.TeamStatus;
-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.util.KnownRepositories;
-
-public class CVSStatus extends TeamStatus {
-
- /*** Status codes ***/
- public static final int SERVER_ERROR = -10;
- public static final int NO_SUCH_TAG = -11;
- public static final int CONFLICT = -12;
- public static final int ERROR_LINE = -14; // generic uninterpreted E line from the server
- public static final int TAG_ALREADY_EXISTS = -15;
- public static final int COMMITTING_SYNC_INFO_FAILED = -16;
- public static final int DOES_NOT_EXIST = -17;
- public static final int FOLDER_NEEDED_FOR_FILE_DELETIONS = -18;
- public static final int CASE_VARIANT_EXISTS = -19;
- public static final int UNSUPPORTED_SERVER_VERSION = -20;
- public static final int SERVER_IS_CVSNT = -21;
- public static final int SERVER_IS_UNKNOWN = -22;
- public static final int PROTOCOL_ERROR = -23;
- public static final int ERROR_LINE_PARSE_FAILURE = -24;
- public static final int FAILED_TO_CACHE_SYNC_INFO = -25;
- public static final int UNMEGERED_BINARY_CONFLICT = -26;
- public static final int INVALID_LOCAL_RESOURCE_PATH = -27;
- public static final int RESPONSE_HANDLING_FAILURE = -28;
- public static final int COMMUNICATION_FAILURE = -29;
- public static final int AUTHENTICATION_FAILURE = -30;
-
- // Path for resource related status
- private ICVSFolder commandRoot;
- // Server information
- private ICVSRepositoryLocation cvsLocation;
-
- public CVSStatus(int severity, int code, String message, Throwable t, ICVSRepositoryLocation cvsLocation) {
- super(severity, CVSProviderPlugin.ID, code, message, t,null);
- this.cvsLocation = cvsLocation;
- }
-
- public CVSStatus(int severity, int code, String message,ICVSRepositoryLocation cvsLocation) {
- this(severity, code, message, null, cvsLocation);
- }
-
- public CVSStatus(int severity, int code, String message, Throwable t, IResource cvsResource) {
- super(severity, CVSProviderPlugin.ID, code, message, t, cvsResource);
- }
-
- public CVSStatus(int severity, int code, String message, IResource resource) {
- this(severity, code, message, null, resource);
- }
-
- public CVSStatus(int severity, int code, String message, Throwable t, ICVSFolder commandRoot) {
- super(severity, CVSProviderPlugin.ID, code, message, t, null);
- this.commandRoot = commandRoot;
- }
-
- public CVSStatus(int severity, int code, String message, ICVSFolder commandRoot) {
- this(severity, code, message, null, commandRoot);
- }
-
- public CVSStatus(int severity, int code, String message, Throwable t) {
- super(severity, CVSProviderPlugin.ID, code, message, t, null);
- }
-
- public CVSStatus(int severity, String message, Throwable t) {
- super(severity, CVSProviderPlugin.ID, CVSStatus.ERROR, message, t, null);
- }
-
- public CVSStatus(int severity, String message) {
- super(severity, CVSProviderPlugin.ID, CVSStatus.ERROR, message, null, null);
- }
-
- /**
- * @see IStatus#getMessage()
- */
- public String getMessage() {
- String message = super.getMessage();
- if (commandRoot != null) {
- message = NLS.bind(CVSMessages.CVSStatus_messageWithRoot, new String[] { commandRoot.getName(), message });
- }
- return message;
- }
-
- /**
- * Return whether this status is wrapping an internal error.
- * An internal error is any error for which the wrapped exception
- * is not a CVS exception. Check deeply to make sure there isn't
- * an internal error buried deep down.
- * @return whether this status is wrapping an internal error
- */
- public boolean isInternalError() {
- Throwable ex = getException();
- if (ex instanceof CVSException) {
- CVSException cvsEx = (CVSException) ex;
- IStatus status = cvsEx.getStatus();
- return isInternalError(status);
- }
- return ex != null;
- }
-
- /**
- * Return whether this status is wrapping an internal error.
- * An internal error is any error for which the wrapped exception
- * is not a CVS exception. Check deeply to make sure there isn't
- * an internal error buried deep down.
- * @return whether this status is wrapping an internal error
- */
- public static boolean isInternalError(IStatus status) {
- if (status instanceof CVSStatus) {
- return ((CVSStatus)status).isInternalError();
- }
- if (status.isMultiStatus()) {
- IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- IStatus child = children[i];
- if (isInternalError(child)) {
- return true;
- }
- }
- return false;
- }
- return true;
- }
-
- public ICVSRepositoryLocation getCvsLocation() {
- if (cvsLocation==null){
- try {
- if (commandRoot!=null){
- FolderSyncInfo info = commandRoot.getFolderSyncInfo();
- if (info!=null){
- String repoString = info.getRoot();
- cvsLocation = KnownRepositories.getInstance().getRepository(repoString);
- }
- } else if (getResource()!=null){
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(getResource().getProject());
- FolderSyncInfo info = folder.getFolderSyncInfo();
- if (info!=null){
- String repoString = info.getRoot();
- cvsLocation = KnownRepositories.getInstance().getRepository(repoString);
- }
- }
- } catch (CVSException e){
- // do nothing as we are already creating a status for an exception
- // we may need to trace it though
- }
- }
- return cvsLocation;
- }
-
- public ICVSFolder getCommandRoot() {
- return commandRoot;
- }
-
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java
deleted file mode 100644
index 2066da5c4..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.core.variants.ResourceVariantTreeSubscriber;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.resources.*;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
-import org.eclipse.team.internal.ccvs.core.util.SyncFileChangeListener;
-
-/**
- * CVSSyncInfo
- */
-public class CVSSyncInfo extends SyncInfo {
-
- /*
- * Codes that are used in returned IStatus
- */
- private static final int INVALID_RESOURCE_TYPE = 1;
- private static final int INVALID_SYNC_KIND = 2;
- private static final int PARENT_NOT_MANAGED = 3;
- private static final int REMOTE_DOES_NOT_EXIST = 4;
- private static final int SYNC_INFO_CONFLICTS = 5;
- private Subscriber subscriber;
-
- public CVSSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote, Subscriber subscriber) {
- super(local, base, remote, ((ResourceVariantTreeSubscriber)subscriber).getResourceComparator());
- this.subscriber = subscriber;
- }
-
- public Subscriber getSubscriber() {
- return subscriber;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.SyncInfo#computeSyncKind(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected int calculateKind() throws TeamException {
- // special handling for folders, the generic sync algorithm doesn't work well
- // with CVS because folders are not in namespaces (e.g. they exist in all versions
- // and branches).
- IResource local = getLocal();
- if(local.getType() != IResource.FILE) {
- int folderKind = SyncInfo.IN_SYNC;
- ICVSRemoteFolder remote = (ICVSRemoteFolder)getRemote();
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)local);
- boolean isCVSFolder = false;
- try {
- isCVSFolder = cvsFolder.isCVSFolder();
- } catch (CVSException e) {
- // Assume the folder is not a CVS folder
- }
- if(!local.exists()) {
- if(remote != null) {
- if (isCVSFolder) {
- // TODO: This assumes all CVS folders are in-sync even if they have been pruned!
- folderKind = SyncInfo.IN_SYNC;
- } else {
- folderKind = SyncInfo.INCOMING | SyncInfo.ADDITION;
- }
- } else {
- // ignore conflicting deletion to keep phantom sync info
- }
- } else {
- if(remote == null) {
- if(isCVSFolder) {
- // TODO: This is not really an incoming deletion
- // The folder will be pruned once any children are commited
- folderKind = SyncInfo.IN_SYNC;
- //folderKind = SyncInfo.INCOMING | SyncInfo.DELETION;
- } else {
- folderKind = SyncInfo.OUTGOING | SyncInfo.ADDITION;
- }
- } else if(!isCVSFolder) {
- folderKind = SyncInfo.CONFLICTING | SyncInfo.ADDITION;
- } else {
- // folder exists both locally and remotely and are considered in sync, however
- // we aren't checking the folder mappings to ensure that they are the same.
- }
- }
- return folderKind;
- }
-
- // 1. Run the generic sync calculation algorithm, then handle CVS specific
- // sync cases.
- int kind = super.calculateKind();
-
- // 2. Set the CVS specific sync type based on the workspace sync state provided
- // by the CVS server.
- IResourceVariant remote = getRemote();
- if(remote!=null && (kind & SyncInfo.PSEUDO_CONFLICT) == 0) {
- RemoteResource cvsRemote = (RemoteResource)remote;
- int type = cvsRemote.getWorkspaceSyncState();
- switch(type) {
- // the server compared both text files and decided that it cannot merge
- // them without line conflicts.
- case Update.STATE_CONFLICT:
- return kind | SyncInfo.MANUAL_CONFLICT;
-
- // the server compared both text files and decided that it can safely merge
- // them without line conflicts.
- case Update.STATE_MERGEABLE_CONFLICT:
- return kind | SyncInfo.AUTOMERGE_CONFLICT;
- }
- }
-
- // 3. unmanage delete/delete conflicts and return that they are in sync
- kind = handleDeletionConflicts(kind);
-
- return kind;
- }
-
- /*
- * If the resource has a delete/delete conflict then ensure that the local is unmanaged so that the
- * sync info can be properly flushed.
- */
- protected int handleDeletionConflicts(int kind) {
- if(kind == (SyncInfo.CONFLICTING | SyncInfo.DELETION | SyncInfo.PSEUDO_CONFLICT)) {
- try {
- IResource local = getLocal();
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(local);
- if(!cvsResource.isFolder() && cvsResource.isManaged()) {
- // Reconcile the conflicting deletion in the background
- SyncFileChangeListener.getDeferredHandler().handleConflictingDeletion(local);
- }
- return SyncInfo.IN_SYNC;
- } catch(CVSException e) {
- CVSProviderPlugin.log(e);
- return SyncInfo.CONFLICTING | SyncInfo.DELETION;
- }
- }
- return kind;
- }
-
- /*
- * Update the sync info of the local resource in such a way that the local changes can be committed.
- * @return IStatus
- * For folders, the makeInSYnc method is called and the return codes mentioned there apply
- * for folders.
- */
- public IStatus makeOutgoing(IProgressMonitor monitor) throws TeamException {
-
- // For folders, there is no outgoing, only in-sync
- if (getLocal().getType() == IResource.FOLDER) {
- return makeInSync();
- }
- int syncKind = getKind();
- boolean incoming = (syncKind & DIRECTION_MASK) == INCOMING;
- boolean outgoing = (syncKind & DIRECTION_MASK) == OUTGOING;
-
- ICVSResource local = CVSWorkspaceRoot.getCVSResourceFor(getLocal());
- RemoteResource remote = (RemoteResource)getRemote();
- ResourceSyncInfo origInfo = local.getSyncInfo();
- MutableResourceSyncInfo info = null;
- if(origInfo!=null) {
- info = origInfo.cloneMutable();
- }
-
- if (outgoing) {
- // The sync info is alright, it's already outgoing!
- return Status.OK_STATUS;
- } else if (incoming) {
- // We have an incoming change, addition, or deletion that we want to ignore
- if (local.exists()) {
- if (remote == null) {
- info.setAdded();
- } else {
- // Otherwise change the revision to the remote revision and dirty the file
- info.setRevision(remote.getSyncInfo().getRevision());
- info.setTimeStamp(null);
- }
- } else {
- // We have an incoming add, turn it around as an outgoing delete
- if (remote == null) {
- // Both the local and remote do not exist so clear the sync info
- info = null;
- return Status.OK_STATUS;
- } else {
- info = remote.getSyncInfo().cloneMutable();
- info.setDeleted(true);
- }
- }
- } else if (local.exists()) {
- // We have a conflict and a local resource!
- if (getRemote() != null) {
- if (getBase() != null) {
- // We have a conflicting change, Update the local revision
- info.setRevision(remote.getSyncInfo().getRevision());
- } else {
- try {
- // We have conflicting additions.
- // We need to fetch the contents of the remote to get all the relevant information (timestamp, permissions)
- // The most important thing we get is the keyword substitution mode which must be right to perform the commit
- remote.getStorage(Policy.monitorFor(monitor)).getContents();
- info = remote.getSyncInfo().cloneMutable();
- } catch (CoreException e) {
- throw TeamException.asTeamException(e);
- }
- }
- } else if (getBase() != null) {
- // We have a remote deletion. Make the local an addition
- info.setAdded();
- } else {
- // There's a local, no base and no remote. We can't possible have a conflict!
- Assert.isTrue(false);
- }
- } else {
- // We have a conflict and there is no local!
- if (getRemote() != null) {
- // We have a local deletion that conflicts with remote changes.
- info.setRevision(remote.getSyncInfo().getRevision());
- info.setDeleted(true);
- } else {
- // We have conflicting deletions. Clear the sync info
- info = null;
- return Status.OK_STATUS;
- }
- }
- if(info!=null) {
- FolderSyncInfo parentInfo = local.getParent().getFolderSyncInfo();
- if (parentInfo == null) {
- return new CVSStatus(IStatus.ERROR, PARENT_NOT_MANAGED, NLS.bind(CVSMessages.CVSSyncInfo_9, new String[] { getLocal().getFullPath().toString()}), getLocal());
- }
- info.setTag(parentInfo.getTag());
- }
- ((ICVSFile)local).setSyncInfo(info, ICVSFile.UNKNOWN);
- return Status.OK_STATUS;
- }
-
- /*
- * Load the resource and folder sync info into the local from the remote
- *
- * This method can be used on incoming folder additions to set the folder sync info properly
- * without hitting the server again. It also applies to conflicts that involves unmanaged
- * local resources.
- *
- * @return an IStatus with the following severity and codes
- * <ul>
- * <li>IStatus.WARNING
- * <ul>
- * <li>INVALID_RESOURCE_TYPE - makeInSync only works on folders
- * <li>INVALID_SYNC_KIND - sync direction must be incoming or conflicting
- * </ul>
- * <li>IStatus.ERROR
- * <ul>
- * <li>PARENT_NOT_MANAGED - the local parent of the resource is not under CVS control
- * <li>SYNC_INFO_CONFLICTS - Sync info already exists locally and differs from the info
- * in the remote handle.
- * <li>REMOTE_DOES_NOT_EXIST - There is no local sync info and there is no remote handle
- * </ul>
- * </ul>
- */
- public IStatus makeInSync() throws CVSException {
-
- // Only works on folders
- if (getLocal().getType() == IResource.FILE) {
- return new CVSStatus(IStatus.WARNING, INVALID_RESOURCE_TYPE, NLS.bind(CVSMessages.CVSSyncInfo_7, new String[] { getLocal().getFullPath().toString()}), getLocal());
- }
-
- // Only works on outgoing and conflicting changes
- boolean outgoing = (getKind() & DIRECTION_MASK) == OUTGOING;
- if (outgoing) {
- return new CVSStatus(IStatus.WARNING, INVALID_SYNC_KIND, NLS.bind(CVSMessages.CVSSyncInfo_8, new String[] { getLocal().getFullPath().toString() }), getLocal());
- }
-
- // The parent must be managed
- ICVSFolder local = CVSWorkspaceRoot.getCVSFolderFor((IContainer)getLocal());
- if (getLocal().getType() == IResource.FOLDER && ! local.getParent().isCVSFolder())
- return new CVSStatus(IStatus.ERROR, PARENT_NOT_MANAGED, NLS.bind(CVSMessages.CVSSyncInfo_9, new String[] { getLocal().getFullPath().toString() }), getLocal());
-
- // Ensure that the folder exists locally
- if (! local.exists()) {
- local.mkdir();
- }
-
- // If the folder already has CVS info, check that the remote and local match
- RemoteFolder remote = (RemoteFolder)getRemote();
- if((local.isManaged() || getLocal().getType() == IResource.PROJECT) && local.isCVSFolder()) {
- // If there's no remote, assume everything is OK
- if (remote == null) return Status.OK_STATUS;
- // Verify that the root and repository are the same
- FolderSyncInfo remoteInfo = remote.getFolderSyncInfo();
- FolderSyncInfo localInfo = local.getFolderSyncInfo();
- if ( ! localInfo.getRoot().equals(remoteInfo.getRoot())) {
- return new CVSStatus(IStatus.ERROR, SYNC_INFO_CONFLICTS, NLS.bind(CVSMessages.CVSRemoteSyncElement_rootDiffers, (new Object[] {local.getName(), remoteInfo.getRoot(), localInfo.getRoot()})),getLocal());
- } else if ( ! localInfo.getRepository().equals(remoteInfo.getRepository())) {
- return new CVSStatus(IStatus.ERROR, SYNC_INFO_CONFLICTS, NLS.bind(CVSMessages.CVSRemoteSyncElement_repositoryDiffers, (new Object[] {local.getName(), remoteInfo.getRepository(), localInfo.getRepository()})),getLocal());
- }
- // The folders are in sync so just return
- return Status.OK_STATUS;
- }
-
- // The remote must exist if the local is not managed
- if (remote == null) {
- return new CVSStatus(IStatus.ERROR, REMOTE_DOES_NOT_EXIST, NLS.bind(CVSMessages.CVSSyncInfo_10, new String[] { getLocal().getFullPath().toString() }),getLocal());
- }
-
- // Since the parent is managed, this will also set the resource sync info. It is
- // impossible for an incoming folder addition to map to another location in the
- // repo, so we assume that using the parent's folder sync as a basis is safe.
- // It is also impossible for an incomming folder to be static.
- FolderSyncInfo remoteInfo = remote.getFolderSyncInfo();
- FolderSyncInfo localInfo = local.getParent().getFolderSyncInfo();
- MutableFolderSyncInfo newInfo = remoteInfo.cloneMutable();
- newInfo.setTag(localInfo.getTag());
- newInfo.setStatic(false);
- local.setFolderSyncInfo(newInfo);
- return Status.OK_STATUS;
- }
-
- public String toString() {
- IResourceVariant base = getBase();
- IResourceVariant remote = getRemote();
- StringBuffer result = new StringBuffer(super.toString());
- result.append("Local: "); //$NON-NLS-1$
- result.append(getLocal().toString());
- result.append(" Base: "); //$NON-NLS-1$
- if (base == null) {
- result.append("none"); //$NON-NLS-1$
- } else {
- result.append(base.toString());
- }
- result.append(" Remote: "); //$NON-NLS-1$
- if (remote == null) {
- result.append("none"); //$NON-NLS-1$
- } else {
- result.append(remote.toString());
- }
- return result.toString();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.SyncInfo#getContentIdentifier()
- */
- public String getLocalContentIdentifier() {
- try {
- IResource local = getLocal();
- if (local != null && local.getType() == IResource.FILE) {
- // it's a file, return the revision number if we can find one
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile) local);
- ResourceSyncInfo info = cvsFile.getSyncInfo();
- if (info != null) {
- return info.getRevision();
- }
- }
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- return null;
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java
deleted file mode 100644
index 151a4ebdf..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.diff.IDiff;
-import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.variants.*;
-import org.eclipse.team.internal.ccvs.core.filehistory.CVSResourceVariantFileRevision;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.core.mapping.ResourceVariantFileRevision;
-import org.eclipse.team.internal.core.mapping.SyncInfoToDiffConverter;
-
-/**
- * This class provides common functionality for three way synchronizing
- * for CVS.
- */
-public abstract class CVSSyncTreeSubscriber extends ResourceVariantTreeSubscriber implements IAdaptable {
-
- public static final String SYNC_KEY_QUALIFIER = "org.eclipse.team.cvs"; //$NON-NLS-1$
-
- private IResourceVariantComparator comparisonCriteria;
-
- private QualifiedName id;
- private String name;
- private SyncInfoToDiffConverter converter = new CVSSyncInfoToDiffConverter();
-
- public class CVSSyncInfoToDiffConverter extends SyncInfoToDiffConverter {
- protected ResourceVariantFileRevision asFileRevision(IResourceVariant variant) {
- return new CVSResourceVariantFileRevision(variant);
- }
- }
-
- CVSSyncTreeSubscriber(QualifiedName id, String name) {
- this.id = id;
- this.name = name;
- this.comparisonCriteria = new CVSRevisionNumberCompareCriteria(isThreeWay());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.ISyncTreeSubscriber#getId()
- */
- public QualifiedName getId() {
- return id;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.ISyncTreeSubscriber#getName()
- */
- public String getName() {
- return name;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.ISyncTreeSubscriber#getSyncInfo(org.eclipse.core.resources.IResource)
- */
- public SyncInfo getSyncInfo(IResource resource) throws TeamException {
- if (!isSupervised(resource)) return null;
- if(resource.getType() == IResource.FILE || !isThreeWay()) {
- return super.getSyncInfo(resource);
- } else {
- // In CVS, folders do not have a base. Hence, the remote is used as the base.
- IResourceVariant remoteResource = getRemoteTree().getResourceVariant(resource);
- return getSyncInfo(resource, remoteResource, remoteResource);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.ISyncTreeSubscriber#isSupervised(org.eclipse.core.resources.IResource)
- */
- public boolean isSupervised(IResource resource) throws TeamException {
- try {
- RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId());
- if (provider == null) return false;
- // TODO: what happens for resources that don't exist?
- // TODO: is it proper to use ignored here?
- ICVSResource cvsThing = CVSWorkspaceRoot.getCVSResourceFor(resource);
- if (cvsThing.isIgnored()) {
- // An ignored resource could have an incoming addition (conflict)
- return getRemoteTree().hasResourceVariant(resource);
- }
- return true;
- } catch (TeamException e) {
- // If there is no resource in core this means there is no local and no remote
- // so the resource is not supervised.
- if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND || !resource.getProject().isAccessible()) {
- return false;
- }
- throw e;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.TeamSubscriber#getDefaultComparisonCriteria()
- */
- public IResourceVariantComparator getResourceComparator() {
- return comparisonCriteria;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.core.subscribers.caches.ResourceVariantTreeSubscriber#getSyncInfo(org.eclipse.core.resources.IResource, org.eclipse.team.core.synchronize.IResourceVariant, org.eclipse.team.core.synchronize.IResourceVariant)
- */
- protected SyncInfo getSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote) throws TeamException {
- CVSSyncInfo info = new CVSSyncInfo(local, base, remote, this);
- info.init();
- return info;
- }
-
- /*
- * Indicate whether file contents should be cached on a refresh
- */
- protected boolean getCacheFileContentsHint() {
- return false;
- }
-
- /*
- * Indicate whether the subscriber is two-way or three-way
- */
- protected boolean isThreeWay() {
- return true;
- }
-
- protected boolean rootsEqual(Subscriber other) {
- Set roots1 = new HashSet(Arrays.asList(other.roots()));
- Set roots2 = new HashSet(Arrays.asList(roots()));
- if(roots1.size() != roots2.size()) return false;
- return roots2.containsAll(roots1);
- }
-
-
- public IDiff getDiff(IResource resource) throws CoreException {
- SyncInfo info = getSyncInfo(resource);
- if (info == null || info.getKind() == SyncInfo.IN_SYNC)
- return null;
- return converter.getDeltaFor(info);
- }
- public Object getAdapter(Class adapter) {
- if (adapter == SyncInfoToDiffConverter.class) {
- return converter;
- }
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTag.java
deleted file mode 100644
index 8cc60f527..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTag.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.core.history.ITag;
-
-/**
- * A tag in CVS gives a label to a collection of revisions. The labels can represent a version, a branch,
- * or a date.
- */
-public class CVSTag implements ITag {
-
- public final static int HEAD = 0;
- public final static int BRANCH = 1;
- public final static int VERSION = 2;
- public final static int DATE = 3;
-
- public static final CVSTag DEFAULT = new CVSTag();
- public static final CVSTag BASE = new CVSTag("BASE", VERSION); //$NON-NLS-1$
-
- protected String name;
- protected int type;
-
- private static final String DATE_TAG_NAME_FORMAT = "dd MMM yyyy HH:mm:ss Z";//$NON-NLS-1$
- private static final SimpleDateFormat tagNameFormat = new SimpleDateFormat(DATE_TAG_NAME_FORMAT, Locale.US);
- protected static synchronized String dateToTagName(Date date){
- tagNameFormat.setTimeZone(TimeZone.getTimeZone("GMT"));//$NON-NLS-1$
- return tagNameFormat.format(date);
- }
- protected synchronized static Date tagNameToDate(String name){
- if (name == null) return null;
- try {
- return tagNameFormat.parse(name);
- } catch (ParseException e) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR,"Tag name " + name + " is not of the expected format " + DATE_TAG_NAME_FORMAT,e ); //$NON-NLS-1$ //$NON-NLS-2$
- CVSProviderPlugin.log(new CVSException(status));
- return null;
- }
- }
-
- public CVSTag() {
- this("HEAD", HEAD); //$NON-NLS-1$
- }
-
- public CVSTag(String name, int type) {
- this.name = name;
- this.type = type;
- }
- //Write a date in local date tag format
- public CVSTag(Date date) {
- this(dateToTagName(date), DATE);
- }
-
- public boolean equals(Object other) {
- if(other == this) return true;
- if (!(other instanceof CVSTag)) return false;
-
- CVSTag tag = ((CVSTag)other);
- if (getType() != tag.getType()) return false;
- if (!getName().equals(tag.getName())) return false;
- return true;
- }
-
- public String getName() {
- return name;
- }
-
- public int getType() {
- // TODO: getType() will not return accurate types for Tags retrieved from the local CVS Entries file. See Bug: 36758
- return type;
- }
-
- public int hashCode() {
- return name.hashCode();
- }
-
- public int compareTo(CVSTag other) {
- if(getType() == DATE && other.getType()== DATE){
- Date date1 = asDate();
- Date date2 = other.asDate();
- if(date1 == null || date2 == null)return -1;
- return date1.compareTo(date2);
- }
- return getName().compareToIgnoreCase(other.getName());
- }
-
- public static boolean equalTags(CVSTag tag1, CVSTag tag2) {
- if (tag1 == null) tag1 = CVSTag.DEFAULT;
- if (tag2 == null) tag2 = CVSTag.DEFAULT;
- return tag1.equals(tag2);
- }
-
- public static IStatus validateTagName(String tagName) {
- if (tagName == null)
- return new CVSStatus(IStatus.ERROR, CVSMessages.CVSTag_nullName);
- if (tagName.equals("")) //$NON-NLS-1$
- return new CVSStatus(IStatus.ERROR, CVSMessages.CVSTag_emptyName);
- if (!Character. isLetter(tagName.charAt(0)))
- return new CVSStatus(IStatus.ERROR, CVSMessages.CVSTag_beginName);
-
- for (int i = 0; i < tagName.length(); i++) {
- char c = tagName.charAt(i);
- if ( Character.isSpaceChar(c) || c == '$' || c == ',' || c == '.' || c == ':' || c == ';' || c == '@' || c == '|')
- return new CVSStatus(IStatus.ERROR, CVSMessages.CVSTag_badCharName);
- }
- return new CVSStatus(IStatus.OK, CVSMessages.ok);
- }
-
- /**
- * Return the date this tag represents or <code>null</code>
- * if the tag is not of type DATE.
- * @return the date of the tag or <code>null</code>
- */
- public Date asDate(){
- return tagNameToDate(name);
- }
- public boolean isHeadTag() {
- return getType() == HEAD || (getType() == VERSION && getName().equals("HEAD")); //$NON-NLS-1$
- }
-
- public boolean isBaseTag() {
- return getName().equals("BASE"); //$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java
deleted file mode 100644
index 5be340a42..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java
+++ /dev/null
@@ -1,872 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import java.io.*;
-import java.net.URI;
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.resources.team.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.history.IFileHistoryProvider;
-import org.eclipse.team.internal.ccvs.core.client.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.client.listeners.*;
-import org.eclipse.team.internal.ccvs.core.filehistory.CVSFileHistoryProvider;
-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.*;
-import org.eclipse.team.internal.ccvs.core.util.*;
-import org.eclipse.team.internal.core.streams.CRLFtoLFInputStream;
-import org.eclipse.team.internal.core.streams.LFtoCRLFInputStream;
-
-/**
- * CVS implementation of {@link RepositoryProvider}
- */
-public class CVSTeamProvider extends RepositoryProvider {
-
- private static final ResourceRuleFactory RESOURCE_RULE_FACTORY = new CVSResourceRuleFactory();
-
- private static final boolean IS_CRLF_PLATFORM = Arrays.equals(
- System.getProperty("line.separator").getBytes(), new byte[] { '\r', '\n' }); //$NON-NLS-1$
-
- public static final IStatus OK = new Status(IStatus.OK, CVSProviderPlugin.ID, 0, CVSMessages.ok, null);
-
- private CVSWorkspaceRoot workspaceRoot;
- private IProject project;
-
- private static MoveDeleteHook moveDeleteHook= new MoveDeleteHook();
- private static CVSCoreFileModificationValidator fileModificationValidator;
- private static CVSFileHistoryProvider fileHistoryProvider;
-
- // property used to indicate whether new directories should be discovered for the project
- private final static QualifiedName FETCH_ABSENT_DIRECTORIES_PROP_KEY =
- new QualifiedName("org.eclipse.team.cvs.core", "fetch_absent_directories"); //$NON-NLS-1$ //$NON-NLS-2$
- // property used to indicate whether the project is configured to use Watch/edit
- private final static QualifiedName WATCH_EDIT_PROP_KEY =
- new QualifiedName("org.eclipse.team.cvs.core", "watch_edit"); //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * Session property key used to indicate that the project, although not officially shared,
- * is a target of a CVS operation.
- */
- private static final QualifiedName TEMP_SHARED = new QualifiedName(CVSProviderPlugin.ID, "tempShare"); //$NON-NLS-1$
-
- /**
- * Return whether the project is mapped to CVS or is the target of a CVS operation
- * that will most likely lead to the project being shared.
- * @param project the project
- * @return whether the project is mapped to CVS or is the target of a CVS operation
- * that will most likely lead to the project being shared
- */
- public static boolean isSharedWithCVS(IProject project) {
- if (project.isAccessible()) {
- if (RepositoryProvider.isShared(project)) {
- RepositoryProvider provider = RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId());
- if (provider != null)
- return true;
- }
- try {
- Object sessionProperty = project.getSessionProperty(TEMP_SHARED);
- return sessionProperty != null && sessionProperty.equals(Boolean.TRUE);
- } catch (CoreException e) {
- CVSProviderPlugin.log(e);
- }
- }
- return false;
- }
-
- /**
- * Mark the project as being a target of a CVS operation so the sync info management
- * will occur.
- * @param project the project
- */
- public static void markAsTempShare(IProject project) {
- if (RepositoryProvider.isShared(project))
- return;
- try {
- project.setSessionProperty(CVSTeamProvider.TEMP_SHARED, Boolean.TRUE);
- } catch (CoreException e) {
- CVSProviderPlugin.log(e);
- }
- }
-
- /**
- * Return the file modification validator used for all CVS repository providers.
- * @return the file modification validator used for all CVS repository providers
- */
- protected static CVSCoreFileModificationValidator internalGetFileModificationValidator() {
- if (CVSTeamProvider.fileModificationValidator == null) {
- CVSTeamProvider.fileModificationValidator = new CVSCoreFileModificationValidator();
- }
- return CVSTeamProvider.fileModificationValidator;
- }
-
- /**
- * No-arg Constructor for IProjectNature conformance
- */
- public CVSTeamProvider() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IProjectNature#deconfigure()
- */
- public void deconfigure() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.RepositoryProvider#deconfigured()
- */
- public void deconfigured() {
- // when a nature is removed from the project, notify the synchronizer that
- // we no longer need the sync info cached. This does not affect the actual CVS
- // meta directories on disk, and will remain unless a client calls unmanage().
- try {
- EclipseSynchronizer.getInstance().deconfigure(getProject(), null);
- internalSetWatchEditEnabled(null);
- internalSetFetchAbsentDirectories(null);
- } catch(CVSException e) {
- // Log the exception and let the disconnect continue
- CVSProviderPlugin.log(e);
- }
- ResourceStateChangeListeners.getListener().projectDeconfigured(getProject());
- }
- /**
- * @see IProjectNature#getProject()
- */
- public IProject getProject() {
- return project;
- }
-
- /**
- * @see IProjectNature#setProject(IProject)
- */
- public void setProject(IProject project) {
- this.project = project;
- this.workspaceRoot = new CVSWorkspaceRoot(project);
- // We used to check to see if the project had CVS folders and log
- // if it didn't However, in some scenarios, the project can be mapped
- // before the CVS folders have been created (see bug 173610)
- }
-
- /**
- * Return the remote location to which the receiver's project is mapped.
- */
- public ICVSRepositoryLocation getRemoteLocation() throws CVSException {
- try {
- return workspaceRoot.getRemoteLocation();
- } catch (CVSException e) {
- // If we can't get the remote location, we should disconnect since nothing can be done with the provider
- try {
- RepositoryProvider.unmap(project);
- } catch (TeamException ex) {
- CVSProviderPlugin.log(ex);
- }
- // We need to trigger a decorator refresh
- throw e;
- }
- }
-
- 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,
- NLS.bind(CVSMessages.CVSTeamProvider_invalidResource, (new Object[] {resource.getFullPath().toString(), project.getName()})),
- null));
- }
-
- /*
- * Get the arguments to be passed to a commit or update
- */
- private String[] getValidArguments(IResource[] resources, LocalOption[] options) throws CVSException {
- List arguments = new ArrayList(resources.length);
- for (int i=0;i<resources.length;i++) {
- checkIsChild(resources[i]);
- IPath cvsPath = resources[i].getFullPath().removeFirstSegments(1);
- if (cvsPath.segmentCount() == 0) {
- arguments.add(Session.CURRENT_LOCAL_FOLDER);
- } else {
- arguments.add(cvsPath.toString());
- }
- }
- return (String[])arguments.toArray(new String[arguments.size()]);
- }
-
- private ICVSResource[] getCVSArguments(IResource[] resources) {
- ICVSResource[] cvsResources = new ICVSResource[resources.length];
- for (int i = 0; i < cvsResources.length; i++) {
- cvsResources[i] = CVSWorkspaceRoot.getCVSResourceFor(resources[i]);
- }
- return cvsResources;
- }
-
- /*
- * This method expects to be passed an InfiniteSubProgressMonitor
- */
- public void setRemoteRoot(ICVSRepositoryLocation location, IProgressMonitor monitor) throws TeamException {
-
- // Check if there is a differnece between the new and old roots
- final String root = location.getLocation(false);
- if (root.equals(workspaceRoot.getRemoteLocation()))
- return;
-
- try {
- workspaceRoot.getLocalRoot().run(new ICVSRunnable() {
- public void run(IProgressMonitor progress) throws CVSException {
- try {
- // 256 ticks gives us a maximum of 1024 which seems reasonable for folders is a project
- progress.beginTask(null, 100);
- final IProgressMonitor monitor = Policy.infiniteSubMonitorFor(progress, 100);
- monitor.beginTask(null, 256);
-
- // 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(NLS.bind(CVSMessages.CVSTeamProvider_updatingFolder, new String[] { info.getRepository() }));
- MutableFolderSyncInfo newInfo = info.cloneMutable();
- newInfo.setRoot(root);
- folder.setFolderSyncInfo(newInfo);
- folder.acceptChildren(this);
- }
- }
- });
- } finally {
- progress.done();
- }
- }
- }, monitor);
- } finally {
- monitor.done();
- }
- }
-
- /*
- * Helper to indicate if the resource is a child of the receiver's project
- */
- private boolean isChildResource(IResource resource) {
- return resource.getProject().getName().equals(project.getName());
- }
-
- public void configureProject() throws CoreException {
- getProject().setSessionProperty(TEMP_SHARED, null);
- ResourceStateChangeListeners.getListener().projectConfigured(getProject());
- }
- /**
- * Sets the keyword substitution mode for the specified resources.
- * <p>
- * Applies the following rules in order:<br>
- * <ul>
- * <li>If a file is not managed, skips it.</li>
- * <li>If a file is not changing modes, skips it.</li>
- * <li>If a file is being changed from binary to text, corrects line delimiters
- * then commits it, then admins it.</li>
- * <li>If a file is added, changes the resource sync information locally.</li>
- * <li>Otherwise commits the file (with FORCE to create a new revision), then admins it.</li>
- * </ul>
- * All files that are admin'd are committed with FORCE to prevent other developers from
- * casually trying to commit pending changes to the repository without first checking out
- * a new copy. This is not a perfect solution, as they could just as easily do an UPDATE
- * and not obtain the new keyword sync info.
- * </p>
- *
- * @param changeSet a map from IFile to KSubstOption
- * @param monitor the progress monitor
- * @return a status code indicating success or failure of the operation
- *
- * @throws TeamException
- */
- public IStatus setKeywordSubstitution(final Map /* from IFile to KSubstOption */ changeSet,
- final String comment,
- IProgressMonitor monitor) throws TeamException {
- final IStatus[] result = new IStatus[] { ICommandOutputListener.OK };
- workspaceRoot.getLocalRoot().run(new ICVSRunnable() {
- public void run(final IProgressMonitor monitor) throws CVSException {
- final Map /* from KSubstOption to List of String */ filesToAdmin = new HashMap();
- final Collection /* of ICVSFile */ filesToCommitAsText = new HashSet(); // need fast lookup
- final boolean useCRLF = IS_CRLF_PLATFORM && (CVSProviderPlugin.getPlugin().isUsePlatformLineend());
-
- /*** determine the resources to be committed and/or admin'd ***/
- for (Iterator it = changeSet.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- IFile file = (IFile) entry.getKey();
- KSubstOption toKSubst = (KSubstOption) entry.getValue();
-
- // only set keyword substitution if resource is a managed file
- checkIsChild(file);
- ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor(file);
- if (! mFile.isManaged()) continue;
-
- // only set keyword substitution if new differs from actual
- byte[] syncBytes = mFile.getSyncBytes();
- KSubstOption fromKSubst = ResourceSyncInfo.getKeywordMode(syncBytes);
- if (toKSubst.equals(fromKSubst)) continue;
-
- // change resource sync info immediately for an outgoing addition
- if (ResourceSyncInfo.isAddition(syncBytes)) {
- mFile.setSyncBytes(ResourceSyncInfo.setKeywordMode(syncBytes, toKSubst), ICVSFile.UNKNOWN);
- continue;
- }
-
- // nothing do to for deletions
- if (ResourceSyncInfo.isDeletion(syncBytes)) continue;
-
- // file exists remotely so we'll have to commit it
- if (fromKSubst.isBinary() && ! toKSubst.isBinary()) {
- // converting from binary to text
- cleanLineDelimiters(file, useCRLF, new NullProgressMonitor()); // XXX need better progress monitoring
- // remember to commit the cleaned resource as text before admin
- filesToCommitAsText.add(mFile);
- }
- // remember to admin the resource
- List list = (List) filesToAdmin.get(toKSubst);
- if (list == null) {
- list = new ArrayList();
- filesToAdmin.put(toKSubst, list);
- }
- list.add(mFile);
- }
-
- /*** commit then admin the resources ***/
- // compute the total work to be performed
- int totalWork = filesToCommitAsText.size() + 1;
- for (Iterator it = filesToAdmin.values().iterator(); it.hasNext();) {
- List list = (List) it.next();
- totalWork += list.size();
- totalWork += 1; // Add 1 for each connection that needs to be made
- }
- if (totalWork != 0) {
- monitor.beginTask(CVSMessages.CVSTeamProvider_settingKSubst, totalWork);
- try {
- // commit files that changed from binary to text
- // NOTE: The files are committed as text with conversions even if the
- // resource sync info still says "binary".
- if (filesToCommitAsText.size() != 0) {
- Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */);
- session.open(Policy.subMonitorFor(monitor, 1), true /* open for modification */);
- try {
- String keywordChangeComment = comment;
- if (keywordChangeComment == null || keywordChangeComment.length() == 0)
- keywordChangeComment = CVSMessages.CVSTeamProvider_changingKeywordComment;
- result[0] = Command.COMMIT.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] { Command.DO_NOT_RECURSE, Commit.FORCE,
- Command.makeArgumentOption(Command.MESSAGE_OPTION, keywordChangeComment) },
- (ICVSResource[]) filesToCommitAsText.toArray(new ICVSResource[filesToCommitAsText.size()]),
- filesToCommitAsText,
- null,
- Policy.subMonitorFor(monitor, filesToCommitAsText.size()));
- } finally {
- session.close();
- }
-
- // if errors were encountered, abort
- if (! result[0].isOK()) return;
- }
-
- // admin files that changed keyword substitution mode
- // NOTE: As confirmation of the completion of a command, the server replies
- // with the RCS command output if a change took place. Rather than
- // assume that the command succeeded, we listen for these lines
- // and update the local ResourceSyncInfo for the particular files that
- // were actually changed remotely.
- for (Iterator it = filesToAdmin.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- final KSubstOption toKSubst = (KSubstOption) entry.getKey();
- final List list = (List) entry.getValue();
- // do it
- Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */);
- session.open(Policy.subMonitorFor(monitor, 1), true /* open for modification */);
- try {
- result[0] = Command.ADMIN.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] { toKSubst },
- (ICVSResource[]) list.toArray(new ICVSResource[list.size()]),
- new AdminKSubstListener(toKSubst),
- Policy.subMonitorFor(monitor, list.size()));
- } finally {
- session.close();
- }
- // if errors were encountered, abort
- if (! result[0].isOK()) return;
- }
- } finally {
- monitor.done();
- }
- }
- }
- }, Policy.monitorFor(monitor));
- return result[0];
- }
-
- /**
- * This method translates the contents of a file from binary into text (ASCII).
- * Fixes the line delimiters in the local file to reflect the platform's
- * native encoding. Performs CR/LF -> LF or LF -> CR/LF conversion
- * depending on the platform but does not affect delimiters that are
- * already correctly encoded.
- */
- public static void cleanLineDelimiters(IFile file, boolean useCRLF, IProgressMonitor progress)
- throws CVSException {
- try {
- // convert delimiters in memory
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- InputStream is = new BufferedInputStream(file.getContents());
- try {
- // Always convert CR/LF into LFs
- is = new CRLFtoLFInputStream(is);
- if (useCRLF) {
- // For CR/LF platforms, translate LFs to CR/LFs
- is = new LFtoCRLFInputStream(is);
- }
- for (int b; (b = is.read()) != -1;) bos.write(b);
- bos.close();
- } finally {
- is.close();
- }
- // write file back to disk with corrected delimiters if changes were made
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- file.setContents(bis, false /*force*/, false /*keepHistory*/, progress);
- } catch (CoreException e) {
- throw CVSException.wrapException(file, CVSMessages.CVSTeamProvider_cleanLineDelimitersException, e);
- } catch (IOException e) {
- throw CVSException.wrapException(file, CVSMessages.CVSTeamProvider_cleanLineDelimitersException, e);
- }
- }
-
- /*
- * @see RepositoryProvider#getID()
- */
- public String getID() {
- return CVSProviderPlugin.getTypeId();
- }
-
- /*
- * @see RepositoryProvider#getMoveDeleteHook()
- */
- public IMoveDeleteHook getMoveDeleteHook() {
- return moveDeleteHook;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.RepositoryProvider#getFileModificationValidator()
- */
- public IFileModificationValidator getFileModificationValidator() {
- return getFileModificationValidator2();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.RepositoryProvider#getFileModificationValidator2()
- */
- public FileModificationValidator getFileModificationValidator2() {
- return internalGetFileModificationValidator();
- }
-
- /**
- * Checkout (cvs edit) the provided resources so they can be modified locally and committed.
- * This will make any read-only resources in the list writable and will notify the server
- * that the file is being edited. This notification may be done immediately or at some
- * later point depending on whether contact with the server is possble at the time of
- * invocation or the value of the notify server parameter.
- *
- * The recurse parameter is equivalent to the cvs local options -l (<code>true</code>) and
- * -R (<code>false</code>). The notifyServer parameter can be used to defer server contact
- * until the next command. This may be approrpiate if no shell or progress monitor is available
- * to the caller. The notification bit field indicates what temporary watches are to be used while
- * the file is being edited. The possible values that can be ORed together are ICVSFile.EDIT,
- * ICVSFile.UNEDIT and ICVSFile.COMMIT. There pre-ORed convenience values ICVSFile.NO_NOTIFICATION
- * and ICVSFile.NOTIFY_ON_ALL are also available.
- *
- * @param resources the resources to be edited
- * @param recurse indicates whether to recurse (-R) or not (-l)
- * @param notifyServer indicates whether to notify the server now, if possible,
- * or defer until the next command.
- * @param notifyForWrittable
- * @param notification the temporary watches.
- * @param progress progress monitor to provide progress indication/cancellation or <code>null</code>
- * @exception CVSException if this method fails.
- * @since 2.1
- *
- * @see CVSTeamProvider#unedit
- */
- public void edit(IResource[] resources, boolean recurse, boolean notifyServer, final boolean notifyForWritable, final int notification, IProgressMonitor progress) throws CVSException {
- final int notify;
- if (notification == ICVSFile.NO_NOTIFICATION) {
- if (CVSProviderPlugin.getPlugin().isWatchOnEdit()) {
- notify = ICVSFile.NOTIFY_ON_ALL;
- } else {
- notify = ICVSFile.NO_NOTIFICATION;
- }
- } else {
- notify = notification;
- }
- notifyEditUnedit(resources, recurse, notifyServer, new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {
- if (notifyForWritable || file.isReadOnly())
- file.edit(notify, notifyForWritable, Policy.monitorFor(null));
- }
- public void visitFolder(ICVSFolder folder) throws CVSException {
- // nothing needs to be done here as the recurse will handle the traversal
- }
- }, null /* no scheduling rule */, progress);
- }
-
- /**
- * Unedit the given resources. Any writtable resources will be reverted to their base contents
- * and made read-only and the server will be notified that the file is no longer being edited.
- * This notification may be done immediately or at some
- * later point depending on whether contact with the server is possble at the time of
- * invocation or the value of the notify server parameter.
- *
- * The recurse parameter is equivalent to the cvs local options -l (<code>true</code>) and
- * -R (<code>false</code>). The notifyServer parameter can be used to defer server contact
- * until the next command. This may be approrpiate if no shell or progress monitor is available
- * to the caller.
- *
- * @param resources the resources to be unedited
- * @param recurse indicates whether to recurse (-R) or not (-l)
- * @param notifyServer indicates whether to notify the server now, if possible,
- * or defer until the next command.
- * @param progress progress monitor to provide progress indication/cancellation or <code>null</code>
- * @exception CVSException if this method fails.
- * @since 2.1
- *
- * @see CVSTeamProvider#edit
- */
- public void unedit(IResource[] resources, boolean recurse, boolean notifyServer, IProgressMonitor progress) throws CVSException {
- notifyEditUnedit(resources, recurse, notifyServer, new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {
- if (!file.isReadOnly())
- file.unedit(Policy.monitorFor(null));
- }
- public void visitFolder(ICVSFolder folder) throws CVSException {
- // nothing needs to be done here as the recurse will handle the traversal
- }
- }, getProject() /* project scheduling rule */, progress);
- }
-
- /*
- * This method captures the common behavior between the edit and unedit methods.
- */
- private void notifyEditUnedit(final IResource[] resources, final boolean recurse, final boolean notifyServer, final ICVSResourceVisitor editUneditVisitor, ISchedulingRule rule, IProgressMonitor monitor) throws CVSException {
- final CVSException[] exception = new CVSException[] { null };
- IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- final ICVSResource[] cvsResources = getCVSArguments(resources);
-
- // mark the files locally as being checked out
- try {
- for (int i = 0; i < cvsResources.length; i++) {
- cvsResources[i].accept(editUneditVisitor, recurse);
- }
- } catch (CVSException e) {
- exception[0] = e;
- return;
- }
-
- // send the noop command to the server in order to deliver the notifications
- if (notifyServer) {
- monitor.beginTask(null, 100);
- Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true);
- try {
- try {
- session.open(Policy.subMonitorFor(monitor, 10), true /* open for modification */);
- } catch (CVSException e1) {
- // If the connection cannot be opened, just exit normally.
- // The notifications will be sent when a connection can be made
- return;
- }
- Command.NOOP.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- cvsResources,
- null,
- Policy.subMonitorFor(monitor, 90));
- } catch (CVSException e) {
- exception[0] = e;
- } finally {
- session.close();
- monitor.done();
- }
- }
- }
- };
- try {
- ResourcesPlugin.getWorkspace().run(workspaceRunnable, rule, 0, Policy.monitorFor(monitor));
- } catch (CoreException e) {
- if (exception[0] == null) {
- throw CVSException.wrapException(e);
- } else {
- CVSProviderPlugin.log(CVSException.wrapException(e));
- }
- }
- if (exception[0] != null) {
- throw exception[0];
- }
- }
-
- /**
- * Gets the etchAbsentDirectories.
- * @return Returns a boolean
- */
- public boolean getFetchAbsentDirectories() throws CVSException {
- try {
- String property = getProject().getPersistentProperty(FETCH_ABSENT_DIRECTORIES_PROP_KEY);
- if (property == null) return CVSProviderPlugin.getPlugin().getFetchAbsentDirectories();
- return Boolean.valueOf(property).booleanValue();
- } catch (CoreException e) {
- throw new CVSException(new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, NLS.bind(CVSMessages.CVSTeamProvider_errorGettingFetchProperty, new String[] { project.getName() }), e, project));
- }
- }
-
- /**
- * Sets the fetchAbsentDirectories.
- * @param etchAbsentDirectories The etchAbsentDirectories to set
- */
- public void setFetchAbsentDirectories(boolean fetchAbsentDirectories) throws CVSException {
- internalSetFetchAbsentDirectories(fetchAbsentDirectories ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
- }
-
- public void internalSetFetchAbsentDirectories(String fetchAbsentDirectories) throws CVSException {
- try {
- getProject().setPersistentProperty(FETCH_ABSENT_DIRECTORIES_PROP_KEY, fetchAbsentDirectories);
- } catch (CoreException e) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, NLS.bind(CVSMessages.CVSTeamProvider_errorSettingFetchProperty, new String[] { project.getName() }), e, project);
- throw new CVSException(status);
- }
- }
-
- /**
- * @see org.eclipse.team.core.RepositoryProvider#canHandleLinkedResources()
- */
- public boolean canHandleLinkedResources() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.RepositoryProvider#canHandleLinkedResourceURI()
- */
- public boolean canHandleLinkedResourceURI() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.RepositoryProvider#validateCreateLink(org.eclipse.core.resources.IResource, int, org.eclipse.core.runtime.IPath)
- */
- public IStatus validateCreateLink(IResource resource, int updateFlags, IPath location) {
- return internalValidateCreateLink(resource);
- }
-
- private IStatus internalValidateCreateLink(IResource resource) {
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(resource.getParent().getFolder(new Path(resource.getName())));
- try {
- if (cvsFolder.isCVSFolder()) {
- // There is a remote folder that overlaps with the link so disallow
- return new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, NLS.bind(CVSMessages.CVSTeamProvider_overlappingRemoteFolder, new String[] { resource.getFullPath().toString() }),resource);
- } else {
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(resource.getParent().getFile(new Path(resource.getName())));
- if (cvsFile.isManaged()) {
- // there is an outgoing file deletion that overlaps the link so disallow
- return new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, NLS.bind(CVSMessages.CVSTeamProvider_overlappingFileDeletion, new String[] { resource.getFullPath().toString() }),resource);
- }
- }
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- return e.getStatus();
- }
- return Status.OK_STATUS;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.RepositoryProvider#validateCreateLink(org.eclipse.core.resources.IResource, int, java.net.URI)
- */
- public IStatus validateCreateLink(IResource resource, int updateFlags, URI location) {
- return internalValidateCreateLink(resource);
- }
-
- /**
- * Get the editors of the resources by calling the <code>cvs editors</code> command.
- *
- * @author <a href="mailto:gregor.kohlwes@csc.com,kohlwes@gmx.net">Gregor Kohlwes</a>
- * @param resources
- * @param progress
- * @return IEditorsInfo[]
- * @throws CVSException
- */
- public EditorsInfo[] editors(
- IResource[] resources,
- IProgressMonitor progress)
- throws CVSException {
-
- // Build the local options
- LocalOption[] commandOptions = new LocalOption[] {
- };
- progress.worked(10);
- // Build the arguments list
- String[] arguments = getValidArguments(resources, commandOptions);
-
- // Build the listener for the command
- EditorsListener listener = new EditorsListener();
-
- // Check if canceled
- if (progress.isCanceled()) {
- return new EditorsInfo[0];
- }
- // Build the session
- Session session =
- new Session(
- workspaceRoot.getRemoteLocation(),
- workspaceRoot.getLocalRoot());
-
- // Check if canceled
- if (progress.isCanceled()) {
- return new EditorsInfo[0];
- }
- progress.beginTask(null, 100);
- try {
- // Opening the session takes 20% of the time
- session.open(Policy.subMonitorFor(progress, 20), false /* read-only */);
-
- if (!progress.isCanceled()) {
- // Execute the editors command
- Command.EDITORS.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- commandOptions,
- arguments,
- listener,
- Policy.subMonitorFor(progress, 80));
- }
- } finally {
- session.close();
- progress.done();
- }
- // Return the infos about the editors
- return listener.getEditorsInfos();
- }
-
- /**
- * Return the commit comment template that was provided by the server.
- *
- * @return String
- * @throws CVSException
- */
- public String getCommitTemplate() throws CVSException {
- ICVSFolder localFolder = getCVSWorkspaceRoot().getLocalRoot();
- ICVSFile templateFile = CVSWorkspaceRoot.getCVSFileFor(
- SyncFileWriter.getTemplateFile(
- (IContainer)localFolder.getIResource()));
- if (!templateFile.exists()) return null;
- InputStream in = new BufferedInputStream(templateFile.getContents());
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- int b;
- do {
- b = in.read();
- if (b != -1)
- out.write((byte)b);
- } while (b != -1);
- out.close();
- return new String(out.toString());
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- } finally {
- try {
- in.close();
- } catch (IOException e) {
- // Since we already have the contents, just log this exception
- CVSProviderPlugin.log(CVSException.wrapException(e));
- }
- }
- }
-
- /**
- * Return true if the project is configured to use watch/edit. A project will use
- * watch/edit if it was checked out when the global preference to use watch/edit is
- * turned on.
- * @return boolean
- */
- public boolean isWatchEditEnabled() throws CVSException {
- IProject project = getProject();
- try {
- String property = (String)project.getSessionProperty(WATCH_EDIT_PROP_KEY);
- if (property == null) {
- property = project.getPersistentProperty(WATCH_EDIT_PROP_KEY);
- if (property == null) {
- // The persistant property for the project was never set (i.e. old project)
- // Use the global preference to determine if the project is using watch/edit
- return CVSProviderPlugin.getPlugin().isWatchEditEnabled();
- } else {
- project.setSessionProperty(WATCH_EDIT_PROP_KEY, property);
- }
- }
- return Boolean.valueOf(property).booleanValue();
- } catch (CoreException e) {
- if (project.isAccessible()) {
- // We only care if the project still exists
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, NLS.bind(CVSMessages.CVSTeamProvider_errorGettingWatchEdit, new String[] { project.getName() }), e, project);
- throw new CVSException(status);
- }
- }
- return false;
- }
-
- public void setWatchEditEnabled(boolean enabled) throws CVSException {
- internalSetWatchEditEnabled(enabled ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
- }
-
- private void internalSetWatchEditEnabled(String enabled) throws CVSException {
- try {
- IProject project = getProject();
- project.setPersistentProperty(WATCH_EDIT_PROP_KEY, enabled);
- project.setSessionProperty(WATCH_EDIT_PROP_KEY, enabled);
- } catch (CoreException e) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, NLS.bind(CVSMessages.CVSTeamProvider_errorSettingWatchEdit, new String[] { project.getName() }), e, project);
- throw new CVSException(status);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.RepositoryProvider#getRuleFactory()
- */
- public IResourceRuleFactory getRuleFactory() {
- return RESOURCE_RULE_FACTORY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.RepositoryProvider#getFileHistoryProvider()
- */
- public IFileHistoryProvider getFileHistoryProvider() {
- if (CVSTeamProvider.fileHistoryProvider == null) {
- CVSTeamProvider.fileHistoryProvider = new CVSFileHistoryProvider();
- }
- return CVSTeamProvider.fileHistoryProvider;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java
deleted file mode 100644
index 93688fcda..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProviderType.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.*;
-import org.eclipse.team.core.*;
-import org.eclipse.team.core.mapping.IChangeGroupingRequestor;
-import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.core.TeamPlugin;
-import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
-
-
-/**
- * This class represents the CVS Provider's capabilities in the absence of a
- * particular project.
- */
-
-public class CVSTeamProviderType extends RepositoryProviderType implements IAdaptable {
-
- private static AutoShareJob autoShareJob;
-
- public static class AutoShareJob extends Job {
-
- List projectsToShare = new ArrayList();
-
- AutoShareJob() {
- super(CVSMessages.CVSTeamProviderType_0);
- }
-
- public boolean isQueueEmpty() {
- return projectsToShare.isEmpty();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#shouldSchedule()
- */
- public boolean shouldSchedule() {
- return !isQueueEmpty();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#shouldRun()
- */
- public boolean shouldRun() {
- synchronized (projectsToShare) {
- for (Iterator iter = projectsToShare.iterator(); iter.hasNext();) {
- IProject project = (IProject) iter.next();
- if (RepositoryProvider.isShared(project)) {
- iter.remove();
- }
- }
- return !projectsToShare.isEmpty();
- }
- }
-
- public void share(IProject project) {
- if (!RepositoryProvider.isShared(project)) {
- synchronized (projectsToShare) {
- if (!projectsToShare.contains(project))
- projectsToShare.add(project);
- }
- if(getState() == Job.NONE && !isQueueEmpty())
- schedule();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus run(IProgressMonitor monitor) {
- IProject next = null;
- next = getNextProject();
- monitor.beginTask(null, IProgressMonitor.UNKNOWN);
- while (next != null) {
- autoconnectCVSProject(next, Policy.subMonitorFor(monitor, IProgressMonitor.UNKNOWN));
- next = getNextProject();
- }
- monitor.done();
- return Status.OK_STATUS;
- }
-
- private IProject getNextProject() {
- IProject next = null;
- synchronized (projectsToShare) {
- if (!projectsToShare.isEmpty()) {
- next = (IProject)projectsToShare.remove(0);
- }
- }
- return next;
- }
-
- /*
- * Auto-connect to the repository using CVS/ directories
- */
- private void autoconnectCVSProject(IProject project, IProgressMonitor monitor) {
- try {
- ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project);
- FolderSyncInfo info = folder.getFolderSyncInfo();
- if (info != null) {
- // Set the sharing
- CVSWorkspaceRoot.setSharing(project, info, monitor);
- }
- } catch (TeamException e) {
- CVSProviderPlugin.log(IStatus.ERROR, "Could not auto-share project " + project.getName(), e); //$NON-NLS-1$
- }
- }
- }
-
- private synchronized static AutoShareJob getAutoShareJob() {
- if (autoShareJob == null) {
- autoShareJob = new AutoShareJob();
- autoShareJob.addJobChangeListener(new JobChangeAdapter() {
- public void done(IJobChangeEvent event) {
- // Reschedule the job if it has unprocessed projects
- if (!autoShareJob.isQueueEmpty()) {
- autoShareJob.schedule();
- }
- }
- });
- autoShareJob.setSystem(true);
- autoShareJob.setPriority(Job.SHORT);
- // Must run with the workspace rule to ensure that projects added while we're running
- // can be shared
- autoShareJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
- }
- return autoShareJob;
- }
-
- /**
- * @see org.eclipse.team.core.RepositoryProviderType#supportsProjectSetImportRelocation()
- */
- public boolean supportsProjectSetImportRelocation() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.RepositoryProviderType#getProjectSetCapability()
- */
- public ProjectSetCapability getProjectSetCapability() {
- return new CVSProjectSetCapability();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.RepositoryProviderType#metaFilesDetected(org.eclipse.core.resources.IProject, org.eclipse.core.resources.IContainer[])
- */
- public void metaFilesDetected(IProject project, IContainer[] containers) {
- for (int i = 0; i < containers.length; i++) {
- IContainer container = containers[i];
- IContainer cvsDir = null;
- if (container.getName().equals("CVS")) { //$NON-NLS-1$
- cvsDir = container;
- } else {
- IResource resource = container.findMember("CVS"); //$NON-NLS-1$
- if (resource.getType() != IResource.FILE) {
- cvsDir = (IContainer)resource;
- }
- }
- try {
- if (cvsDir != null && !cvsDir.isTeamPrivateMember())
- cvsDir.setTeamPrivateMember(true);
- } catch (CoreException e) {
- TeamPlugin.log(IStatus.ERROR, "Could not flag meta-files as team-private for " + cvsDir.getFullPath(), e); //$NON-NLS-1$
- }
- }
- if (CVSProviderPlugin.getPlugin().isAutoshareOnImport())
- getAutoShareJob().share(project);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.RepositoryProviderType#getSubscriber()
- */
- public Subscriber getSubscriber() {
- return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- if (adapter == ActiveChangeSetManager.class || adapter == IChangeGroupingRequestor.class)
- return CVSProviderPlugin.getPlugin().getChangeSetManager();
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java
deleted file mode 100644
index 32e617f4b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java
+++ /dev/null
@@ -1,443 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.resources.mapping.ResourceTraversal;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.*;
-import org.eclipse.team.core.diff.IDiff;
-import org.eclipse.team.core.diff.IThreeWayDiff;
-import org.eclipse.team.core.subscribers.*;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.synchronize.SyncInfoSet;
-import org.eclipse.team.core.variants.*;
-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.*;
-import org.eclipse.team.internal.ccvs.core.util.ResourceStateChangeListeners;
-import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
-
-/**
- * CVSWorkspaceSubscriber
- */
-public class CVSWorkspaceSubscriber extends CVSSyncTreeSubscriber implements IResourceStateChangeListener {
-
- private CVSResourceVariantTree baseTree, remoteTree;
-
- // qualified name for remote sync info
- private static final String REMOTE_RESOURCE_KEY = "remote-resource-key"; //$NON-NLS-1$
-
- private boolean contentFetch;
-
- CVSWorkspaceSubscriber(QualifiedName id, String name) {
- super(id, name);
-
- // install sync info participant
- ResourceVariantByteStore baseSynchronizer = new CVSBaseResourceVariantTree();
- baseTree = new CVSResourceVariantTree(baseSynchronizer, null, getCacheFileContentsHint()) {
- public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
- // TODO Ensure that file contents are cached for modified local files
- try {
- monitor.beginTask(null, 100);
- return new IResource[0];
- } finally {
- monitor.done();
- }
- }
- };
- CVSDescendantResourceVariantByteStore remoteSynchronizer = new CVSDescendantResourceVariantByteStore(
- baseSynchronizer,
- new PersistantResourceVariantByteStore(new QualifiedName(SYNC_KEY_QUALIFIER, REMOTE_RESOURCE_KEY)));
- remoteTree = new CVSResourceVariantTree(remoteSynchronizer, null, getCacheFileContentsHint()) {
- public boolean isCacheFileContentsHint() {
- return getCacheFileContentsHint();
- }
- };
-
- ResourceStateChangeListeners.getListener().addResourceStateChangeListener(this);
- }
-
- /*
- * Return the list of projects shared with a CVS team provider.
- *
- * [Issue : this will have to change when folders can be shared with
- * a team provider instead of the current project restriction]
- * (non-Javadoc)
- * @see org.eclipse.team.core.sync.ISyncTreeSubscriber#roots()
- */
- public IResource[] roots() {
- List result = new ArrayList();
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- if(project.isOpen()) {
- RepositoryProvider provider = RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId());
- if(provider != null) {
- result.add(project);
- }
- }
- }
- return (IProject[]) result.toArray(new IProject[result.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#resourceSyncInfoChanged(org.eclipse.core.resources.IResource[])
- */
- public void resourceSyncInfoChanged(IResource[] changedResources) {
- internalResourceSyncInfoChanged(changedResources, true);
- }
-
- private void internalResourceSyncInfoChanged(IResource[] changedResources, boolean canModifyWorkspace) {
- getRemoteByteStore().handleResourceChanges(changedResources, canModifyWorkspace);
- fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, changedResources));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#externalSyncInfoChange(org.eclipse.core.resources.IResource[])
- */
- public void externalSyncInfoChange(IResource[] changedResources) {
- internalResourceSyncInfoChanged(changedResources, false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#resourceModified(org.eclipse.core.resources.IResource[])
- */
- public void resourceModified(IResource[] changedResources) {
- // This is only ever called from a delta POST_CHANGE
- // which causes problems since the workspace tree is closed
- // for modification and we flush the sync info in resourceSyncInfoChanged
-
- // Since the listeners of the Subscriber will also listen to deltas
- // we don't need to propogate this.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#projectConfigured(org.eclipse.core.resources.IProject)
- */
- public void projectConfigured(IProject project) {
- SubscriberChangeEvent delta = new SubscriberChangeEvent(this, ISubscriberChangeEvent.ROOT_ADDED, project);
- fireTeamResourceChange(new SubscriberChangeEvent[] {delta});
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#projectDeconfigured(org.eclipse.core.resources.IProject)
- */
- public void projectDeconfigured(IProject project) {
- try {
- getRemoteTree().flushVariants(project, IResource.DEPTH_INFINITE);
- } catch (TeamException e) {
- CVSProviderPlugin.log(e);
- }
- SubscriberChangeEvent delta = new SubscriberChangeEvent(this, ISubscriberChangeEvent.ROOT_REMOVED, project);
- fireTeamResourceChange(new SubscriberChangeEvent[] {delta});
- }
-
- public void setRemote(IResource resource, IResourceVariant remote, IProgressMonitor monitor) throws TeamException {
- // TODO: This exposes internal behavior to much
- IResource[] changedResources =
- ((CVSResourceVariantTree)getRemoteTree()).collectChanges(resource, remote, IResource.DEPTH_INFINITE, monitor);
- if (changedResources.length != 0) {
- fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, changedResources));
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getBaseSynchronizationCache()
- */
- protected IResourceVariantTree getBaseTree() {
- return baseTree;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getRemoteSynchronizationCache()
- */
- protected IResourceVariantTree getRemoteTree() {
- return remoteTree;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.Subscriber#collectOutOfSync(org.eclipse.core.resources.IResource[], int, org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void collectOutOfSync(IResource[] resources, int depth, final SyncInfoSet set, final IProgressMonitor monitor) {
- monitor.beginTask(null, IProgressMonitor.UNKNOWN);
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- try {
- if (!isSupervised(resource)) {
- return;
- }
- } catch (TeamException e) {
- // fallthrough and try to collect sync info
- CVSProviderPlugin.log(e);
- }
- try {
- visit(resource, new IResourceVisitor() {
- public boolean visit(IResource innerResource) throws CoreException {
- try {
- Policy.checkCanceled(monitor);
- if (innerResource.getType() != IResource.FILE) {
- monitor.subTask(NLS.bind(CVSMessages.CVSWorkspaceSubscriber_1, new String[] { innerResource.getFullPath().toString() }));
- }
- if (isOutOfSync(innerResource, monitor)) {
- SyncInfo info = getSyncInfo(innerResource);
- if (info != null && info.getKind() != 0) {
- set.add(info);
- }
- }
- } catch (TeamException e) {
- set.addError(new TeamStatus(
- IStatus.ERROR, CVSProviderPlugin.ID, ITeamStatus.RESOURCE_SYNC_INFO_ERROR,
- NLS.bind(CVSMessages.CVSWorkspaceSubscriber_2, new String[] { innerResource.getFullPath().toString(), e.getMessage() }), e, innerResource));
- }
- return true;
- }
- }, depth);
- } catch (CoreException e) {
- set.addError(new TeamStatus(
- IStatus.ERROR, CVSProviderPlugin.ID, ITeamStatus.SYNC_INFO_SET_ERROR,
- e.getMessage(), e, ResourcesPlugin.getWorkspace().getRoot()));
- }
- }
- monitor.done();
- }
-
- private void visit(IResource resource, IResourceVisitor visitor, int depth) throws CoreException {
- boolean keepGoing = visitor.visit(resource);
- if (keepGoing && depth != IResource.DEPTH_ZERO) {
- IResource[] members = members(resource);
- for (int i = 0; i < members.length; i++) {
- IResource member = members[i];
- visit(member, visitor, depth == IResource.DEPTH_ONE ? IResource.DEPTH_ZERO : IResource.DEPTH_INFINITE);
- }
- }
- }
-
- /* internal use only */ boolean isOutOfSync(IResource resource, IProgressMonitor monitor) throws TeamException {
- return (hasIncomingChange(resource) || hasOutgoingChange(resource, monitor));
- }
-
- private boolean hasIncomingChange(IResource resource) throws TeamException {
- return getRemoteByteStore().isVariantKnown(resource);
- }
-
- private boolean hasOutgoingChange(IResource resource, IProgressMonitor monitor) throws CVSException {
- if (resource.getType() == IResource.PROJECT || resource.getType() == IResource.ROOT) {
- // a project (or the workspace root) cannot have outgoing changes
- return false;
- }
- int state = EclipseSynchronizer.getInstance().getModificationState(resource.getParent());
- if (state == ICVSFile.CLEAN) {
- // if the parent is known to be clean then the resource must also be clean
- return false;
- }
- if (resource.getType() == IResource.FILE) {
- // A file is an outgoing change if it is modified
- ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)resource);
- return file.isModified(monitor);
- } else {
- // A folder is an outgoing change if it is not a CVS folder and not ignored
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)resource);
- return !folder.isCVSFolder() && !folder.isIgnored();
- }
- }
-
- /*
- * TODO: Should not need to access this here
- */
- private CVSDescendantResourceVariantByteStore getRemoteByteStore() {
- return (CVSDescendantResourceVariantByteStore)((CVSResourceVariantTree)getRemoteTree()).getByteStore();
- }
-
- /**
- * Update the remote tree to the base
- * @param folder
- * @param recurse
- */
- public void updateRemote(CVSTeamProvider provider, ICVSFolder folder, boolean recurse, IProgressMonitor monitor) throws TeamException {
- try {
- monitor.beginTask(null, IProgressMonitor.UNKNOWN);
- IResource resource = folder.getIResource();
- if (resource != null) {
- ICVSResource tree = buildBaseTree(
- resource,
- false,
- Policy.subMonitorFor(monitor, 50));
- setRemote(resource, (IResourceVariant)tree, Policy.subMonitorFor(monitor, 50));
- }
- } finally {
- monitor.done();
- }
- }
-
- public ICVSRemoteResource buildBaseTree(IResource resource, boolean immutable, IProgressMonitor monitor) throws TeamException {
- try {
- monitor.beginTask(null, IProgressMonitor.UNKNOWN);
- return ((CVSResourceVariantTree)getBaseTree()).buildTree(null, resource, immutable, monitor);
- } finally {
- monitor.done();
- }
- }
-
- public ICVSRemoteResource buildRemoteTree(IResource resource, boolean immutable, IProgressMonitor monitor) throws TeamException {
- try {
- monitor.beginTask(null, IProgressMonitor.UNKNOWN);
- return ((CVSResourceVariantTree)getRemoteTree()).buildTree(null, resource, immutable, monitor);
- } finally {
- monitor.done();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.Subscriber#getState(org.eclipse.core.resources.mapping.ResourceMapping, int, org.eclipse.core.runtime.IProgressMonitor)
- */
- public int getState(ResourceMapping mapping, int stateMask, IProgressMonitor monitor) throws CoreException {
- if ((stateMask & IThreeWayDiff.INCOMING) == 0) {
- // If we're only interested in outgoing changes, used the cached modified state
- ResourceTraversal[] traversals = mapping.getTraversals(new SubscriberResourceMappingContext(this, false), monitor);
- if (hasLocalChanges(traversals, monitor)) {
- int state = IThreeWayDiff.OUTGOING;
- state |= getOutgoingKind(traversals, monitor);
- return state;
- } else {
- return 0;
- }
- }
- return super.getState(mapping, stateMask, monitor);
- }
-
- private int getOutgoingKind(ResourceTraversal[] traversals, IProgressMonitor monitor) throws CoreException {
- int kind = 0;
- for (int i = 0; i < traversals.length; i++) {
- ResourceTraversal traversal = traversals[i];
- IResource[] resources = traversal.getResources();
- for (int j = 0; j < resources.length; j++) {
- IResource resource = resources[j];
- IDiff node = getDiff(resource);
- if (node == null)
- return IDiff.CHANGE;
- int nextKind = node.getKind();
- if (kind == 0)
- kind = nextKind;
- if (nextKind != kind || nextKind == IDiff.CHANGE)
- return IDiff.CHANGE;
- }
- }
- return kind;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.Subscriber#hasLocalChanges(org.eclipse.core.resources.mapping.ResourceTraversal[], org.eclipse.core.runtime.IProgressMonitor)
- */
- public boolean hasLocalChanges(ResourceTraversal[] traversals, IProgressMonitor monitor) throws CoreException {
- monitor = Policy.monitorFor(monitor);
- for (int i = 0; i < traversals.length; i++) {
- ResourceTraversal traversal = traversals[i];
- IResource[] resources = traversal.getResources();
- switch (traversal.getDepth()) {
- case IResource.DEPTH_ZERO:
- for (int j = 0; j < resources.length; j++) {
- IResource resource = resources[j];
- if (isDirectlyDirty(resource, monitor)) {
- return true;
- }
- }
- break;
- case IResource.DEPTH_INFINITE:
- for (int j = 0; j < resources.length; j++) {
- IResource resource = resources[j];
- if (isDirty(resource, monitor)) {
- return true;
- }
- }
- break;
- case IResource.DEPTH_ONE:
- for (int j = 0; j < resources.length; j++) {
- IResource resource = resources[j];
- if (isDirectlyDirty(resource, monitor)) {
- return true;
- }
- IResource[] children = members(resource);
- for (int k = 0; k < children.length; k++) {
- IResource child = children[k];
- if (isDirectlyDirty(child, monitor)) {
- return true;
- }
- }
- }
- break;
- }
- }
- return false;
- }
-
- private boolean isDirectlyDirty(IResource resource, IProgressMonitor monitor) throws CoreException {
- if (resource.getType() == IResource.FILE) {
- if (isDirty(resource, monitor))
- return true;
- } else {
- IDiff node = getDiff(resource);
- if (node != null
- && node instanceof IThreeWayDiff
- && ((IThreeWayDiff)node).getLocalChange() != null
- && ((IThreeWayDiff)node).getLocalChange().getKind() != IDiff.NO_CHANGE)
- return true;
- }
- return false;
- }
-
- public boolean isDirty(final ICVSResource cvsResource, IProgressMonitor monitor) throws CVSException {
- if (cvsResource.exists())
- return !cvsResource.isIgnored() && cvsResource.isModified(monitor);
- return cvsResource.isManaged() && cvsResource.isModified(monitor);
- }
-
- public boolean isDirty(IResource resource, IProgressMonitor monitor) throws CVSException {
- try {
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- return isDirty(cvsResource, monitor);
- } catch (CVSException e) {
- //if we get an error report it to the log but assume dirty.
- boolean accessible = resource.getProject().isAccessible();
- if (accessible) {
- throw e;
- }
- // Return dirty if the project is open and clean otherwise
- return accessible;
- }
-
- }
-
- public Object getAdapter(Class adapter) {
- if (adapter == ActiveChangeSetManager.class) {
- return CVSProviderPlugin.getPlugin().getChangeSetManager();
- }
- return super.getAdapter(adapter);
- }
-
- public void refreshWithContentFetch(ResourceTraversal[] traversals, IProgressMonitor monitor) throws TeamException {
- try {
- contentFetch = true;
- refresh(traversals, monitor);
- } finally {
- contentFetch = false;
- }
- }
-
- protected boolean getCacheFileContentsHint() {
- return contentFetch;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/EditorsInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/EditorsInfo.java
deleted file mode 100644
index 08a790746..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/EditorsInfo.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CSC - Intial implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-/**
- * Instances of EditorsInfo represent information for a CVS resurce that results
- * from the cvs editors command.
- *
- * @author <a href="mailto:gregor.kohlwes@csc.com,kohlwes@gmx.net">Gregor Kohlwes</a>
- */
-
-public class EditorsInfo {
- public EditorsInfo() {
- }
-
- private String userName;
- private String fileName;
- private String dateString;
- private String computerName;
-
-
- /**
- * Returns the userName.
- * @return String
- */
- public String getUserName() {
- return userName;
- }
-
- /**
- * Sets the userName.
- * @param userName The userName to set
- */
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- /**
- * Returns the dateString.
- * @return String
- */
- public String getDateString() {
- return dateString;
- }
-
- /**
- * Returns the fileName.
- * @return String
- */
- public String getFileName() {
- return fileName;
- }
-
- /**
- * Sets the dateString.
- * @param dateString The dateString to set
- */
- public void setDateString(String dateString) {
- this.dateString = dateString;
- }
-
- /**
- * Sets the fileName.
- * @param fileName The fileName to set
- */
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
-
- /**
- * Returns the computerName.
- * @return String
- */
- public String getComputerName() {
- return computerName;
- }
-
- /**
- * Sets the computerName.
- * @param computerName The computerName to set
- */
- public void setComputerName(String computerName) {
- this.computerName = computerName;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSDecoratorEnablementListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSDecoratorEnablementListener.java
deleted file mode 100644
index 178019b2f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSDecoratorEnablementListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-/**
- * A decorator enablement listener is notified of changes to the enablement
- * of CVS state decorators.
- * <p>
- * Clients may implement this interface.
- * </p>
- * @see CVSProviderPlugin#addDecoratorEnablementListener(ICVSDecoratorEnablementListener)
- */
-public interface ICVSDecoratorEnablementListener {
- /**
- * Called when CVS decoration is enabled or disabled. Implementers can use the
- * decorator enablement change as a chance to create or destroy cached CVS information
- * that would help decorate CVS elements.
- *
- * @param enabled a flag indicating the enablement state of the decorators.
- */
- void decoratorEnablementChanged(boolean enabled);
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
deleted file mode 100644
index 0a9dc85c1..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Red Hat Incorporated - is/setExecutable() code
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import java.util.Date;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.syncinfo.NotifyInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * 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, ICVSStorage {
-
- // Constants used to indicate the type of updated response from the server
- public static final int UPDATED = 1;
- public static final int MERGED = 2;
- public static final int UPDATE_EXISTING = 3;
- public static final int CREATED = 4;
-
- // Constants used to indicate temporary watches
- public static final int NO_NOTIFICATION = 0;
- public static final int NOTIFY_ON_EDIT = 1;
- public static final int NOTIFY_ON_UNEDIT = 2;
- public static final int NOTIFY_ON_COMMIT = 4;
- public static final int NOTIFY_ON_ALL = NOTIFY_ON_EDIT | NOTIFY_ON_UNEDIT | NOTIFY_ON_COMMIT;
-
- // Constants used to indicate modification state when setting sync info
- public static final int UNKNOWN = 0;
- public static final int CLEAN = 1;
- public static final int DIRTY = 2;
-
- /**
- * 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 byte[] getSyncBytes() 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.
- *
- * Note: This method makes use of a ResourceSyncInfo object which has the parsed
- * contents of the resource sync info. Clients can manipulate the values using
- * MutableResourceSyncInfo and then set the sync info using this method.
- *
- * @param info the resource synchronization to associate with this resource.
- */
- public void setSyncInfo(ResourceSyncInfo info, int modificationState) 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.
- *
- * Note: This method sets the sync info to the bytes provided as-is. It is the caller's
- * responsibility to ensure that these bytes are of the proper format. Use with caution.
- *
- * @param info the resource synchronization to associate with this resource.
- */
- public void setSyncBytes(byte[] syncBytes, int modificationState) throws CVSException;
-
- /**
- * Sets the file to read-only (<code>true</code>) or writable (<code>false</code>).
- *
- * This method is used by the command framework and should not be used by other clients.
- * Other clients should use <code>edit</code> and <code>unedit</code> instead as they
- * will report the change to the server if appropriate.
- */
- void setReadOnly(boolean readOnly) throws CVSException;
-
- /**
- * Answers whether the file is read-only or not. If a file is read-only, <code>edit</code>
- * should be invoked to make the file editable.
- */
- boolean isReadOnly() throws CVSException;
-
- /**
- * Sets the file to be executable (<code>ture</code>) or not executable
- * (<code>false</code>) if the platform supports it.
- */
- public void setExecutable(boolean executable) throws CVSException;
-
- /**
- * Answers whether the file is executable or not.
- *
- * @returns <code>false</code> if the platform doesn't support the executable flag.
- */
- public boolean isExecutable() throws CVSException;
-
- /**
- * Copy the resource to another file in the same directory
- *
- * This method is used by the command framework and should not be used by other clients.
- */
- void copyTo(String filename) throws CVSException;
-
- /**
- * Answers the current timestamp for this file with second precision.
- *
- * This method is used by the command framework and should not be used by other clients.
- */
- Date getTimeStamp();
-
- /**
- * If the date is <code>null</code> then the current time is used. After setTimeStamp is
- * invoked, it is assumed that the file is CLEAN. If this is not the case, it is the clients
- * responsibility to invoke setSyncBytes() with the appropriate modification state.
- *
- * This method is used by the command framework and should not be used by other clients.
- */
- void setTimeStamp(Date date) throws CVSException;
-
- /**
- * Answers <code>true</code> if the file has changed since it was last updated
- * from the repository, if the file does not exist, or is not managed. And <code>false</code>
- * if it has not changed.
- */
- boolean isModified(IProgressMonitor monitor) throws CVSException;
-
- /**
- * Answers the revision history for this file. This is similar to the
- * output of the log command.
- */
- public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Mark the file as checked out to allow local editing (analogous to "cvs edit").
- * If this method is invoked when <code>isCheckedOut()</code> returns <code>false</code>,
- * a notification message that will be sent to the server on the next connection
- * If <code>isCheckedOut()</code> returns <code>true</code> then nothing is done.
- *
- * @param notifications the set of operations for which the local user would like notification
- * while the local file is being edited.
- * @param notifyForWritable
- */
- public void edit(int notifications, boolean notifyForWritable, IProgressMonitor monitor) throws CVSException;
-
- /**
- * Undo a checkout of the file (analogous to "cvs unedit").
- * If this method is invoked when <code>isCheckedOut()</code> returns <code>true</code>,
- * a notification message that will be sent to the server on the next connection
- * If <code>isCheckedOut()</code> returns <code>false</code> then nothing is done.
- */
- public void unedit(IProgressMonitor monitor) throws CVSException;
-
- /**
- * This method is invoked by the checked-in handler after the file
- * has been committed.
- * @param entryLine the entry line recieved from the server (can be null)
- * @param commit whether the checkin is comming from a cvs commit or not
- */
- public void checkedIn(String entryLine, boolean commit) throws CVSException;
-
- /**
- * Answer any pending notification information associated with the receiver.
- *
- * This method is used by the command framework and should not be used by other clients.
- */
- public NotifyInfo getPendingNotification() throws CVSException;
-
- /**
- * Indicate to the file that the pending notification was successfully communicated to the server.
- *
- * This method is used by the command framework and should not be used by other clients.
- */
- public void notificationCompleted() throws CVSException;
-
- /**
- * Indicate whether the file has been "cvs edit"ed. This is determined by
- * looking in the CVS/Base folder for a file of the same name as the
- * file (i.e. no files are read so the method can be called by time critical
- * code like menu enablement).
- *
- * @return boolean
- */
- public boolean isEdited() throws CVSException;
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFileModificationValidator.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFileModificationValidator.java
deleted file mode 100644
index 1ab9f3f4d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFileModificationValidator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * @author Administrator
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
- */
-public interface ICVSFileModificationValidator {
-
- public IStatus validateMoveDelete(IFile[] files, IProgressMonitor monitor);
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java
deleted file mode 100644
index 579d21d86..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFolder.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-
-/**
- * The CVS analog of a directory. CVS folders have access to synchronization information
- * that describes the association between the folder and the remote repository.
- *
- * @see ICVSResource
- * @see ICVSFile
- */
-public interface ICVSFolder extends ICVSResource {
-
- public static final int FILE_MEMBERS = 1;
- public static final int FOLDER_MEMBERS = 2;
- public static final int IGNORED_MEMBERS = 4;
- public static final int UNMANAGED_MEMBERS = 8;
- public static final int MANAGED_MEMBERS = 16;
- public static final int EXISTING_MEMBERS = 32;
- public static final int PHANTOM_MEMBERS = 64;
- public static final int ALL_MEMBERS = FILE_MEMBERS
- | FOLDER_MEMBERS
- | IGNORED_MEMBERS
- | UNMANAGED_MEMBERS
- | MANAGED_MEMBERS
- | EXISTING_MEMBERS
- | PHANTOM_MEMBERS;
- public static final int ALL_EXISTING_MEMBERS = FILE_MEMBERS
- | FOLDER_MEMBERS
- | IGNORED_MEMBERS
- | UNMANAGED_MEMBERS
- | MANAGED_MEMBERS
- | EXISTING_MEMBERS;
- public static final int ALL_UNIGNORED_MEMBERS = FILE_MEMBERS
- | FOLDER_MEMBERS
- | UNMANAGED_MEMBERS
- | MANAGED_MEMBERS
- | EXISTING_MEMBERS
- | PHANTOM_MEMBERS;
-
- /**
- * Answers and array of <code>ICVSResource</code> elements that are immediate
- * children of this remote resource, in no particular order. The server may be contacted.
- *
- * @param monitor a progress monitor to indicate the duration of the operation, or
- * <code>null</code> if progress reporting is not required.
- *
- * @return array of immediate children of this remote resource.
- */
- public ICVSResource[] fetchChildren(IProgressMonitor monitor) throws CVSException;
-
- /**
- * Answer the immediate children of the resource that are known
- * at the time of invocation. The server is never contacted.
- * The flags indicate the type of members to be included.
- * Here are the rules for specifying just one flag:
- *
- * a) FILE_MEMBERS and FOLDER_MEMBERS will return managed
- * and unmanaged resource of the corresponding type
- * b) IGNORED_MEMBERS, MANAGED_RESOURCES and UNMANAGED_RESOURCES
- * will return files and folders of the given type
- * c) EXISTING_MEMBERS and PHANTOM_MEMBERS will return existing
- * and phantom resource of the corresponding type
- *
- * Note: Unmanaged resources are those that are neither managed or ignored.
- *
- * If all of the flags from either group a), group b) or group c)
- * are not present, the same rule for default types applies.
- * For example,
- * - FILE_MEMBERS | FOLDER_MEMBERS will return all managed
- * and unmanaged, existing and phantom files and folders.
- * - IGNORED_MEMBERS | UNMANAGED_MEMBERS will return all
- * ignored or unmanaged, existing or phantom files and folders
- * If a flag from each group is present, the result is the
- * union of the sets. For example,
- * - FILE_MEMBERS | IGNORED_MEMBERS | EXISTING_MEMBERS will return all
- * existing ignored files.
- */
- public ICVSResource[] members(int flags) throws CVSException;
-
- /**
- * Answers a child folder of this resource with the given name or <code>null</code> if
- * the given folder does not have a child with that name.
- */
- public ICVSFolder getFolder(String name) throws CVSException;
-
- /**
- * Answers a child file of this resource with the given name or <code>null</code> if
- * the given folder does not have a child with that name.
- */
- public ICVSFile getFile(String name) throws CVSException;
-
- /**
- * Return the child resource at the given path relative to
- * the receiver.
- */
- public ICVSResource getChild(String path) throws CVSException;
-
- /**
- * Create the folder if it did not exist before. Does only
- * work if the direct subfolder did exist.
- *
- * @throws CVSException if for some reason it was not possible to create the folder
- */
- public void mkdir() throws CVSException;
-
- /**
- * Answers the folder's synchronization information or <code>null</code> if the folder
- * is not a CVS folder.
- * <p>
- * To modify the folder sync info the caller must call <code>setFolderSyncInfo</code> with
- * new sync information.</p>
- */
- public FolderSyncInfo getFolderSyncInfo() throws CVSException;
-
- /**
- * Set the folder sync information for this folder. Setting the folder information
- * to <code>null</code> is not supported. The only mechanism for removing an existing
- * CVS folder is to delete the resource.
- */
- public void setFolderSyncInfo(FolderSyncInfo folderInfo) throws CVSException;
-
- /**
- * Accepts the visitor on all files and all subFolder in the folder. Files are
- * visited first, then all the folders..
- */
- public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException;
-
- /**
- * Answers <code>true</code> if the folder has valid CVS synchronization information and
- * <code>false</code> otherwise.
- *
- * Note: This method does not throw an exception so this method does not differentiate
- * between a folder not be shared with CVS and a folder that is shared but whose sync info has
- * become corrupt. Use getFolderSyncInfo() to differentiate between these situations.
- *
- * Also Note: A folder that is a CVS folder may not exist in the workspace. The purpose of
- * such a folder is to act as a remotely existing folder that does not exist locally.
- * This is normally done in order to remember outgoing file deletions when a parent
- * folder is deleted.
- * Creating the folder will result in a folder that is mapped to a remote folder.
- */
- public boolean isCVSFolder() throws CVSException;
-
- /**
- * 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 job 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;
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSListener.java
deleted file mode 100644
index f2aa07982..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSListener.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-
-public interface ICVSListener {
- public void repositoryAdded(ICVSRepositoryLocation root);
- public void repositoryRemoved(ICVSRepositoryLocation root);
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java
deleted file mode 100644
index f5efd79a8..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-import java.io.InputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-
- /**
- * This interface represents a file in a repository.
- * Instances of this interface can be used to fetch the contents
- * of the remote file.
- *
- * In the future, additional information should be available (tags, revisions, etc.)
- *
- * Clients are not expected to implement this interface.
- */
-public interface ICVSRemoteFile extends ICVSRemoteResource, ICVSFile {
-
- /**
- * Returns a stream over the contents of this remote element.
- *
- * @param progress a progress monitor to indicate the duration of the operation, or
- * <code>null</code> if progress reporting is not required.
- */
- public InputStream getContents(IProgressMonitor progress) throws TeamException;
-
- /**
- * Get the log entry for the revision the remote file represents.
- * This method will return null until after the getContents(IProgressMonitor)
- * method is called (i.e. the call to getContents also fetches the entry.
- */
- public ILogEntry getLogEntry(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Get all the log entries of the remote file
- */
- public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Get the revision of the remote file (e.g. 1.1)
- *
- * The revision depends on any tagging associated with the remote parent used
- * to access the file.
- */
- public String getRevision() throws TeamException;
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java
deleted file mode 100644
index 0f0eff968..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-
- /**
- * This interface represents a remote folder in a repository. It provides
- * access to the members (remote files and folders) of a remote folder
- *
- * Clients are not expected to implement this interface.
- */
-public interface ICVSRemoteFolder extends ICVSRemoteResource, ICVSFolder {
-
- // This constant is the name of the folder at the root of a repository
- public static final String REPOSITORY_ROOT_FOLDER_NAME = ""; //$NON-NLS-1$
-
- /**
- * Return the context of this handle. The returned tag can be a branch or
- * version tag.
- */
- public CVSTag getTag();
-
- /**
- * Return the local options that are used to determine how memebers are retrieved.
- *
- * Interesting options are:
- * Checkout.ALIAS
- * Command.DO_NOT_RECURSE
- */
- public LocalOption[] getLocalOptions();
-
- /**
- * Indicates whether the remote folder can be expanded.
- *
- * This is a temporary (hopefully) means of indicating certain types of folders
- * (i.e. module definitions) that are not expandable due to lack of mdoule expansion.
- * They can still be checked out.
- */
- public boolean isExpandable();
-
- /**
- * Indicates whether the remote folder is an actual remote folder is a
- * module defined in the CVSROOT/modules file (or some other module
- * definition).
- */
- public boolean isDefinedModule();
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java
deleted file mode 100644
index 7921004f9..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-
-/**
- * The interface represents a resource that exists in a CVS repository.
- * It purpose is to provide information about the remote resource from
- * the repository.
- *
- * Clients are not expected to implement this interface.
- */
-public interface ICVSRemoteResource extends ICVSResource, IAdaptable {
-
- /**
- * Answers if the remote element may have children.
- *
- * @return <code>true</code> if the remote element may have children and
- * <code>false</code> otherwise.
- */
- public boolean isContainer();
-
- /**
- * Return the repository
- */
- public ICVSRepositoryLocation getRepository();
-
- /**
- * Returns the parent of this remote resource or <code>null</code> if the
- * remote resource does not have a parent.
- */
- public ICVSRemoteResource getRemoteParent();
-
- /**
- * Does the remote resource represented by this handle exist on the server. This
- * method may contact the server and be long running.
- */
- public boolean exists(IProgressMonitor monitor) throws TeamException;
-
- /**
- * Answers the repository relative path of this remote folder.
- */
- public String getRepositoryRelativePath();
-
- /**
- * Compares two objects for equality; for cvs remote resources, equality is defined in
- * terms of their handles: same cvs resource type, equal relative paths, and
- * for files, identical revision numbers. Remote resources are not equal to objects other
- * than cvs remote resources.
- *
- * @param other the other object
- * @return an indication of whether the objects are equals
- */
- public boolean equals(Object other);
-
- /**
- * Allows a client to change the context of a remote resource handle. For
- * example, if a remote resource was created with the HEAD context (e.g. can
- * be used to browse the main branch) use this method to change the
- * context to another branch tag or to a version tag.
- */
- public ICVSRemoteResource forTag(CVSTag tagName);
-
- /**
- * Tag the remote resources referenced by the receiver (using rtag)
- */
- public IStatus tag(CVSTag tag, LocalOption[] localOptions, IProgressMonitor monitor) throws CVSException;
-
- /**
- * TODO: Temporary
- * @param progress
- * @return
- */
- public ICVSRemoteResource[] members(IProgressMonitor progress) throws TeamException;
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java
deleted file mode 100644
index b86c1a221..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * This interface provides access to the specific portions of
- * the repository location string for use by connection methods
- * and the user authenticator.
- *
- * It is not intended to implemented by clients.
- *
- * @see IUserAuthenticator
- * @see IConnectionMethod
- */
-public interface ICVSRepositoryLocation extends IAdaptable {
-
- /**
- * port value which indicates to a connection method to use the default port
- */
- public static int USE_DEFAULT_PORT = 0;
-
- /**
- * Return the connection method for making the connection
- */
- public IConnectionMethod getMethod();
-
- /**
- * Returns the host where the repository is located
- */
- public String getHost();
-
- /**
- * Returns the port to connect to or USE_DEFAULT_PORT if
- * the connection method is to use its default port.
- */
- public int getPort();
-
- /**
- * Returns the root directory of the repository.
- */
- public String getRootDirectory();
-
- /**
- * Returns the string representing the receiver. This string
- * should contain enough information to recreate the receiver.
- */
- public String getLocation(boolean forDisplay);
-
- /**
- * Returns the immediate children of this location. If tag is <code>null</code> the
- * HEAD branch is assumed.
- *
- * If modules is true, then the module definitions from the CVSROOT/modules file are returned.
- * Otherwise, the root level projects are returned.
- *
- * @param tag the context in which to return the members (e.g. branch or version).
- */
- public ICVSRemoteResource[] members(CVSTag tag, boolean modules, IProgressMonitor progress) throws CVSException;
-
- /**
- * Returns a handle to a remote file at this repository location using the given tag as the
- * context. The corresponding remote file may not exist or may be a folder.
- */
- public ICVSRemoteFile getRemoteFile(String remotePath, CVSTag tag);
-
- /**
- * Returns a handle to a remote folder at this repository location using the given tag as the
- * context. The corresponding remote folder may not exist or may be a file.
- */
- public ICVSRemoteFolder getRemoteFolder(String remotePath, CVSTag tag);
-
- /**
- * encoding for commit comments.
- */
- public String getEncoding();
-
- /**
- * Return the connection timeout value in seconds.
- * A value of 0 means there is no timeout value.
- */
- public int getTimeout();
-
- /**
- * Return the username
- */
- public String getUsername();
-
- /**
- * Returns the user information for the location.
- */
- public IUserInfo getUserInfo(boolean allowModificationOfUsername);
-
- /**
- * Flush any cahced user information related to the repository location
- */
- public void flushUserInfo();
-
- /**
- * Validate that the receiver can be used to connect to a repository.
- * An exception is thrown if connection fails
- *
- * @param monitor the progress monitor used while validating
- */
- public void validateConnection(IProgressMonitor monitor) throws CVSException;
-
- /**
- * Set the option to allow the user settings to be cached between sessions.
- * @since 3.0
- */
- public void setAllowCaching(boolean allowCaching);
-
- /**
- * Returns if the user info for this location is cached
- */
- public boolean getUserInfoCached();
-
- /**
- * Sets the user information used for this location
- */
- public void setUsername(String username);
-
- /**
- * Sets the user information used for this location
- */
- public void setPassword(String password);
-
- /**
- * Returns the plugged-in authenticator for this location.
- * @since 3.0
- */
- public IUserAuthenticator getUserAuthenticator();
-
- /**
- * Sets the plugged-in authenticator for this location. This is a hook
- * for testing.
- * @since 3.0
- */
- public void setUserAuthenticator(IUserAuthenticator authenticator);
-
- /**
- * Sets encoding for commit messages.
- * @since 3.0
- */
- public void setEncoding(String encoding);
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java
deleted file mode 100644
index 6926f9aa9..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResource.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * 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() throws CVSException;
-
- /**
- * Unmanage the given resource by purging any CVS synchronization associated with the
- * resource. The only way a resource can become managed is by running the
- * appropriate CVS commands (e.g. add/commit/update).
- */
- public void unmanage(IProgressMonitor monitor) throws CVSException;
-
- /**
- * Answer whether the resource could be ignored because it is in the one of the
- * ignore lists maintained by CVS. Even if a resource is ignored, it can still be
- * added to a repository, at which time it should never be ignored by the CVS
- * client.
- *
- * @return <code>true</code> if this resource is listed in one of the ignore
- * files maintained by CVS and <code>false</code> otherwise.
- */
- public boolean isIgnored() throws CVSException;
-
- /**
- * Add the following pattern to the file's parent ignore list
- *
- * XXX This should really be a method of ICVSFolder
- */
- 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 underlying IResource for the cvs resource (or null if there
- * is not a corresponding local resource).
- *
- * @return the IResource that corresponds to the CVS resource
- */
- public IResource getIResource();
-
- /**
- * Answers the local relative path from the given ancestor to the receiver.
- * This method will return a path for files that are themselves not added
- * to CVS control but who have an ancestor that is under CVS control.
- *
- * @return the ancestor relative path for this resource.
- */
- public String getRelativePath(ICVSFolder ancestor) throws CVSException;
-
- /**
- * Return the repository relative path of the remote resource. Return
- * <code>null</code> if the resource is not under CVS control.
- *
- * @return
- * @throws CVSException
- */
- public String getRepositoryRelativePath() throws CVSException;
-
- /**
- * Get the absolute remote location of a resource. This method is used by
- * the CVS command infrastructure during command execution. The root is used
- * in situations where the resource is not under CVS control. The remote
- * path that the resource would have if it was is determined by recursively
- * searching the resource's parent until a managed folder is found. The
- * provided root is used to stop the recursive search if no managed parent
- * is found.
- *
- * @param root the root folder of the command.
- *
- * @return the remote location.
- */
- public String getRemoteLocation(ICVSFolder root) 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;
-
- /**
- * 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;
-
- /**
- * Accept a visitor to this resource. The recurse parameter corresponds to the CVS
- * -l (do not recurse) and -R (recurse) options. If recurse is false, only the resource
- * and it's children are visited. Otherwise, the resource and all it's decendants are
- * visited.
- */
- public void accept(ICVSResourceVisitor visitor, boolean recurse) throws CVSException;
-
- /**
- * Method isModified.
- * @return boolean
- */
- public boolean isModified(IProgressMonitor monitor) throws CVSException;
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java
deleted file mode 100644
index 8947867f5..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSResourceVisitor.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-
-
-/**
- * Interface for an visitor of the IManagedResources.
- */
-public interface ICVSResourceVisitor {
- public void visitFile(ICVSFile file) throws CVSException;
- public void visitFolder(ICVSFolder folder) throws CVSException;
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java
deleted file mode 100644
index 2ff3e426a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRunnable.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * A runnable which executes as a batch operation within a specific cvs local
- * workspace.
- * The <code>ICVSRunnable</code> interface should be implemented by any class whose
- * instances are intended to be run by <code>IWorkspace.run</code>.
- * <p>
- * Clients may implement this interface.
- * </p>
- * @see
- */
-public interface ICVSRunnable {
- /**
- * Runs the operation reporting progress to and accepting
- * cancellation requests from the given progress monitor.
- * <p>
- * Implementors of this method should check the progress monitor
- * for cancellation when it is safe and appropriate to do so. The cancellation
- * request should be propagated to the caller by throwing
- * <code>OperationCanceledException</code>.
- * </p>
- *
- * @param monitor a progress monitor, or <code>null</code> if progress
- * reporting and cancellation are not desired
- * @exception CoreException if this operation fails.
- */
- public void run(IProgressMonitor monitor) throws CVSException;
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSStorage.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSStorage.java
deleted file mode 100644
index 11f44c95d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSStorage.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import java.io.InputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * This interface is used by the Session to transfer file contents.
- * It is used for regular files in a local sandbox as well as special files
- * such as the CVS/Template file.
- */
-public interface ICVSStorage {
-
- /**
- * Return the name for this ICVSStorage.
- * @return
- */
- String getName();
-
- /**
- * Set the contents of the file to the contents of the provided input stream.
- *
- * This method is used by the command framework and should not be used by other clients.
- * Other clients should set the contents of the underlying <code>IFile</code> which
- * can be obtained using <code>getIResource()</code>.
- *
- * @param responseType the type of reponse that was received from the server
- *
- * UPDATED - could be a new file or an existing file
- * MERGED - merging remote changes with local changes. Failure could result in loss of local changes
- * CREATED - contents for a file that doesn't exist locally
- * UPDATE_EXISTING - Replacing a local file with no local changes with remote changes.
- */
- public void setContents(InputStream stream, int responseType, boolean keepLocalHistory, IProgressMonitor monitor) throws CVSException;
-
- /**
- * Answers the size of the file.
- */
- long getSize();
-
- /**
- * Gets an input stream for reading from the file.
- * It is the responsibility of the caller to close the stream when finished.
- */
- InputStream getContents() throws CVSException;
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IConnectionMethod.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IConnectionMethod.java
deleted file mode 100644
index 979b0870e..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IConnectionMethod.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-/**
- * Implementators of this class can act as factories for creating connections to a CVS server
- * with the desired custom communication protocol. Providers of CVS connection methods must implement
- * this interface and register the implementation with the extension point:
- *
- * org.eclipse.team.cvs.core.connectionmethods
- *
- * The <code>createConnection()</code> method will be invoked by the CVS client when the user
- * is attempting to make a connection to the server using the connection name which matches
- * the <code>String</code> returned by <code>getName()</code> (e.g. "pserver", "ext", etc.).
- */
-public interface IConnectionMethod {
-
- /**
- * Returns the name of this connection method (e.g."local", "ext").
- */
- public String getName();
-
- /**
- * Creates a new server connection using the given repository root
- * (which includes the user name) and the given password.
- * If password is not given, null will be passed.
- */
- public IServerConnection createConnection(ICVSRepositoryLocation location, String password);
-
- /**
- * Some connection method may persist the physical connection to the server
- * through several IServerConnections. For example, when making several
- * successive connections to the same location using SSH2, it would be very
- * expensive to re-connect, re-negotiate and re-authenticate for each
- * operation; therefore the SSH2 connection method will create one SSH
- * session and open several channels (one for each IServerConnection
- * created), and keep the session open until disconnect() is called.
- * <p>
- * This method actually closes any connection to the indicated location.
- * </p>
- */
- public void disconnect(ICVSRepositoryLocation location);
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ILogEntry.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ILogEntry.java
deleted file mode 100644
index 3312c5967..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ILogEntry.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-import java.util.Date;
-
-import org.eclipse.core.runtime.IAdaptable;
-
-/**
- * Instances of ILogEntry represent an entry for a CVS file that results
- * from the cvs log command.
- *
- * Clients are not expected to implement this interface
- */
-public interface ILogEntry extends IAdaptable {
-
- /**
- * Get the revision for the entry
- */
- public String getRevision();
-
- /**
- * Get the author of the revision
- */
- public String getAuthor();
-
- /**
- * Get the date the revision was committed
- */
- public Date getDate();
-
- /**
- * Get the comment for the revision
- */
- public String getComment();
-
- /**
- * Get the state
- */
- public String getState();
-
- /**
- * Get the tags associated with the revision
- */
- public CVSTag[] getTags();
-
- /**
- * Get the remote file for this entry
- */
- public ICVSRemoteFile getRemoteFile();
-
- /**
- * Does the log entry represent a deletion (stat = "dead")
- */
- public boolean isDeletion();
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IResourceStateChangeListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IResourceStateChangeListener.java
deleted file mode 100644
index 9c6f9ebee..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IResourceStateChangeListener.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-import java.util.EventListener;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-
-/**
- * A resource state change listener is notified of changes to resources
- * regarding their team state.
- * <p>
- * Clients may implement this interface.
- * </p>
- * @see ITeamManager#addResourceStateChangeListener(IResourceStateChangeListener)
- */
-public interface IResourceStateChangeListener extends EventListener{
-
- /**
- * Notifies this listener that some resource sync info state changes have
- * already happened. For example, a resource's base revision may have
- * changed. The resource tree is open for modification when this method is
- * invoked, so markers can be created, etc.
- * <p>
- * Note: This method is called by the CVS core; it is not intended to be
- * called directly by clients.
- * </p>
- *
- * @param changedResources that have sync info state changes
- *
- * [Note: The changed state event is purposely vague. For now it is only
- * a hint to listeners that they should query the provider to determine the
- * resources new sync info.]
- */
- public void resourceSyncInfoChanged(IResource[] changedResources);
-
- /**
- * Notifies this listener that the resource sync info may have been changed
- * by an external tool. It is not always easy to differentiate external
- * changes from intenal ones. Therefore, the changed resources may include
- * some whose sync info was changed internally. This method is called
- * from a POST_CHANGE delta listener so the workspace cannot be modified.
- *
- * @param changeResources that have sync info state changes
- */
- public void externalSyncInfoChange(IResource[] changedResources);
-
- /**
- * Notifies this listener that the resource's have been modified. This
- * doesn't necessarily mean that the resource state isModified. The listener
- * must check the state.
- * <p>
- * Note: This method is called by CVS team core; it is not intended to be
- * called directly by clients.
- * </p>
- *
- * @param changedResources that have changed state
- * @param changeType the type of state change.
- */
- public void resourceModified(IResource[] changedResources);
-
- /**
- * Notifies this listener that the project has just been configured
- * to be a CVS project.
- * <p>
- * Note: This method is called by the CVS core; it is not intended to be
- * called directly by clients.
- * </p>
- *
- * @param project The project that has just been configured
- */
- public void projectConfigured(IProject project);
-
- /**
- * Notifies this listener that the project has just been deconfigured
- * and no longer has the CVS nature.
- * <p>
- * Note: This method is called by the CVS core; it is not intended to be
- * called directly by clients.
- * </p>
- *
- * @param project The project that has just been configured
- */
- public void projectDeconfigured(IProject project);
-
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IServerConnection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IServerConnection.java
deleted file mode 100644
index 660e97e20..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IServerConnection.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException;
-/**
-* CVS supports different connection methods for communicating between a client and the server.
-* Furthermore, custom connection methods can be added. Connection methods are added
-* to the CVS client as an IConnectionMethod, which can be used to create connections of
-* type IServerConnection.
-*
-* @see IConnectionMethod
-*/
-public interface IServerConnection {
- /**
- * Open a connection to the CVS server.
- *
- * Throw CVSAuthenticationException if the username or password is invalid.
- * Throw IOExceptions for other failures.
- */
- public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException;
- /**
- * Close the connection
- *
- * Throw IOException on failures
- */
- public void close() throws IOException;
- /**
- * Get the input stream to receive responses from the server
- */
- public InputStream getInputStream();
- /**
- * Get the output stream to send requests to the server
- */
- public OutputStream getOutputStream();
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java
deleted file mode 100644
index 6eb5cbc7f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserAuthenticator.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Atsuhiko Yamanaka, JCraft,Inc. - adding promptForKeyboradInteractive method
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-import java.util.Map;
-
-/**
- * IUserAuthenticators are used to ensure that the user
- * is validated for access to a given repository. The
- * user is prompted for a username and password as
- * appropriate for the given repository type.
- */
-public interface IUserAuthenticator {
-
- /**
- * Button id for an "Ok" button (value 0).
- */
- public int OK_ID = 0;
-
- /**
- * Button id for a "Cancel" button (value 1).
- */
- public int CANCEL_ID = 1;
-
- /**
- * Button id for a "Yes" button (value 2).
- */
- public int YES_ID = 2;
-
- /**
- * Button id for a "No" button (value 3).
- */
- public int NO_ID = 3;
-
- /**
- * Constant for a prompt with no type (value 0).
- */
- public final static int NONE = 0;
-
- /**
- * Constant for an error prompt (value 1).
- */
- public final static int ERROR = 1;
-
- /**
- * Constant for an information prompt (value 2).
- */
- public final static int INFORMATION = 2;
-
- /**
- * Constant for a question prompt (value 3).
- */
- public final static int QUESTION = 3;
-
- /**
- * Constant for a warning dialog (value 4).
- */
- public final static int WARNING = 4;
-
- /**
- * Authenticates the user for access to a given repository.
- * The obtained values for user name and password will be placed
- * into the supplied user info object. Implementors are allowed to
- * save user names and passwords. The user should be prompted for
- * user name and password if there is no saved one, or if <code>retry</code>
- * is <code>true</code>.
- *
- * @param location The repository location to authenticate the user for or <code>null</code>
- * if this authentication is not for a CVS repository location.
- * @param info The object to place user validation information into.
- * @param retry <code>true</code> if a previous attempt to log in failed.
- * @param message An optional message to display if, e.g., previous authentication failed.
- * @return true if the validation was successful, and false otherwise.
- */
- public void promptForUserInfo(ICVSRepositoryLocation location, IUserInfo userInfo, String message) throws CVSException;
-
- /**
- * Prompts the user for a number values using text fields. The labels are provided in
- * the <core>prompt</code> array. Implementors will return the entered values, or null if
- * the user cancel the prompt.
- *
- * @param location The repository location to authenticate the user for or <code>null</code>
- * if this authentication is not for a CVS repository location.
- * @param destination The destination in the format like username@hostname:port
- * @param name A name about this dialog.
- * @param instruction A message for the instruction.
- * @param prompt Labels for text fields.
- * @param echo the array to show which fields are secret.
- * @return the entered values, or null if the user canceled.
- *
- * @since 3.0
- */
- public String[] promptForKeyboradInteractive(ICVSRepositoryLocation location, String destination, String name, String instruction, String[] prompt, boolean[] echo) throws CVSException;
-
- /**
- * Prompts the authenticator for additional information regarding this authentication
- * request. A default implementation of this method should return the <code>defaultResponse</code>,
- * whereas alternate implementations could prompt the user with a dialog.
- *
- * @param location the repository location for this authentication or <code>null</code>
- * if this authentication is not for a CVS repository location.
- * @param promptType one of the following values:
- * <ul>
- * <li> <code>NONE</code> for a unspecified prompt type </li>
- * <li> <code>ERROR</code> for an error prompt </li>
- * <li> <code>INFORMATION</code> for an information prompt </li>
- * <li> <code>QUESTION </code> for a question prompt </li>
- * <li> <code>WARNING</code> for a warning prompt </li>
- * </ul>
- * @param title the prompt title that could be displayed to the user
- * @param message the prompt
- * @param promptResponses the possible responses to the prompt
- * @param defaultResponse the default response to the prompt
- * @return the response to the prompt
- *
- * @since 3.0
- */
- public int prompt(ICVSRepositoryLocation location, int promptType, String title, String message, int[] promptResponses, int defaultResponseIndex);
-
- /**
- * The host key for the given location has changed.
- * @param location
- * @return true if new host key should be accepted
- */
- public boolean promptForHostKeyChange(ICVSRepositoryLocation location);
-
- /**
- * If the project set contains only partial repository information (some of
- * location are unknown) we will display a dialog to associate each project
- * set repository with a known repository location or create a new one or at
- * last use the default locations.
- *
- * @param alternativeMap
- * a map of CVS repository locations form the project set (as
- * keys) and a list of suggested alternative (known) CVS
- * repository locations (as values)
- * @return a map of CVS repository locations from the project set (as keys)
- * and confirmed CVS repository locations to be used during checkout
- * (as values) or <code>null</code> if the operation is to be
- * canceled
- */
- public abstract Map promptToConfigureRepositoryLocations(Map alternativeMap);
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserInfo.java
deleted file mode 100644
index 14adb11cc..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/IUserInfo.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-/**
- * Instances of this class represent a username password pair.
- * Both values can be set and the username can be retrieved.
- * However, it is possible that the username is not mutable.
- * Users must check before trying to set the username.
- *
- * Clients are not expected to implement this interface
- */
-public interface IUserInfo {
- /**
- * Get the username for this user.
- */
- public String getUsername();
- /**
- * Return true if the username is mutable. If not, setUsername should not be called.
- */
- public boolean isUsernameMutable();
- /**
- * Sets the password for this user.
- */
- public void setPassword(String password);
- /**
- * Sets the username for this user. This should not be called if
- * isUsernameMutable() returns false.
- */
- public void setUsername(String username);
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java
deleted file mode 100644
index f6bb234b8..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core;
-
-
-import java.io.PrintStream;
-import java.lang.reflect.Field;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.internal.core.InfiniteSubProgressMonitor;
-
-public class Policy {
- public static PrintStream recorder;
-
- //debug constants
- public static boolean DEBUG_METAFILE_CHANGES = false;
- public static boolean DEBUG_CVS_PROTOCOL = false;
- public static boolean DEBUG_THREADING = false;
- public static boolean DEBUG_DIRTY_CACHING = false;
- public static boolean DEBUG_SYNC_CHANGE_EVENTS = false;
-
- static {
- //init debug options
- if (CVSProviderPlugin.getPlugin().isDebugging()) {
- DEBUG_METAFILE_CHANGES = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/metafiles"));//$NON-NLS-1$ //$NON-NLS-2$
- DEBUG_CVS_PROTOCOL = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/cvsprotocol"));//$NON-NLS-1$ //$NON-NLS-2$
- DEBUG_THREADING = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/threading"));//$NON-NLS-1$ //$NON-NLS-2$
- DEBUG_DIRTY_CACHING = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/dirtycaching"));//$NON-NLS-1$ //$NON-NLS-2$
- DEBUG_SYNC_CHANGE_EVENTS = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/syncchangeevents"));//$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * Progress monitor helpers
- */
- public static void checkCanceled(IProgressMonitor monitor) {
- if (monitor.isCanceled())
- throw new OperationCanceledException();
- }
- public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
- if (monitor == null)
- return new NullProgressMonitor();
- return monitor;
- }
-
- public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
- if (monitor == null)
- return new NullProgressMonitor();
- if (monitor instanceof NullProgressMonitor)
- return monitor;
- return new SubProgressMonitor(monitor, ticks);
- }
-
- public static IProgressMonitor infiniteSubMonitorFor(IProgressMonitor monitor, int ticks) {
- if (monitor == null)
- return new NullProgressMonitor();
- if (monitor instanceof NullProgressMonitor)
- return monitor;
- return new InfiniteSubProgressMonitor(monitor, ticks);
- }
-
- public static boolean isDebugProtocol() {
- return DEBUG_CVS_PROTOCOL || recorder != null;
- }
-
- public static void printProtocolLine(String line) {
- printProtocol(line, true);
- }
-
- public static void printProtocol(String string, boolean newLine) {
- if (DEBUG_CVS_PROTOCOL) {
- System.out.print(string);
- if (newLine) {
- System.out.println();
- }
- }
- if (recorder != null) {
- recorder.print(string);
- if (newLine) {
- recorder.println();
- }
- }
- }
-
- public static String getMessage(String key) {
- try {
- Field f = CVSMessages.class.getDeclaredField(key);
- Object o = f.get(null);
- if (o instanceof String)
- return (String)o;
- } catch (SecurityException e) {
- } catch (NoSuchFieldException e) {
- } catch (IllegalArgumentException e) {
- } catch (IllegalAccessException e) {
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java
deleted file mode 100644
index ae2b8d4d2..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractMessageCommand.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-
-/**
- * Superclass for commands that do not change the structure on
- * the local working copy (it can change the content of the files).<br>
- * Most of the subclasses are asking the server for response in
- * message format (log, status)
- */
-abstract class AbstractMessageCommand extends Command {
-
- protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // Send all folders that are already managed to the server
- new FileStructureVisitor(session, localOptions, false, false).visit(session, resources, monitor);
- return resources;
- }
-
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java
deleted file mode 100644
index ec891993f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Matt McCutchen <hashproduct+eclipse@gmail.com> - Bug 178874 Test failure against CVS 1.11.22
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.util.*;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * An ICVSResourceVisitor that is superclass to all ICVSResourceVisitor's used
- * by Command and it's subclasses.
- * Provides helper methods to send files and folders with modifications
- * to the server.
- *
- * This class does not perform a beginTask of done on the provided monitor.
- * It is used only to signal worl and subTask.
- */
-abstract class AbstractStructureVisitor implements ICVSResourceVisitor {
-
- protected Session session;
- private ICVSFolder lastFolderSent;
- protected IProgressMonitor monitor;
- protected boolean sendQuestionable;
- protected boolean sendModifiedContents;
- private boolean sendBinary;
-
- private boolean recurse = true;
-
- public AbstractStructureVisitor(Session session, LocalOption[] localOptions, boolean sendQuestionable, boolean sendModifiedContents) {
- this(session, localOptions, sendQuestionable, sendModifiedContents, true);
- }
-
- public AbstractStructureVisitor(Session session, LocalOption[] localOptions, boolean sendQuestionable, boolean sendModifiedContents, boolean sendBinary) {
- this.session = session;
- this.sendQuestionable = sendQuestionable;
- this.sendModifiedContents = sendModifiedContents;
- this.sendBinary = sendBinary;
- if (Command.DO_NOT_RECURSE.isElementOf(localOptions))
- recurse = false;
- }
-
- /**
- * Helper method to indicate if a directory has already been sent to the server
- */
- protected boolean isLastSent(ICVSFolder folder) {
- return folder.equals(lastFolderSent);
- }
-
- /**
- * Helper method to record if a directory has already been sent to the server
- */
- protected void recordLastSent(ICVSFolder folder) {
- lastFolderSent = folder;
- }
-
- /**
- * Helper which indicates if a folder is an orphaned subtree.
- * That is, a directory which contains a CVS subdirectory but is
- * not managed by its parent. The root directory of the session
- * is not considered orphaned even if it is not managed by its
- * parent.
- */
- protected boolean isOrphanedSubtree(ICVSFolder mFolder) throws CVSException {
- return mFolder.isCVSFolder() && ! mFolder.isManaged() && ! mFolder.equals(session.getLocalRoot()) && mFolder.getParent().isCVSFolder();
- }
-
- /**
- * Send the folder relative to the root to the server. Send all
- * appropiate modifier like Sticky, Questionable, Static-directory.
- * <br>
- * Folders will only be sent once.
- */
- protected void sendFolder(ICVSFolder mFolder) throws CVSException {
-
- Policy.checkCanceled(monitor);
-
- boolean exists = mFolder.exists();
- FolderSyncInfo info = mFolder.getFolderSyncInfo();
- boolean isCVSFolder = info != null;
-
- // We are only interested in folders that exist or are CVS folders
- // A folder could be a non-existant CVS folder if it is a holder for outgoing file deletions
- if ( ! exists && ! isCVSFolder) return;
-
- // Do not send the same folder twice
- if (isLastSent(mFolder)) return;
-
- // Do not send virtual directories
- if (isCVSFolder && info.isVirtualDirectory()) {
- return;
- }
-
- String localPath = mFolder.getRelativePath(session.getLocalRoot());
-
- monitor.subTask(NLS.bind(CVSMessages.AbstractStructureVisitor_sendingFolder, new String[] { Util.toTruncatedPath(mFolder, session.getLocalRoot(), 3) }));
-
- // Deal with questionable directories
- boolean isQuestionable = exists && (! isCVSFolder || isOrphanedSubtree(mFolder));
- if (isQuestionable) {
- if (sendQuestionable) {
- // We need to make sure the parent folder was sent
- sendFolder(mFolder.getParent());
- session.sendQuestionable(mFolder);
- }
- return;
- }
-
- // Send the directory to the server
- String remotePath = mFolder.getRemoteLocation(session.getLocalRoot());
- if (remotePath == null) {
- IStatus status = new CVSStatus(IStatus.ERROR,CVSStatus.ERROR, CVSMessages.AbstractStructureVisitor_noRemote, session.getLocalRoot());
- throw new CVSException(status);
- }
- session.sendDirectory(localPath, remotePath);
-
- // Send any directory properties to the server
- if (info != null) {
-
- if (info.getIsStatic()) {
- session.sendStaticDirectory();
- }
-
- CVSEntryLineTag tag = info.getTag();
-
- if (tag != null && tag.getType() != CVSTag.HEAD) {
- session.sendSticky(tag.toEntryLineFormat(false));
- }
- }
-
- // Record that we sent this folder
- recordLastSent(mFolder);
-
- monitor.worked(1);
- }
-
- /**
- * Send the information about the file to the server.
- *
- * If the file is modified, its contents are sent as well.
- */
- protected void sendFile(ICVSFile mFile) throws CVSException {
-
- Policy.checkCanceled(monitor);
-
- // Send the parent folder if it hasn't been sent already
- sendFolder(mFile.getParent());
-
- // Send the file's entry line to the server
- byte[] syncBytes = mFile.getSyncBytes();
- boolean isManaged = syncBytes != null;
-
- if (isManaged) {
- sendPendingNotification(mFile);
- } else {
- // If the file is not managed, send a questionable to the server if the file exists locally
- // A unmanaged, locally non-existant file results from the explicit use of the file name as a command argument
- if (sendQuestionable) {
- if (mFile.exists()) {
- session.sendQuestionable(mFile);
- }
- return;
- }
- // else we are probably doing an import so send the file contents below
- }
-
- // Determine if we need to send the contents.
- // If the file is unmodified since a conflict, we need to not send the
- // contents so that the server rejects the file (bug 178874).
- boolean sendContents = mFile.exists() && mFile.isModified(monitor)
- && !mFile.getSyncInfo().isNeedsMerge(mFile.getTimeStamp());
- if (ResourceSyncInfo.isDeletion(syncBytes)) {
- sendEntryLineToServer(mFile, syncBytes);
- } else if (sendContents) {
- // Perform the send of modified contents in a sheduling rule to ensure that
- // the contents are not modified while we are sending them
- final IResource resource = mFile.getIResource();
- try {
- if (resource != null)
- Job.getJobManager().beginRule(resource, monitor);
-
- sendEntryLineToServer(mFile, syncBytes);
- if (mFile.exists() && mFile.isModified(null)) {
- boolean binary = ResourceSyncInfo.isBinary(syncBytes);
- if (sendModifiedContents) {
- session.sendModified(mFile, binary, sendBinary, monitor);
- } else {
- session.sendIsModified(mFile, binary, monitor);
- }
- } else {
- session.sendUnchanged(mFile);
- }
- } finally {
- if (resource != null)
- Job.getJobManager().endRule(resource);
- }
- } else {
- sendEntryLineToServer(mFile, syncBytes);
- session.sendUnchanged(mFile);
- }
-
- monitor.worked(1);
- }
-
- private void sendEntryLineToServer(ICVSFile mFile, byte[] syncBytes) throws CVSException {
- if (syncBytes != null) {
- String syncBytesToServer = ResourceSyncInfo.getTimestampToServer(syncBytes, mFile.getTimeStamp());
- session.sendEntry(syncBytes, syncBytesToServer);
- }
- }
-
- protected void sendPendingNotification(ICVSFile mFile) throws CVSException {
- NotifyInfo notify = mFile.getPendingNotification();
- if (notify != null) {
- sendFolder(mFile.getParent());
- session.sendNotify(mFile.getParent(), notify);
- }
- }
-
- /**
- * This method is used to visit a set of ICVSResources. Using it ensures
- * that a common parent between the set of resources is only sent once
- */
- public void visit(Session session, ICVSResource[] resources, IProgressMonitor monitor) throws CVSException {
-
- // Sort the resources to avoid sending the same directory multiple times
- List resourceList = new ArrayList(resources.length);
- resourceList.addAll(Arrays.asList(resources));
- final ICVSFolder localRoot = session.getLocalRoot();
- Collections.sort(resourceList, new Comparator() {
- public int compare(Object object1, Object object2) {
- ICVSResource resource1 = (ICVSResource)object1;
- ICVSResource resource2 = (ICVSResource)object2;
- try {
- String path1 = resource1.getParent().getRelativePath(localRoot);
- String path2 = resource2.getParent().getRelativePath(localRoot);
- int pathCompare = path1.compareTo(path2);
- if (pathCompare == 0) {
- if (resource1.isFolder() == resource2.isFolder()) {
- return resource1.getName().compareTo(resource2.getName());
- } else if (resource1.isFolder()) {
- return 1;
- } else {
- return -1;
- }
- } else {
- return pathCompare;
- }
- } catch (CVSException e) {
- return resource1.getName().compareTo(resource2.getName());
- }
- }
- });
-
- // Create a progress monitor suitable for the visit
- int resourceHint = 64;
- monitor.beginTask(null, resourceHint);
- this.monitor = Policy.infiniteSubMonitorFor(monitor, resourceHint);
- try {
- // Visit all the resources
- this.monitor.beginTask(null, resourceHint);
- session.setSendFileTitleKey(getSendFileMessage());
- for (int i = 0; i < resourceList.size(); i++) {
- ((ICVSResource)resourceList.get(i)).accept(this);
- }
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Return a send file message that contains one argument slot
- * for the file name.
- * @return a send file message that contains one argument slot
- * for the file name
- */
- protected String getSendFileMessage() {
- return CVSMessages.AbstractStructureVisitor_sendingFile;
- }
- public boolean isRecurse() {
- return recurse;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java
deleted file mode 100644
index b8dfba8f1..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableFolderSyncInfo;
-
-public class Add extends Command {
- /*** Local options: specific to add ***/
-
- protected Add() { }
- protected String getRequestId() {
- return "add"; //$NON-NLS-1$
- }
-
- protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // Check that all the arguments can give you an
- // repo that you will need while traversing the
- // file-structure
- for (int i = 0; i < resources.length; i++) {
- Assert.isNotNull(resources[i].getRemoteLocation(session.getLocalRoot()));
- }
-
- // Get a vistor and use it on every resource we should
- // work on
- AddStructureVisitor visitor = new AddStructureVisitor(session, localOptions);
- visitor.visit(session, resources, monitor);
- return resources;
- }
-
- /**
- * If the add succeeded then folders have to be initialized with the
- * sync info
- */
- protected IStatus commandFinished(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor,
- IStatus status) throws CVSException {
-
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- return status;
- }
-
- for (int i = 0; i < resources.length; i++) {
- if (resources[i].isFolder()) {
- ICVSFolder mFolder = (ICVSFolder) resources[i];
- FolderSyncInfo info = mFolder.getParent().getFolderSyncInfo();
- if (info == null) {
- status = mergeStatus(status, new CVSStatus(IStatus.ERROR, NLS.bind(CVSMessages.Add_invalidParent, new String[] { mFolder.getRelativePath(session.getLocalRoot()) })));
- } else {
- String repository = info.getRepository() + "/" + mFolder.getName(); //$NON-NLS-1$
- MutableFolderSyncInfo newInfo = info.cloneMutable();
- newInfo.setRepository(repository);
- mFolder.setFolderSyncInfo(newInfo);
- }
- }
- }
- return status;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Command#getDefaultCommandOutputListener()
- */
- protected ICommandOutputListener getDefaultCommandOutputListener() {
- return new CommandOutputListener() {
- public IStatus errorLine(String line,
- ICVSRepositoryLocation location, ICVSFolder commandRoot,
- IProgressMonitor monitor) {
-
- String serverMessage = getServerMessage(line, location);
- if (serverMessage != null) {
- if (serverMessage.indexOf("cvs commit") != -1 && serverMessage.indexOf("add") != -1 && serverMessage.indexOf("permanently") != -1) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- return OK;
- if (serverMessage.startsWith("scheduling file") && serverMessage.indexOf("for addition") != -1) //$NON-NLS-1$ //$NON-NLS-2$
- return OK;
- }
- return super.errorLine(line, location, commandRoot, monitor);
- }
- };
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java
deleted file mode 100644
index 4ce700957..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AddStructureVisitor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-
-/**
- * This visitor is used by the Add command to ensure that the parent
- * folder is sent along with the added resource.
- */
-class AddStructureVisitor extends AbstractStructureVisitor {
-
- public AddStructureVisitor(Session session, LocalOption[] localOptions) {
- super(session, localOptions, false, true);
- }
-
- /**
- * @see ICVSResourceVisitor#visitFile(IManagedFile)
- */
- public void visitFile(ICVSFile mFile) throws CVSException {
-
- // Send the parent folder
- sendFolder(mFile.getParent());
-
- // Sends the Is-modified request if it is supported, otherwise
- // the file contents are sent as binary. The server does not
- // need the contents at this stage so this should not be a problem.
- session.sendIsModified(mFile, true, monitor);
-
- }
-
- /**
- * @see ICVSResourceVisitor#visitFolder(ICVSFolder)
- */
- public void visitFolder(ICVSFolder mFolder) throws CVSException {
-
- Assert.isNotNull(mFolder);
-
- // Send the parent folder
- sendFolder(mFolder.getParent());
-
- // Send the directory
- String localPath = mFolder.getRelativePath(session.getLocalRoot());
- String remotePath = mFolder.getRemoteLocation(session.getLocalRoot());
- session.sendDirectory(localPath, remotePath);
-
- // Record that we sent this folder
- recordLastSent(mFolder);
- }
-
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Admin.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Admin.java
deleted file mode 100644
index 58afba45a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Admin.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-public class Admin extends AbstractMessageCommand {
- /*** Local options: specific to admin ***/
-
- protected Admin() { }
- protected String getRequestId() {
- return "admin"; //$NON-NLS-1$
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Annotate.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Annotate.java
deleted file mode 100644
index 3c1a04a7a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Annotate.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-/**
- * The CVS Annotate Command.
- * Answers a resource with each line annotated with the revision the line
- * was added/changed and the user making the change.
- */
-public class Annotate extends AbstractMessageCommand {
-
- public static final Object FORCE_BINARY_ANNOTATE = new LocalOption("-F"); //$NON-NLS-1$
-
- protected Annotate() { }
-
- protected String getRequestId() {
- return "annotate"; //$NON-NLS-1$
- }
-
- // Local options specific to Annotate - revision (can be tag or revision)
- public static LocalOption makeRevisionOption(String revision) {
- return new LocalOption("-r" + revision, null); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ByteCountOutputStream.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ByteCountOutputStream.java
deleted file mode 100644
index c1f89d81b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ByteCountOutputStream.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.io.*;
-
-class ByteCountOutputStream extends OutputStream {
-
- private long size = 0;
-
- public void write(int b) throws IOException {
- size++;
- }
- public long getSize() {
- return size;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java
deleted file mode 100644
index 32f73719a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CRLFDetectInputStream.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.io.*;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-
-/**
- * Stream which detects CRLF in text file contents recieved from the server
- */
-public class CRLFDetectInputStream extends FilterInputStream {
-
- private boolean previousCR;
- private String filename;
- private boolean reported = false;
-
- protected CRLFDetectInputStream(InputStream in, ICVSStorage file) {
- super(in);
- try {
- this.filename = getFileName(file);
- } catch (CVSException e) {
- this.filename = file.getName();
- }
- }
-
- private String getFileName(ICVSStorage storage) throws CVSException {
- String fileName;
- if (storage instanceof ICVSFile) {
- ICVSFile file = (ICVSFile)storage;
- fileName = file.getRepositoryRelativePath();
- if (fileName == null) {
- IResource resource = file.getIResource();
- if (resource == null) {
- fileName = file.getName();
- } else {
- // Use the resource path if there is one since the remote pat
- fileName = file.getIResource().getFullPath().toString();
- }
- }
- } else {
- fileName = storage.getName();
- }
- return fileName;
- }
-
- /**
- * Wraps the underlying stream's method.
- * Translates CR/LF sequences to LFs transparently.
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred will be zero
- * @throws IOException if an i/o error occurs
- */
- public int read() throws IOException {
- int next = in.read();
- if (next != -1) {
- testForCRLF((byte)next);
- }
- return next;
- }
-
- /**
- * Wraps the underlying stream's method.
- * Translates CR/LF sequences to LFs transparently.
- * @throws InterruptedIOException if the operation was interrupted before all of the
- * bytes specified have been skipped, bytesTransferred may be non-zero
- * @throws IOException if an i/o error occurs
- */
- public int read(byte[] buffer, int off, int len) throws IOException {
- int count = super.read(buffer, off, len);
- for (int i = off; i < count; i++) {
- testForCRLF(buffer[i]);
- }
- return count;
- }
-
- /**
- * Test the byte to see if a CRLF sequence was read
- */
- private void testForCRLF(byte next) {
- if (reported) return;
- if (previousCR && next == '\n') {
- CVSProviderPlugin.log(IStatus.WARNING, NLS.bind(CVSMessages.CRLFDetectInputStream_0, new String[] { filename }), null);
- reported = true;
- }
- previousCR = (next == '\r');
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java
deleted file mode 100644
index 8f621315c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * Handles a "Checked-in" response from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Checked-in ??? \n
- * [...]
- * </pre>
- * Then
- * </p>
- */
-class CheckedInHandler extends ResponseHandler {
- public String getResponseID() {
- return "Checked-in"; //$NON-NLS-1$
- }
-
- public void handle(Session session, String localDir, IProgressMonitor monitor) throws CVSException {
- // read additional data for the response
- String repositoryFile = session.readLine();
- String entryLine = session.readLine();
-
- // clear file update modifiers
- session.setModTime(null);
-
- // Get the local file
- String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$
- ICVSFolder mParent = session.getLocalRoot().getFolder(localDir);
- ICVSFile mFile = mParent.getFile(fileName);
-
- // Marked the local file as checked-in
- monitor.subTask(NLS.bind(CVSMessages.CheckInHandler_checkedIn, new String[] { Util.toTruncatedPath((ICVSResource)mFile, session.getLocalRoot(), 3) }));
- mFile.checkedIn(entryLine, session.getCurrentCommand() instanceof Commit);
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java
deleted file mode 100644
index 4b00f40c7..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.listeners.*;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteModule;
-
-public class Checkout extends Command {
- /*** Local options: specific to checkout ***/
- public static final LocalOption DO_NOT_SHORTEN = new LocalOption("-N"); //$NON-NLS-1$
- public static final LocalOption FETCH_MODULE_ALIASES = new LocalOption("-c"); //$NON-NLS-1$
- public static LocalOption makeDirectoryNameOption(String moduleName) {
- return new LocalOption("-d", moduleName); //$NON-NLS-1$
- }
-
- /*** Default command output listener ***/
- private static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new UpdateListener(null);
-
- /** Command options found in the CVSROOT/modules file */
- public static LocalOption ALIAS = new LocalOption("-a"); //$NON-NLS-1$
- public static LocalOption makeStatusOption(String status) {
- return new LocalOption("-s", status); //$NON-NLS-1$
- }
-
- protected Checkout() { }
- protected String getRequestId() {
- return "co"; //$NON-NLS-1$
- }
-
- protected ICommandOutputListener getDefaultCommandOutputListener() {
- return DEFAULT_OUTPUT_LISTENER;
- }
-
- protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions,
- String[] arguments) throws CVSException {
-
- // We shouldn't have any arguments if we're fetching the module definitions
- if (arguments.length < 1 && ! FETCH_MODULE_ALIASES.isElementOf(localOptions)) throw new IllegalArgumentException();
-
- // We can determine the local directories using either the -d option or the module expansions
- Option dOption = findOption(localOptions, "-d"); //$NON-NLS-1$
- if (dOption != null) {
- // Should we append the expansions to the -d argument?
- return new ICVSResource[] {session.getLocalRoot().getFolder(dOption.argument)};
- }
- String[] modules = session.getModuleExpansions();
- ICVSResource[] resources = new ICVSResource[modules.length];
- for (int i = 0; i < resources.length; i++) {
- resources[i] = session.getLocalRoot().getFolder(modules[i]);
- }
- return resources;
- }
-
- /**
- * Start the Checkout command:
- * Send the module that is going to be checked-out to the server
- * by reading the name of the resource given
- * (This has to change to we give it the name of the modul and the
- * Checkout creates everything for us)
- */
- protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // We need a folder to put the project(s) we checkout into
- Assert.isTrue(session.getLocalRoot().isFolder());
-
- // Send the information about the local workspace resources to the server
- List resourcesToSend = new ArrayList(resources.length);
- for (int i = 0; i < resources.length; i++) {
- ICVSResource resource = resources[i];
- if (resource.exists() && resource.isFolder() && ((ICVSFolder)resource).isCVSFolder()) {
- resourcesToSend.add(resource);
- }
- }
- if ( ! resourcesToSend.isEmpty()) {
- resources = (ICVSResource[]) resourcesToSend.toArray(new ICVSResource[resourcesToSend.size()]);
- new FileStructureVisitor(session, localOptions, true, true).visit(session, resources, monitor);
- } else {
- monitor.beginTask(null, 100);
- monitor.done();
- }
- return resources;
- }
-
- protected void sendLocalWorkingDirectory(Session session) throws CVSException {
- session.sendConstructedRootDirectory();
- }
-
- /**
- * On sucessful finish, prune empty directories if
- * the -P option was specified (or is implied by -D or -r)
- */
- protected IStatus commandFinished(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor,
- IStatus status) throws CVSException {
- // If we didn't succeed, don't do any post processing
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- return status;
- }
-
- // If we are retrieving the modules file, ignore other options
- if (FETCH_MODULE_ALIASES.isElementOf(localOptions)) return status;
-
- // If we are pruning (-P) or getting a sticky copy (-D or -r), then prune empty directories
- if (PRUNE_EMPTY_DIRECTORIES.isElementOf(localOptions) ||
- (findOption(localOptions, "-D") != null) || //$NON-NLS-1$
- (findOption(localOptions, "-r") != null)) { //$NON-NLS-1$
-
- // Prune empty directories
- new PruneFolderVisitor().visit(session, resources);
- }
-
- return status;
- }
-
- /**
- * Override execute to perform a expand-modules before the checkout
- */
- protected IStatus doExecute(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener,
- IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(null, 100);
-
- if ( ! FETCH_MODULE_ALIASES.isElementOf(localOptions)) {
- // Execute the expand-modules command.
- // This will put the expansions in the session for later retrieval
- IStatus status = Request.EXPAND_MODULES.execute(session, arguments, Policy.subMonitorFor(monitor, 10));
- if (status.getCode() == CVSStatus.SERVER_ERROR)
- return status;
-
- // If -d is not included in the local options, then send -N (do not shorten directory paths)
- // to the server (as is done by other cvs clients)
- if (findOption(localOptions, "-d") == null) { //$NON-NLS-1$
- if ( ! DO_NOT_SHORTEN.isElementOf(localOptions)) {
- LocalOption[] newLocalOptions = new LocalOption[localOptions.length + 1];
- newLocalOptions[0] = DO_NOT_SHORTEN;
- System.arraycopy(localOptions, 0, newLocalOptions, 1, localOptions.length);
- localOptions = newLocalOptions;
- }
- }
- }
-
- return super.doExecute(session, globalOptions, localOptions, arguments, listener, Policy.subMonitorFor(monitor, 90));
- }
-
- /**
- * Perform a checkout to get the module expansions defined in the CVSROOT/modules file
- */
- public RemoteModule[] getRemoteModules(Session session, CVSTag tag, IProgressMonitor monitor)
- throws CVSException {
-
- ModuleDefinitionsListener moduleDefinitionListener = new ModuleDefinitionsListener();
-
- IStatus status = super.execute(session, NO_GLOBAL_OPTIONS, new LocalOption[] {FETCH_MODULE_ALIASES}, NO_ARGUMENTS,
- moduleDefinitionListener, monitor);
-
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
-
- return RemoteModule.createRemoteModules(moduleDefinitionListener.getModuleExpansions(), session.getCVSRepositoryLocation(), tag);
- }
-
- protected String getDisplayText() {
- return "checkout"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckoutWithOverwrite.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckoutWithOverwrite.java
deleted file mode 100644
index b5169ab3a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckoutWithOverwrite.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-
-/**
- * This checkout will overwrite any resources even for created responses
- */
-public class CheckoutWithOverwrite extends Checkout {
-
- /**
- * This class overrides the "Created" handler but uses the "Updated"
- * behavior which will overwrite existing files.
- */
- public class CreatedResponseHandler extends UpdatedHandler {
- public CreatedResponseHandler() {
- super(UpdatedHandler.HANDLE_UPDATED);
- }
- public String getResponseID() {
- return "Created"; //$NON-NLS-1$
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Command#doExecute(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[], org.eclipse.team.internal.ccvs.core.client.Command.LocalOption[], java.lang.String[], org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus doExecute(
- Session session,
- GlobalOption[] globalOptions,
- LocalOption[] localOptions,
- String[] arguments,
- ICommandOutputListener listener,
- IProgressMonitor monitor)
- throws CVSException {
-
- ResponseHandler newCreated = new CreatedResponseHandler();
- ResponseHandler oldCreated = session.getResponseHandler(newCreated.getResponseID());
- session.registerResponseHandler(newCreated);
- try {
- return super.doExecute(
- session,
- globalOptions,
- localOptions,
- arguments,
- listener,
- monitor);
- } finally {
- session.registerResponseHandler(oldCreated);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java
deleted file mode 100644
index 52c3a26b9..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java
+++ /dev/null
@@ -1,834 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Matt McCutchen <hashproduct+eclipse@gmail.com> - Bug 179174 CVS client sets timestamps back when replacing
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.util.*;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-
-/**
- * Abstract base class for command requests.
- * Provides a framework for implementing command execution.
- */
-public abstract class Command extends Request {
- /*** Command singleton instances ***/
- public final static Add ADD = new Add();
- public final static Admin ADMIN = new Admin();
- public final static Annotate ANNOTATE = new Annotate();
- public final static Checkout CHECKOUT = new CheckoutWithOverwrite();
- public final static Commit COMMIT = new Commit();
- public final static Diff DIFF = new Diff();
- public final static RDiff RDIFF = new RDiff();
- public final static Editors EDITORS = new Editors();
- public final static Import IMPORT = new Import();
- public final static Log LOG = new Log();
- public final static Remove REMOVE = new Remove();
- public final static Status STATUS = new Status();
- public final static Tag TAG = new Tag();
- // The CUSTOM_TAG command has special handling for added and removed resources.
- // This behavior supports branching with local changes in the workspace
- public final static Tag CUSTOM_TAG = new Tag(true);
- public final static RTag RTAG = new RTag();
- public final static Update UPDATE = new Update();
- public final static Update REPLACE = new Replace();
- public final static SyncUpdate SYNCUPDATE = new SyncUpdate();
- public final static Version VERSION = new Version();
- public final static NOOPCommand NOOP = new NOOPCommand();
-
- // Empty argument array
- public final static String[] NO_ARGUMENTS = new String[0];
-
- /*** Global options ***/
- // Empty global option array
- public static final GlobalOption[] NO_GLOBAL_OPTIONS = new GlobalOption[0];
- // Do not change file contents
- public static final GlobalOption DO_NOT_CHANGE = new GlobalOption("-n"); //$NON-NLS-1$
- // Do not record this operation into CVS command history
- public static final GlobalOption DO_NOT_LOG = new GlobalOption("-l"); //$NON-NLS-1$
- // Make new working files read-only
- public static final GlobalOption MAKE_READ_ONLY = new GlobalOption("-r"); //$NON-NLS-1$
- // Trace command execution
- public static final GlobalOption TRACE_EXECUTION = new GlobalOption("-t"); //$NON-NLS-1$
-
- /*** Global options: quietness ***/
- // Don't be quiet (normal verbosity)
- public static final QuietOption VERBOSE = new QuietOption(""); //$NON-NLS-1$
- // Be somewhat quiet (suppress informational messages)
- public static final QuietOption PARTLY_QUIET = new QuietOption("-q"); //$NON-NLS-1$
- // Be really quiet (silent but for serious problems)
- public static final QuietOption SILENT = new QuietOption("-Q"); //$NON-NLS-1$
-
- /*** Local options: common to many commands ***/
- // Empty local option array
- public static final LocalOption[] NO_LOCAL_OPTIONS = new LocalOption[0];
- // valid for: annotate checkout commit diff export log rdiff remove rtag status tag update
- public static final LocalOption RECURSE = new LocalOption("-R"); //$NON-NLS-1$
- public static final LocalOption DO_NOT_RECURSE = new LocalOption("-l"); //$NON-NLS-1$
- // valid for: checkout export update
- public static final LocalOption PRUNE_EMPTY_DIRECTORIES = new LocalOption("-P"); //$NON-NLS-1$
- // valid for: checkout export update
- public static final LocalOption MESSAGE_OPTION = new LocalOption("-m"); //$NON-NLS-1$
-
- /*** Local options: keyword substitution mode ***/
- // valid for: add admin checkout export import update
- private static final Map ksubstOptionMap = new HashMap();
- public static final KSubstOption KSUBST_BINARY = new KSubstOption("-kb"); //$NON-NLS-1$
- public static final KSubstOption KSUBST_TEXT = new KSubstOption("-ko"); //$NON-NLS-1$
- public static final KSubstOption KSUBST_TEXT_EXPAND = new KSubstOption("-kkv"); //$NON-NLS-1$
- public static final KSubstOption KSUBST_TEXT_EXPAND_LOCKER = new KSubstOption("-kkvl"); //$NON-NLS-1$
- public static final KSubstOption KSUBST_TEXT_VALUES_ONLY = new KSubstOption("-kv"); //$NON-NLS-1$
- public static final KSubstOption KSUBST_TEXT_KEYWORDS_ONLY = new KSubstOption("-kk"); //$NON-NLS-1$
-
- /*** Default command output listener ***/
- protected static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new CommandOutputListener();
-
- /**
- * Prevents client code from instantiating us.
- */
- protected Command() { }
-
- /**
- * Provides the default command output listener which is used to accumulate errors.
- *
- * Subclasses can override this method in order to properly interpret information
- * received from the server.
- */
- protected ICommandOutputListener getDefaultCommandOutputListener() {
- return DEFAULT_OUTPUT_LISTENER;
- }
-
- /**
- * Sends the command's arguments to the server.
- * [template method]
- * <p>
- * The default implementation sends all arguments. Subclasses may override
- * this method to provide alternate behaviour.
- * </p>
- *
- * @param session the CVS session
- * @param arguments the arguments that were supplied by the caller of execute()
- */
- protected void sendArguments(Session session, String[] arguments) throws CVSException {
- for (int i = 0; i < arguments.length; ++i) {
- session.sendArgument(arguments[i]);
- }
- }
-
- /**
- * Describes the local resource state to the server prior to command execution.
- * [template method]
- * <p>
- * Commands must override this method to inform the server about the state of
- * local resources using the Entries, Modified, Unchanged, and Questionable
- * requests as needed.
- * </p>
- * <p>
- * This method should return the resources that are of interest to the
- * <code>Command#commandFinished()</code> method. In most cases, it
- * is the same resources that are provided but in some cases (e.g. Commit)
- * the resources to be passed to the above method are different.
- * </p>
- *
- * @param session the CVS session
- * @param globalOptions the global options for the command
- * @param localOptions the local options for the command
- * @param resources the resource arguments for the command
- * @param monitor the progress monitor
- * @return ICVSResource[]
- */
- protected abstract ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException;
-
- /**
- * Cleans up after command execution.
- * [template method]
- * <p>
- * The default implementation is a no-op. Subclasses may override this
- * method to follow up command execution on the server with clean up
- * operations on local resources.
- * </p>
- *
- * @param session the CVS session
- * @param globalOptions the global options for the command
- * @param localOptions the local options for the command
- * @param resources the resource arguments for the command
- * @param monitor the progress monitor
- * @param status the status accumulated so far. If the code == CVSStatus.SERVER_ERROR
- * then the command failed
- * @return status the status past in plus any additional status accumulated during the finish
- */
- protected IStatus commandFinished(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor,
- IStatus status) throws CVSException {
- return status;
- }
-
- /**
- * Sends the local working directory path prior to command execution.
- * [template method]
- * <p>
- * The default implementation sends the paths of local root directory
- * (assuming it exists). Subclasses may override this method to provide
- * alternate behaviour.
- * </p>
- *
- * @param session the CVS session
- */
- protected void sendLocalWorkingDirectory(Session session) throws CVSException {
- ICVSFolder localRoot = session.getLocalRoot();
- if (localRoot.isCVSFolder()) {
- session.sendLocalRootDirectory();
- } else {
- session.sendConstructedRootDirectory();
- }
- }
-
- /**
- * Computes an array of ICVSResources corresponding to command arguments.
- * [template method]
- * <p>
- * The default implementation assumes that all arguments supplied to the
- * command represent resources in the local root that are to be manipulated.
- * Subclasses must override this method if this assumption does not hold.
- * </p>
- * @param session the CVS session
- * @param localOptions the command local options
- * @param arguments the command arguments
- * @return the resource arguments for the command
- */
- protected ICVSResource[] computeWorkResources(Session session,
- LocalOption[] localOptions, String[] arguments) throws CVSException {
- ICVSFolder localRoot = session.getLocalRoot();
-
- if (arguments.length == 0) {
- // As a convenience, passing no arguments to the CVS command
- // implies the command will operate on the local root folder.
- return new ICVSResource[] { localRoot };
- } else {
- // Assume all arguments represent resources that are descendants
- // of the local root folder.
- ICVSResource[] resources = new ICVSResource[arguments.length];
- for (int i = 0; i < arguments.length; i++) {
- ICVSResource resource = localRoot.getChild(arguments[i]);
- // file does not exist, it could have been deleted. It doesn't matter
- // which type we return since only the name of the resource is used
- // and sent to the server.
- if(resource==null) {
- if(localRoot.getName().length()==0) {
- // Return a folder because it is the safest choice when
- // localRoot is a handle to the IWorkspaceRoot!
- resource = localRoot.getFolder(arguments[i]);
- } else {
- resource = localRoot.getFile(arguments[i]);
- }
- }
- resources[i] = resource;
- }
- return resources;
- }
- }
-
- /**
- * Send an array of Resources.
- * @param localOptions
- *
- * @see Command#sendFileStructure(ICVSResource,IProgressMonitor,boolean,boolean,boolean)
- */
- protected void sendFileStructure(Session session, ICVSResource[] resources,
- LocalOption[] localOptions, boolean emptyFolders, IProgressMonitor monitor) throws CVSException {
- checkResourcesManaged(session, resources);
-
- new FileStructureVisitor(session, localOptions, emptyFolders, true).visit(session, resources, monitor);
- }
-
- /**
- * Checks that all work resources are managed.
- * @param session TODO
- * @param resources the resource arguments for the command
- *
- * @throws CVSException if some resources are not managed
- */
- protected void checkResourcesManaged(Session session, ICVSResource[] resources) throws CVSException {
- for (int i = 0; i < resources.length; ++i) {
- ICVSFolder folder;
- if (resources[i].isFolder()) {
- folder = (ICVSFolder) resources[i];
- }
- else {
- folder = resources[i].getParent();
- }
- if (!folder.isCVSFolder() && folder.exists()) {
- IStatus status = new CVSStatus(IStatus.ERROR,CVSStatus.ERROR,NLS.bind(CVSMessages.Command_argumentNotManaged, new String[] { folder.getName() }),session.getLocalRoot());
- throw new CVSException(status);
- }
- }
- }
-
- /**
- * Executes a CVS command.
- * <p>
- * Dispatches the commands, retrieves the results, and determines whether or
- * not an error occurred. A listener may be supplied to capture message text
- * that would normally be written to the standard error and standard output
- * streams of a command line CVS client.
- * </p>
- * @param session the open CVS session
- * @param globalOptions the array of global options, or NO_GLOBAL_OPTIONS
- * @param localOptions the array of local options, or NO_LOCAL_OPTIONS
- * @param arguments the array of arguments (usually filenames relative to localRoot), or NO_ARGUMENTS
- * @param listener the command output listener, or null to discard all messages
- * @param monitor the progress monitor
- * @return a status code indicating success or failure of the operation
- * @throws CVSException if a fatal error occurs (e.g. connection timeout)
- */
- public final IStatus execute(final Session session, final GlobalOption[] globalOptions,
- final LocalOption[] localOptions, final String[] arguments, final ICommandOutputListener listener,
- IProgressMonitor pm) throws CVSException {
- final IStatus[] status = new IStatus[1];
- ICVSRunnable job = new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- // update the global and local options
- GlobalOption[] gOptions = filterGlobalOptions(session, globalOptions);
- LocalOption[] lOptions = filterLocalOptions(session, gOptions, localOptions);
-
- // print the invocation string to the console
- if (session.isOutputToConsole() || Policy.isDebugProtocol()) {
- IPath commandRootPath;
- IResource resource = session.getLocalRoot().getIResource();
- if (resource == null) {
- commandRootPath = Path.EMPTY;
- } else {
- commandRootPath = resource.getFullPath();
- }
- String line = constructCommandInvocationString(commandRootPath, gOptions, lOptions, arguments);
- ConsoleListeners.getInstance().commandInvoked(session, line);
- if (Policy.isDebugProtocol()) Policy.printProtocolLine("CMD> " + line); //$NON-NLS-1$
- }
-
- // run the command
- try {
- session.setCurrentCommand(Command.this);
- status[0] = doExecute(session, gOptions, lOptions, arguments, listener, monitor);
- notifyConsoleOnCompletion(session, status[0], null);
- } catch (CVSException e) {
- notifyConsoleOnCompletion(session, null, e);
- throw e;
- } catch (RuntimeException e) {
- notifyConsoleOnCompletion(session, null, e);
- throw e;
- }
- }
- };
- if (isWorkspaceModification()) {
- session.getLocalRoot().run(job, pm);
- } else {
- job.run(pm);
- }
- return status[0];
- }
-
- /**
- * Return whether this command modifies the workspace.
- * If <code>true</code> is returned, a scheduling rule on
- * the session local root is obtained. Otherwise, no
- * scheduling rule is obtained. By default, <code>true</code>
- * is returned
- * @return whether this command modifies the workspace
- */
- protected boolean isWorkspaceModification() {
- return true;
- }
-
- private void notifyConsoleOnCompletion(Session session, IStatus status, Exception exception) {
- ConsoleListeners.getInstance().commandCompleted(session, status, exception);
- if (Policy.isDebugProtocol()) {
- if (status != null) Policy.printProtocolLine("RESULT> " + status.toString()); //$NON-NLS-1$
- else Policy.printProtocolLine("RESULT> " + exception.toString()); //$NON-NLS-1$
- }
- }
-
- protected IStatus doExecute(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener,
- IProgressMonitor monitor) throws CVSException {
- ICVSResource[] resources = null;
- /*** setup progress monitor ***/
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- Policy.checkCanceled(monitor);
- try {
- /*** prepare for command ***/
- // clear stale command state from previous runs
- session.setNoLocalChanges(DO_NOT_CHANGE.isElementOf(globalOptions));
- session.setModTime(null);
-
- /*** initiate command ***/
- // send global options
- for (int i = 0; i < globalOptions.length; i++) {
- globalOptions[i].send(session);
- }
- Policy.checkCanceled(monitor);
- // send local options
- for (int i = 0; i < localOptions.length; i++) {
- localOptions[i].send(session);
- }
- Policy.checkCanceled(monitor);
- // compute the work resources
- resources = computeWorkResources(session, localOptions, arguments);
- Policy.checkCanceled(monitor);
- // send local working directory state contributes 48% of work
- resources = sendLocalResourceState(session, globalOptions, localOptions,
- resources, Policy.infiniteSubMonitorFor(monitor, 48));
- Policy.checkCanceled(monitor);
- // escape file names, see bug 149683
- for(int i = 0; i < arguments.length; i++){
- if(arguments[i].startsWith("-")){ //$NON-NLS-1$
- arguments[i] = "./" + arguments[i]; //$NON-NLS-1$
- }
- }
- // send arguments
- sendArguments(session, arguments);
- // send local working directory path
- sendLocalWorkingDirectory(session);
-
- // if no listener was provided, use the command's default in order to get error reporting
- if (listener == null) listener = getDefaultCommandOutputListener();
-
- /*** execute command and process responses ***/
- // Processing responses contributes 50% of work.
- IStatus status = executeRequest(session, listener, Policy.subMonitorFor(monitor, 50));
-
- // Finished adds last 2% of work.
- status = commandFinished(session, globalOptions, localOptions, resources, Policy.subMonitorFor(monitor, 2),
- status);
- return status;
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Constucts the CVS command invocation string corresponding to the arguments.
- *
- * @param globalOptions the global options
- * @param localOption the local options
- * @param arguments the arguments
- * @return the command invocation string
- */
- private String constructCommandInvocationString(IPath commandRootPath, GlobalOption[] globalOptions,
- LocalOption[] localOptions, String[] arguments) {
- StringBuffer commandLine = new StringBuffer("cvs"); //$NON-NLS-1$
- for (int i = 0; i < globalOptions.length; ++i) {
- String option = globalOptions[i].toString();
- if (option.length() == 0) continue;
- commandLine.append(' ');
- commandLine.append(option);
- }
- commandLine.append(' ');
- commandLine.append(getRequestId());
- for (int i = 0; i < localOptions.length; ++i) {
- String option = localOptions[i].toString();
- if (option.length() == 0) continue;
- commandLine.append(' ');
- commandLine.append(option);
- }
- for (int i = 0; i < arguments.length; ++i) {
- if (arguments[i].length() == 0) continue;
- commandLine.append(" \""); //$NON-NLS-1$
- IPath completePath = commandRootPath;
- if (!arguments[i].equals(Session.CURRENT_LOCAL_FOLDER)) {
- completePath = completePath.append(arguments[i]);
- }
- commandLine.append(completePath.toString());
- commandLine.append('"');
- }
- return commandLine.toString();
- }
-
- /**
- * Superclass for all CVS command options
- */
- protected static abstract class Option {
- protected String option, argument;
- protected Option(String option, String argument) {
- this.option = option;
- this.argument = argument;
- }
- /**
- * Determines if this option is an element of an array of options
- * @param array the array of options
- * @return true iff the array contains this option
- */
- public boolean isElementOf(Option[] array) {
- return findOption(array, option) != null;
- }
- /**
- * Returns the option part of the option
- */
- String getOption() {
- return option;
- }
- /**
- * Compares two options for equality.
- * @param other the other option
- */
- public boolean equals(Object other) {
- if (this == other) return true;
- if (other instanceof Option) {
- Option otherOption = (Option) other;
- return option.equals(otherOption.option);
- }
- return false;
- }
- /**
- * Sends the option to a CVS server
- * @param session the CVS session
- */
- public abstract void send(Session session) throws CVSException;
- /*
- * To make debugging a tad easier.
- */
- public String toString() {
- if (argument != null && argument.length() != 0) {
- return option + " \"" + argument + '"'; //$NON-NLS-1$
- } else {
- return option;
- }
- }
- }
- /**
- * Option subtype for global options that are common to all commands.
- */
- public static class GlobalOption extends Option {
- protected GlobalOption(String option) {
- super(option, null);
- }
- public void send(Session session) throws CVSException {
- session.sendGlobalOption(option);
- }
- /**
- * Add the given global option to the end of the provided list
- *
- * @param newOption
- * @param options
- * @return GlobalOption[]
- */
- protected GlobalOption[] addToEnd(GlobalOption[] options) {
- GlobalOption[] globalOptions = new GlobalOption[options.length + 1];
- System.arraycopy(options, 0, globalOptions, 0, options.length);
- globalOptions[globalOptions.length - 1] = this;
- return globalOptions;
- }
- }
- /**
- * Option subtype for global quietness options.
- */
- public static final class QuietOption extends GlobalOption {
- private QuietOption(String option) {
- super(option);
- }
- public void send(Session session) throws CVSException {
- if (option.length() != 0) super.send(session);
- }
- }
- /**
- * Option subtype for local options that vary from command to command.
- */
- public static class LocalOption extends Option {
- protected LocalOption(String option) {
- super(option, null);
- }
- protected LocalOption(String option, String argument) {
- super(option, argument);
- }
- public void send(Session session) throws CVSException {
- session.sendArgument(option);
- if (argument != null) session.sendArgument(argument);
- }
- public LocalOption[] addTo(LocalOption[] options) {
- if (this.isElementOf(options)) {
- return options;
- }
- LocalOption[] newOptions = new LocalOption[options.length + 1];
- System.arraycopy(options, 0, newOptions, 0, options.length);
- newOptions[options.length] = this;
- return newOptions;
- }
- public LocalOption[] removeFrom(LocalOption[] options) {
- if (!this.isElementOf(options)) {
- return options;
- }
- List result = new ArrayList();
- for (int i = 0; i < options.length; i++) {
- Command.LocalOption option = options[i];
- if (!option.equals(this)) {
- result.add(option);
- }
- }
- return (LocalOption[]) result.toArray(new LocalOption[result.size()]);
- }
- }
- /**
- * Options subtype for keyword substitution options.
- */
- public static class KSubstOption extends LocalOption {
- private boolean isUnknownMode;
- private KSubstOption(String option) {
- this(option, false);
- }
- private KSubstOption(String option, boolean isUnknownMode) {
- super(option);
- this.isUnknownMode = isUnknownMode;
- ksubstOptionMap.put(option, this);
- }
- /**
- * Gets the KSubstOption instance for the specified mode.
- *
- * @param mode the mode, e.g. -kb
- * @return an instance for that mode
- */
- public static KSubstOption fromMode(String mode) {
- if (mode.length() == 0) mode = "-kkv"; // use default //$NON-NLS-1$
- KSubstOption option = (KSubstOption) ksubstOptionMap.get(mode);
- if (option == null) option = new KSubstOption(mode, true);
- return option;
- }
- /**
- * Gets the KSubstOption instance for the specified file.
- *
- * @param file the file to get the option for
- * @return an instance for that mode
- */
- public static KSubstOption fromFile(IFile file) {
- if (CVSProviderPlugin.isText(file))
- return getDefaultTextMode();
- return KSUBST_BINARY;
- }
- /**
- * Returns an array of all valid modes.
- */
- public static KSubstOption[] getAllKSubstOptions() {
- return (KSubstOption[]) ksubstOptionMap.values().toArray(new KSubstOption[ksubstOptionMap.size()]);
- }
- /**
- * Returns the entry line mode string for this instance. Note that it might return blank strings
- * for certain options. For UI, use {@link #toMode()} which will always return the a string
- * containing the keyword substitution.
- */
- public String toEntryLineMode() {
- if (KSUBST_TEXT_EXPAND.equals(this)) return ""; //$NON-NLS-1$
- return getOption();
- }
-
- /**
- * Returns the entry line mode string for this instance.
- */
- public String toMode(){
- return getOption();
- }
-
- /**
- * Returns true if the substitution mode requires no data translation
- * during file transfer.
- */
- public boolean isBinary() {
- return KSUBST_BINARY.equals(this);
- }
- /**
- * Returns a short localized text string describing this mode.
- */
- public String getShortDisplayText() {
- if (isUnknownMode)
- return NLS.bind(CVSMessages.KSubstOption_unknown_short, new String[] { option });
- if (option.equals("-kb")) //$NON-NLS-1$
- return CVSMessages.KSubstOption__kb_short;
- if (option.equals("-kkv")) //$NON-NLS-1$
- return CVSMessages.KSubstOption__kkv_short;
- if (option.equals("-ko")) //$NON-NLS-1$
- return CVSMessages.KSubstOption__ko_short;
- if (option.equals("-kk")) //$NON-NLS-1$
- return CVSMessages.KSubstOption__kk_short;
- if (option.equals("-kv")) //$NON-NLS-1$
- return CVSMessages.KSubstOption__kv_short;
- if (option.equals("-kkvl")) //$NON-NLS-1$
- return CVSMessages.KSubstOption__kkvl_short;
- return NLS.bind(CVSMessages.KSubstOption_unknown_short, new String[] { option });
- }
- /**
- * Returns a long localized text string describing this mode.
- */
- public String getLongDisplayText() {
- if (isUnknownMode)
- return NLS.bind(CVSMessages.KSubstOption_unknown_long, new String[] { option });
- if (option.equals("-kb")) //$NON-NLS-1$
- return CVSMessages.KSubstOption__kb_long;
- if (option.equals("-kkv")) //$NON-NLS-1$
- return CVSMessages.KSubstOption__kkv_long;
- if (option.equals("-ko")) //$NON-NLS-1$
- return CVSMessages.KSubstOption__ko_long;
- if (option.equals("-kk")) //$NON-NLS-1$
- return CVSMessages.KSubstOption__kk_long;
- if (option.equals("-kv")) //$NON-NLS-1$
- return CVSMessages.KSubstOption__kv_long;
- if (option.equals("-kkvl")) //$NON-NLS-1$
- return CVSMessages.KSubstOption__kkvl_long;
- return NLS.bind(CVSMessages.KSubstOption_unknown_long, new String[] { option });
- }
- /**
- * Return the text mode that will be used by default
- */
- public static KSubstOption getDefaultTextMode() {
- return CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption();
- }
- }
-
- /**
- * Makes a -m log message option.
- * Valid for: add commit import
- */
- public static LocalOption makeArgumentOption(LocalOption option, String argument) {
- if(argument == null) {
- argument = ""; //$NON-NLS-1$
- }
- return new LocalOption(option.getOption(), argument);
- }
-
- /**
- * Makes a -r or -D option for a tag.
- * Valid for: checkout export history rdiff update
- */
- public static LocalOption makeTagOption(CVSTag tag) {
- int type = tag.getType();
- switch (type) {
- case CVSTag.BRANCH:
- case CVSTag.VERSION:
- return new LocalOption("-r", tag.getName()); //$NON-NLS-1$
- case CVSTag.DATE:
- return new LocalOption("-D", tag.getName()); //$NON-NLS-1$
- default:
- // tag must not be HEAD
- throw new IllegalArgumentException(CVSMessages.Command_invalidTag);
- }
- }
-
- /**
- * Find a specific option in an array of options
- * @param array the array of options
- * @param option the option string to search for
- * @return the first element matching the option string, or null if none
- */
- public static Option findOption(Option[] array, String option) {
- for (int i = 0; i < array.length; ++i) {
- if (array[i].getOption().equals(option)) return array[i];
- }
- return null;
- }
-
- /**
- * Collect all arguments of a specific option from an array of options
- * @param array the array of options
- * @param option the option string to search for
- * @return an array of all arguments of belonging to matching options
- */
- protected static String[] collectOptionArguments(Option[] array, String option) {
- List /* of String */ list = new ArrayList();
- for (int i = 0; i < array.length; ++i) {
- if (array[i].getOption().equals(option)) {
- list.add(array[i].argument);
- }
- }
- return (String[]) list.toArray(new String[list.size()]);
- }
-
- /**
- * Allows commands to filter the set of global options to be sent.
- * This method invokes the method of the same name on the session
- * itself in order to get any session wide or globally set options.
- * Subclasses that override this method should call the superclass.
- *
- * @param session the session
- * @param globalOptions the global options, read-only
- * @return the filtered global options
- */
- protected GlobalOption[] filterGlobalOptions(Session session, GlobalOption[] globalOptions) {
- return session.filterGlobalOptions(globalOptions);
- }
-
- /**
- * Allows commands to filter the set of local options to be sent.
- * Subclasses that override this method should call the superclass.
- *
- * @param session the session
- * @param globalOptions the global options, read-only
- * @param localOptions the local options, read-only
- * @return the filtered local options
- */
- protected LocalOption[] filterLocalOptions(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions) {
- return localOptions;
- }
-
- /**
- * Execute a CVS command on an array of ICVSResource. This method simply converts
- * the ICVSResource to String paths relative to the local root of the session and
- * invokes <code>execute(Session, GlobalOption[], LocalOption[], String[], ICommandOutputListener, IProgressMonitor)</code>.
- * </p>
- * @param session the open CVS session
- * @param globalOptions the array of global options, or NO_GLOBAL_OPTIONS
- * @param localOptions the array of local options, or NO_LOCAL_OPTIONS
- * @param arguments the array of ICVSResource to be operated on
- * @param listener the command output listener, or null to discard all messages
- * @param monitor the progress monitor
- * @return a status code indicating success or failure of the operation
- * @throws CVSException if a fatal error occurs (e.g. connection timeout)
- *
- * @see Command#execute(Session, GlobalOption[], LocalOption[], String[], ICommandOutputListener, IProgressMonitor)
- */
- public final IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions, ICVSResource[] arguments,
- ICommandOutputListener listener, IProgressMonitor pm) throws CVSException {
-
- String[] stringArguments = convertArgumentsForOpenSession(arguments, session);
- return execute(session, globalOptions, localOptions, stringArguments, listener, pm);
- }
-
- protected String[] convertArgumentsForOpenSession(ICVSResource[] arguments, Session openSession) throws CVSException {
- // Convert arguments
- List stringArguments = new ArrayList(arguments.length);
- for (int i = 0; i < arguments.length; i++) {
- stringArguments.add(arguments[i].getRelativePath(openSession.getLocalRoot()));
- }
- return (String[]) stringArguments.toArray(new String[stringArguments.size()]);
- }
-
- /**
- * Method mergeStatus.
- * @param status
- * @param cVSStatus
- * @return IStatus
- */
- protected IStatus mergeStatus(IStatus accumulatedStatus, IStatus newStatus) {
- if (accumulatedStatus.isMultiStatus()) {
- ((MultiStatus)accumulatedStatus).merge(newStatus);
- return accumulatedStatus;
- }
- if (accumulatedStatus.isOK()) return newStatus;
- if (newStatus.isOK()) return accumulatedStatus;
- MultiStatus result = new MultiStatus(CVSProviderPlugin.ID, IStatus.INFO,
- new IStatus[] {accumulatedStatus, newStatus},
- NLS.bind(CVSMessages.Command_warnings, new String[] { getDisplayText() }), null);
- return result;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CommandOutputListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CommandOutputListener.java
deleted file mode 100644
index 8eed8512b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CommandOutputListener.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-
-public class CommandOutputListener implements ICommandOutputListener {
-
- /*
- * Failure string that is returned from the server when pserver is used and the root directory
- * is not readable. The problem can be fixed by making the directory readable or by using -f in
- * the pserver configuration file. We will ignore the error since it does not affect the command.
- */
- public static final String ROOT_CVSIGNORE_READ_FAILURE = "cvs server: cannot open /root/.cvsignore: Permission denied"; //$NON-NLS-1$
-
- public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
- return OK;
- }
- public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
- String protocolError = getProtocolError(line, location);
- if (protocolError != null) {
- return new CVSStatus(IStatus.ERROR, CVSStatus.PROTOCOL_ERROR, protocolError, commandRoot);
- }
- if (line.equals(ROOT_CVSIGNORE_READ_FAILURE) || getServerMessage(ROOT_CVSIGNORE_READ_FAILURE, location).equals(getServerMessage(line, location))) {
- // Don't report this as an error since it does not affect the command
- return new CVSStatus(IStatus.WARNING, CVSStatus.ERROR_LINE, line, commandRoot);
- }
- return new CVSStatus(IStatus.ERROR, CVSStatus.ERROR_LINE, line, commandRoot);
- }
-
- /**
- * Return the portion of the line that describes the error if the error line
- * is a protocol error or null if the line is not a protocol error.
- *
- * @param line the error line received from the server
- * @param location the repository location
- * @return String the potocol error or null
- */
- protected String getProtocolError(String line, ICVSRepositoryLocation location) {
- if (line.startsWith("Protocol error:")) { //$NON-NLS-1$
- return line;
- }
- return null;
- }
-
- public String getServerMessage(String line, ICVSRepositoryLocation location) {
- return ((CVSRepositoryLocation)location).getServerMessageWithoutPrefix(line, SERVER_PREFIX);
- }
-
- public String getServerAbortedMessage(String line, ICVSRepositoryLocation location) {
- return ((CVSRepositoryLocation)location).getServerMessageWithoutPrefix(line, SERVER_ABORTED_PREFIX);
- }
-
- public String getServerRTagMessage(String line, ICVSRepositoryLocation location) {
- return ((CVSRepositoryLocation)location).getServerMessageWithoutPrefix(line, RTAG_PREFIX);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java
deleted file mode 100644
index 6ad5c676b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import java.util.Collection;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-
-public class Commit extends Command {
- /*** Local options: specific to commit ***/
- // Forces a file to be committed even if it has not been modified; implies -l.
- // NOTE: This option is not fully supported -- a file will not be sent
- // unless it is dirty. The primary use is to resend a file that may
- // or may not be changed (e.g. could depend on CR/LF translations, etc...)
- // and force the server to create a new revision and reply Checked-in.
- public static final LocalOption FORCE = new LocalOption("-f"); //$NON-NLS-1$
-
- protected Commit() { }
- protected String getRequestId() {
- return "ci"; //$NON-NLS-1$
- }
-
- /**
- * Send all files under the workingFolder as changed files to
- * the server.
- */
- protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // Get the folders we want to work on
- checkResourcesManaged(session, resources);
-
- // Send all changed files to the server
- ModifiedFileSender visitor = new ModifiedFileSender(session, localOptions);
- visitor.visit(session, resources, monitor);
-
- // Send the changed files as arguments (because this is what other cvs clients do)
- ICVSFile[] changedFiles = visitor.getModifiedFiles();
- for (int i = 0; i < changedFiles.length; i++) {
- // escape file names, see bug 149683
- String fileName = changedFiles[i].getRelativePath(session.getLocalRoot());
- if(fileName.startsWith("-")){ //$NON-NLS-1$
- fileName = "./" + fileName; //$NON-NLS-1$
- }
- session.sendArgument(fileName);
- }
- return changedFiles;
- }
-
- /**
- * On successful finish, prune empty directories if the -P or -D option was specified.
- */
- protected IStatus commandFinished(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor,
- IStatus status) throws CVSException {
- // If we didn't succeed, don't do any post processing
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- return status;
- }
-
- // If pruning is enable, prune empty directories after a commit
- if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories()) {
- new PruneFolderVisitor().visit(session, resources);
- }
-
- // Reset the timestamps of any committed files that are still dirty.
- // Only do so if there were no E messages from the server
- if (status.isOK()) {
- for (int i = 0; i < resources.length; i++) {
- ICVSResource resource = resources[i];
- if (!resource.isFolder()) {
- ICVSFile cvsFile = (ICVSFile)resources[i];
- if (cvsFile.exists() && cvsFile.isModified(null)) {
- status = mergeStatus(status, clearModifiedState(cvsFile));
- }
- }
- }
- }
- return status;
- }
-
- protected IStatus clearModifiedState(ICVSFile cvsFile) throws CVSException {
- byte[] info = cvsFile.getSyncBytes();
- IResource resource = cvsFile.getIResource();
- String filePath;
- if (resource == null) {
- filePath = cvsFile.getRepositoryRelativePath();
- } else {
- filePath = resource.getFullPath().toString();
- }
- if (info == null) {
- // There should be sync info. Log the problem
- return new Status(IStatus.WARNING, CVSProviderPlugin.ID, 0, NLS.bind(CVSMessages.Commit_syncInfoMissing, new String[] { filePath }), null);
- }
- cvsFile.checkedIn(null, true /* commit in progress */);
- return new Status(IStatus.INFO, CVSProviderPlugin.ID, 0, NLS.bind(CVSMessages.Commit_timestampReset, new String[] { filePath }), null); //;
- }
-
- /**
- * We do not want to send the arguments here, because we send
- * them in sendRequestsToServer (special handling).
- */
- protected void sendArguments(Session session, String[] arguments) throws CVSException {
- }
-
- public final IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions,
- ICVSResource[] arguments, Collection filesToCommitAsText,
- ICommandOutputListener listener, IProgressMonitor pm) throws CVSException {
-
- session.setTextTransferOverride(filesToCommitAsText);
- try {
- return super.execute(session, globalOptions, localOptions, arguments, listener, pm);
- } finally {
- session.setTextTransferOverride(null);
- }
- }
-
- protected String getDisplayText() {
- return "commit"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ConsoleListeners.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ConsoleListeners.java
deleted file mode 100644
index f5ec56c79..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ConsoleListeners.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener;
-
-/**
- * Class which forwards CVS console output to 1 or more
- * registered console listeners.
- */
-public class ConsoleListeners implements IConsoleListener {
-
- private static ConsoleListeners instance = new ConsoleListeners();
- private Set listeners = new HashSet();
-
- /**
- * Return the console listeners
- * @return the console listeners
- */
- public static ConsoleListeners getInstance() {
- return instance;
- }
-
- public void addListener(IConsoleListener listener) {
- synchronized(listeners) {
- listeners.add(listener);
- }
- }
-
- public void removeListener(IConsoleListener listener) {
- synchronized(listeners) {
- listeners.remove(listener);
- }
- }
-
- private IConsoleListener[] getListeners() {
- synchronized(listeners) {
- return (IConsoleListener[]) listeners.toArray(new IConsoleListener[listeners.size()]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#commandInvoked(java.lang.String)
- */
- public void commandInvoked(final Session session, final String line) {
- if (listeners.isEmpty()) return;
- IConsoleListener[] listeners = getListeners();
- for (int i = 0; i < listeners.length; i++) {
- final IConsoleListener listener = listeners[i];
- Platform.run(new ISafeRunnable() {
- public void handleException(Throwable exception) {
- // Exception logged by Platform
- }
- public void run() throws Exception {
- listener.commandInvoked(session, line);
- }
- });
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#messageLineReceived(java.lang.String)
- */
- public void messageLineReceived(final Session session, final String line, final IStatus status) {
- if (listeners.isEmpty()) return;
- IConsoleListener[] listeners = getListeners();
- for (int i = 0; i < listeners.length; i++) {
- final IConsoleListener listener = listeners[i];
- Platform.run(new ISafeRunnable() {
- public void handleException(Throwable exception) {
- // Exception logged by Platform
- }
- public void run() throws Exception {
- listener.messageLineReceived(session, line, status);
- }
- });
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#errorLineReceived(java.lang.String)
- */
- public void errorLineReceived(final Session session, final String line, final IStatus status) {
- if (listeners.isEmpty()) return;
- IConsoleListener[] listeners = getListeners();
- for (int i = 0; i < listeners.length; i++) {
- final IConsoleListener listener = listeners[i];
- Platform.run(new ISafeRunnable() {
- public void handleException(Throwable exception) {
- // Exception logged by Platform
- }
- public void run() throws Exception {
- listener.errorLineReceived(session, line, status);
- }
- });
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener#commandCompleted(org.eclipse.core.runtime.IStatus, java.lang.Exception)
- */
- public void commandCompleted(final Session session, final IStatus status, final Exception exception) {
- if (listeners.isEmpty()) return;
- IConsoleListener[] listeners = getListeners();
- for (int i = 0; i < listeners.length; i++) {
- final IConsoleListener listener = listeners[i];
- Platform.run(new ISafeRunnable() {
- public void handleException(Throwable exception) {
- // Exception logged by Platform
- }
- public void run() throws Exception {
- listener.commandCompleted(session, status, exception);
- }
- });
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java
deleted file mode 100644
index d2a25d5c1..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CopyHandler.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.*;
-
-/**
- * Handles a "Copy-file" response from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Copy-file myproject/ \n
- * /u/cvsroot/myproject/oldfile.txt \n
- * newfile.txt
- * [...]
- * </pre>
- * Then we copy (or optionally rename) the local file "oldfile.txt" in
- * folder "myproject" to "newfile.txt". This response is used to create
- * a backup copy of an existing file before merging in new changes.
- * </p>
- */
-class CopyHandler extends ResponseHandler {
- public String getResponseID() {
- return "Copy-file"; //$NON-NLS-1$
- }
-
- public void handle(Session session, String localDir,
- IProgressMonitor monitor) throws CVSException {
- // read additional data for the response
- String repositoryFile = session.readLine();
- String newFile = session.readLine();
- if (session.isNoLocalChanges() || ! session.isCreateBackups()) return;
-
- // Get the local file
- String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$
- ICVSFolder mParent = session.getLocalRoot().getFolder(localDir);
- ICVSFile mFile = mParent.getFile(fileName);
-
- Assert.isTrue(mParent.exists());
- Assert.isTrue(mFile.exists() && mFile.isManaged());
-
- // rename the file
- mFile.copyTo(newFile);
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java
deleted file mode 100644
index 07ef7f070..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Diff.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-
-/**
- * Runs the CVS diff command.
- */
-public class Diff extends Command {
- /*** Local options: specific to diff ***/
- public static final LocalOption UNIFIED_FORMAT = new LocalOption("-u"); //$NON-NLS-1$
- public static final LocalOption CONTEXT_FORMAT = new LocalOption("-c"); //$NON-NLS-1$
- public static final LocalOption INCLUDE_NEWFILES = new LocalOption("-N"); //$NON-NLS-1$
- public static final LocalOption BRIEF = new LocalOption("--brief"); //$NON-NLS-1$
-
- protected Diff() { }
- protected String getRequestId() {
- return "diff"; //$NON-NLS-1$
- }
-
- /**
- * Overwritten to throw the CVSDiffException if the server returns an error, because it just does
- * so when there is a difference between the checked files.
- */
- protected IStatus doExecute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions,
- String[] arguments, ICommandOutputListener listener, IProgressMonitor monitor) throws CVSException {
- try {
- IStatus status = super.doExecute(session, globalOptions, localOptions, arguments, listener, monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- if (status.isMultiStatus()) {
- IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- IStatus child = children[i];
- if (child.getMessage().indexOf("[diff aborted]") != -1) { //$NON-NLS-1$
- throw new CVSServerException(status);
- }
- }
- }
- }
- return status;
- } catch (CVSServerException e) {
- if (e.containsErrors()) throw e;
- return e.getStatus();
- }
- }
-
- protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- checkResourcesManaged(session, resources);
- DiffStructureVisitor visitor = new DiffStructureVisitor(session, localOptions);
- visitor.visit(session, resources, monitor);
- return resources;
- }
-
- protected String getServerErrorMessage() {
- return CVSMessages.Diff_serverError;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java
deleted file mode 100644
index 4c3d45c3b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * The diff command needs to send a file structure to the server that differs somewhat from the canonical
- * format sent by other commands. Instead of sending new files as questionables this class sends
- * new files as modified and fakes them being added. The contents are sent to the server and are
- * included in the returned diff report.
- */
-class DiffStructureVisitor extends FileStructureVisitor {
-
- public DiffStructureVisitor(Session session, LocalOption[] localOptions) {
- super(session, localOptions, true, true);
- }
-
- /**
- * Send unmanaged files as modified with a default entry line.
- */
- protected void sendFile(ICVSFile mFile) throws CVSException {
- byte[] info = mFile.getSyncBytes();
- if (info==null) {
- return;
- }
-
- // Send the parent folder if it hasn't been sent already
- sendFolder(mFile.getParent());
- Policy.checkCanceled(monitor);
- session.sendEntry(info, null);
-
- if (!mFile.exists()) {
- return;
- }
-
- if (mFile.isModified(null)) {
- session.sendModified(mFile, ResourceSyncInfo.isBinary(info), monitor);
- } else {
- session.sendUnchanged(mFile);
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Editors.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Editors.java
deleted file mode 100644
index 4175282e9..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Editors.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CSC - Intial implementation
- * IBM Corporation - ongoing maintenance
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-/**
- *
- * The editors command
- *
- * @author <a href="mailto:kohlwes@gmx.net">Gregor Kohlwes</a>
- */
-public class Editors extends AbstractMessageCommand {
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.client.Request#getRequestId()
- */
- protected String getRequestId() {
- return "editors"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Command#isWorkspaceModification()
- */
- protected boolean isWorkspaceModification() {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java
deleted file mode 100644
index dd7297c7c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-public class ExpandModules extends Request {
- protected ExpandModules() { }
- protected String getRequestId() {
- return "expand-modules"; //$NON-NLS-1$
- }
-
- public IStatus execute(Session session, String[] modules, IProgressMonitor monitor) throws CVSException {
- // Reset the module expansions before the responses arrive
- session.resetModuleExpansion();
- for (int i = 0; i < modules.length; ++i) {
- session.sendArgument(modules[i]);
- }
- return executeRequest(session, Command.DEFAULT_OUTPUT_LISTENER, monitor);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java
deleted file mode 100644
index 298c3384e..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/FileStructureVisitor.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-
-/**
- * Visitor to send the local file structure to the CVS Server.
- *
- * Files are sent as Unchanged or Modified.
- * Folders are sent if they contain files unless sendEmptyFolders is true
- * in which case all folders are sent.
- *
- * @param sendEmptyFolders sends the folder-entrie even if there is no file
- to send in it
- */
-
-class FileStructureVisitor extends AbstractStructureVisitor {
-
- private boolean sendEmptyFolders;
-
- public FileStructureVisitor(Session session, LocalOption[] localOptions, boolean sendEmptyFolders, boolean sendModifiedContents) {
- this(session, localOptions, sendEmptyFolders, sendModifiedContents, true);
- }
-
- public FileStructureVisitor(Session session, LocalOption[] localOptions, boolean sendEmptyFolders, boolean sendModifiedContents, boolean sendBinary) {
- super(session, localOptions, true, sendModifiedContents, sendBinary);
- this.sendEmptyFolders = sendEmptyFolders;
- }
-
- /**
- * @see ICVSResourceVisitor#visitFile(IManagedFile)
- */
- public void visitFile(ICVSFile mFile) throws CVSException {
- sendFile(mFile);
- }
-
- /**
- * @see ICVSResourceVisitor#visitFolder(ICVSFolder)
- */
- public void visitFolder(ICVSFolder mFolder) throws CVSException {
-
- if (sendEmptyFolders) {
- // If we want to send empty folder, that just send it when
- // we come to it
- sendFolder(mFolder);
- }
-
- boolean exists = mFolder.exists();
- boolean isCVSFolder = mFolder.isCVSFolder();
-
- // We are only interested in CVS folders
- // A folder could be a non-existant CVS folder if it is a holder for outgoing file deletions
- if ( ! isCVSFolder) return;
-
- if (exists && isOrphanedSubtree(mFolder)) {
- return;
- }
-
- // Send files, then the questionable folders, then the managed folders
- ICVSResource[] children = mFolder.members(ICVSFolder.ALL_UNIGNORED_MEMBERS);
- sendFiles(children);
- sendQuestionableFolders(children);
- if (isRecurse()) {
- sendManagedFolders(children);
- }
- }
-
- /**
- * Method sendManagedFolders.
- * @param children
- */
- private void sendManagedFolders(ICVSResource[] children) throws CVSException {
- for (int i = 0; i < children.length; i++) {
- ICVSResource resource = children[i];
- if (resource.isFolder() && resource.isManaged()) {
- resource.accept(this);
- }
- }
- }
-
- /**
- * Method sendQuestionableFolders.
- * @param children
- */
- private void sendQuestionableFolders(ICVSResource[] children) throws CVSException {
- for (int i = 0; i < children.length; i++) {
- ICVSResource resource = children[i];
- if (resource.isFolder() && ! resource.isManaged()) {
- resource.accept(this);
- }
- }
- }
-
- /**
- * Method sendFiles.
- * @param children
- */
- private void sendFiles(ICVSResource[] children) throws CVSException {
- for (int i = 0; i < children.length; i++) {
- ICVSResource resource = children[i];
- if (!resource.isFolder()) {
- resource.accept(this);
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java
deleted file mode 100644
index 8ff4cac82..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-
-
-public class Import extends Command {
- protected Import() { }
- protected String getRequestId() {
- return "import"; //$NON-NLS-1$
- }
-
- protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions,
- String[] arguments) throws CVSException {
- if (arguments.length < 3) throw new IllegalArgumentException();
- return new ICVSResource[0];
- }
-
- protected IStatus doExecute(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener,
- IProgressMonitor monitor) throws CVSException {
-
- // If the branch option is not provided, a default value of 1.1.1 is used.
- // This is done to maintain reference client compatibility
- if (findOption(localOptions, "-b") == null) { //$NON-NLS-1$
- LocalOption[] newLocalOptions = new LocalOption[localOptions.length + 1];
- newLocalOptions[0] = new LocalOption("-b", "1.1.1"); //$NON-NLS-1$ //$NON-NLS-2$
- System.arraycopy(localOptions, 0, newLocalOptions, 1, localOptions.length);
- localOptions = newLocalOptions;
- }
- return super.doExecute(session, globalOptions, localOptions, arguments, listener, monitor);
- }
-
- protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- ICVSResourceVisitor visitor = new ImportStructureVisitor(session,
- collectOptionArguments(localOptions, "-W"), monitor); //$NON-NLS-1$
- session.getLocalRoot().accept(visitor);
- return resources;
- }
-
- protected void sendLocalWorkingDirectory(Session session) throws CVSException {
- session.sendConstructedRootDirectory();
- }
-
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java
deleted file mode 100644
index d218a4e82..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ImportStructureVisitor.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.Team;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.util.FileNameMatcher;
-
-/**
- * The ImportStructureVisitor sends the content of the folder it is
- * used on to the server. It constructs the locations of the resources
- * because the resources do not yet have a remote-location.<br>
- * It can also ignore certain files and decides wether to send
- * a file in binary or text mode due to a specification that is passed
- * as a "wrapper" argument.
- */
-class ImportStructureVisitor implements ICVSResourceVisitor {
-
- private static final String KEYWORD_OPTION = "-k"; //$NON-NLS-1$
- private static final String QUOTE = "'"; //$NON-NLS-1$
-
- protected Session session;
- protected IProgressMonitor monitor;
-
- private FileNameMatcher ignoreMatcher;
- private FileNameMatcher wrapMatcher;
-
- /**
- * Constructor for ImportStructureVisitor.
- * @param requestSender
- * @param mRoot
- * @param monitor
- */
- public ImportStructureVisitor(Session session,
- String[] wrappers, IProgressMonitor monitor) {
-
- this.session = session;
- this.monitor = Policy.infiniteSubMonitorFor(monitor, 512);
- wrapMatcher = initWrapMatcher(wrappers);
- }
-
-
- /**
- * Inits the wrapMatcher, that is responsible to find out
- * whether a file is to be send as a binary (on an import)
- * or not.
- *
- * Takes wrappers of this format:
- * *.class -k 'o'
- *
- * and inits the FileNameMatcher to give
- * -ko back if you call it with match("somename.class")
- *
- * ignores all wrappers, that do not contain -k
- */
- private FileNameMatcher initWrapMatcher(String[] wrappers) {
-
- FileNameMatcher wrapMatcher;
-
- if (wrappers == null) {
- return null;
- }
-
- wrapMatcher = new FileNameMatcher();
-
- for (int i = 0; i < wrappers.length; i++) {
-
- if (wrappers[i].indexOf(KEYWORD_OPTION) == -1) {
- continue;
- }
-
- StringTokenizer st = new StringTokenizer(wrappers[i]);
- String pattern = st.nextToken();
- String option = st.nextToken();
- // get rid of the quotes
- StringTokenizer quoteSt =
- new StringTokenizer(st.nextToken(),QUOTE);
- option += quoteSt.nextToken();
-
- wrapMatcher.register(pattern,option);
- }
-
- return wrapMatcher;
- }
-
- /**
- * @see ICVSResourceVisitor#visitFile(IManagedFile)
- */
- public void visitFile(ICVSFile mFile) throws CVSException {
- if (ignoreMatcher != null && ignoreMatcher.match(mFile.getName())) {
- return;
- }
-
- boolean binary = Team.getFileContentManager().getType((IFile)mFile.getIResource()) == Team.BINARY;
- if (wrapMatcher != null) {
- String mode = wrapMatcher.getMatch(mFile.getName());
- if (mode != null) binary = KSubstOption.fromMode(mode).isBinary();
- }
- session.sendModified(mFile, binary, monitor);
- }
-
- /**
- * @see ICVSResourceVisitor#visitFolder(ICVSFolder)
- */
- public void visitFolder(ICVSFolder mFolder) throws CVSException {
-
- if (ignoreMatcher != null && ignoreMatcher.match(mFolder.getName())) {
- return;
- }
-
- String localPath = mFolder.getRelativePath(session.getLocalRoot());
- monitor.subTask(NLS.bind(CVSMessages.AbstractStructureVisitor_sendingFolder, new String[] { localPath }));
-
- session.sendConstructedDirectory(localPath);
- mFolder.acceptChildren(this);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java
deleted file mode 100644
index 69e6befda..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-
-public class Log extends AbstractMessageCommand {
- /*** Local options: specific to log ***/
-
- public static LocalOption makeRevisionOption(String revision) {
- return new LocalOption("-r" + revision, null); //$NON-NLS-1$
- }
- public static final LocalOption RCS_FILE_NAMES_ONLY = new LocalOption("-R"); //$NON-NLS-1$
-
- public static final LocalOption NO_TAGS = new LocalOption("-N"); //$NON-NLS-1$
-
- protected Log() { }
- protected String getRequestId() {
- return "log"; //$NON-NLS-1$
- }
-
- protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // Send all folders that are already managed to the server
- boolean sendEmptyFolders = Command.findOption(localOptions, RCS_FILE_NAMES_ONLY.getOption()) != null;
- new FileStructureVisitor(session, localOptions, sendEmptyFolders, false /* send modified contents */).visit(session, resources, monitor);
- return resources;
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java
deleted file mode 100644
index 7bc1bc22b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-public class MTHandler extends ResponseHandler {
-
- private String nextLine;
- private boolean isLineAvailable;
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.ResponseHandler#getInstance()
- */
- ResponseHandler getInstance() {
- return new MTHandler();
- }
-
- /**
- * @see ResponseHandler#getResponseID()
- */
- public String getResponseID() {
- return "MT"; //$NON-NLS-1$
- }
-
- /**
- * @see ResponseHandler#handle(Session, String, IProgressMonitor)
- */
- public void handle(Session session, String argument, IProgressMonitor monitor)
- throws CVSException {
-
- // If there was a line available from before, clear it
- if (isLineAvailable()) {
- startNextLine();
- }
-
- if (argument.charAt(0) == '+') {
- // Reset any previously accumulated text
- startNextLine();
- } else if (argument.charAt(0) == '-') {
- // Mark the line as available in case there was no trailing newline
- if (nextLine != null) {
- isLineAvailable = true;
- }
- } else {
- // Extract the tag and text from the line
- String tag;
- String text;
- int spaceIndex = argument.indexOf(' ');
- if (spaceIndex == -1) {
- tag = argument;
- text = null;
- } else {
- tag = argument.substring(0, spaceIndex);
- text = argument.substring(spaceIndex + 1);
- }
-
- // Accumulate the line and indicate if its available for use
- if (tag.equals("newline")) { //$NON-NLS-1$
- isLineAvailable = true;
- } else if (text != null) {
- // Reset the previous line if required
- if (isLineAvailable()) {
- startNextLine();
- }
- // Accumulate the line
- if (nextLine == null) {
- nextLine = text;
- } else {
- // The text from the sevrver contains spaces when appropriate so just append
- nextLine = nextLine + text;
- }
- }
- }
- }
-
- /**
- * Check if there is a line available. If there is, it should be fetched with
- * getLine() immediatly before the next MT response is processed.
- */
- public boolean isLineAvailable() {
- return isLineAvailable;
- }
-
- /**
- * Get the available line. This purges the line from the handler
- */
- public String getLine() {
- return nextLine;
- }
-
- private void startNextLine() {
- isLineAvailable = false;
- nextLine = null;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java
deleted file mode 100644
index 8a9f75cbf..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import java.text.ParseException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.util.CVSDateFormatter;
-
-/**
- * Handles a "Mod-time" response from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Mod-time 18 Oct 2001 20:21:13 -0330\n
- * [...]
- * </pre>
- * Then we parse and remember the date for use in subsequent
- * file transfer responses such as Updated.
- * </p>
- */
-class ModTimeHandler extends ResponseHandler {
- public String getResponseID() {
- return "Mod-time"; //$NON-NLS-1$
- }
-
- public void handle(Session session, String timeStamp,
- IProgressMonitor monitor) throws CVSException {
- try {
- session.setModTime(CVSDateFormatter.serverStampToDate(timeStamp));
- } catch (ParseException e) {
- IStatus status = new CVSStatus(IStatus.ERROR,CVSStatus.ERROR,NLS.bind(CVSMessages.ModTimeHandler_invalidFormat, new String[] { timeStamp }), e, session.getLocalRoot());
- throw new CVSException(status);
- }
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModifiedFileSender.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModifiedFileSender.java
deleted file mode 100644
index 25d552516..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModifiedFileSender.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-
-/**
- * Visit the CVS file structure, only sending files if they are modified.
- */
-class ModifiedFileSender extends FileStructureVisitor {
-
- private final Set modifiedFiles;
-
- public ModifiedFileSender(Session session, LocalOption[] localOptions) {
- super(session, localOptions, false, true);
- modifiedFiles = new HashSet();
- }
-
- /**
- * Override sendFile to only send modified files
- */
- protected void sendFile(ICVSFile mFile) throws CVSException {
- // Only send the file if its modified
- if (mFile.isManaged() && mFile.isModified(null)) {
- super.sendFile(mFile);
- modifiedFiles.add(mFile);
- }
- }
-
- protected String getSendFileMessage() {
- return null;
- }
-
- /**
- * Return all the files that have been send to the server
- */
- public ICVSFile[] getModifiedFiles() {
- return (ICVSFile[]) modifiedFiles.toArray(new ICVSFile[modifiedFiles.size()]);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModuleExpansionHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModuleExpansionHandler.java
deleted file mode 100644
index f9ac3170b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModuleExpansionHandler.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-public class ModuleExpansionHandler extends ResponseHandler {
-
- /*
- * @see ResponseHandler#getResponseID()
- */
- public String getResponseID() {
- return "Module-expansion";//$NON-NLS-1$
- }
-
- /*
- * @see ResponseHandler#handle(Session, String, IProgressMonitor)
- */
- public void handle(Session session, String expansion, IProgressMonitor monitor)
- throws CVSException {
-
- session.addModuleExpansion(expansion);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPCommand.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPCommand.java
deleted file mode 100644
index 331e7609c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPCommand.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-
-/**
- * Noop command that sends edit notifications to the server.
- */
-public class NOOPCommand extends Command {
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.client.Command#sendLocalResourceState(Session, GlobalOption[], LocalOption[], ICVSResource[], IProgressMonitor)
- */
- protected ICVSResource[] sendLocalResourceState(
- Session session,
- GlobalOption[] globalOptions,
- LocalOption[] localOptions,
- ICVSResource[] resources,
- IProgressMonitor monitor)
- throws CVSException {
-
- // The noop visitor will send any pending notifications
- new NOOPVisitor(session, localOptions).visit(session, resources, monitor);
- return resources;
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.client.Request#getRequestId()
- */
- protected String getRequestId() {
- return "noop"; //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.client.Command#sendArguments(Session, String[])
- */
- protected void sendArguments(Session session, String[] arguments)throws CVSException {
- // don't send any arguments
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Command#isWorkspaceModification()
- */
- protected boolean isWorkspaceModification() {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPVisitor.java
deleted file mode 100644
index c2c5a8c0a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NOOPVisitor.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-
-/**
- * Send the contents of the CVS/Notify files to the server
- */
-public class NOOPVisitor extends AbstractStructureVisitor {
-
- public NOOPVisitor(Session session, LocalOption[] localOptions) {
- // Only send non-empty folders
- super(session, localOptions, false, false);
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor#visitFile(ICVSFile)
- */
- public void visitFile(ICVSFile file) throws CVSException {
- sendPendingNotification(file);
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor#visitFolder(ICVSFolder)
- */
- public void visitFolder(ICVSFolder folder) throws CVSException {
- if (isRecurse() && folder.isCVSFolder()) {
- folder.acceptChildren(this);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java
deleted file mode 100644
index 123b8303e..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-public class NewEntryHandler extends ResponseHandler {
-
- /*
- * @see ResponseHandler#getResponseID()
- */
- public String getResponseID() {
- return "New-entry"; //$NON-NLS-1$
- }
-
- /*
- * @see ResponseHandler#handle(Session, String, IProgressMonitor)
- */
- public void handle(Session session, String localDir, IProgressMonitor monitor)
- throws CVSException {
-
- // read additional data for the response
- String repositoryFile = session.readLine();
- String entryLine = session.readLine();
-
- // Clear the recorded mod-time
- session.setModTime(null);
-
- // Get the local file
- String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$
- ICVSFolder mParent = session.getLocalRoot().getFolder(localDir);
- ICVSFile mFile = mParent.getFile(fileName);
-
- ResourceSyncInfo fileInfo = mFile.getSyncInfo();
- MutableResourceSyncInfo newInfo = fileInfo.cloneMutable();
- newInfo.setEntryLine(entryLine);
- // Set the tag to the previous tag if the new tag is the base tag (see bug 106876)
- CVSTag newTag = newInfo.getTag();
- if(newTag != null && newTag.isBaseTag()) {
- newInfo.setTag(fileInfo.getTag());
- }
- mFile.setSyncInfo(newInfo, ICVSFile.UNKNOWN);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NotifiedHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NotifiedHandler.java
deleted file mode 100644
index 86f424602..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NotifiedHandler.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-
-/**
- * @author Administrator
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
- */
-public class NotifiedHandler extends ResponseHandler {
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.client.ResponseHandler#getResponseID()
- */
- public String getResponseID() {
- return "Notified"; //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.client.ResponseHandler#handle(Session, String, IProgressMonitor)
- */
- public void handle(
- Session session,
- String localDir,
- IProgressMonitor monitor)
- throws CVSException {
-
- // read additional data for the response
- // (which is the full repository path of the file)
- String repositoryFilePath = session.readLine();
-
- // clear the notify info for the file
- ICVSFolder folder = session.getLocalRoot().getFolder(localDir);
- ICVSFile file = folder.getFile(new Path(null, repositoryFilePath).lastSegment());
- file.notificationCompleted();
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java
deleted file mode 100644
index 14dde597b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/PruneFolderVisitor.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-
-/**
- * Goes recursivly through the folders checks if they are empyty
- * and deletes them. Of course it is starting at the leaves of the
- * recusion (the folders that do not have subfolders).
- */
-public class PruneFolderVisitor implements ICVSResourceVisitor {
-
- private ICVSFolder localRoot;
-
- public PruneFolderVisitor() {
- }
-
- /**
- * This method is used to visit a set of ICVSResources.
- */
- public void visit(Session s, ICVSResource[] resources) throws CVSException {
- visit(s.getLocalRoot(), resources);
- }
-
- /**
- * This method is used to visit a set of ICVSResources.
- */
- public void visit(ICVSFolder root, ICVSResource[] resources) throws CVSException {
- localRoot = root;
-
- // Visit the resources
- Set prunableParents = new HashSet();
- for (int i = 0; i < resources.length; i++) {
- ICVSResource cvsResource = resources[i];
- // prune the resource and it's children when appropriate
- cvsResource.accept(this);
- // if the resource doesn't exists, attempt to prune it's parent
- if (!cvsResource.exists())
- prunableParents.add(cvsResource.getParent());
- }
- for (Iterator iter = prunableParents.iterator(); iter.hasNext();) {
- ICVSFolder cvsFolder = (ICVSFolder)iter.next();
- pruneFolderAndParentsIfAppropriate(cvsFolder);
- }
- }
- /**
- * @see ICVSResourceVisitor#visitFile(IManagedFile)
- */
- public void visitFile(ICVSFile file) throws CVSException {
- // nothing to do here
- }
-
- /**
- * @see ICVSResourceVisitor#visitFolder(ICVSFolder)
- */
- public void visitFolder(ICVSFolder folder) throws CVSException {
- // First prune any empty children
- folder.acceptChildren(this);
- // Then prune the folder if it is empty
- pruneFolderIfAppropriate(folder);
- }
-
- private void pruneFolderIfAppropriate(ICVSFolder folder) throws CVSException {
- // Only prune managed folders that are not the root of the operation
- if (folder.exists() && folder.isManaged()
- && ! folder.equals(getLocalRoot())
- && folder.members(ICVSFolder.ALL_EXISTING_MEMBERS).length == 0) {
-
- // Delete the folder but keep a phantom for local folders
- folder.delete();
- }
- }
-
- private ICVSFolder getLocalRoot() {
- return localRoot;
- }
-
- /**
- * Attempt to prune the given folder. If the folder is pruned, attempt to prune it's parent.
- */
- private void pruneFolderAndParentsIfAppropriate(ICVSFolder folder) throws CVSException {
- pruneFolderIfAppropriate(folder);
- if (!folder.exists()) {
- ICVSFolder parent = folder.getParent();
- pruneFolderAndParentsIfAppropriate(parent);
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RDiff.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RDiff.java
deleted file mode 100644
index b1f5f1ebb..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RDiff.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-
-public class RDiff extends RemoteCommand {
-
- /*** Local options: specific to rdiff ***/
- public static final LocalOption SUMMARY = new LocalOption("-s", null); //$NON-NLS-1$
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Request#getRequestId()
- */
- protected String getRequestId() {
- return "rdiff"; //$NON-NLS-1$
- }
-
- /**
- * Makes a -r or -D option for a tag.
- * Valid for: checkout export history rdiff update
- */
- public static LocalOption makeTagOption(CVSTag tag) {
- if (tag == null) tag = CVSTag.DEFAULT;
- int type = tag.getType();
- switch (type) {
- case CVSTag.BRANCH:
- case CVSTag.VERSION:
- case CVSTag.HEAD:
- return new LocalOption("-r", tag.getName()); //$NON-NLS-1$
- case CVSTag.DATE:
- return new LocalOption("-D", tag.getName()); //$NON-NLS-1$
- default:
- // Unknow tag type!!!
- throw new IllegalArgumentException();
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RLog.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RLog.java
deleted file mode 100644
index 12b9220cd..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RLog.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.util.Date;
-
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-
-/**
- * The "cvs rlog..." command
- */
-public class RLog extends RemoteCommand {
-
- /*** Local options: specific to rlog ***/
- public static final LocalOption NO_TAGS = new LocalOption("-N"); //$NON-NLS-1$
- public static final LocalOption ONLY_INCLUDE_CHANGES = new LocalOption("-S"); //$NON-NLS-1$
- public static final LocalOption REVISIONS_ON_DEFAULT_BRANCH = new LocalOption("-b"); //$NON-NLS-1$
- public static final LocalOption LOCAL_DIRECTORY_ONLY = new LocalOption("-l"); //$NON-NLS-1$
- /**
- * Makes a -r option for rlog. Here are the currently supported options:
- *
- * tag1 tag2 result
- * ==== ==== =================================
- * date date date<date (all revisions between date and later)
- * tag tag tag:tag (all revisions between tag and tag, must be on same branch)
- * branch date >date (all revisions of date or later)
- * branch tag tag: (all revisions from tag to the end of branchs tip)
- *
- * Valid for: rlog
- */
- public static LocalOption makeTagOption(CVSTag tag1, CVSTag tag2) {
- int type1 = tag1.getType();
- int type2 = tag2.getType();
-
- if(type1 == type2) {
- switch (type1) {
- case CVSTag.HEAD:
- case CVSTag.BRANCH:
- // A range of branches - all revisions on all the branches in that range.
- case CVSTag.VERSION:
- // Revisions from tag1 to tag2 (they must be on the same branch).
- return new LocalOption("-r" + tag1.getName() + ":" + tag2.getName(), null); //$NON-NLS-1$ //$NON-NLS-2$
- case CVSTag.DATE:
- // Selects revisions created between DATE1 and DATE2. If DATE1 is after DATE2, use > instead; otherwise, no log messages are retrieved.
- Date date1 = tag1.asDate();
- Date date2 = tag2.asDate();
- String operator = "<"; //$NON-NLS-1$
- if(date1.compareTo(date2) > 0) {
- operator = ">"; //$NON-NLS-1$
- }
- return new LocalOption("-d", tag1.getName() + operator + tag2.getName()); //$NON-NLS-1$
- default:
- // Unknow tag type!!!
- throw new IllegalArgumentException();
- }
- }
-
- if((type1 == CVSTag.BRANCH || type1 == CVSTag.HEAD) && type2 == CVSTag.DATE) {
- return new LocalOption("-d", ">" + tag2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- if((type1 == CVSTag.BRANCH || type1 == CVSTag.HEAD) && type2 == CVSTag.VERSION) {
- return new LocalOption("-r" + tag2.getName() + ":", null); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // defaults
- switch (type1) {
- case CVSTag.HEAD:
- case CVSTag.BRANCH:
- // All revisions on this branch
- case CVSTag.VERSION:
- // revisions in this tag
- return new LocalOption("-r" + tag1.getName(), null); //$NON-NLS-1$
- case CVSTag.DATE:
- // Revisions at this date tag
- return new LocalOption("-d", tag1.getName()); //$NON-NLS-1$
- default:
- // Unknow tag type!!!
- throw new IllegalArgumentException();
- }
- }
-
- /***
- * Experimental - Used for obtaining the latest revisions on HEAD or the specified branch.
- * @param tag1
- * @return the option to use
- *
- * Valid for rlog
- */
- public static LocalOption getCurrentTag(CVSTag tag1) {
-
- int type = tag1.getType();
-
- switch (type){
- case CVSTag.HEAD:
- return new LocalOption("-r"); //$NON-NLS-1$
-
- case CVSTag.BRANCH:
- return new LocalOption("-r" + tag1.getName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
-
- case CVSTag.VERSION:
- return new LocalOption("-r" + tag1.getName()); //$NON-NLS-1$
-
- case CVSTag.DATE:
- return new LocalOption("-d", tag1.asDate().toString()); //$NON-NLS-1$
- default:
- // Unknow tag type!!!
- throw new IllegalArgumentException();
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Request#getRequestId()
- */
- protected String getRequestId() {
- return "rlog"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java
deleted file mode 100644
index 99ff4de83..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.TagListener;
-
-public class RTag extends RemoteCommand {
- /*** Local options: specific to tag ***/
- public static final LocalOption CREATE_BRANCH = Tag.CREATE_BRANCH;
- public static final LocalOption CLEAR_FROM_REMOVED = new LocalOption("-a", null); //$NON-NLS-1$
- public static final LocalOption FORCE_REASSIGNMENT = new LocalOption("-F", null); //$NON-NLS-1$
- public static final LocalOption FORCE_BRANCH_REASSIGNMENT = new LocalOption("-B", null); //$NON-NLS-1$
-
- /*** Default command output listener ***/
- private static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new TagListener();
-
- /**
- * Makes a -r or -D option for a tag.
- * Valid for: checkout export history rdiff update
- */
- public static LocalOption makeTagOption(CVSTag tag) {
- int type = tag.getType();
- switch (type) {
- case CVSTag.BRANCH:
- case CVSTag.VERSION:
- case CVSTag.HEAD:
- return new LocalOption("-r", tag.getName()); //$NON-NLS-1$
- case CVSTag.DATE:
- return new LocalOption("-D", tag.getName()); //$NON-NLS-1$
- default:
- // Unknow tag type!!!
- throw new IllegalArgumentException();
- }
- }
-
- protected String getRequestId() {
- return "rtag"; //$NON-NLS-1$
- }
-
- protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions,
- String[] arguments) throws CVSException {
- if (arguments.length < 2) throw new IllegalArgumentException();
- return super.computeWorkResources(session, localOptions, arguments);
- }
-
- public IStatus execute(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, CVSTag sourceTag, CVSTag tag, String[] arguments,
- IProgressMonitor monitor) throws CVSException {
-
- if(tag.getType() != CVSTag.VERSION && tag.getType() != CVSTag.BRANCH) {
- throw new CVSException(new CVSStatus(IStatus.ERROR, CVSMessages.Tag_notVersionOrBranchError));
- }
-
- // Add the source tag to the local options
- List modifiedLocalOptions = new ArrayList(localOptions.length + 1);
- if (sourceTag==null) sourceTag = CVSTag.DEFAULT;
- modifiedLocalOptions.addAll(Arrays.asList(localOptions));
- modifiedLocalOptions.add(makeTagOption(sourceTag));
-
- // Add the CREATE_BRANCH option for a branch tag
- if (tag.getType() == CVSTag.BRANCH) {
- if ( ! CREATE_BRANCH.isElementOf(localOptions)) {
- modifiedLocalOptions.add(CREATE_BRANCH);
- }
- }
-
- // Add the tag name to the start of the arguments
- String[] newArguments = new String[arguments.length + 1];
- newArguments[0] = tag.getName();
- System.arraycopy(arguments, 0, newArguments, 1, arguments.length);
-
- return execute(session, globalOptions,
- (LocalOption[]) modifiedLocalOptions.toArray(new LocalOption[modifiedLocalOptions.size()]),
- newArguments, null, monitor);
- }
-
- public IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions,
- CVSTag sourceTag, CVSTag tag, ICVSRemoteResource[] arguments, IProgressMonitor monitor)
- throws CVSException {
-
- String[] stringArguments = convertArgumentsForOpenSession(arguments, session);
-
- return execute(session, globalOptions, localOptions, sourceTag, tag, stringArguments, monitor);
- }
-
- protected ICommandOutputListener getDefaultCommandOutputListener() {
- return DEFAULT_OUTPUT_LISTENER;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java
deleted file mode 100644
index fbecc624b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-
-/**
- * This class acts as a super class for those CVS commands that do not send up the local file structure
- */
-public abstract class RemoteCommand extends Command {
-
- protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions,
- String[] arguments) throws CVSException {
- return new ICVSResource[0];
- }
-
- protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // do nothing
- monitor.beginTask(null, 100);
- monitor.done();
- return resources;
- }
-
- protected void sendLocalWorkingDirectory(Session session) throws CVSException {
- // do nothing
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Command#convertArgumentsForOpenSession(org.eclipse.team.internal.ccvs.core.ICVSResource[], org.eclipse.team.internal.ccvs.core.client.Session)
- */
- protected String[] convertArgumentsForOpenSession(
- ICVSResource[] arguments,
- Session openSession)
- throws CVSException {
-
- // Convert arguments
- List stringArguments = new ArrayList(arguments.length);
- for (int i = 0; i < arguments.length; i++) {
- ICVSResource resource = arguments[i];
- String remotePath;
- if (isDefinedModule(resource)) {
- remotePath = resource.getName();
- } else {
- remotePath = resource.getRepositoryRelativePath();
-
- }
- stringArguments.add(remotePath);
- }
- return (String[]) stringArguments.toArray(new String[stringArguments.size()]);
- }
-
- private boolean isDefinedModule(ICVSResource resource) {
- return resource instanceof ICVSRemoteFolder && ((ICVSRemoteFolder)resource).isDefinedModule();
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java
deleted file mode 100644
index a275fdf72..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Remove.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-
-public class Remove extends Command {
- /*** Local options: specific to remove ***/
-
- protected Remove() { }
- protected String getRequestId() {
- return "remove"; //$NON-NLS-1$
- }
-
- protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // Send all modified files to the server
- // XXX Does the command line client send all modified files?
- new ModifiedFileSender(session, localOptions).visit(session, resources, monitor);
- return resources;
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java
deleted file mode 100644
index 274a3d45e..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoveEntryHandler.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-
-/**
- * Handles a "Remove-entry" response from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Remove-entry ??? \n
- * [...]
- * </pre>
- * Then
- * </p>
- */
-
-/**
- * It removes the file from both the entries of the parent-folder.
- * This happen, when the folder has allready been removed locally
- * what happens on a checkin that includes a removed file.
- */
-class RemoveEntryHandler extends ResponseHandler {
- public String getResponseID() {
- return "Remove-entry"; //$NON-NLS-1$
- }
-
- public void handle(Session session, String localDir,
- IProgressMonitor monitor) throws CVSException {
- // read additional data for the response
- String repositoryFile = session.readLine();
-
- // Get the local file
- String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$
- ICVSFolder mParent = session.getLocalRoot().getFolder(localDir);
- ICVSFile mFile = mParent.getFile(fileName);
- if (mFile.exists()) {
- IStatus status = new CVSStatus(IStatus.ERROR,CVSStatus.ERROR, NLS.bind(CVSMessages.RemoveEntryHandler_2, new String[] { mFile.getRepositoryRelativePath() }),session.getLocalRoot());
- CVSProviderPlugin.log(status);
- } else {
- mFile.unmanage(null);
- }
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java
deleted file mode 100644
index 237eb0976..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-
-/**
- * Handles a "Removed" response from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Removed ??? \n
- * [...]
- * </pre>
- * Then
- * </p>
- */
-
-/**
- * It removes the file from both the entries of the parent-folder
- * and from the local filesystem.
- */
-class RemovedHandler extends ResponseHandler {
- public String getResponseID() {
- return "Removed"; //$NON-NLS-1$
- }
-
- public void handle(Session session, String localDir, IProgressMonitor monitor) throws CVSException {
-
- // read additional data for the response
- String repositoryFile = session.readLine();
-
- // Get the local file
- String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$
- ICVSFolder mParent = session.getLocalRoot().getFolder(localDir);
- ICVSFile mFile = mParent.getFile(fileName);
-
- if ( ! mFile.isManaged()) {
- IStatus status = new CVSStatus(IStatus.ERROR,CVSStatus.ERROR,NLS.bind(CVSMessages.RemovedHandler_invalid, new String[] { new Path(null, localDir).append(fileName).toString() }),session.getLocalRoot());
- throw new CVSException(status);
- }
-
- // delete then unmanage the file
- try {
- if (mFile.isReadOnly()) mFile.setReadOnly(false);
- mFile.delete();
- mFile.unmanage(null);
- } catch (CVSException e) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.RESPONSE_HANDLING_FAILURE, NLS.bind(CVSMessages.RemovedHandler_0, new String[] { getPath(mFile) }), e, session.getLocalRoot());
- session.handleResponseError(status);
- }
- }
-
- private String getPath(ICVSFile file) {
- IResource resource = file.getIResource();
- if (resource != null) {
- return resource.getFullPath().toString();
- }
- try {
- return file.getRepositoryRelativePath();
- } catch (CVSException e1) {
- return file.getName();
- }
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Replace.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Replace.java
deleted file mode 100644
index 04f039f20..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Replace.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Matt McCutchen <hashproduct+eclipse@gmail.com> - Bug 179174 CVS client sets timestamps back when replacing
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.util.Date;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-
-/**
- * A specialized update that will ignore unmanaged local content like
- * CheckoutWithOverwrite and avoid setting back the timestamps of files
- * recreated after being deleted by PrepareForReplaceVisitor.
- */
-public class Replace extends Update {
-
- private Set/*<ICVSFile>*/ prepDeletedFiles = null;
-
- public Replace() {}
- public Replace(Set/*<ICVSFile>*/ prepDeletedFiles) {
- this.prepDeletedFiles = prepDeletedFiles;
- }
-
- /**
- * This class overrides the "Created" handler but uses the "Updated"
- * behavior which will overwrite existing files.
- */
- public class CreatedResponseHandler extends UpdatedHandler {
- public CreatedResponseHandler() {
- super(UpdatedHandler.HANDLE_UPDATED);
- }
- public String getResponseID() {
- return "Created"; //$NON-NLS-1$
- }
- protected void receiveTargetFile(Session session, ICVSFile file, String entryLine, Date modTime,
- boolean binary, boolean readOnly, boolean executable, IProgressMonitor monitor) throws CVSException {
- // Discard any timestamp for files being recreated after being
- // deleted by PrepareForReplaceVisitor.
- if (prepDeletedFiles != null && prepDeletedFiles.contains(file))
- modTime = null;
- super.receiveTargetFile(session, file, entryLine, modTime, binary, readOnly, executable, monitor);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Command#doExecute(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[], org.eclipse.team.internal.ccvs.core.client.Command.LocalOption[], java.lang.String[], org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus doExecute(
- Session session,
- GlobalOption[] globalOptions,
- LocalOption[] localOptions,
- String[] arguments,
- ICommandOutputListener listener,
- IProgressMonitor monitor)
- throws CVSException {
-
- ResponseHandler newCreated = new CreatedResponseHandler();
- ResponseHandler oldCreated = session.getResponseHandler(newCreated.getResponseID());
- session.registerResponseHandler(newCreated);
- try {
- return super.doExecute(
- session,
- globalOptions,
- localOptions,
- arguments,
- listener,
- monitor);
- } finally {
- session.registerResponseHandler(oldCreated);
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java
deleted file mode 100644
index 9278f4b71..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-
-/**
- * Abstract base class for requests that are to be sent to the server.
- */
-public abstract class Request {
- public static final ExpandModules EXPAND_MODULES = new ExpandModules();
- public static final ValidRequests VALID_REQUESTS = new ValidRequests();
-
- /*** Response handler map ***/
- private static final Map responseHandlers = new HashMap();
-
- private static void initializeHandlerCache() {
- synchronized(responseHandlers) {
- registerResponseHandler(new CheckedInHandler());
- registerResponseHandler(new CopyHandler());
- registerResponseHandler(new ModTimeHandler());
- registerResponseHandler(new NewEntryHandler());
- registerResponseHandler(new RemovedHandler());
- registerResponseHandler(new RemoveEntryHandler());
- registerResponseHandler(new StaticHandler(true));
- registerResponseHandler(new StaticHandler(false));
- registerResponseHandler(new StickyHandler(true));
- registerResponseHandler(new StickyHandler(false));
- registerResponseHandler(new UpdatedHandler(UpdatedHandler.HANDLE_UPDATED));
- registerResponseHandler(new UpdatedHandler(UpdatedHandler.HANDLE_UPDATE_EXISTING));
- registerResponseHandler(new UpdatedHandler(UpdatedHandler.HANDLE_CREATED));
- registerResponseHandler(new UpdatedHandler(UpdatedHandler.HANDLE_MERGED));
- registerResponseHandler(new ValidRequestsHandler());
- registerResponseHandler(new ModuleExpansionHandler());
- registerResponseHandler(new MTHandler());
- registerResponseHandler(new NotifiedHandler());
- registerResponseHandler(new TemplateHandler());
- }
- }
- private static void registerResponseHandler(ResponseHandler handler) {
- synchronized(responseHandlers) {
- responseHandlers.put(handler.getResponseID(), handler);
- }
- }
-
- /**
- * This method is invoked by Session to get a mutable copy of the
- * global list of acceptable response handlers.
- *
- * @return a map of reponse handlers
- */
- protected static Map getReponseHandlerMap() {
- synchronized(responseHandlers) {
- if (responseHandlers.isEmpty()) {
- initializeHandlerCache();
- }
- Map copy = new HashMap();
- for (Iterator iter = responseHandlers.values().iterator(); iter.hasNext();) {
- ResponseHandler handler = (ResponseHandler) iter.next();
- copy.put(handler.getResponseID(), handler.getInstance());
-
- }
- return copy;
- }
- }
- /**
- * Prevents client code from instantiating us.
- */
- protected Request() { }
-
- /**
- * Returns the string used to invoke this request on the server.
- * [template method]
- *
- * @return the request identifier string
- */
- protected abstract String getRequestId();
-
- /**
- * Executes a request and processes the responses.
- *
- * @param session the open CVS session
- * @param listener the command output listener, or null to discard all messages
- * @param monitor the progress monitor
- * @return a status code indicating success or failure of the operation
- */
- protected IStatus executeRequest(Session session, ICommandOutputListener listener,
- IProgressMonitor monitor) throws CVSException {
- // send request
- session.sendRequest(getRequestId());
-
- // This number can be tweaked if the monitor is judged to move too
- // quickly or too slowly. After some experimentation this is a good
- // number for both large projects (it doesn't move so quickly as to
- // give a false sense of speed) and smaller projects (it actually does
- // move some rather than remaining still and then jumping to 100).
- final int TOTAL_WORK = 300;
- monitor.beginTask(CVSMessages.Command_receivingResponses, TOTAL_WORK);
- monitor.subTask(CVSMessages.Command_receivingResponses);
- int halfWay = TOTAL_WORK / 2;
- int currentIncrement = 4;
- int nextProgress = currentIncrement;
- int worked = 0;
-
- // If the session is connected to a CVSNT server (1.11.1.1), we'll need to do some special handling for
- // some errors. Unfortunately, CVSNT 1.11.1.1 will drop the connection after so some functionality is
- // still effected
- boolean isCVSNT = session.isCVSNT();
-
- session.clearErrors();
- for (;;) {
- // update monitor work amount
- if (--nextProgress <= 0) {
- monitor.worked(1);
- worked++;
- if (worked >= halfWay) {
- // we have passed the current halfway point, so double the
- // increment and reset the halfway point.
- currentIncrement *= 2;
- halfWay += (TOTAL_WORK - halfWay) / 2;
- }
- // reset the progress counter to another full increment
- nextProgress = currentIncrement;
- }
- Policy.checkCanceled(monitor);
-
- // retrieve a response line
- String response = session.readLine();
- int spacePos = response.indexOf(' ');
- String argument;
- if (spacePos != -1) {
- argument = response.substring(spacePos + 1);
- response = response.substring(0, spacePos);
- } else argument = ""; //$NON-NLS-1$
-
- // handle completion responses
- if (response.equals("ok")) { //$NON-NLS-1$
- break;
- } else if (response.equals("error") || (isCVSNT && response.equals(""))) { //$NON-NLS-1$ //$NON-NLS-2$
- argument = argument.trim();
- boolean serious = false;
- if (argument.length() == 0) {
- argument = getServerErrorMessage();
- } else {
- argument = NLS.bind(CVSMessages.Command_seriousServerError, new String[] { argument });
- if (!session.hasErrors()) {
- session.addError(new CVSStatus(IStatus.ERROR, CVSStatus.SERVER_ERROR, argument,session.getLocalRoot()));
- }
- serious = true;
- }
-
- if (!session.hasErrors()) {
- session.addError(new CVSStatus(IStatus.ERROR, CVSStatus.SERVER_ERROR, CVSMessages.Command_noMoreInfoAvailable,session.getLocalRoot()));
- }
- IStatus status = new MultiStatus(CVSProviderPlugin.ID, CVSStatus.SERVER_ERROR,
- session.getErrors(),
- argument, null);
- if (serious) {
- throw new CVSServerException(status);
- } else {
- // look for particularly bad errors in the accumulated statii
- IStatus[] errors = session.getErrors();
- for (int i = 0; i < errors.length; i++) {
- IStatus s = errors[i];
- if (s.getCode() == CVSStatus.PROTOCOL_ERROR) {
- throw new CVSServerException(status);
- }
- }
- }
- return status;
- // handle message responses
- } else if (response.equals("MT")) { //$NON-NLS-1$
- // Handle the MT response
- MTHandler handler = (MTHandler) session.getResponseHandler(response);
- if (handler != null) {
- handler.handle(session, argument, monitor);
- } else {
- throw new CVSException(new org.eclipse.core.runtime.Status(IStatus.ERROR,
- CVSProviderPlugin.ID, TeamException.IO_FAILED,
- NLS.bind(CVSMessages.Command_unsupportedResponse, new String[] { response, argument }), null));
- }
- // If a line is available, pass it on to the message listener
- // and console as if it were an M response
- if (handler.isLineAvailable()) {
- String line = handler.getLine();
- IStatus status = listener.messageLine(line, session.getCVSRepositoryLocation(), session.getLocalRoot(), monitor);
- session.addError(status); // The session ignores OK status
- ConsoleListeners.getInstance().messageLineReceived(session, line, status);
-
- }
- } else if (response.equals("M")) { //$NON-NLS-1$
- IStatus status = listener.messageLine(argument, session.getCVSRepositoryLocation(), session.getLocalRoot(), monitor);
- session.addError(status); // The session ignores OK status
- ConsoleListeners.getInstance().messageLineReceived(session, argument, status);
- } else if (response.equals("E")) { //$NON-NLS-1$
- IStatus status = listener.errorLine(argument, session.getCVSRepositoryLocation(), session.getLocalRoot(), monitor);
- session.addError(status); // The session ignores OK status
- ConsoleListeners.getInstance().errorLineReceived(session, argument, status);
- // handle other responses
- } else {
- ResponseHandler handler = session.getResponseHandler(response);
- if (handler != null) {
- handler.handle(session, argument, monitor);
- } else {
- throw new CVSException(new org.eclipse.core.runtime.Status(IStatus.ERROR,
- CVSProviderPlugin.ID, TeamException.IO_FAILED,
- NLS.bind(CVSMessages.Command_unsupportedResponse, new String[] { response, argument }), null));
- }
- }
- }
- if (!session.hasErrors()) {
- return ICommandOutputListener.OK;
- } else {
- return new MultiStatus(CVSProviderPlugin.ID, IStatus.INFO,
- session.getErrors(),
- NLS.bind(CVSMessages.Command_warnings, new String[] { getDisplayText() }), null); //
- }
- }
-
- /*
- * Provide the message that is used for the status that is generated when the server
- * reports as error.
- */
- protected String getServerErrorMessage() {
- return NLS.bind(CVSMessages.Command_serverError, new String[] { getDisplayText() }); //
- }
- protected String getDisplayText() {
- return getRequestId();
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java
deleted file mode 100644
index 176d29036..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * Handles server responses that arise as a result of issuing a request
- * (usually a command) to a CVS server. The processing of each such
- * response is deferred to subclasses.
- */
-public abstract class ResponseHandler {
- /**
- * Returns the text string of the server response handled by this object.
- * @return the id
- */
- public abstract String getResponseID();
-
- /**
- * Handles a server response.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Clear-sticky myDirectory \n
- * /u/cvsroot/myDirectory \n
- * [...]
- * </pre>
- * Then the <code>handle</code> method of the <code>ResponseHandler</code>
- * for <em>Clear-sticky</em> will be invoked with <code>argument</code>
- * set to <em>"myDirectory"</em>. It must then read the remaining
- * response data from the connection (<em>"/u/cvsroot/myDirectory"</em>
- * including the newline) and take any necessary action.
- * </p><p>
- * Note: The type and quantity of additional data that must be read
- * from the connection varies on a per-response basis.
- * </p>
- * @param session the Session used for CVS communication
- * @param argument the argument supplied with the response
- * @param monitor the progress monitor for the current CVS command
- */
- public abstract void handle(Session session, String argument,
- IProgressMonitor monitor) throws CVSException;
-
- /**
- * Creates a new CVS folder.
- * @param localDir the local path of the folder relative to root
- * @param repositoryDir the remote path of the folder relative to the repository
- * @return the new folder
- */
- protected static ICVSFolder createFolder(
- Session session,
- String localDir,
- String repositoryDir) throws CVSException {
-
- ICVSFolder folder = session.getLocalRoot().getFolder(localDir);
- if (!folder.exists()
- && (!CVSProviderPlugin.getPlugin().getPruneEmptyDirectories()
- || !folder.getParent().isCVSFolder())) {
- // Only create the folder if pruning is disabled or the
- // folder's parent is not a CVS folder (which occurs on checkout).
- // When pruning is enabled, the folder will be lazily created
- // when it contains a file (see getExistingFolder)
- folder.mkdir();
- }
- if (! folder.isCVSFolder()) {
- String repositoryRoot = session.getRepositoryRoot();
- String relativePath;
- if (repositoryDir.startsWith(repositoryRoot)) {
- // The repositoryDir is an absolute path
- relativePath = Util.getRelativePath(repositoryRoot, repositoryDir);
- } else {
- // The repositoryDir is already a relative path
- relativePath = repositoryDir;
- }
- IResource resource = folder.getIResource();
- if (resource != null) {
- IProject project = resource.getProject();
- if (project != null && project.isAccessible() && !CVSTeamProvider.isSharedWithCVS(project)) {
- // The project isn't shared but we are about to perform an operation on it.
- // we need to flag the project as shared so that the sync info management works
- CVSTeamProvider.markAsTempShare(project);
- }
- }
- try{
- folder.setFolderSyncInfo(new FolderSyncInfo(
- relativePath,
- session.getCVSRepositoryLocation().getLocation(false),
- null, false));
- } catch (CVSException ex){
- IStatus status = ex.getStatus();
- if (status != null){
- if (status.getCode() == IResourceStatus.INVALID_VALUE){
- //if it's an invalid value, just ignore the exception (see Bug# 152053),
- //else throw it again
- } else {
- throw ex;
- }
- }
- }
- }
- return folder;
- }
-
- protected ICVSFolder getExistingFolder(Session session, String localDir) throws CVSException {
- ICVSFolder mParent = session.getLocalRoot().getFolder(localDir);
- if (! mParent.exists()) {
- // First, check if the parent is a phantom
- IContainer container = (IContainer)mParent.getIResource();
- if (container != null) {
- try {
- // Create all the parents as need
- recreatePhantomFolders(mParent);
- } catch (CVSException e) {
- if (!handleInvalidResourceName(session, mParent, e)) {
- throw e;
- }
- }
- }
- }
- return mParent;
- }
-
- /**
- * Method recreatePhantomFolders.
- * @param mParent
- */
- private void recreatePhantomFolders(ICVSFolder folder) throws CVSException {
- ICVSFolder parent = folder.getParent();
- if (!parent.exists()) {
- recreatePhantomFolders(parent);
- }
- folder.mkdir();
- }
-
- /**
- * Return as instance that can be used by an open session. Subclasses that contain
- * session related state must override this message to return a copy of themselves.
- */
- /* package */ ResponseHandler getInstance() {
- return this;
- }
-
- protected boolean handleInvalidResourceName(Session session, ICVSResource resource, CVSException e) {
- int code = e.getStatus().getCode();
- if (code == IResourceStatus.INVALID_VALUE
- || code == IResourceStatus.INVALID_RESOURCE_NAME
- || code == IResourceStatus.RESOURCE_NOT_FOUND
- || code == IResourceStatus.RESOURCE_EXISTS
- || code == IResourceStatus.RESOURCE_WRONG_TYPE
- || code == IResourceStatus.CASE_VARIANT_EXISTS
- || code == IResourceStatus.PATH_OCCUPIED) {
-
- try {
- IResource local = resource.getIResource();
- String path;
- if (local == null) {
- path = resource.getRepositoryRelativePath();
- } else {
- path = local.getFullPath().toString();
- }
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.INVALID_LOCAL_RESOURCE_PATH, NLS.bind(CVSMessages.ResponseHandler_0, new String[] { path, e.getMessage() }), e, session.getLocalRoot());
- session.handleResponseError(status);
- } catch (CVSException e1) {
- CVSProviderPlugin.log(e1);
- }
- return true;
- }
- return false;
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
deleted file mode 100644
index 96996950f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
+++ /dev/null
@@ -1,1038 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Red Hat Incorporated - is/setExecutable() code
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
-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.Connection;
-import org.eclipse.team.internal.ccvs.core.syncinfo.NotifyInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-import org.eclipse.team.internal.core.streams.*;
-
-/**
- * Maintains CVS communication state for the lifetime of a connection
- * to a remote repository. This class covers the initialization, use,
- * and eventual shutdown of a dialogue between a CVS client and a
- * remote server. This dialogue may be monitored through the use of
- * a console.
- *
- * Initially the Session is in a CLOSED state during which communication
- * with the server cannot take place. Once OPENED, any number of commands
- * may be issued serially to the server, one at a time. When finished, the
- * Session MUST be CLOSED once again to prevent eventual local and/or
- * remote resource exhaustion. The session can either be discarded, or
- * re-opened for use with the same server though no state is persisted from
- * previous connections except for console attributes.
- *
- * CVSExceptions are thrown only as a result of unrecoverable errors. Once
- * this happens, commands must no longer be issued to the server. If the
- * Session is in the OPEN state, it is still the responsibility of the
- * caller to CLOSE it before moving on.
- */
-public class Session {
- public static final String CURRENT_LOCAL_FOLDER = "."; //$NON-NLS-1$
- public static final String CURRENT_REMOTE_FOLDER = ""; //$NON-NLS-1$
- public static final String SERVER_SEPARATOR = "/"; //$NON-NLS-1$
-
- // default file transfer buffer size (in bytes)
- private static final int TRANSFER_BUFFER_SIZE = 8192;
- // update progress bar in increments of this size (in bytes)
- // no incremental progress shown for files smaller than this size
- private static final int TRANSFER_PROGRESS_INCREMENT = 32768;
-
- public static final boolean IS_CRLF_PLATFORM = Arrays.equals(
- System.getProperty("line.separator").getBytes(), new byte[] { '\r', '\n' }); //$NON-NLS-1$
-
- private CVSRepositoryLocation location;
- private ICVSFolder localRoot;
- private boolean outputToConsole;
- private Connection connection = null;
- private String validRequests = null;
- private Date modTime = null;
- private boolean noLocalChanges = false;
- private boolean createBackups = true;
- private int compressionLevel = 0;
- private List expansions;
- private Collection /* of ICVSFile */ textTransferOverrideSet = null;
-
- // state need to indicate whether
- private boolean ignoringLocalChanges = false;
-
- // The resource bundle key that provides the file sending message
- private String sendFileTitleMessage;
- private Map responseHandlers;
-
- // List of errors accumulated while the command is executing
- private List errors = new ArrayList();
-
- private Command currentCommand;
-
- /**
- * Creates a new CVS session, initially in the CLOSED state.
- * By default, command output is directed to the console.
- *
- * @param location the CVS repository location used for this session
- * @param localRoot represents the current working directory of the client
- */
- public Session(ICVSRepositoryLocation location, ICVSFolder localRoot) {
- this(location, localRoot, true);
- }
-
- /**
- * Creates a new CVS session, initially in the CLOSED state.
- *
- * @param location the CVS repository location used for this session
- * @param localRoot represents the current working directory of the client
- * @param outputToConsole if true, command output is directed to the console
- */
- public Session(ICVSRepositoryLocation location, ICVSFolder localRoot, boolean outputToConsole) {
- this.location = (CVSRepositoryLocation) location;
- this.localRoot = localRoot;
- this.outputToConsole = outputToConsole;
- }
-
- /*
- * Add a module expansion receivered from the server.
- * This is only used by the ModuleExpansionsHandler
- */
- protected void addModuleExpansion(String expansion) {
- expansions.add(expansion);
- }
-
- /*
- * Add a module expansion receivered from the server.
- * This is only used by the ExpandModules command
- */
- protected void resetModuleExpansion() {
- if (expansions == null)
- expansions = new ArrayList();
- else
- expansions.clear();
- }
-
- /**
- * Opens, authenticates and initializes a connection to the server specified
- * for the remote location.
- *
- * @param monitor the progress monitor
- * @throws IllegalStateException if the Session is not in the CLOSED state
- */
- public void open(IProgressMonitor monitor) throws CVSException {
- open(monitor, true /* write access*/);
- }
-
- public void open(IProgressMonitor monitor, boolean writeAccess) throws CVSException {
- if (connection != null) throw new IllegalStateException();
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- boolean opened = false;
-
- try {
- connection = getLocationForConnection(writeAccess).openConnection(Policy.subMonitorFor(monitor, 50));
-
- // If we're connected to a CVSNT server or we don't know the platform,
- // accept MT. Otherwise don't.
- boolean useMT = ! (location.getServerPlatform() == CVSRepositoryLocation.CVS_SERVER);
- if ( ! useMT) {
- removeResponseHandler("MT"); //$NON-NLS-1$
- }
-
- // tell the server the names of the responses we can handle
- connection.writeLine("Valid-responses " + makeResponseList()); //$NON-NLS-1$
- // Flush in order to recieve the valid requests
- connection.flush();
-
- // ask for the set of valid requests
- IStatus status = Request.VALID_REQUESTS.execute(this, Policy.subMonitorFor(monitor, 40));
- if (!status.isOK()) {
- throw new CVSException(status);
- }
-
- // set the root directory on the server for this connection
- connection.writeLine("Root " + getRepositoryRoot()); //$NON-NLS-1$
-
- // enable compression
- compressionLevel = CVSProviderPlugin.getPlugin().getCompressionLevel();
- if (compressionLevel != 0 && isValidRequest("gzip-file-contents")) { //$NON-NLS-1$
- // Enable the use of CVS 1.8 per-file compression mechanism.
- // The newer Gzip-stream request seems to be problematic due to Java's
- // GZIPInputStream tendency to block on read() rather than to return a
- // partially filled buffer. The latter option would be better since it
- // can make more effective use of the code dictionary, if it can be made
- // to work...
- connection.writeLine("gzip-file-contents " + Integer.toString(compressionLevel)); //$NON-NLS-1$
- } else {
- compressionLevel = 0;
- }
-
- // get the server platform if it is unknown
- if (CVSProviderPlugin.getPlugin().isDetermineVersionEnabled() && location.getServerPlatform() == CVSRepositoryLocation.UNDETERMINED_PLATFORM) {
- Command.VERSION.execute(this, location, Policy.subMonitorFor(monitor, 10));
- }
- opened = true;
- } finally {
- if (connection != null && ! opened) {
- close();
- }
- monitor.done();
- }
- }
-
- /*
- * Return the location to be used for this connection
- */
- private CVSRepositoryLocation getLocationForConnection(boolean writeAccess) {
- return location;
- }
-
- /**
- * Closes a connection to the server.
- *
- * @throws IllegalStateException if the Session is not in the OPEN state
- */
- public void close() {
- if (connection != null) {
- connection.close();
- connection = null;
- validRequests = null;
- }
- }
-
- /**
- * Determines if the server supports the specified request.
- *
- * @param request the request string to verify
- * @return true iff the request is supported
- */
- public boolean isValidRequest(String request) {
- return (validRequests == null) ||
- (validRequests.indexOf(" " + request + " ") != -1); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public boolean isCVSNT() {
- if (location.getServerPlatform() == CVSRepositoryLocation.UNDETERMINED_PLATFORM) {
- return location.getRootDirectory().indexOf(':') == 1;
- } else {
- return location.getServerPlatform() == CVSRepositoryLocation.CVSNT_SERVER;
- }
- }
-
- /**
- * Returns the local root folder for this session.
- * <p>
- * Generally speaking, specifies the "current working directory" at
- * the time of invocation of an equivalent CVS command-line client.
- * </p>
- *
- * @return the local root folder
- */
- public ICVSFolder getLocalRoot() {
- return localRoot;
- }
-
- /**
- * Return the list of module expansions communicated from the server.
- *
- * The modules expansions are typically a directory path of length 1
- * but can be of greater length on occasion.
- */
- public String[] getModuleExpansions() {
- if (expansions == null) return new String[0];
- return (String[]) expansions.toArray(new String[expansions.size()]);
- }
-
- /**
- * Returns the repository root folder for this session.
- * <p>
- * Specifies the unqualified path to the CVS repository root folder
- * on the server.
- * </p>
- *
- * @return the repository root folder
- */
- public String getRepositoryRoot() {
- return location.getRootDirectory();
- }
-
- /**
- * Returns an object representing the CVS repository location for this session.
- *
- * @return the CVS repository location
- */
- public ICVSRepositoryLocation getCVSRepositoryLocation() {
- return location;
- }
-
- /**
- * Receives a line of text minus the newline from the server.
- *
- * @return the line of text
- */
- public String readLine() throws CVSException {
- return connection.readLine();
- }
-
- /**
- * Sends a line of text followed by a newline to the server.
- *
- * @param line the line of text
- */
- public void writeLine(String line) throws CVSException {
- connection.writeLine(line);
- }
-
- /**
- * Sends an argument to the server.
- * <p>e.g. sendArgument("Hello\nWorld\n Hello World") sends:
- * <pre>
- * Argument Hello \n
- * Argumentx World \n
- * Argumentx Hello World \n
- * </pre></p>
- *
- * @param arg the argument to send
- */
- public void sendArgument(String arg) throws CVSException {
- connection.write("Argument "); //$NON-NLS-1$
- int oldPos = 0;
- for (;;) {
- int pos = arg.indexOf('\n', oldPos);
- if (pos == -1) break;
- connection.writeLine(stripTrainingCR(arg.substring(oldPos, pos)));
- connection.write("Argumentx "); //$NON-NLS-1$
- oldPos = pos + 1;
- }
- connection.writeLine(stripTrainingCR(arg.substring(oldPos)));
- }
-
- /*
- * Remove any trailing CR from the string
- */
- private String stripTrainingCR(String string) {
- if (string.endsWith("\r")) { //$NON-NLS-1$
- return string.substring(0, string.length() - 1);
- }
- return string;
- }
-
- /**
- * Sends a request to the server and flushes any output buffers.
- *
- * @param requestId the string associated with the request to be executed
- */
- public void sendRequest(String requestId) throws CVSException {
- connection.writeLine(requestId);
- connection.flush();
- }
-
- /**
- * Sends an Is-modified request to the server without the file contents.
- * <p>e.g. if a file called "local_file" was modified, sends:
- * <pre>
- * Is-modified local_file \n
- * </pre></p><p>
- * This request is an optimized form of the Modified request and may not
- * be supported by all servers. Hence, if it is not supported, a Modified
- * request is sent instead along with the file's contents. According to
- * the CVS protocol specification, this request is only safe for use with
- * some forms of: admin, annotate, diff, editors, log, watch-add, watch-off,
- * watch-on, watch-remove, and watchers.<br>
- * It may be possible to use this for: add, export, remove and status.<br>
- * Do not use with co, ci, history, init, import, release, rdiff, rtag, or update.
- * </p><p>
- * Note: The most recent Directory request must have specified the file's
- * parent folder.
- * </p>
- *
- * @param file the file that was modified
- * @see #sendModified
- */
- public void sendIsModified(ICVSFile file, boolean isBinary, IProgressMonitor monitor)
- throws CVSException {
- if (isValidRequest("Is-modified")) { //$NON-NLS-1$
- connection.writeLine("Is-modified " + file.getName()); //$NON-NLS-1$
- } else {
- sendModified(file, isBinary, monitor);
- }
- }
-
- /**
- * Sends a Static-directory request to the server.
- * <p>
- * Indicates that the directory specified in the most recent Directory request
- * is static. No new files will be checked out into this directory unless
- * explicitly requested.
- * </p>
- */
- public void sendStaticDirectory() throws CVSException {
- connection.writeLine("Static-directory"); //$NON-NLS-1$
- }
-
- /**
- * Sends a Directory request to the server with a constructed path.
- * <p>
- * It may be necessary at times to guess the remote path of a directory since
- * it does not exist yet. In this case we construct a remote path based on the
- * local path by prepending the local path with the repository root. This may
- * not work in the presence of modules, so only use it for creating new projects.
- * </p><p>
- * Note: A CVS repository root can end with a trailing slash. The CVS server
- * expects that the repository root sent contain this extra slash. Including
- * the foward slash in addition to the absolute remote path makes for a string
- * containing two consecutive slashes (e.g. /home/cvs/repo//projecta/a.txt).
- * This is valid in the CVS protocol.
- * </p>
- */
- public void sendConstructedDirectory(String localDir) throws CVSException {
- String path = Util.appendPath(getRepositoryRoot(), localDir);
- sendDirectory(localDir, path);
- }
-
- /**
- * Sends a Directory request to the server.
- * <p>e.g. sendDirectory("local_dir", "remote_dir") sends:
- * <pre>
- * Directory local_dir
- * repository_root/remote_dir
- * </pre></p>
- *
- * @param localDir the path of the local directory relative to localRoot
- * @param remoteDir the path of the remote directory relative to repositoryRoot
- */
- public void sendDirectory(String localDir, String remoteDir) throws CVSException {
- if (localDir.length() == 0) localDir = CURRENT_LOCAL_FOLDER;
- connection.writeLine("Directory " + localDir); //$NON-NLS-1$
- connection.writeLine(remoteDir);
- }
-
- /**
- * Sends a Directory request for the localRoot.
- */
- public void sendLocalRootDirectory() throws CVSException {
- sendDirectory(CURRENT_LOCAL_FOLDER, localRoot.getRemoteLocation(localRoot));
- }
-
- /**
- * Sends a Directory request for the localRoot with a constructed path.
- * <p>
- * Use this when creating a new project that does not exist in the repository.
- * </p>
- * @see #sendConstructedDirectory
- */
- public void sendConstructedRootDirectory() throws CVSException {
- sendConstructedDirectory(""); //$NON-NLS-1$
- }
-
- /**
- * Sends an Entry request to the server.
- * <p>
- * Indicates that a file is managed (but it may not exist locally). Sends
- * the file's entry line to the server to indicate the version that was
- * previously checked out.
- * </p><p>
- * Note: The most recent Directory request must have specified the file's
- * parent folder.
- * </p>
- *
- * @param entryLine the formatted entry line of the managed file.
- */
- public void sendEntry(byte[] syncBytes, String serverTimestamp) throws CVSException {
- connection.write("Entry "); //$NON-NLS-1$
- if (serverTimestamp == null) {
- serverTimestamp = ""; //$NON-NLS-1$
- }
- int start = Util.getOffsetOfDelimeter(syncBytes, (byte)'/', 0, 3);
- if (start == -1) {
- // something is wrong with the entry line so just send it as is
- // and let the server report the error.
- connection.writeLine(new String(syncBytes));
- return;
- }
- int end = Util.getOffsetOfDelimeter(syncBytes, (byte)'/', start + 1, 1);
- if (end == -1) {
- // something is wrong with the entry line so just send it as is
- // and let the server report the error.
- connection.writeLine(new String(syncBytes));
- return;
- }
- connection.write(new String(syncBytes, 0, start + 1));
- connection.write(serverTimestamp);
- connection.writeLine(new String(syncBytes, end, syncBytes.length - end));
- }
-
- /**
- * Sends a global options to the server.
- * <p>e.g. sendGlobalOption("-n") sends:
- * <pre>
- * Global_option -n \n
- * </pre></p>
- *
- * @param option the global option to send
- */
- public void sendGlobalOption(String option) throws CVSException {
- connection.writeLine("Global_option " + option); //$NON-NLS-1$
- }
-
- /**
- * Sends an Unchanged request to the server.
- * <p>e.g. if a file called "local_file" was not modified, sends:
- * <pre>
- * Unchanged local_file \n
- * </pre></p><p>
- * Note: The most recent Directory request must have specified the file's
- * parent folder.
- * </p>
- *
- * @param file the file that was not modified
- */
- public void sendUnchanged(ICVSFile file) throws CVSException {
- connection.writeLine("Unchanged " + file.getName()); //$NON-NLS-1$
- }
-
- /**
- * Sends the Notify request to the server
- */
- public void sendNotify(ICVSFolder parent, NotifyInfo info)
- throws CVSException {
-
- String filename = info.getName();
- connection.writeLine("Notify " + filename); //$NON-NLS-1$
- connection.writeLine(info.getServerLine(parent));
- }
-
- /**
- * Sends a Questionable request to the server.
- * <p>
- * Indicates that a file exists locally but is unmanaged. Asks the server
- * whether or not the file should be ignored in subsequent CVS operations.
- * The reply to the request occurs in the form of special M-type message
- * responses prefixed with '?' when the next command is executed.
- * </p><p>
- * Note: The most recent Directory request must have specified the file's
- * parent folder.
- * </p>
- *
- * @param resource the local file or folder
- */
- public void sendQuestionable(ICVSResource resource) throws CVSException {
- connection.writeLine("Questionable " + resource.getName()); //$NON-NLS-1$
- }
-
- /**
- * Sends a Sticky tag request to the server.
- * <p>
- * Indicates that the directory specified in the most recent Directory request
- * has a sticky tag or date, and sends the tag's contents.
- * </p>
- *
- * @param tag the sticky tag associated with the directory
- */
- public void sendSticky(String tag) throws CVSException {
- connection.writeLine("Sticky " + tag); //$NON-NLS-1$
- }
-
- /**
- * Sends a Modified request to the server along with the file contents.
- * <p>e.g. if a file called "local_file" was modified, sends:
- * <pre>
- * Modified local_file \n
- * file_permissions \n
- * file_size \n
- * [... file_contents ...]
- * </pre></p><p>
- * Under some circumstances, Is-modified may be used in place of this request.<br>
- * Do not use with history, init, import, rdiff, release, rtag, or update.
- * </p><p>
- * Note: The most recent Directory request must have specified the file's
- * parent folder.
- * </p>
- *
- * @param file the file that was modified
- * @param isBinary if true the file is sent without translating line delimiters
- * @param monitor the progress monitor
- * @see #sendIsModified
- */
- public void sendModified(ICVSFile file, boolean isBinary, IProgressMonitor monitor)
- throws CVSException {
- sendModified(file, isBinary, true, monitor);
- }
-
- public void sendModified(ICVSFile file, boolean isBinary, boolean sendBinary, IProgressMonitor monitor)
- throws CVSException {
-
- String filename = file.getName();
- connection.writeLine("Modified " + filename); //$NON-NLS-1$
- // send the default permissions for now
- if (file.isExecutable()) {
- connection.writeLine(ResourceSyncInfo.getDefaultExecutablePermissions());
- } else {
- connection.writeLine(ResourceSyncInfo.getDefaultPermissions());
- }
- sendFile(file, isBinary, sendBinary, monitor);
- }
-
- /**
- * Sends a file to the remote CVS server, possibly translating line delimiters.
- * <p>
- * Line termination sequences are automatically converted to linefeeds only
- * (required by the CVS specification) when sending non-binary files. This
- * may alter the actual size and contents of the file that is sent.
- * </p><p>
- * Note: Non-binary files must be small enough to fit in available memory.
- * </p>
- * @param file the file to be sent
- * @param isBinary is true if the file should be sent without translation
- * @param monitor the progress monitor
- */
- public void sendFile(ICVSStorage file, boolean isBinary, boolean sendBinary, IProgressMonitor monitor) throws CVSException {
- // check overrides
- if (textTransferOverrideSet != null &&
- textTransferOverrideSet.contains(file)) isBinary = false;
-
- // update progress monitor
- final String title = NLS.bind(getSendFileTitleMessage(), (new Object[]{ Util.toTruncatedPath(file, localRoot, 3) }));
- monitor.subTask(NLS.bind(CVSMessages.Session_transferNoSize, new String[] { title }));
- try {
- InputStream in = null;
- long length;
- try {
- if (isBinary && !sendBinary) {
- byte[] bytes = "hello".getBytes(); //$NON-NLS-1$
- sendUncompressedBytes(new ByteArrayInputStream(bytes), bytes.length);
- return;
- }
-
- if (compressionLevel == 0) {
- in = file.getContents();
- if (!isBinary && IS_CRLF_PLATFORM){
- // uncompressed text
- byte[] buffer = new byte[TRANSFER_BUFFER_SIZE];
- in = new CRLFtoLFInputStream(in);
- ByteCountOutputStream counter = new ByteCountOutputStream();
- try {
- for (int count; (count = in.read(buffer)) != -1;) counter.write(buffer, 0, count);
- } finally {
- counter.close();
- }
- in.close();
- length = counter.getSize();
- in = new CRLFtoLFInputStream(file.getContents());
- } else {
- // uncompressed binary
- length = file.getSize();
- }
- in = new ProgressMonitorInputStream(in, length, TRANSFER_PROGRESS_INCREMENT, monitor) {
- protected void updateMonitor(long bytesRead, long bytesTotal, IProgressMonitor monitor) {
- if (bytesRead == 0) return;
- Assert.isTrue(bytesRead <= bytesTotal);
- monitor.subTask(NLS.bind(CVSMessages.Session_transfer, (new Object[] { title, Long.toString(bytesRead >> 10), Long.toString(bytesTotal >> 10) })));
- }
- };
- sendUncompressedBytes(in, length);
- } else {
- monitor.subTask(NLS.bind(CVSMessages.Session_calculatingCompressedSize, new String[] { Util.toTruncatedPath(file, localRoot, 3) }));
- in = file.getContents();
- byte[] buffer = new byte[TRANSFER_BUFFER_SIZE];
- ByteCountOutputStream counter = new ByteCountOutputStream();
- OutputStream zout = new GZIPOutputStream(counter);
- if (!isBinary && IS_CRLF_PLATFORM) in = new CRLFtoLFInputStream(in);
- try {
- for (int count; (count = in.read(buffer)) != -1;) zout.write(buffer, 0, count);
- } finally {
- zout.close();
- }
- in.close();
- in = file.getContents();
- in = new ProgressMonitorInputStream(in, file.getSize(), TRANSFER_PROGRESS_INCREMENT, monitor) {
- protected void updateMonitor(long bytesRead, long bytesTotal, IProgressMonitor monitor) {
- if (bytesRead == 0) return;
- Assert.isTrue(bytesRead <= bytesTotal);
- monitor.subTask(NLS.bind(CVSMessages.Session_transfer, (new Object[] { title, Long.toString(bytesRead >> 10), Long.toString(bytesTotal >> 10) })));
- }
- };
- if (!isBinary && IS_CRLF_PLATFORM) in = new CRLFtoLFInputStream(in);
- sendCompressedBytes(in, counter.getSize());
- }
- } finally {
- if (in != null) in.close();
- }
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /*
- * Send the contents of the input stream to CVS.
- * Length must equal the number of bytes that will be transferred
- * across the wire, that is, the compressed file size.
- */
- private void sendCompressedBytes(InputStream in, long length) throws IOException, CVSException {
- String sizeLine = "z" + Long.toString(length); //$NON-NLS-1$
- writeLine(sizeLine);
- OutputStream out = connection.getOutputStream();
- GZIPOutputStream zo = new GZIPOutputStream(out);
- byte[] buffer = new byte[TRANSFER_BUFFER_SIZE];
- for (int count;
- (count = in.read(buffer)) != -1;)
- zo.write(buffer, 0, count);
- zo.finish();
- }
-
- /*
- * Send the contents of the input stream to CVS.
- * Length must equal the number of bytes that will be transferred
- * across the wire.
- */
- private void sendUncompressedBytes(InputStream in, long length) throws IOException, CVSException {
- OutputStream out = connection.getOutputStream();
- String sizeLine = Long.toString(length);
- writeLine(sizeLine);
- byte[] buffer = new byte[TRANSFER_BUFFER_SIZE];
- for (int count; (count = in.read(buffer)) != -1;) out.write(buffer, 0, count);
- }
-
-
-
-
- /**
- * Receives a file from the remote CVS server, possibly translating line delimiters.
- * <p>
- * Line termination sequences are automatically converted to platform format
- * only when receiving non-binary files. This may alter the actual size and
- * contents of the file that is received.
- * </p><p>
- * Translation is performed on-the-fly, so the file need not fit in available memory.
- * </p>
- * @param file the file to be received
- * @param isBinary is true if the file should be received without translation
- * @param responseType one of the ICVSFile updated types (UPDATED, CREATED, MERGED, UPDATE_EXISTING)
- * indicating what repsonse type provided the file contents
- * @param monitor the progress monitor
- */
- public void receiveFile(ICVSStorage file, boolean isBinary, int responseType, IProgressMonitor monitor)
- throws CVSException {
- // check overrides
- if (textTransferOverrideSet != null &&
- textTransferOverrideSet.contains(file)) isBinary = false;
-
- // update progress monitor
- final String title = NLS.bind(CVSMessages.Session_receiving, (new Object[]{ Util.toTruncatedPath(file, localRoot, 3) }));
- monitor.subTask(NLS.bind(CVSMessages.Session_transferNoSize, new String[] { title }));
- // get the file size from the server
- long size;
- boolean compressed = false;
- String sizeLine = null;
- try {
- sizeLine = readLine();
- if (sizeLine.charAt(0) == 'z') {
- compressed = true;
- sizeLine = sizeLine.substring(1);
- }
- size = Long.parseLong(sizeLine, 10);
- } catch (NumberFormatException e) {
- // In some cases, the server will give us an error line here
- if (sizeLine != null && sizeLine.startsWith("E")) { //$NON-NLS-1$
- handleErrorLine(sizeLine.substring(1).trim(), org.eclipse.core.runtime.Status.OK_STATUS);
- return;
- } else {
- IStatus status = new CVSStatus(IStatus.ERROR,CVSStatus.ERROR,CVSMessages.Session_badInt, e, localRoot);
- throw new CVSException(status);
- }
- }
- // create an input stream that spans the next 'size' bytes from the connection
- InputStream in = new SizeConstrainedInputStream(connection.getInputStream(), size, true /*discardOnClose*/);
- // setup progress monitoring
- in = new ProgressMonitorInputStream(in, size, TRANSFER_PROGRESS_INCREMENT, monitor) {
- protected void updateMonitor(long bytesRead, long bytesTotal, IProgressMonitor monitor) {
- if (bytesRead == 0) return;
- monitor.subTask(NLS.bind(CVSMessages.Session_transfer, (new Object[] { title, Long.toString(bytesRead >> 10), Long.toString(bytesTotal >> 10) })));
- }
- };
- // if compression enabled, decompress on the fly
- if (compressed) {
- try {
- in = new GZIPInputStream(in);
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- }
- // if not binary, translate line delimiters on the fly
- if (! isBinary) {
- // switch from LF to CRLF if appropriate
- if (IS_CRLF_PLATFORM && CVSProviderPlugin.getPlugin().isUsePlatformLineend()) {
- // auto-correct for CRLF line-ends that come from the server
- in = new CRLFtoLFInputStream(in);
- // convert LF to CRLF
- in = new LFtoCRLFInputStream(in);
- } else {
- // be nice and warn about text files that contain CRLF
- in = new CRLFDetectInputStream(in, file);
- }
- }
- // write the file locally
- file.setContents(in, responseType, true, new NullProgressMonitor());
- }
-
- /**
- * Stores the value of the last Mod-time response encountered.
- * Valid only for the duration of a single CVS command.
- */
- void setModTime(Date modTime) {
- this.modTime = modTime;
- }
-
- /**
- * Returns the stored value of the last Mod-time response,
- * or null if there was none while processing the current command.
- */
- Date getModTime() {
- return modTime;
- }
-
- /**
- * Stores true if the -n global option was specified for the current command.
- * Valid only for the duration of a single CVS command.
- */
- void setNoLocalChanges(boolean noLocalChanges) {
- this.noLocalChanges = noLocalChanges;
- }
-
- /**
- * Returns true if the -n global option was specified for the current command,
- * false otherwise.
- */
- boolean isNoLocalChanges() {
- return noLocalChanges;
- }
-
- /**
- * Callback hook for the ValidRequestsHandler to specify the set of valid
- * requests for this session.
- */
- void setValidRequests(String validRequests) {
- this.validRequests = " " + validRequests + " "; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public boolean isOutputToConsole() {
- return outputToConsole;
- }
-
- /**
- * Stores a flag as to whether .# files will be created. (Default is true)
- * @param createBackups if true, creates .# files at the server's request
- */
- void setCreateBackups(boolean createBackups) {
- this.createBackups = createBackups;
- }
-
- /**
- * Returns a flag as to whether .# files will be created.
- */
- boolean isCreateBackups() {
- return createBackups;
- }
-
- /**
- * Gets the sendFileTitleKey.
- * @return Returns a String
- */
- String getSendFileTitleMessage() {
- if (sendFileTitleMessage == null)
- return CVSMessages.Session_sending;
- return sendFileTitleMessage;
- }
-
- /**
- * Sets the sendFileTitleKey.
- * @param sendFileTitleKey The sendFileTitleKey to set
- */
- public void setSendFileTitleKey(String sendFileTitleMessage) {
- this.sendFileTitleMessage = sendFileTitleMessage;
- }
-
- /**
- * Remembers a set of files that must be transferred as 'text'
- * regardless of what the isBinary parameter to sendFile() is.
- *
- * @param textTransferOverrideSet the set of ICVSFiles to override, or null if none
- */
- public void setTextTransferOverride(Collection textTransferOverrideSet) {
- this.textTransferOverrideSet = textTransferOverrideSet;
- }
-
- /**
- * Filter the provided global options using parameters set on this session
- * or globally. The session may add global options that correspond to user
- * preferences or remove those that contradict requirements for this
- * particular session.
- *
- * @param globalOptions the global options, read-only
- * @return the filtered global options
- */
- protected GlobalOption[] filterGlobalOptions(GlobalOption[] globalOptions) {
- if (! Command.DO_NOT_CHANGE.isElementOf(globalOptions)) {
- // Get the user preference for verbosity
- QuietOption quietOption = CVSProviderPlugin.getPlugin().getQuietness();
- if (quietOption != null) {
- globalOptions = quietOption.addToEnd(globalOptions);
- }
- // Get the user preference for read-only
- if (isWatchEditEnabled()) {
- if (!Command.MAKE_READ_ONLY.isElementOf(globalOptions)) {
- globalOptions = Command.MAKE_READ_ONLY.addToEnd(globalOptions);
- }
- }
- }
- return globalOptions;
- }
-
- private boolean isWatchEditEnabled() {
- // First, look at the global preference
- if (CVSProviderPlugin.getPlugin().getPluginPreferences().getBoolean(CVSProviderPlugin.READ_ONLY)) {
- return true;
- }
- // If there is a provider, use the providers setting for watch/edit
- try {
- IResource resource = getLocalRoot().getIResource();
- if (resource != null && resource.getType() != IResource.ROOT) {
- RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId());
- if (provider != null) {
- return ((CVSTeamProvider) provider).isWatchEditEnabled();
- }
- }
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- return false;
- }
-
- /**
- * Method setIgnoringLocalChanges.
- * @param b
- */
- protected void setIgnoringLocalChanges(boolean b) {
- ignoringLocalChanges = b;
- }
- /**
- * Returns the ignoringLocalChanges.
- * @return boolean
- */
- protected boolean isIgnoringLocalChanges() {
- return ignoringLocalChanges;
- }
-
- /*
- * Get the response handler map to be used for this session. The map is created by making a copy of the global
- * reponse handler map.
- */
- protected Map getReponseHandlers() {
- if (responseHandlers == null) {
- responseHandlers = Request.getReponseHandlerMap();
- }
- return responseHandlers;
- }
-
- /*
- * Makes a list of all valid responses; for initializing a session.
- * @return a space-delimited list of all valid response strings
- */
- private String makeResponseList() {
- StringBuffer result = new StringBuffer("ok error M E"); //$NON-NLS-1$
- Iterator elements = getReponseHandlers().keySet().iterator();
- while (elements.hasNext()) {
- result.append(' ');
- result.append((String) elements.next());
- }
-
- return result.toString();
- }
- public void registerResponseHandler(ResponseHandler handler) {
- getReponseHandlers().put(handler.getResponseID(), handler);
- }
-
- public void removeResponseHandler(String responseID) {
- getReponseHandlers().remove(responseID);
- }
-
- public ResponseHandler getResponseHandler(String responseID) {
- return (ResponseHandler)getReponseHandlers().get(responseID);
- }
-
- /**
- * Accumulate the added errors so they can be included in the status returned
- * when the command execution is finished. OK status are ignored.
- * @param status the status to be accumulated
- */
- public void addError(IStatus status) {
- if (!status.isOK())
- errors.add(status);
- }
-
- public boolean hasErrors() {
- return !errors.isEmpty();
- }
-
- public IStatus[] getErrors() {
- return (IStatus[]) errors.toArray(new IStatus[errors.size()]);
- }
-
- public void clearErrors() {
- errors.clear();
- }
-
- public void setCurrentCommand(Command c) {
- currentCommand = c;
- }
-
- public Command getCurrentCommand() {
- return currentCommand;
- }
-
- /**
- * Report the given error line to any listeners
- * @param line the error line
- * @param status the status that indicates any problems encountered parsing the line
- */
- public void handleErrorLine(String line, IStatus status) {
- ConsoleListeners.getInstance().errorLineReceived(this, line, status);
- }
-
- /**
- * An error has occurred while processing responses from the
- * server. Place this error is the status that will be returned
- * from the command and show the error in the console
- * @param status the status that descibes the error
- */
- public void handleResponseError(IStatus status) {
- addError(status);
- handleErrorLine(NLS.bind(CVSMessages.Session_0, new String[] { status.getMessage() }), status);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java
deleted file mode 100644
index 7464d716d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StaticHandler.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableFolderSyncInfo;
-
-/**
- * Handles any "Set-static-directory" and "Clear-static-directory" responses
- * from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Set-static-directory myproject/ \n
- * /u/cvsroot/myproject/ \n
- * [...]
- * </pre>
- * Then we set or clear the static flag of the folder "myproject",
- * automatically creating it if it does not exist locally,
- * </p>
- */
-class StaticHandler extends ResponseHandler {
- private final boolean setStaticDirectory;
-
- public StaticHandler(boolean setStaticDirectory) {
- this.setStaticDirectory = setStaticDirectory;
- }
-
- public String getResponseID() {
- if (setStaticDirectory) {
- return "Set-static-directory"; //$NON-NLS-1$
- } else {
- return "Clear-static-directory"; //$NON-NLS-1$
- }
- }
-
- public void handle(Session session, String localDir,
- IProgressMonitor monitor) throws CVSException {
- // read additional data for the response
- String repositoryDir = session.readLine();
-
- // create the directory then set or clear the static flag
- Assert.isTrue(repositoryDir.endsWith("/")); //$NON-NLS-1$
- repositoryDir = repositoryDir.substring(0, repositoryDir.length() - 1);
- try {
- ICVSFolder folder = createFolder(session, localDir, repositoryDir);
- FolderSyncInfo syncInfo = folder.getFolderSyncInfo();
- // Added to ignore sync info for workspace root
- if (syncInfo == null) return;
- MutableFolderSyncInfo newInfo = syncInfo.cloneMutable();
- newInfo.setStatic(setStaticDirectory);
- // only set the sync info if it has changed
- if (!syncInfo.equals(newInfo))
- folder.setFolderSyncInfo(newInfo);
- } catch (CVSException e) {
- if (!handleInvalidResourceName(session, session.getLocalRoot().getFolder(localDir), e)) {
- throw e;
- }
- }
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Status.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Status.java
deleted file mode 100644
index 146ad41d0..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Status.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-public class Status extends AbstractMessageCommand {
- /*** Local options: specific to status ***/
-
- protected Status() { }
- protected String getRequestId() {
- return "status"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java
deleted file mode 100644
index 080b5ce50..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/StickyHandler.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.*;
-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.MutableFolderSyncInfo;
-
-/**
- * Handles any "Set-sticky" and "Clear-stick" responses from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Set-sticky myproject/ \n
- * /u/cvsroot/myproject/ \n
- * Tsometag \n
- * [...]
- * </pre>
- * Then we set or clear the sticky tag property of the folder "myproject",
- * automatically creating it if it does not exist locally,
- * </p>
- */
-class StickyHandler extends ResponseHandler {
- private final boolean setSticky;
-
- public StickyHandler(boolean setSticky) {
- this.setSticky = setSticky;
- }
-
- public String getResponseID() {
- if (setSticky) {
- return "Set-sticky"; //$NON-NLS-1$
- } else {
- return "Clear-sticky"; //$NON-NLS-1$
- }
- }
-
- public void handle(Session session, String localDir,
- IProgressMonitor monitor) throws CVSException {
- // read additional data for the response
- String repositoryDir = session.readLine();
- String tag = null;
- if (setSticky) {
- tag = session.readLine();
- if (tag != null && tag.length() == 0) tag = null;
- }
-
- // create the directory then set or clear the sticky tag
- Assert.isTrue(repositoryDir.endsWith("/")); //$NON-NLS-1$
- repositoryDir = repositoryDir.substring(0, repositoryDir.length() - 1);
- try {
- ICVSFolder folder = createFolder(session, localDir, repositoryDir);
- FolderSyncInfo syncInfo = folder.getFolderSyncInfo();
- // Added to ignore sync info for workspace root
- if (syncInfo == null) return;
- MutableFolderSyncInfo newInfo = syncInfo.cloneMutable();
- newInfo.setTag(tag != null ? new CVSEntryLineTag(tag) : null);
- /* if we are reverting to BASE we do not change anything here
- * see bug 106876 */
- if(tag != null && tag.equals("TBASE")) //$NON-NLS-1$
- newInfo.setTag(syncInfo.getTag());
- // only set the sync info if it has changed
- if (!syncInfo.equals(newInfo))
- folder.setFolderSyncInfo(newInfo);
- } catch (CVSException e) {
- if (!handleInvalidResourceName(session, session.getLocalRoot().getFolder(localDir), e)) {
- throw e;
- }
- }
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/SyncUpdate.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/SyncUpdate.java
deleted file mode 100644
index 62e15e50a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/SyncUpdate.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-
-public class SyncUpdate extends Update {
-
- public SyncUpdate() { };
-
- /*
- * @see Command#sendFileStructure(ICVSResource,IProgressMonitor,boolean,boolean,boolean)
- */
- protected void sendFileStructure(Session session, ICVSResource[] resources,
- LocalOption[] localOptions, boolean emptyFolders, IProgressMonitor monitor) throws CVSException {
-
- checkResourcesManaged(session, resources);
- new FileStructureVisitor(session, localOptions, emptyFolders, true, false).visit(session, resources, monitor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Command#isWorkspaceModification()
- */
- protected boolean isWorkspaceModification() {
- // The sync-update will not modify the workspace
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Command#filterGlobalOptions(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[])
- */
- protected GlobalOption[] filterGlobalOptions(Session session, GlobalOption[] globalOptions) {
- // Ensure that the DO_NOT_CHANGE (-n) global option is present
- if (! Command.DO_NOT_CHANGE.isElementOf(globalOptions)) {
- globalOptions = Command.DO_NOT_CHANGE.addToEnd(globalOptions);
- }
- return super.filterGlobalOptions(session, globalOptions);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java
deleted file mode 100644
index 3cb2e9978..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.TagListener;
-
-public class Tag extends Command {
- /*** Local options: specific to tag ***/
- public static final LocalOption CREATE_BRANCH = new LocalOption("-b", null); //$NON-NLS-1$
- public static final LocalOption FORCE_REASSIGNMENT = new LocalOption("-F", null); //$NON-NLS-1$
-
- /*** Default command output listener ***/
- private static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new TagListener();
-
- // handle added and removed resources in a special way
- private boolean customBehaviorEnabled;
-
- protected Tag(boolean customBehaviorEnabled) {
- this.customBehaviorEnabled = customBehaviorEnabled;
- }
-
- protected Tag() {
- this(false);
- }
-
- protected String getRequestId() {
- return "tag"; //$NON-NLS-1$
- }
-
- protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions,
- String[] arguments) throws CVSException {
-
- if (arguments.length < 1) throw new IllegalArgumentException();
- String[] allButFirst = new String[arguments.length - 1];
- System.arraycopy(arguments, 1, allButFirst, 0, arguments.length - 1);
- return super.computeWorkResources(session, localOptions, allButFirst);
- }
-
- public IStatus execute(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, CVSTag tag, String[] arguments, ICommandOutputListener listener,
- IProgressMonitor monitor) throws CVSException {
-
- if(tag.getType() != CVSTag.VERSION && tag.getType() != CVSTag.BRANCH) {
- throw new CVSException(new CVSStatus(IStatus.ERROR, CVSMessages.Tag_notVersionOrBranchError));
- }
-
- // Add the CREATE_BRANCH option for a branch tag
- if (tag.getType() == CVSTag.BRANCH) {
- if ( ! CREATE_BRANCH.isElementOf(localOptions)) {
- LocalOption[] newLocalOptions = new LocalOption[localOptions.length + 1];
- System.arraycopy(localOptions, 0, newLocalOptions, 0, localOptions.length);
- newLocalOptions[newLocalOptions.length - 1] = CREATE_BRANCH;
- localOptions = newLocalOptions;
- }
- }
-
- // Add the tag name to the start of the arguments
- String[] newArguments = new String[arguments.length + 1];
- newArguments[0] = tag.getName();
- System.arraycopy(arguments, 0, newArguments, 1, arguments.length);
-
- return execute(session, globalOptions, localOptions, newArguments, listener, monitor);
- }
-
- public IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions,
- CVSTag tag, ICVSResource[] arguments, ICommandOutputListener listener, IProgressMonitor monitor)
- throws CVSException {
-
- String[] stringArguments = convertArgumentsForOpenSession(arguments, session);
-
- return execute(session, globalOptions, localOptions, tag, stringArguments, listener, monitor);
- }
-
- protected ICommandOutputListener getDefaultCommandOutputListener() {
- return DEFAULT_OUTPUT_LISTENER;
- }
-
- protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // Send all folders that are already managed to the server
- if (customBehaviorEnabled) {
- new TagFileSender(session, localOptions).visit(session, resources, monitor);
- } else {
- new FileStructureVisitor(session, localOptions, false, false).visit(session, resources, monitor);
- }
- return resources;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java
deleted file mode 100644
index a15df388f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * Special visitor which handles added and removed files in a special way.
- * Added resources are skipped. Deleted resources are sent as if they were not deleted.
- */
-class TagFileSender extends FileStructureVisitor {
-
- public TagFileSender(Session session, LocalOption[] localOptions) {
- super(session, localOptions, false, false);
- }
-
- /**
- * Override sendFile to provide custom handling of added and deleted resources.
- * Added resources are skipped. Deleted resources are sent as if they were not deleted.
- */
- protected void sendFile(ICVSFile mFile) throws CVSException {
- Policy.checkCanceled(monitor);
- byte[] syncBytes = mFile.getSyncBytes();
- if (syncBytes != null) {
- // Send the parent folder if it hasn't been sent already
- sendFolder(mFile.getParent());
- // Send the file if appropriate
- if (ResourceSyncInfo.isDeletion(syncBytes)) {
- // makes this resource sync undeleted
- syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes);
- }
- if (!ResourceSyncInfo.isAddition(syncBytes)) {
- session.sendEntry(syncBytes, ResourceSyncInfo.getTimestampToServer(syncBytes, mFile.getTimeStamp()));
- session.sendIsModified(mFile, ResourceSyncInfo.isBinary(syncBytes), monitor);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java
deleted file mode 100644
index 1f64df408..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TemplateHandler.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.io.*;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter;
-
-/**
- * @author Administrator
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
- */
-public class TemplateHandler extends ResponseHandler {
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.client.ResponseHandler#getResponseID()
- */
- public String getResponseID() {
- return "Template"; //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.client.ResponseHandler#handle(org.eclipse.team.internal.ccvs.core.client.Session, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void handle(Session session, String localDir, IProgressMonitor monitor) throws CVSException {
- session.readLine(); /* read the remote dir which is not needed */
- // Only read the template file if the container exists.
- // This is OK as we only use the template from the project folder which must exist
- ICVSFolder localFolder = session.getLocalRoot().getFolder(localDir);
- IContainer container = (IContainer)localFolder.getIResource();
- ICVSStorage templateFile = null;
- if (container != null && container.exists()) {
- try {
- templateFile = CVSWorkspaceRoot.getCVSFileFor(SyncFileWriter.getTemplateFile(container));
- } catch (CVSException e) {
- // Log the inability to create the template file
- CVSProviderPlugin.log(new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, "Could not write template file in " + container.getFullPath() + ": " + e.getMessage(), e, session.getLocalRoot())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- if (container == null || templateFile == null) {
- // Create a dummy storage handle to recieve the contents from the server
- templateFile = new ICVSStorage() {
- public String getName() {
- return "Template"; //$NON-NLS-1$
- }
- public void setContents(
- InputStream stream,
- int responseType,
- boolean keepLocalHistory,
- IProgressMonitor monitor)
- throws CVSException {
-
- try {
- // Transfer the contents
- OutputStream out = new ByteArrayOutputStream();
- try {
- byte[] buffer = new byte[1024];
- int read;
- while ((read = stream.read(buffer)) >= 0) {
- Policy.checkCanceled(monitor);
- out.write(buffer, 0, read);
- }
- } finally {
- out.close();
- }
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- } finally {
- try {
- stream.close();
- } catch (IOException e1) {
- // Ignore close errors
- }
- }
- }
- public long getSize() {
- return 0;
- }
- public InputStream getContents() throws CVSException {
- return new ByteArrayInputStream(new byte[0]);
- }
- };
- }
- try {
- session.receiveFile(templateFile, false, UpdatedHandler.HANDLE_UPDATED, monitor);
- } catch (CVSException e) {
- if (!(templateFile instanceof ICVSFile && handleInvalidResourceName(session, (ICVSFile)templateFile, e))) {
- throw e;
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java
deleted file mode 100644
index c12730723..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.UpdateListener;
-
-public class Update extends Command {
- /*** Local options: specific to update ***/
- public static final LocalOption CLEAR_STICKY = new LocalOption("-A"); //$NON-NLS-1$
- public static final LocalOption IGNORE_LOCAL_CHANGES = new LocalOption("-C"); //$NON-NLS-1$
- public static final LocalOption RETRIEVE_ABSENT_DIRECTORIES = new LocalOption("-d"); //$NON-NLS-1$
- public static final LocalOption JOIN = new LocalOption("-j"); //$NON-NLS-1$
-
- /*** Default command output listener ***/
- private static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new UpdateListener(null);
-
- /*** File information status returned from update ***/
- public static final int STATE_NONE = 0; // no state information available
- public static final int STATE_ADDED_LOCAL = 1; // new file locally that was added but not comitted to server yet
- public static final int STATE_UNKOWN = 2; // new file locally but not added to server
- public static final int STATE_REMOTE_CHANGES = 3; // remote changes to an unmodified local file
- public static final int STATE_DELETED = 4; // removed locally but still exists on the server
- public static final int STATE_MODIFIED = 5; // modified locally
- public static final int STATE_CONFLICT = 6; // modified locally and on the server but cannot be auto-merged
- public static final int STATE_MERGEABLE_CONFLICT = 7; // modified locally and on the server but can be auto-merged
-
- /**
- * Makes a -r or -D or -A option for a tag.
- * Valid for: checkout export history rdiff update
- */
- public static LocalOption makeTagOption(CVSTag tag) {
- int type = tag.getType();
- switch (type) {
- case CVSTag.HEAD:
- return CLEAR_STICKY;
- default:
- return Command.makeTagOption(tag);
- }
- }
-
- protected Update() { }
- protected String getRequestId() {
- return "update"; //$NON-NLS-1$
- }
-
- protected ICommandOutputListener getDefaultCommandOutputListener() {
- return DEFAULT_OUTPUT_LISTENER;
- }
-
- protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
-
- // Send all folders that are already managed to the server
- // even folders that are empty
- sendFileStructure(session, resources, localOptions, true, monitor);
- return resources;
- }
-
- /**
- * On successful finish, prune empty directories if the -P or -D option was specified.
- */
- protected IStatus commandFinished(Session session, GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor,
- IStatus status) throws CVSException {
- // If we didn't succeed, don't do any post processing
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- return status;
- }
-
- // If we are pruning (-P), then prune empty directories
- // Note, the CVS spec says that Date (-D) and version (-r) updates
- // should automatically prune but this is a problem for remote CVS handles
- // which fetch a level at a time
- if (PRUNE_EMPTY_DIRECTORIES.isElementOf(localOptions)) {
- // Delete empty directories
- new PruneFolderVisitor().visit(session, resources);
-
- }
- return status;
- }
-
- protected LocalOption[] filterLocalOptions(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions) {
- List newOptions = new ArrayList(Arrays.asList(localOptions));
-
- if (shouldRetrieveAbsentDirectories(session) && ! RETRIEVE_ABSENT_DIRECTORIES.isElementOf(localOptions)) {
- newOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
- }
-
- // Prune empty directories if pruning is enabled and the command in not being run in non-update mode
- if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories() && ! PRUNE_EMPTY_DIRECTORIES.isElementOf(localOptions)) {
- if (! DO_NOT_CHANGE.isElementOf(globalOptions)) {
- newOptions.add(Command.PRUNE_EMPTY_DIRECTORIES);
- }
- }
- localOptions = (LocalOption[]) newOptions.toArray(new LocalOption[newOptions.size()]);
- return super.filterLocalOptions(session, globalOptions, localOptions);
- }
-
- /**
- * Return whether the update command should retrieve absent directories.
- * @param session the session
- * @return whether the update command should retrieve absent directories
- */
- protected boolean shouldRetrieveAbsentDirectories(Session session) {
- // Look for absent directories if enabled and the option is not already included
- IResource resource = null;
- RepositoryProvider provider = null;
- // If there is a provider, use the providers setting
- try {
- resource = session.getLocalRoot().getIResource();
- if (resource != null) {
- provider = RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId());
- if (provider != null) {
- if (((CVSTeamProvider)provider).getFetchAbsentDirectories()) {
- return true;
- }
- }
- }
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- // If there is no provider, use the global setting
- if (provider == null) {
- if (CVSProviderPlugin.getPlugin().getFetchAbsentDirectories()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * We allow unmanaged resources as long as there parents are managed.
- *
- * @see Command#checkResourcesManaged(Session, ICVSResource[])
- */
- protected void checkResourcesManaged(Session session, ICVSResource[] resources) throws CVSException {
- for (int i = 0; i < resources.length; ++i) {
- ICVSFolder folder;
- if (resources[i].isFolder()) {
- if (((ICVSFolder)resources[i]).isCVSFolder()) {
- folder = (ICVSFolder)resources[i];
- } else {
- folder = resources[i].getParent();
- }
- }
- else {
- folder = resources[i].getParent();
- }
- if (folder==null || (!folder.isCVSFolder() && folder.exists())) {
- if (folder == null)
- folder = (ICVSFolder)resources[i];
- IStatus status = new CVSStatus(IStatus.ERROR,CVSStatus.ERROR,NLS.bind(CVSMessages.Command_argumentNotManaged, new String[] { folder.getName() }),session.getLocalRoot());
- throw new CVSException(status);
- }
- }
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.client.Command#doExecute(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption, org.eclipse.team.internal.ccvs.core.client.Command.LocalOption, java.lang.String, org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus doExecute(
- Session session,
- GlobalOption[] globalOptions,
- LocalOption[] localOptions,
- String[] arguments,
- ICommandOutputListener listener,
- IProgressMonitor monitor)
- throws CVSException {
-
- session.setIgnoringLocalChanges(IGNORE_LOCAL_CHANGES.isElementOf(localOptions));
- try {
- return super.doExecute(
- session,
- globalOptions,
- localOptions,
- arguments,
- listener,
- monitor);
- } finally {
- session.setIgnoringLocalChanges(false);
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java
deleted file mode 100644
index 8c7f4d734..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Red Hat Incorporated - is/setExecutable() code
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.listeners.*;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * This custom update command will only update files that
- * are either incoming changes (Update-existing) or auto-mergable
- * (Merged with no "+=" in entry line).
- */
-public class UpdateMergableOnly extends Update {
-
- private static final String LOCAL_FILE_PATH_VARIABLE_NAME = "localFilePath"; //$NON-NLS-1$
- private static ServerMessageLineMatcher MERGE_UPDATE_CONFLICTING_ADDITION_MATCHER;
- static {
- // TODO: temprary until proper lifecycle is defined
- initializePatterns();
- }
- public static void initializePatterns() {
- try {
- MERGE_UPDATE_CONFLICTING_ADDITION_MATCHER = new ServerMessageLineMatcher(
- IMessagePatterns.MERGE_UPDATE_CONFLICTING_ADDITION, new String[] {LOCAL_FILE_PATH_VARIABLE_NAME});
- } catch (CVSException e) {
- // This is serious as the listener will not function properly
- CVSProviderPlugin.log(e);
- }
- }
-
- List skippedFiles = new ArrayList();
-
- public class MergableOnlyUpdatedHandler extends UpdatedHandler {
-
- public MergableOnlyUpdatedHandler() {
- // handle "Merged" responses
- super(UpdatedHandler.HANDLE_MERGED);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.UpdatedHandler#getTargetFile(org.eclipse.team.internal.ccvs.core.ICVSFolder, java.lang.String, byte[])
- */
- protected ICVSFile getTargetFile(ICVSFolder mParent, String fileName, byte[] entryBytes) throws CVSException {
- String adjustedFileName = fileName;
- if (ResourceSyncInfo.isMergedWithConflicts(entryBytes)) {
- // for merged-with-conflict, return a temp file
- adjustedFileName = ".##" + adjustedFileName + " " + ResourceSyncInfo.getRevision(entryBytes); //$NON-NLS-1$ //$NON-NLS-2$
- skippedFiles.add(((IContainer)mParent.getIResource()).getFile(new Path(null, fileName)));
- }
- return super.getTargetFile(mParent, adjustedFileName, entryBytes);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.UpdatedHandler#receiveTargetFile(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.ICVSFile, java.lang.String, java.util.Date, boolean, boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void receiveTargetFile(
- Session session,
- ICVSFile mFile,
- String entryLine,
- Date modTime,
- boolean binary,
- boolean readOnly,
- boolean executable,
- IProgressMonitor monitor)
- throws CVSException {
-
- if (ResourceSyncInfo.isMergedWithConflicts(entryLine.getBytes())) {
- // For merged-with-conflict, just recieve the file contents.
- // Use the Updated handler type so that the file will be created or
- // updated.
- session.receiveFile(mFile, binary, UpdatedHandler.HANDLE_UPDATED, monitor);
- // Now delete the file since it is not used
- mFile.delete();
- } else {
- super.receiveTargetFile(session, mFile, entryLine, modTime, binary, readOnly, executable, monitor);
- }
- }
- }
-
- /**
- * Override the general update listener to handle the following
- * message:
- * cvs server: file folder/file.ext exists, but has been added in revision TAG_NAME
- * This is required because MergeSubscriber adjusts the base when an update
- * occurs and we can end up in a situation where the update faile with the
- * above message (see buh 58654).
- */
- public class MergeUpdateListener extends UpdateListener {
- public MergeUpdateListener(IUpdateMessageListener updateMessageListener) {
- super(updateMessageListener);
- }
- public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
- Map variables = MERGE_UPDATE_CONFLICTING_ADDITION_MATCHER.processServerMessage(line);
- if (variables != null) {
- String filePath = (String)variables.get(LOCAL_FILE_PATH_VARIABLE_NAME);
- try {
- ICVSResource cvsResource = commandRoot.getChild(filePath);
- IResource resource = cvsResource.getIResource();
- if (resource != null && resource.getType() == IResource.FILE) {
- skippedFiles.add(resource);
- return OK;
- }
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- // Fall through to let the superclass process the error line
- }
- }
- return super.errorLine(line, location, commandRoot, monitor);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Command#doExecute(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[], org.eclipse.team.internal.ccvs.core.client.Command.LocalOption[], java.lang.String[], org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus doExecute(
- Session session,
- GlobalOption[] globalOptions,
- LocalOption[] localOptions,
- String[] arguments,
- ICommandOutputListener listener,
- IProgressMonitor monitor)
- throws CVSException {
-
- MergableOnlyUpdatedHandler newHandler = new MergableOnlyUpdatedHandler();
- ResponseHandler oldHandler = session.getResponseHandler(newHandler.getResponseID());
- skippedFiles.clear();
- try {
- session.registerResponseHandler(newHandler);
- // Don't create backup files since merges won't be overridden
- session.setCreateBackups(false);
- return super.doExecute(
- session,
- globalOptions,
- localOptions,
- arguments,
- new MergeUpdateListener(null),
- monitor);
- } finally {
- session.registerResponseHandler(oldHandler);
- session.setCreateBackups(true);
- }
- }
-
- public IFile[] getSkippedFiles() {
- return (IFile[]) skippedFiles.toArray(new IFile[skippedFiles.size()]);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java
deleted file mode 100644
index dd6e43bed..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Red Hat Incorporated - is/setExecutable() code
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import java.util.Date;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * Handles any "Updated" and "Merged" responses
- * from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Updated ???\n
- * [...]
- * </pre>
- * Then
- * </p>
- */
-
-/**
- * Does get information about the file that is updated
- * and the file-content itself and puts it on the fileSystem.
- *
- * The difference beetween the "Updated" and the "Merged" is, that
- * an "Merged" file is not going to be up-to-date after the operation.
- *
- * Requiers a exisiting parent-folder.
- */
-public class UpdatedHandler extends ResponseHandler {
-
- private int handlerType;
-
- public static final int HANDLE_UPDATED = ICVSFile.UPDATED;
- public static final int HANDLE_MERGED = ICVSFile.MERGED;
- public static final int HANDLE_UPDATE_EXISTING = ICVSFile.UPDATE_EXISTING;
- public static final int HANDLE_CREATED = ICVSFile.CREATED;
-
- private static final String READ_ONLY_FLAG = "u=rw"; //$NON-NLS-1$
- private static final String EXECUTE_FLAG = "x"; //$NON-NLS-1$
-
- public UpdatedHandler(int handlerType) {
- this.handlerType = handlerType;
- }
-
- public String getResponseID() {
- switch (handlerType) {
- case HANDLE_UPDATED: return "Updated"; //$NON-NLS-1$
- case HANDLE_MERGED: return "Merged"; //$NON-NLS-1$
- case HANDLE_UPDATE_EXISTING: return "Update-existing"; //$NON-NLS-1$
- case HANDLE_CREATED: return "Created"; //$NON-NLS-1$
- }
- return null;
- }
-
- public void handle(Session session, String localDir, IProgressMonitor monitor) throws CVSException {
- // read additional data for the response
- String repositoryFile = session.readLine();
- String entryLine = session.readLine();
- byte[] entryBytes = entryLine.getBytes();
- String permissionsLine = session.readLine();
-
- // clear file update modifiers
- Date modTime = session.getModTime();
- session.setModTime(null);
-
- // Get the local file
- String fileName = repositoryFile.substring(repositoryFile.lastIndexOf("/") + 1); //$NON-NLS-1$
- ICVSFolder mParent = getExistingFolder(session, localDir);
- ICVSFile mFile = getTargetFile(mParent, fileName, entryBytes);
-
- boolean binary = ResourceSyncInfo.isBinary(entryBytes);
- boolean readOnly = permissionsLine.indexOf(READ_ONLY_FLAG) == -1;
- boolean executable = permissionsLine.indexOf(EXECUTE_FLAG) != -1;
-
- try {
- // The file may have been set as read-only by a previous checkout/update
- if (mFile.isReadOnly()) mFile.setReadOnly(false);
- } catch (CVSException e) {
- // Just log and keep going
- CVSProviderPlugin.log(e);
- }
-
- try {
- receiveTargetFile(session, mFile, entryLine, modTime, binary, readOnly, executable, monitor);
- } catch (CVSException e) {
- // An error occurred while recieving the file.
- // If it is due to an invalid file name,
- // accumulate the error and continue.
- // Otherwise, exit
- if (!handleInvalidResourceName(session, mFile, e)) {
- throw e;
- }
- }
- }
-
- protected ICVSFile getTargetFile(ICVSFolder mParent, String fileName, byte[] entryBytes) throws CVSException {
- return mParent.getFile(fileName);
- }
-
- protected void receiveTargetFile(Session session, ICVSFile mFile, String entryLine, Date modTime, boolean binary, boolean readOnly, boolean executable, IProgressMonitor monitor) throws CVSException {
-
- // receive the file contents from the server
- session.receiveFile(mFile, binary, handlerType, monitor);
-
- // Set the timestamp in the file and get it again so that we use the *real* timestamp
- // in the sync info. The os may not actually set the time we provided :)
- mFile.setTimeStamp(modTime);
- modTime = mFile.getTimeStamp();
- ResourceSyncInfo info = new ResourceSyncInfo(entryLine, null);
- MutableResourceSyncInfo newInfoWithTimestamp = info.cloneMutable();
- newInfoWithTimestamp.setTimeStamp(modTime);
-
- //see bug 106876
- CVSTag tag = newInfoWithTimestamp.getTag();
- if(tag != null && CVSTag.BASE.getName().equals(tag.getName())){
- newInfoWithTimestamp.setTag(mFile.getSyncInfo().getTag());
- }
-
- int modificationState = ICVSFile.UNKNOWN;
- if(handlerType==HANDLE_MERGED) {
- newInfoWithTimestamp.setMerged();
- } else if (!session.isIgnoringLocalChanges()
- && !info.isAdded() /* could be an added entry during a merge in which case it is dirty */
- && (handlerType==HANDLE_UPDATE_EXISTING || handlerType==HANDLE_CREATED)) {
- // both these cases result in an unmodified file.
- // reporting is handled by the FileModificationManager
- modificationState = ICVSFile.CLEAN;
- CVSProviderPlugin.getPlugin().getFileModificationManager().updated(mFile);
- }
- mFile.setSyncInfo(newInfoWithTimestamp, modificationState);
- try {
- if (readOnly) mFile.setReadOnly(true);
- if (executable) mFile.setExecutable(true);
- } catch (CVSException e) {
- // Just log and keep going
- CVSProviderPlugin.log(e);
- }
- }
-
- public int getHandlerType() {
- return handlerType;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java
deleted file mode 100644
index cdb088eb0..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequests.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-class ValidRequests extends Request {
-
- protected ValidRequests() { }
-
- protected String getRequestId() {
- return "valid-requests"; //$NON-NLS-1$
- }
-
- public IStatus execute(Session session, IProgressMonitor monitor) throws CVSException {
- return executeRequest(session, Command.DEFAULT_OUTPUT_LISTENER, monitor);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequestsHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequestsHandler.java
deleted file mode 100644
index d2c60a837..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ValidRequestsHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-
-/**
- * Handles a "Valid-requests" response from the CVS server.
- * <p>
- * Suppose as a result of performing a command the CVS server responds
- * as follows:<br>
- * <pre>
- * [...]
- * Valid-requests ci co update Root Directory Valid-responses Argument ...\n
- * [...]
- * </pre>
- * Then we remember the set of valid requests for this session in
- * preparation for isValidRequests queries.
- * </p>
- */
-class ValidRequestsHandler extends ResponseHandler {
- public String getResponseID() {
- return "Valid-requests"; //$NON-NLS-1$
- }
-
- public void handle(Session session, String validRequests,
- IProgressMonitor monitor) throws CVSException {
- // remember the set of valid requests for this session
- session.setValidRequests(validRequests);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java
deleted file mode 100644
index 5fdee7d52..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-
-/**
- * Here are some of the output formats we know about:
- *
- * Concurrent Versions System (CVS) 1.11.1p1 (client/server)
- * Concurrent Versions System (CVS) NT 1.11.1.1 (Build 27)
- * Concurrent Versions System (CVSNT) 1.11.1.3 (Build 57a) (client/server)
- */
-public class Version extends RemoteCommand {
-
- private static final String CVS_NT_PREFIX_1 = "Concurrent Versions System (CVS) NT "; //$NON-NLS-1$
- private static final String CVS_NT_PREFIX_2 = "Concurrent Versions System (CVSNT) "; //$NON-NLS-1$
- private static final String CVS_PREFIX = "Concurrent Versions System (CVS) "; //$NON-NLS-1$
- /**
- * @see Request#getRequestId()
- */
- protected String getRequestId() {
- return "version"; //$NON-NLS-1$
- }
-
- public IStatus execute(Session session, final ICVSRepositoryLocation location, IProgressMonitor monitor) throws CVSException {
-
- // The server may not support the version request
- if ( ! session.isValidRequest(getRequestId())) {
- IStatus status = new CVSStatus(IStatus.WARNING, CVSStatus.SERVER_IS_UNKNOWN, NLS.bind(CVSMessages.Version_versionNotValidRequest, new String[] { location.getHost() }), session.getLocalRoot());
- ((CVSRepositoryLocation)location).setServerPlaform(CVSRepositoryLocation.UNKNOWN_SERVER);
- CVSProviderPlugin.log(status);
- return status;
- }
-
- ICommandOutputListener listener = new ICommandOutputListener() {
- public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
- String knownPrefix = null;
- boolean isCVSNT = false;
- if (line.startsWith(CVS_NT_PREFIX_1)) {
- isCVSNT = true;
- knownPrefix = CVS_NT_PREFIX_1;
- } else if (line.startsWith(CVS_NT_PREFIX_2)) {
- isCVSNT = true;
- knownPrefix = CVS_NT_PREFIX_2;
- } else if (line.startsWith(CVS_PREFIX)) {
- knownPrefix = CVS_PREFIX;
- }
- IStatus status = OK;
- int serverType = CVSRepositoryLocation.CVS_SERVER;
- if (knownPrefix != null) {
- String versionNumber = line.substring(knownPrefix.length(), line.indexOf(' ', knownPrefix.length() + 1));
- if (versionNumber.startsWith("1.10") || versionNumber.equals("1.11") || versionNumber.equals("1.11.1")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- serverType = CVSRepositoryLocation.UNSUPPORTED_SERVER;
- status = new CVSStatus(IStatus.WARNING, CVSStatus.UNSUPPORTED_SERVER_VERSION, NLS.bind(CVSMessages.Version_unsupportedVersion, new String[] { location.getHost(), versionNumber }),location);
- } else if (isCVSNT) {
- serverType = CVSRepositoryLocation.CVSNT_SERVER;
- }
- } else {
- serverType = CVSRepositoryLocation.UNKNOWN_SERVER;
- status = new CVSStatus(IStatus.INFO, CVSStatus.SERVER_IS_UNKNOWN, NLS.bind(CVSMessages.Version_unknownVersionFormat, new String[] { location.getHost(), line }), location);
- }
- ((CVSRepositoryLocation)location).setServerPlaform(serverType);
- return status;
- }
- public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
- return new CVSStatus(IStatus.ERROR, CVSStatus.ERROR_LINE, line, commandRoot);
- }
- };
-
- return execute(session, NO_GLOBAL_OPTIONS, NO_LOCAL_OPTIONS, new String[] {}, listener, monitor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Command#isWorkspaceModification()
- */
- protected boolean isWorkspaceModification() {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java
deleted file mode 100644
index 78341bb1e..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * Used with 'admin -ksubst' to capture lines of text that are issued
- * as confirmation that the remote keyword substitution mode has been
- * changed. When encountered, updates the local ResourceSyncInfo for
- * the file in question to reflect
- *
- * e.g.
- * RCS file: path/filename,v
- * done
- *
- * We don't expect to see anything special on stderr if the command succeeds.
- */
-public class AdminKSubstListener extends CommandOutputListener {
- private KSubstOption ksubstMode;
-
- public AdminKSubstListener(KSubstOption ksubstMode) {
- this.ksubstMode = ksubstMode;
- }
-
- public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot,
- IProgressMonitor monitor) {
- if (line.startsWith("RCS file:")) { //$NON-NLS-1$
- String rcsFile = line.substring(10).trim();
- if (! rcsFile.endsWith(",v")) { //$NON-NLS-1$
- return new CVSStatus(IStatus.ERROR,
- NLS.bind(CVSMessages.AdminKSubstListener_expectedRCSFile, new String[] { rcsFile }));
- }
- IPath rcsFilePath = new Path(null, Util.removeAtticSegment(rcsFile.substring(0, rcsFile.length() - 2)));
- try {
- ICVSFile file = findLocalFileFor(commandRoot, rcsFilePath);
- //ResourceSyncInfo info = file.getSyncInfo();
- byte[] syncBytes = file.getSyncBytes();
- if (syncBytes != null) {
- // only update sync info if we have it locally
- file.setSyncBytes(ResourceSyncInfo.setKeywordMode(syncBytes, ksubstMode), ICVSFile.UNKNOWN);
- }
- } catch (CVSException e) {
- return e.getStatus();
- }
- }
- return OK;
- }
-
- private ICVSFile findLocalFileFor(ICVSFolder commandRoot, IPath rcsFilePath) throws CVSException {
-
- // First, look for the local file by following the remote path
- FolderSyncInfo info = commandRoot.getFolderSyncInfo();
- String remoteRootLocation = info.getRemoteLocation();
- if (remoteRootLocation == null) {
- throw new CVSException(new CVSStatus(IStatus.ERROR,
- CVSMessages.AdminKSubstListener_commandRootNotManaged));
- }
- IPath remoteRootPath = new Path(null, remoteRootLocation);
- if (remoteRootPath.isPrefixOf(rcsFilePath)) {
- IPath relativeFilePath = rcsFilePath.removeFirstSegments(remoteRootPath.segmentCount());
- ICVSFile file = commandRoot.getFile(relativeFilePath.toString());
- if (file.isManaged() && isMatchingPath(file, rcsFilePath)) {
- return file;
- }
- }
-
- // We couldn't find the file that way which means we're working in a defined module.
- // Scan all folders looking for a match
- ICVSFolder parent = findFolder(commandRoot, rcsFilePath.removeLastSegments(1));
- if (parent != null) {
- ICVSFile file = parent.getFile(rcsFilePath.lastSegment());
- if (file.isManaged()) {
- return file;
- }
- }
-
- // No file was found so return null;
- throw new CVSException(new CVSStatus(IStatus.ERROR,
- NLS.bind(CVSMessages.AdminKSubstListener_expectedChildOfCommandRoot, new String[] { rcsFilePath.toString(), remoteRootPath.toString() })));
- }
-
- private ICVSFolder findFolder(ICVSFolder commandRoot, IPath path) throws CVSException {
- final String remotePath = path.toString();
- final ICVSFolder[] result = new ICVSFolder[] { null };
- commandRoot.accept(new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {
- // Nothing to do for files
- }
- public void visitFolder(ICVSFolder folder) throws CVSException {
- FolderSyncInfo info = folder.getFolderSyncInfo();
- if (info != null && info.getRemoteLocation().equals(remotePath)) {
- // We found the folder we're looking for
- result[0] = folder;
- }
- if (result[0] == null) {
- folder.acceptChildren(this);
- }
- }
- });
- return result[0];
- }
-
- private boolean isMatchingPath(ICVSFile file, IPath rcsFilePath) throws CVSException {
- FolderSyncInfo info = file.getParent().getFolderSyncInfo();
- return info != null
- && info.getRemoteLocation().equals(rcsFilePath.removeLastSegments(1).toString());
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java
deleted file mode 100644
index d7576883b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AnnotateListener.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
-
-public class AnnotateListener extends CommandOutputListener {
-
-/**
- * Handle output from the CVS Annotate command.
- */
- ByteArrayOutputStream aStream = new ByteArrayOutputStream();
- List blocks = new ArrayList();
- int lineNumber;
-
- public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
- String error = null;
- CVSAnnotateBlock aBlock = new CVSAnnotateBlock(line, lineNumber++);
- if (!aBlock.isValid()) {
- error = line;
- }
-
- /**
- * Make sure all lines have a line terminator.
- */
- try {
- aStream.write(line.substring(aBlock.getSourceOffset()).getBytes());
- if (!(line.endsWith("\r") || line.endsWith("\r\n"))) { //$NON-NLS-1$ //$NON-NLS-2$
- aStream.write(System.getProperty("line.separator").getBytes()); //$NON-NLS-1$
- }
- } catch (IOException e) {
- }
- add(aBlock);
- if (error != null)
- return new CVSStatus(IStatus.ERROR, CVSStatus.ERROR_LINE_PARSE_FAILURE, error, commandRoot);
- return OK;
- }
-
- public InputStream getContents() {
- return new ByteArrayInputStream(aStream.toByteArray());
- }
-
- public List getCvsAnnotateBlocks() {
- return blocks;
- }
- /**
- * Add an annotate block to the receiver merging this block with the
- * previous block if it is part of the same change.
- * @param aBlock
- */
- private void add(CVSAnnotateBlock aBlock) {
-
- int size = blocks.size();
- if (size == 0) {
- blocks.add(aBlock);
- } else {
- CVSAnnotateBlock lastBlock = (CVSAnnotateBlock) blocks.get(size - 1);
- if (lastBlock.getRevision().equals(aBlock.getRevision())) {
- lastBlock.setEndLine(aBlock.getStartLine());
- } else {
- blocks.add(aBlock);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#errorLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
- if(line.startsWith(CVSMessages.AnnotateListener_3)) {
- String error = CVSMessages.AnnotateListener_4;
- return new CVSStatus(IStatus.ERROR, CVSStatus.SERVER_ERROR, error, commandRoot);
- }
- return super.errorLine(line, location, commandRoot, monitor);
- }
-
- /**
- * Set the contents of the listener to the provided contents.
- * This is done if the contents fetched by the annotate command
- * has a charater set that may have been mangled by the transfer
- * @param remoteContents the actual contens of the file
- */
- public void setContents(InputStream remoteContents) {
- try {
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- byte[] buffer = new byte[1024];
- int n = remoteContents.read(buffer);
- while (n != -1) {
- stream.write(buffer, 0, n);
- n = remoteContents.read(buffer);
- }
- aStream = stream;
- } catch (IOException e) {
- // Log and continue
- CVSProviderPlugin.log(CVSException.wrapException(e));
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java
deleted file mode 100644
index 7de08ec0d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/DiffListener.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-
-import java.io.PrintStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-
-public class DiffListener extends CommandOutputListener {
- PrintStream patchStream;
- boolean wroteToStream;
-
- //Error Messages returned by CVS
- static final String ERR_NOSUCHDIRECTORY = "cvs [diff aborted]: no such directory"; //$NON-NLS-1$
-
- public DiffListener(PrintStream patchStream) {
- this.patchStream = patchStream;
- wroteToStream=false;
- }
-
- public IStatus messageLine(
- String line,
- ICVSRepositoryLocation location,
- ICVSFolder commandRoot,
- IProgressMonitor monitor) {
-
- // Special handling to avoid getting duplicate CRs when generating a patch on windows.
- // If the remote file has CR/LF in it, then the line will have a CR at the end.
- // We need to remove it so we don't end up with two CRs (since the printStream will also add one).
- // On *nix, we want to include the CR since it will not be added by the printStream (see bug 92162).
- if (Session.IS_CRLF_PLATFORM && line.length() > 0 && line.charAt(line.length() - 1) == '\r') {
- line = line.substring(0, line.length() - 1);
- }
- patchStream.println(line);
- wroteToStream=true;
-
- return OK;
- }
-
- public IStatus errorLine(
- String line,
- ICVSRepositoryLocation location,
- ICVSFolder commandRoot,
- IProgressMonitor monitor) {
- // ignore server messages for now - this is used only with the diff
- // request and the errors can be safely ignored.
- if (getServerMessage(line, location) != null) {
- return OK;
- }
-
- //Check to see if this is a no such directory message
- if (line.indexOf(ERR_NOSUCHDIRECTORY) != -1){
- return OK;
- }
- return super.errorLine(line, location, commandRoot, monitor);
- }
-
- public boolean wroteToStream() {
- return wroteToStream;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/EditorsListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/EditorsListener.java
deleted file mode 100644
index db5438fd3..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/EditorsListener.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CSC - Intial implementation
- * IBM Corporation - ongoing maintenance
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.EditorsInfo;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
-
-
-/**
- *
- *
- * Listener for the Editors command
- *
- * @author <a href="mailto:kohlwes@gmx.net">Gregor Kohlwes</a>
- *
- */
-public class EditorsListener extends CommandOutputListener {
- /**
- * List to store the EditorsInfos
- */
- private List infos = new LinkedList();
-
- /**
- * Name of the current file
- */
- private String fileName;
-
- /**
- * Constructor EditorsListener.
- */
- public EditorsListener() {
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#messageLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus messageLine(
- String line,
- ICVSRepositoryLocation location,
- ICVSFolder commandRoot,
- IProgressMonitor monitor) {
-
- // If there is a file with multiple editors
- // then cvs will write the filename only
- // in the first line and the following
- // line will start with a Tab
- if (line.startsWith("\t")) { //$NON-NLS-1$
- line = fileName + line;
- }
- EditorsInfo info = new EditorsInfo();
- StringTokenizer tokenizer = new StringTokenizer(line,"\t"); //$NON-NLS-1$
- int i = 0;
- while(tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- switch (i) {
- case 0:
- info.setFileName(token);
- fileName = token;
- break;
- case 1:
- info.setUserName(token);
- break;
- case 2:
- info.setDateString(token);
- break;
- case 3:
- info.setComputerName(token);
- break;
- default :
- break;
- }
- i++;
- }
-
- infos.add(info);
- return OK;
-
- }
- /**
- * Method getEditorsInfos.
- * @return IEditorsInfo[]
- */
- public EditorsInfo[] getEditorsInfos() {
- return (EditorsInfo[]) infos.toArray(new EditorsInfo[infos.size()]);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java
deleted file mode 100644
index 051591325..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ICommandOutputListener.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-
-/**
- * Instances of this interface can be passed to the <code>Command#execute</code> methods
- * and will receive notification when M or E messages are received from the server.
- */
-public interface ICommandOutputListener {
-
- /*** Status to be returned when no error or warning occured ***/
- public static final IStatus OK = new CVSStatus(IStatus.OK, CVSMessages.ok);
-
- public static final String SERVER_PREFIX = "server: "; //$NON-NLS-1$
- public static final String SERVER_ABORTED_PREFIX = "[server aborted]: "; //$NON-NLS-1$
- public static final String RTAG_PREFIX = "rtag: "; //$NON-NLS-1$
-
- /**
- * Invoked when a message line is received from the server.
- * <p>
- * Any status other than ICommandOutputListener.OK will be accumulated
- * by the command and returned. The severity of the status matches those of
- * IStatus and must indicate whether this is a warning, error, or informational
- * text.while the code should be one of the codes provided by CVSStatus.
- * The status code must not be CVSStatus.SERVER_ERROR.
- * </p>
- *
- * @param line the line of message text sent by the server
- * @param commandRoot the root directory of the command
- * @param monitor the progress monitor
- * @return a status indicating success or failure based on the text
- */
- public IStatus messageLine(String line,
- ICVSRepositoryLocation location,
- ICVSFolder commandRoot,
- IProgressMonitor monitor);
-
- /**
- * Invoked when an error line is received from the server.
- * <p>
- * Any status other than ICommandOutputListener.OK will be accumulated
- * by the command and returned. The severity of the status matches those of
- * IStatus and must indicate whether this is a warning, error, or informational
- * text.while the code should be one of the codes provided by CVSStatus.
- * The status code must not be CVSStatus.SERVER_ERROR.
- * </p>
- *
- * @param line the line of error text sent by the server
- * @param commandRoot the root directory of the command
- * @param monitor the progress monitor
- * @return a status indicating success or failure based on the text
- */
- public IStatus errorLine(String line,
- ICVSRepositoryLocation location,
- ICVSFolder commandRoot,
- IProgressMonitor monitor);
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java
deleted file mode 100644
index a625735f3..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IConsoleListener.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-
-public interface IConsoleListener {
- /**
- * Called when a command is invoked.
- * @param session the session that the command is being executed over
- * @param line the command invocation string
- */
- public void commandInvoked(Session session, String line);
-
- /**
- * Called when a line of message text has been received.
- * @param session the session that the command is being executed over
- * @param line the line of text
- * @param status the status returned from the command message parser
- */
- public void messageLineReceived(Session session, String line, IStatus status);
-
- /**
- * Called when a line of error text has been received.
- * @param session the session that the command is being executed over
- * @param line the line of text
- * @param status the status returned from the command message parser
- */
- public void errorLineReceived(Session session, String line, IStatus status);
-
- /**
- * Called when a command has been completed.
- * @param session the session that the command is being executed over
- * @param status the status code, or null if not applicable
- * @param exception an exception, or null if not applicable
- */
- public void commandCompleted(Session session, IStatus status, Exception exception);
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ILogEntryListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ILogEntryListener.java
deleted file mode 100644
index 91a4c7bc3..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ILogEntryListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-import org.eclipse.team.internal.ccvs.core.ILogEntry;
-
-/**
- * Interface for receiving log entries from the <code>LogListener</code>
- */
-public interface ILogEntryListener {
-
- /**
- * A log entry was received for the current file
- * @param entry the received log entry.
- */
- void handleLogEntryReceived(ILogEntry entry);
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IMessagePatterns.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IMessagePatterns.java
deleted file mode 100644
index 9d3a690df..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IMessagePatterns.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * This class contains the default server message patterns
- */
-public interface IMessagePatterns {
-
- public static final String SERVER_MESSAGE_PREFIX = "\\w* \\w*: "; //$NON-NLS-1$
- public static final String SERVER_ABORTED_MESSAGE_PREFIX = "\\w* [\\w* aborted]: "; //$NON-NLS-1$
-
- // TODO: These patterns could be more specific but this would require non-capturing
- // groups which currently throw off variable matching
- public static final String TAG_PATTERN = "\\w*"; //$NON-NLS-1$
- public static final String REVISION_PATTERN = ".*"; //$NON-NLS-1$
- public static final String FILE_PATH_PATTERN = ".*"; //$NON-NLS-1$
-
- // TODO: It would be better if the prefix was optional but this requires the use of a capturing group which throws the group count off
- public static final String RDIFF_DIRECTORY = SERVER_MESSAGE_PREFIX + "Diffing " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFolderPath"); //$NON-NLS-1$ //$NON-NLS-2$
- public static final String RDIFF_SUMMARY_FILE_DIFF = "File " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFilePath") + " changed from revision " + Util.getVariablePattern(REVISION_PATTERN, "leftRevision") + " to " + Util.getVariablePattern(REVISION_PATTERN, "rightRevision"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- public static final String RDIFF_SUMMARY_NEW_FILE = "File " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFilePath") + " is new; " + TAG_PATTERN + " revision " + Util.getVariablePattern(REVISION_PATTERN, "rightRevision"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- public static final String RDIFF_SUMMARY_DELETED_FILE = "File " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFilePath") + " is removed; not included in release tag " + TAG_PATTERN; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- // This format was introduced in 1.11.7
- public static final String RDIFF_SUMMARY_DELETED_FILE2 = "File " + Util.getVariablePattern(FILE_PATH_PATTERN, "remoteFilePath") + " is removed; " + TAG_PATTERN + " revision " + Util.getVariablePattern(REVISION_PATTERN, "leftRevision"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-
- public static final String MERGE_UPDATE_CONFLICTING_ADDITION = SERVER_MESSAGE_PREFIX + "file " + Util.getVariablePattern(FILE_PATH_PATTERN, "localFilePath") + " exists, but has been added in revision " + TAG_PATTERN; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java
deleted file mode 100644
index 3e0093a37..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-
-public interface IStatusListener {
-
- public static final String FOLDER_REVISION = ""; //$NON-NLS-1$
-
- /**
- * Provides access to the revision of a file through the use of the Status command.
- *
- * @param commandRoot the root directory of the command
- * @param path the absolute remote path of the resource including the repository root directory
- * @param remoteRevision the remote revision of the file
- */
- public void fileStatus(ICVSFolder commandRoot, String path, String remoteRevision);
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java
deleted file mode 100644
index 009e8b42a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IUpdateMessageListener.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-
-/**
- * This listener is used by RemoteFolder to listener for E and M messages
- * from the CVS server in order to determine the files and folders contained in a parent folder.
- */
-public interface IUpdateMessageListener {
- /**
- * Notification that a directory (which may or may not have been reported by
- * directoryInformation()) does not exist.
- *
- * @param commandRoot the root directory of the command
- * @param path the path of the directory relative to the commandRoot
- */
- public void directoryDoesNotExist(ICVSFolder commandRoot, String path);
- /**
- * Notification of information about a directory.
- *
- * @param commandRoot the root directory of the command
- * @param path the path of the directory relative to the commandRoot
- * @param newDirectory true if the directory does not exist locally (i.e. in the commandRoot hierarchy)
- */
- public void directoryInformation(ICVSFolder commandRoot, String path, boolean newDirectory);
- /**
- * Notification of information about a file
- *
- * @param type the type of update for the file (see Update for type constants)
- * @param commandRoot the root directory of the command
- * @param filename the path of the file relative to the commandRoot
- */
- public void fileInformation(int type, ICVSFolder parent, String filename);
- /**
- * Notification that a file does not exists remotely
- *
- * @param commandRoot the root directory of the command
- * @param filename the path of the file relative to the commandRoot
- */
- public void fileDoesNotExist(ICVSFolder parent, String filename);
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java
deleted file mode 100644
index af2937a40..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogEntry.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-
-import java.util.Date;
-
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-
-public class LogEntry extends PlatformObject implements ILogEntry {
-
- private RemoteFile file;
- private String author;
- private Date date;
- private String comment;
- private String state;
- private CVSTag[] tags;
- private String[] revisions;
-
- /*
- * Flatten the text in the multi-line comment
- */
- public static String flattenText(String string) {
- StringBuffer buffer = new StringBuffer(string.length() + 20);
- boolean skipAdjacentLineSeparator = true;
- for (int i = 0; i < string.length(); i++) {
- char c = string.charAt(i);
- if (c == '\r' || c == '\n') {
- if (!skipAdjacentLineSeparator)
- buffer.append(CVSMessages.LogEntry_0);
- skipAdjacentLineSeparator = true;
- } else {
- buffer.append(c);
- skipAdjacentLineSeparator = false;
- }
- }
- return buffer.toString();
- }
-
- public LogEntry(RemoteFile file, String revision, String author, Date date, String comment, String state, CVSTag[] tags) {
- this.file = file.toRevision(revision);
- this.author = author;
- this.date = date;
- this.comment = comment;
- this.state = state;
- this.tags = tags;
- }
-
- public LogEntry(RemoteFile file, String revision, String author, Date date, String comment, String state, CVSTag[] tags, String[] revisions) {
- this(file,revision,author,date,comment,state,tags);
- this.revisions=revisions;
- }
-
- /**
- * @see ILogEntry#getRevision()
- */
- public String getRevision() {
- return file.getRevision();
- }
-
- /**
- * @see ILogEntry#getAuthor()
- */
- public String getAuthor() {
- return author;
- }
-
- /**
- * @see ILogEntry#getDate()
- */
- public Date getDate() {
- return date;
- }
-
- /**
- * @see ILogEntry#getComment()
- */
- public String getComment() {
- return comment;
- }
-
- /**
- * @see ILogEntry#getState()
- */
- public String getState() {
- return state;
- }
-
- /**
- * @see ILogEntry#getTags()
- */
- public CVSTag[] getTags() {
- CVSTag[] result = new CVSTag[tags.length];
- System.arraycopy(tags, 0, result, 0, tags.length);
- return result;
- }
-
- /**
- * @see ILogEntry#getRemoteFile()
- */
- public ICVSRemoteFile getRemoteFile() {
- return file;
- }
-
- /**
- * @see ILogEntry#isDeletion()
- */
- public boolean isDeletion() {
- return getState().equals("dead"); //$NON-NLS-1$
- }
-
- /**
- * In the case where files on a branch haven't been modified since their initial branch point,
- * they keep the revision number of their predecessor. In this case no revision info will be displayed
- * while doing a log, so all branch revision numbers are recorded. This allows the user to pick which revision
- * they are interested in.
- * @return an array of branch revision strings or an empty array if no branch revisions were recorded
- */
- public String[] getBranchRevisions(){
-
- if (revisions != null)
- return revisions;
-
- return new String[0];
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java
deleted file mode 100644
index aab7efce6..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/LogListener.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Brock Janiczak <brockj@tpg.com.au> - Bug 179977 CVS log command doesn't scale well with lots of tags and versions
- * Brock Janiczak <brockj@tpg.com.au> - Bug 194396 Reduce retained memory usage of LogEntry objects
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-import java.text.*;
-import java.util.*;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * Log listener that parses the log entries returned from the
- * server but delegates the handling of the entries to a subclass.
- */
-public class LogListener extends CommandOutputListener {
-
- /*
- * A new format for log dates was introduced in 1.12.9
- */
- private static final String LOG_TIMESTAMP_FORMAT_OLD= "yyyy/MM/dd HH:mm:ss zzz";//$NON-NLS-1$
- private static final String LOG_TIMESTAMP_FORMAT= "yyyy-MM-dd HH:mm:ss zzz";//$NON-NLS-1$
- private static final Locale LOG_TIMESTAMP_LOCALE= Locale.US;
- private final DateFormat LOG_DATE_FORMATTER_OLD = new SimpleDateFormat(LOG_TIMESTAMP_FORMAT_OLD, LOG_TIMESTAMP_LOCALE);
- private final DateFormat LOG_DATE_FORMATTER = new SimpleDateFormat(LOG_TIMESTAMP_FORMAT, LOG_TIMESTAMP_LOCALE);
-
- // Server message prefix used for error detection
- private static final String NOTHING_KNOWN_ABOUT = "nothing known about "; //$NON-NLS-1$
-
- // States of log accumulation.
- private final int DONE = 4;
- private final int COMMENT = 3;
- private final int REVISION = 2;
- private final int SYMBOLIC_NAMES = 1;
- private final int BEGIN = 0;
-
- //Tag used for accumulating all of a branch's revision info
- public final static String BRANCH_REVISION = "branchRevision"; //$NON-NLS-1$
-
- private static final CVSTag[] NO_TAGS = new CVSTag[0];
- private static final String[] NO_VERSIONS = new String[0];
-
- // Instance variables for accumulating Log information
- private RemoteFile currentFile;
- private int state = BEGIN;
- private StringBuffer comment;
- private String fileState;
- private String revision;
- private String author;
- private Date creationDate;
- private List versions = new ArrayList();
- private Map internedStrings = new HashMap();
- private final ILogEntryListener listener;
-
- /**
- * Create a log listener for receiving entries for one or more files.
- */
- public LogListener(ILogEntryListener listener) {
- this.listener = listener;
- }
-
- public LogListener(RemoteFile file, ILogEntryListener listener) {
- this(listener);
- this.currentFile = file;
- }
-
- private String getRelativeFilePath(ICVSRepositoryLocation location, String fileName) {
- if (fileName.endsWith(",v")) { //$NON-NLS-1$
- fileName = fileName.substring(0, fileName.length() - 2);
- }
- fileName = Util.removeAtticSegment(fileName);
- String rootDirectory = location.getRootDirectory();
- if (fileName.startsWith(rootDirectory)) {
- try {
- fileName = Util.getRelativePath(rootDirectory, fileName);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- return null;
- }
- }
- return fileName;
- }
-
- public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
- String serverMessage = getServerMessage(line, location);
- if (serverMessage != null) {
- // look for the following condition
- // E cvs server: nothing known about fileName
- if (serverMessage.startsWith(NOTHING_KNOWN_ABOUT)) {
- return new CVSStatus(IStatus.ERROR, CVSStatus.DOES_NOT_EXIST, line, commandRoot);
- }
- }
- return OK;
- }
-
- public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
- // Fields we will find in the log for a file
- // keys = String (tag name), values = String (tag revision number) */
- switch (state) {
- case BEGIN:
- if (line.startsWith("RCS file: ")) { //$NON-NLS-1$
- // We are starting to recieve the log for a file
- String fileName = getRelativeFilePath(location, line.substring(10).trim());
- if (fileName == null) {
- currentFile = null;
- handleInvalidFileName(location, fileName);
- } else {
- if (currentFile == null || !currentFile.getRepositoryRelativePath().equals(fileName)) {
- // We are starting another file
- beginFile(location, fileName);
- }
- }
- } else if (line.startsWith("symbolic names:")) { //$NON-NLS-1$
- state = SYMBOLIC_NAMES;
- } else if (line.startsWith("revision ")) { //$NON-NLS-1$
- revision = internAndCopyString(line.substring(9));
- state = REVISION;
- } else if (line.startsWith("total revisions:")){ //$NON-NLS-1$
- //if there are no current revision selected and this is a branch then we are in the
- //case where there have been no changes made on the branch since the initial branching
- //and we need to get the revision that the branch was made from
- int indexOfSelectedRevisions = line.lastIndexOf("selected revisions: "); //$NON-NLS-1$
- //20 for length of "selected revisions: "
- String selectedRevisions = line.substring(indexOfSelectedRevisions + 20).trim();
- if (selectedRevisions.equals("0")){ //$NON-NLS-1$
- //ok put into comment state to await ======= and add info to log
- state = COMMENT;
- revision = BRANCH_REVISION;
- comment = new StringBuffer();
- }
- }
- break;
- case SYMBOLIC_NAMES:
- if (line.startsWith("keyword substitution:")) { //$NON-NLS-1$
- state = BEGIN;
- } else {
- int firstColon = line.indexOf(':');
- String tagName = internAndCopyString(line.substring(1, firstColon));
- String tagRevision = internAndCopyString(line.substring(firstColon + 2));
- versions.add(new VersionInfo(tagRevision, tagName));
- }
- break;
- case REVISION:
- // date: 2000/06/19 04:56:21; author: somebody; state: Exp; lines: +114 -45
- // get the creation date
- int endOfDateIndex = line.indexOf(';', 6);
- creationDate = convertFromLogTime(line.substring(6, endOfDateIndex) + " GMT"); //$NON-NLS-1$
-
- // get the author name
- int endOfAuthorIndex = line.indexOf(';', endOfDateIndex + 1);
- author = internAndCopyString(line.substring(endOfDateIndex + 11, endOfAuthorIndex));
-
- // get the file state (because this revision might be "dead")
- fileState = internAndCopyString(line.substring(endOfAuthorIndex + 10, line.indexOf(';', endOfAuthorIndex + 1)));
- comment = new StringBuffer();
- state = COMMENT;
- break;
- case COMMENT:
- // skip next line (info about branches) if it exists, if not then it is a comment line.
- if (line.startsWith("branches:")) break; //$NON-NLS-1$
- if (line.equals("=============================================================================") //$NON-NLS-1$
- || line.equals("----------------------------")) { //$NON-NLS-1$
- state = DONE;
- break;
- }
- //check for null if we are in the waiting to finish case (brought on by branches)
- if (comment == null)
- break;
-
- if (comment.length() != 0) comment.append('\n');
- comment.append(line);
- break;
- }
- if (state == DONE) {
- // we are only interested in tag names for this revision, remove all others.
- List thisRevisionTags = versions.isEmpty() ? Collections.EMPTY_LIST : new ArrayList(3);
- //a parallel lists for revision tags (used only for branches with no commits on them)
- List revisionVersions = versions.isEmpty() ? Collections.EMPTY_LIST : new ArrayList(3);
- for (Iterator i = versions.iterator(); i.hasNext();) {
- VersionInfo version = (VersionInfo) i.next();
- String tagName = version.getTagName();
- String tagRevision = version.getTagRevision();
-
- if (tagRevision.equals(revision) ||
- revision.equals(BRANCH_REVISION)) {
- int type = version.isBranch() ? CVSTag.BRANCH : CVSTag.VERSION;
- thisRevisionTags.add(new CVSTag(tagName, type));
- if (revision.equals(BRANCH_REVISION)){
- //also record the tag revision
- revisionVersions.add(tagRevision);
- }
- }
- }
-
- if (currentFile != null) {
- LogEntry entry = new LogEntry(currentFile, revision, author, creationDate,
- internString(comment.toString()), fileState, !thisRevisionTags.isEmpty() ? (CVSTag[]) thisRevisionTags.toArray(new CVSTag[thisRevisionTags.size()]) : NO_TAGS, !revisionVersions.isEmpty() ? (String[]) revisionVersions.toArray(new String[revisionVersions.size()]) : NO_VERSIONS);
- addEntry(entry);
- }
- state = BEGIN;
- }
- return OK;
- }
-
- protected void beginFile(ICVSRepositoryLocation location, String fileName) {
- currentFile = RemoteFile.create(fileName, location);
- versions.clear();
- }
-
- protected void addEntry(LogEntry entry) {
- listener.handleLogEntryReceived(entry);
- }
-
- protected void handleInvalidFileName(ICVSRepositoryLocation location, String badFilePath) {
- CVSProviderPlugin.log(IStatus.WARNING, "Invalid file path '" + badFilePath + "' received from " + location.toString(), null); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Converts a time stamp as sent from a cvs server for a "log" command into a
- * <code>Date</code>.
- */
- private Date convertFromLogTime(String modTime) {
- DateFormat format = LOG_DATE_FORMATTER;
- // Compatibility for older cvs version (pre 1.12.9)
- if (modTime.length() > 4 && modTime.charAt(4) == '/')
- format = LOG_DATE_FORMATTER_OLD;
-
- try {
- return format.parse(modTime);
- } catch (ParseException e) {
- // fallback is to return null
- return null;
- }
- }
-
- private String internAndCopyString(String string) {
- String internedString = (String) internedStrings.get(string);
- if (internedString == null) {
- internedString = new String(string);
- internedStrings.put(internedString, internedString);
- }
- return internedString;
- }
-
- private String internString(String string) {
- String internedString = (String) internedStrings.get(string);
- if (internedString == null) {
- internedString = string;
- internedStrings.put(internedString, internedString);
- }
- return internedString;
- }
-
- private static class VersionInfo {
- private final String version;
- private final boolean isBranch;
- private String tagRevision;
- private final String tagName;
-
- public VersionInfo(String version, String tagName) {
- this.version = version;
- this.tagName = tagName;
- this.isBranch = isBranchTag(version);
- tagRevision = version;
- if (isBranch) {
- int lastDot = version.lastIndexOf('.');
- if (lastDot == -1) {
- CVSProviderPlugin.log(IStatus.ERROR,
- NLS.bind(CVSMessages.LogListener_invalidRevisionFormat, new String[] { tagName, version }), null);
- } else {
- if (version.charAt(lastDot - 1) == '0' && version.charAt(lastDot - 2) == '.') {
- lastDot = lastDot - 2;
- }
- tagRevision = version.substring(0, lastDot);
- }
- }
- }
-
- public String getVersion() {
- return this.version;
- }
-
- public String getTagName() {
- return this.tagName;
- }
-
- public String getTagRevision() {
- return this.tagRevision;
- }
-
- public boolean isBranch() {
- return isBranch;
- }
-
- /** branch tags have odd number of segments or have
- * an even number with a zero as the second last segment
- * e.g: 1.1.1, 1.26.0.2 are branch revision numbers */
- private boolean isBranchTag(String tagName) {
- // First check if we have an odd number of segments (i.e. even number of dots)
- int numberOfDots = 0;
- int lastDot = 0;
- for (int i = 0; i < tagName.length(); i++) {
- if (tagName.charAt(i) == '.') {
- numberOfDots++;
- lastDot = i;
- }
- }
- if ((numberOfDots % 2) == 0) return true;
- if (numberOfDots == 1) return false;
-
- // If not, check if the second lat segment is a zero
- if (tagName.charAt(lastDot - 1) == '0' && tagName.charAt(lastDot - 2) == '.') return true;
- return false;
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java
deleted file mode 100644
index 99da58e17..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ModuleDefinitionsListener.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
-
-/*
- * This class pares the output of the "cvs checkout -c" command which returns the list of modules
- * defined in the CVSROOT/modules file.
- */
-public class ModuleDefinitionsListener extends CommandOutputListener {
-
- // the last line read from the context (used to accumulate multi-line definitions)
- private String lastLine = ""; //$NON-NLS-1$
-
- private Map moduleMap;
-
- public ModuleDefinitionsListener() {
- reset();
- }
-
- /*
- * @see ICommandOutputListener#messageLine(String, ICVSFolder, IProgressMonitor)
- */
- public IStatus messageLine(
- String line,
- ICVSRepositoryLocation location,
- ICVSFolder commandRoot,
- IProgressMonitor monitor) {
-
- // Lines that start with a space indicate a multi line entry
- if( line.charAt(0) == ' ' ) {
- lastLine += line;
- line = lastLine;
- }
- else
- lastLine = line;
-
- // Use the module name as the key so that multi-line modules will be recorded properly
- int firstSpace = line.indexOf(" "); //$NON-NLS-1$
- if (firstSpace > -1) {
- String module = line.substring(0, firstSpace);
- moduleMap.put(module, line);
- }
- return OK;
- }
-
- public String[] getModuleExpansions() {
- return (String[])moduleMap.values().toArray(new String[moduleMap.size()]);
- }
-
- public void reset() {
- this.moduleMap = new HashMap();
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/RDiffSummaryListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/RDiffSummaryListener.java
deleted file mode 100644
index ff704aacc..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/RDiffSummaryListener.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
-
-/**
- * This class parses the messages recieved in response to an "cvs rdiff -s ..." command
- */
-public class RDiffSummaryListener extends CommandOutputListener {
-
- private static final String RIGHT_REVISION_VARIABLE_NAME = "rightRevision"; //$NON-NLS-1$
- private static final String LEFT_REVISION_VARIABLE_NAME = "leftRevision"; //$NON-NLS-1$
- private static final String REMOTE_FILE_PATH_VARIABLE_NAME = "remoteFilePath"; //$NON-NLS-1$
- private static final String REMOTE_FOLDER_PATH_VARIABLE_NAME = "remoteFolderPath"; //$NON-NLS-1$
-
- private IFileDiffListener listener;
- private static ServerMessageLineMatcher DIRECTORY_MATCHER;
- private static ServerMessageLineMatcher FILE_DIFF_MATCHER;
- private static ServerMessageLineMatcher NEW_FILE_MATCHER;
- private static ServerMessageLineMatcher DELETED_FILE_MATCHER;
- private static ServerMessageLineMatcher DELETED_FILE_MATCHER2;
-
- static {
- // TODO: temprary until proper lifecycle is defined
- initializePatterns();
- }
- public static void initializePatterns() {
- try {
- DIRECTORY_MATCHER = new ServerMessageLineMatcher(
- IMessagePatterns.RDIFF_DIRECTORY, new String[] {REMOTE_FOLDER_PATH_VARIABLE_NAME});
- FILE_DIFF_MATCHER = new ServerMessageLineMatcher(
- IMessagePatterns.RDIFF_SUMMARY_FILE_DIFF, new String[] {REMOTE_FILE_PATH_VARIABLE_NAME, LEFT_REVISION_VARIABLE_NAME, RIGHT_REVISION_VARIABLE_NAME});
- NEW_FILE_MATCHER = new ServerMessageLineMatcher(
- IMessagePatterns.RDIFF_SUMMARY_NEW_FILE, new String[] {REMOTE_FILE_PATH_VARIABLE_NAME, RIGHT_REVISION_VARIABLE_NAME});
- DELETED_FILE_MATCHER = new ServerMessageLineMatcher(
- IMessagePatterns.RDIFF_SUMMARY_DELETED_FILE, new String[] {REMOTE_FILE_PATH_VARIABLE_NAME});
- DELETED_FILE_MATCHER2 = new ServerMessageLineMatcher(
- IMessagePatterns.RDIFF_SUMMARY_DELETED_FILE2, new String[] {REMOTE_FILE_PATH_VARIABLE_NAME, LEFT_REVISION_VARIABLE_NAME});
- } catch (CVSException e) {
- // This is serious as the listener will not function properly
- CVSProviderPlugin.log(e);
- }
- }
-
- public interface IFileDiffListener {
- public void fileDiff(
- String remoteFilePath,
- String leftRevision,
- String rightRevision);
- public void newFile(
- String remoteFilePath,
- String rightRevision);
- public void deletedFile(
- String remoteFilePath,
- String leftRevision);
- public void directory(String remoteFolderPath);
- }
-
- public RDiffSummaryListener(IFileDiffListener listener) {
- this.listener = listener;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#messageLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus messageLine(
- String line,
- ICVSRepositoryLocation location,
- ICVSFolder commandRoot,
- IProgressMonitor monitor) {
-
- Map variables = FILE_DIFF_MATCHER.processServerMessage(line);
- if (variables != null) {
- listener.fileDiff(
- (String)variables.get(REMOTE_FILE_PATH_VARIABLE_NAME),
- (String)variables.get(LEFT_REVISION_VARIABLE_NAME),
- (String)variables.get(RIGHT_REVISION_VARIABLE_NAME));
- return OK;
- }
-
- variables = NEW_FILE_MATCHER.processServerMessage(line);
- if (variables != null) {
- listener.newFile(
- (String)variables.get(REMOTE_FILE_PATH_VARIABLE_NAME),
- (String)variables.get(RIGHT_REVISION_VARIABLE_NAME));
- return OK;
- }
-
- variables = DELETED_FILE_MATCHER.processServerMessage(line);
- if (variables != null) {
- listener.deletedFile(
- (String)variables.get(REMOTE_FILE_PATH_VARIABLE_NAME),
- null);
- return OK;
- }
-
- variables = DELETED_FILE_MATCHER2.processServerMessage(line);
- if (variables != null) {
- listener.deletedFile(
- (String)variables.get(REMOTE_FILE_PATH_VARIABLE_NAME),
- (String)variables.get(LEFT_REVISION_VARIABLE_NAME));
- return OK;
- }
-
- return super.messageLine(line, location, commandRoot, monitor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#errorLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus errorLine(
- String line,
- ICVSRepositoryLocation location,
- ICVSFolder commandRoot,
- IProgressMonitor monitor) {
-
- Map variables = DIRECTORY_MATCHER.processServerMessage(line);
- if (variables != null) {
- listener.directory(
- (String)variables.get(REMOTE_FOLDER_PATH_VARIABLE_NAME));
- return OK;
- }
-
- return super.errorLine(line, location, commandRoot, monitor);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ServerMessageLineMatcher.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ServerMessageLineMatcher.java
deleted file mode 100644
index 7be00a490..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/ServerMessageLineMatcher.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-
-/**
- * This class extracts matches server lines to expected patterns and extracts
- * required information from the line.
- */
-public class ServerMessageLineMatcher {
-
- protected static final Pattern VARIABLE_MATCHING_PATTERN = Pattern.compile("(\\((\\w*):.*:\\2\\))"); //$NON-NLS-1$
-
- Pattern pattern;
- String[] variables;
-
- public ServerMessageLineMatcher(String template, String[] expectedVariables) throws CVSException {
- // Extract the variable names from the template
- Matcher matcher = VARIABLE_MATCHING_PATTERN.matcher(template);
- List variables = new ArrayList();
- while (matcher.find()) {
- if (matcher.groupCount() != 2) {
- IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.ServerMessageLineMatcher_5, new String[] { template }));
- throw new CVSException(status);
- }
- variables.add(matcher.group(2));
- }
- ensureMatches(template, variables, expectedVariables);
- this.variables = (String[]) variables.toArray(new String[variables.size()]);
-
- // Modify the template so it can be used to match message lines from the server
- // (i.e. remove the variable markup)
- for (Iterator iter = variables.iterator(); iter.hasNext();) {
- String element = (String) iter.next();
- template = template.replaceAll(element + ":", ""); //$NON-NLS-1$ //$NON-NLS-2$
- template = template.replaceAll(":" + element, ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Ensure that the number of groups in the pattern match the number of variables
- int count = 0;
- int start = -1;
- while ((start = template.indexOf('(', start + 1)) != -1) {
- count++;
- }
- if (count != variables.size()) {
- IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.ServerMessageLineMatcher_6, new String[] { template }));
- throw new CVSException(status);
- }
-
- // Create the pattern fir matching lines from the server
- this.pattern = Pattern.compile(template);
- }
-
- /*
- * Throw an exception if the found variables do not match the expected variables
- */
- private void ensureMatches(String template, List variables, String[] expectedVariables) throws CVSException {
- for (int i = 0; i < expectedVariables.length; i++) {
- String expected = expectedVariables[i];
- if (!variables.contains(expected)) {
- IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.ServerMessageLineMatcher_7, new String[] { expected, template }));
- throw new CVSException(status);
- }
- }
- }
-
- public Map processServerMessage(String line) {
- Matcher matcher = pattern.matcher(line);
- if (!matcher.find()) return null;
- Assert.isTrue(matcher.groupCount() == variables.length);
- Map result = new HashMap();
- for (int i = 1; i <= matcher.groupCount(); i++) {
- result.put(variables[i - 1], matcher.group(i));
- }
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java
deleted file mode 100644
index e172f03a5..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-public class StatusListener extends CommandOutputListener {
- private static boolean isFolder = false;
- private IStatusListener statusListener;
-
- public StatusListener(IStatusListener statusListener) {
- this.statusListener = statusListener;
- }
-
- public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot,
- IProgressMonitor monitor) {
-
- // We're only concerned about file revisions.
- if (line.startsWith(" Repository revision:")) { //$NON-NLS-1$
- if (!line.startsWith(" Repository revision: No revision control file")) { //$NON-NLS-1$
- int separatingTabIndex = line.indexOf('\t', 24);
- String remoteRevision = line.substring(24, separatingTabIndex);
-
- // This is the full location on the server (e.g. /home/cvs/repo/project/file.txt)
- String fileLocation = line.substring(separatingTabIndex + 1, line.length() - 2);
-
- // Inform the listener about the file revision
- statusListener.fileStatus(commandRoot, removeAtticSegment(fileLocation), remoteRevision);
- }
- }
- return OK;
- }
-
- public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot, IProgressMonitor monitor) {
- String serverMessage = getServerMessage(line, location);
- if (serverMessage != null) {
- if (serverMessage.startsWith("conflict:")) {//$NON-NLS-1$
- // We get this because we made up an entry line to send to the server
- // Therefore, we make this a warning!!!
- return new CVSStatus(IStatus.WARNING, CVSStatus.CONFLICT, line, commandRoot);
- }
- if (serverMessage.startsWith("Examining")) {//$NON-NLS-1$
- isFolder = true;
- return OK;
- }
- }
- if (isFolder) {
- // This used to do something but it was obviously wrong and there was no indication
- // why it was needed. Therefore, I have removed the code to see if anything is effected
- isFolder = false;
- }
- return super.errorLine(line, location, commandRoot, monitor);
- }
-
- /**
- * If the status returns that the file is in the Attic, then remove the
- * Attic segment. This is because files added to a branch that are not in
- * the main trunk (HEAD) are added to the Attic but cvs does magic on
- * updateto put them in the correct location.
- * (e.g. /project/Attic/file.txt -> /project/file.txt)
- */
- private String removeAtticSegment(String path) {
- return Util.removeAtticSegment(path);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java
deleted file mode 100644
index a2e041c98..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/TagListener.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
-
-public class TagListener extends CommandOutputListener {
-
- /*
- * @see ICommandOutputListener#messageLine(String, ICVSFolder, IProgressMonitor)
- */
- public IStatus messageLine(
- String line,
- ICVSRepositoryLocation location,
- ICVSFolder commandRoot,
- IProgressMonitor monitor) {
-
- // Received a warning in the form:
- // W folder/file : v1 already exists on version 1.2 : NOT MOVING tag to version 1.3
- // Indicate this as an error since no tagging was done
- if(line.length() >= 2 && line.charAt(0) == 'W' && line.charAt(1) == ' ') {
- return new CVSStatus(IStatus.ERROR, CVSStatus.TAG_ALREADY_EXISTS, line.substring(2), commandRoot);
- }
-
- return OK;
- }
-
- /*
- * @see ICommandOutputListener#errorLine(String, ICVSFolder, IProgressMonitor)
- */
- public IStatus errorLine(
- String line,
- ICVSRepositoryLocation location,
- ICVSFolder commandRoot,
- IProgressMonitor monitor) {
-
- // Ignore the lines: Tagging folder1/folder2
- String serverMessage = getServerMessage(line, location);
- if ((serverMessage != null) && serverMessage.startsWith("Tagging")) { //$NON-NLS-1$
- return OK;
- }
- String rtagMessage = getServerRTagMessage(line, location);
- if(rtagMessage != null && rtagMessage.startsWith("Tagging") ) { //$NON-NLS-1$
- return OK;
- }
-
- return super.errorLine(line, location, commandRoot, monitor);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java
deleted file mode 100644
index 20ec349b3..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/UpdateListener.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.client.listeners;
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-public class UpdateListener extends CommandOutputListener {
-
- // Pattern matchers
- private static ServerMessageLineMatcher MERGED_BINARY_FILE_LINE_1;
- private static ServerMessageLineMatcher MERGED_BINARY_FILE_LINE_2;
-
- // Pattern Variables
- private static final String REVISION_VARIABLE_NAME = "revision"; //$NON-NLS-1$
- private static final String LOCAL_FILE_PATH_VARIABLE_NAME = "localFilePath"; //$NON-NLS-1$
- private static final String BACKUP_FILE_VARIABLE_NAME = "backupFile"; //$NON-NLS-1$
-
- static {
- try {
- String line1 = "revision " //$NON-NLS-1$
- + Util.getVariablePattern(IMessagePatterns.REVISION_PATTERN, REVISION_VARIABLE_NAME)
- + " from repository is now in " //$NON-NLS-1$
- + Util.getVariablePattern(IMessagePatterns.FILE_PATH_PATTERN, LOCAL_FILE_PATH_VARIABLE_NAME);
- MERGED_BINARY_FILE_LINE_1 = new ServerMessageLineMatcher(
- line1,
- new String[] {REVISION_VARIABLE_NAME, LOCAL_FILE_PATH_VARIABLE_NAME});
- String line2 = "file from working directory is now in " //$NON-NLS-1$
- + Util.getVariablePattern(IMessagePatterns.REVISION_PATTERN, BACKUP_FILE_VARIABLE_NAME);
- MERGED_BINARY_FILE_LINE_2 = new ServerMessageLineMatcher(
- line2,
- new String[] {BACKUP_FILE_VARIABLE_NAME});
-
- } catch (CVSException e) {
- // Shouldn't happen
- CVSProviderPlugin.log(e);
- }
- }
-
- IUpdateMessageListener updateMessageListener;
- boolean merging = false;
- boolean mergingBinary = false;
- String mergedBinaryFileRevision, mergedBinaryFilePath;
-
- public UpdateListener(IUpdateMessageListener updateMessageListener) {
- this.updateMessageListener = updateMessageListener;
- }
-
- public IStatus messageLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot,
- IProgressMonitor monitor) {
- mergingBinary = false;
- if (updateMessageListener == null) return OK;
- if(line.startsWith("Merging differences")) { //$NON-NLS-1$
- merging = true;
- } else if(line.indexOf(' ')==1) {
- // We have a message that indicates the type of update. The possible messages are
- // defined by the prefix constants MLP_*.
- String path = line.substring(2);
- char changeType = line.charAt(0);
-
- // calculate change type
- int type = 0;
- switch(changeType) {
- case 'A': type = Update.STATE_ADDED_LOCAL; break; // new file locally that was added but not comitted to server yet
- case '?': type = Update.STATE_UNKOWN; break; // new file locally but not added to server
- case 'U': type = Update.STATE_REMOTE_CHANGES; break; // remote changes to an unmodified local file
- case 'R': type = Update.STATE_DELETED; break; // removed locally but still exists on the server
- case 'M': type = Update.STATE_MODIFIED; break; // modified locally
- case 'C': type = Update.STATE_CONFLICT; break; // modified locally and on the server but cannot be auto-merged
- case 'D': type = Update.STATE_DELETED; break; // deleted locally but still exists on server
- default: type = Update.STATE_NONE;
- }
-
- if (merging) {
- // If we are merging the modified prefix is used both to show merges and
- // local changes. We have to detect this case and use a more specific change
- // type.
- if (type == Update.STATE_MODIFIED)
- type = Update.STATE_MERGEABLE_CONFLICT;
- merging = false;
- }
- updateMessageListener.fileInformation(type, commandRoot, path);
- }
- return OK;
- }
-
- /**
- * This handler is used by the RemoteResource hierarchy to retrieve E messages
- * from the CVS server in order to determine the folders contained in a parent folder.
- *
- * WARNING: This class parses the message output to determine the state of files in the
- * repository. Unfortunately, these messages seem to be customizable on a server by server basis.
- *
- * Here's a list of responses we expect in various situations:
- *
- * Directory exists remotely:
- * cvs server: Updating folder1/folder2
- * Directory doesn't exist remotely:
- * cvs server: skipping directory folder1/folder2
- * New (or unknown) remote directory
- * cvs server: New Directory folder1/folder2
- * File removed remotely
- * cvs server: folder1/file.ext is no longer in the repository
- * cvs server: warning: folder1/file.ext is not (any longer) pertinent
- * Locally added file was added remotely as well
- * cvs server: conflict: folder/file.ext created independently by second party
- * File removed locally and modified remotely
- * cvs server: conflict: removed file.txt was modified by second party
- * File modified locally but removed remotely
- * cvs server: conflict: file.txt is modified but no longer in the repository
- * Ignored Messages
- * cvs server: cannot open directory ...
- * cvs server: nothing known about ...
- * Tag error that really means there are no files in a directory
- * cvs [server aborted]: no such tag
- * Merge contained conflicts
- * rcsmerge: warning: conflicts during merge
- * Binary file conflict
- * cvs server: nonmergeable file needs merge
- * cvs server: revision 1.4 from repository is now in a1/a2/test
- * cvs server: file from working directory is now in .#test.1.3
- */
- public IStatus errorLine(String line, ICVSRepositoryLocation location, ICVSFolder commandRoot,
- IProgressMonitor monitor) {
-
- try {
- // Reset flag globally here because we have to many exit points
- boolean wasMergingBinary = mergingBinary;
- mergingBinary = false;
- String serverMessage = getServerMessage(line, location);
- if (serverMessage != null) {
- // Strip the prefix from the line
- String message = serverMessage;
- if (message.startsWith("Updating")) { //$NON-NLS-1$
- if (updateMessageListener != null) {
- String path = message.substring(9);
- updateMessageListener.directoryInformation(commandRoot, path, false);
- }
- return OK;
- } else if (message.startsWith("skipping directory")) { //$NON-NLS-1$
- if (updateMessageListener != null) {
- String path = message.substring(18).trim();
- updateMessageListener.directoryDoesNotExist(commandRoot, path);
- }
- return OK;
- } else if (message.startsWith("New directory")) { //$NON-NLS-1$
- if (updateMessageListener != null) {
- String path = message.substring(15, message.lastIndexOf('\''));
- updateMessageListener.directoryInformation(commandRoot, path, true);
- }
- return OK;
- } else if (message.endsWith("is no longer in the repository")) { //$NON-NLS-1$
- if (updateMessageListener != null) {
- String filename = message.substring(0, message.length() - 31);
- filename = stripQuotes(filename);
- updateMessageListener.fileDoesNotExist(commandRoot, filename);
- }
- return OK;
- } else if (message.startsWith("conflict:")) { //$NON-NLS-1$
- /*
- * We can get the following conflict warnings
- * cvs server: conflict: folder/file.ext created independently by second party
- * cvs server: conflict: removed file.txt was modified by second party
- * cvs server: conflict: file.txt is modified but no longer in the repository
- * If we get the above line, we have conflicting additions or deletions and we can expect a server error.
- * We still get "C foler/file.ext" so we don't need to do anything else (except in the remotely deleted case)
- */
- if (updateMessageListener != null) {
- if (message.endsWith("is modified but no longer in the repository")) { //$NON-NLS-1$
- // The "C foler/file.ext" will come after this so if whould be ignored!
- String filename = message.substring(10, message.length() - 44);
- filename = stripQuotes(filename);
- updateMessageListener.fileDoesNotExist(commandRoot, filename);
- }
- }
- return new CVSStatus(IStatus.WARNING, CVSStatus.CONFLICT, line, commandRoot);
- } else if (message.startsWith("warning:")) { //$NON-NLS-1$
- /*
- * We can get the following conflict warnings
- * cvs server: warning: folder1/file.ext is not (any longer) pertinent
- * If we get the above line, we have local changes to a remotely deleted file.
- */
- if (updateMessageListener != null) {
- if (message.endsWith("is not (any longer) pertinent")) { //$NON-NLS-1$
- String filename = message.substring(9, message.length() - 30);
- updateMessageListener.fileDoesNotExist(commandRoot, filename);
- }
- }
- return new CVSStatus(IStatus.WARNING, CVSStatus.CONFLICT, line, commandRoot);
- } else if (message.startsWith("conflicts")) { //$NON-NLS-1$
- // This line is info only. The server doesn't report an error.
- return new CVSStatus(IStatus.INFO, CVSStatus.CONFLICT, line, commandRoot);
- } else if (message.startsWith("nonmergeable file needs merge")) { //$NON-NLS-1$
- mergingBinary = true;
- mergedBinaryFileRevision = null;
- mergedBinaryFilePath = null;
- return OK;
- } else if (wasMergingBinary) {
- Map variables = MERGED_BINARY_FILE_LINE_1.processServerMessage(message);
- if (variables != null) {
- mergedBinaryFileRevision = (String)variables.get(REVISION_VARIABLE_NAME);
- mergedBinaryFilePath = (String)variables.get(LOCAL_FILE_PATH_VARIABLE_NAME);
- mergingBinary = true;
- return OK;
- }
- variables = MERGED_BINARY_FILE_LINE_2.processServerMessage(message);
- if (variables != null) {
- String backupFile = (String)variables.get(BACKUP_FILE_VARIABLE_NAME);
- try {
- if (mergedBinaryFileRevision != null && mergedBinaryFilePath != null) {
- ICVSFile file = commandRoot.getFile(mergedBinaryFilePath);
- IResource resource = file.getIResource();
- if (resource != null) {
- return new CVSStatus(IStatus.ERROR, CVSStatus.UNMEGERED_BINARY_CONFLICT,
- NLS.bind(CVSMessages.UpdateListener_0, (new Object[] {
- resource.getFullPath().toString(),
- mergedBinaryFileRevision,
- resource.getFullPath().removeLastSegments(1).append(backupFile).toString()})), commandRoot);
- }
- }
- } catch (CVSException e1) {
- CVSProviderPlugin.log(e1);
- }
- return OK;
- }
- }
-
- // Fallthrough case for "cvs server" messages
- if (!message.startsWith("cannot open directory") //$NON-NLS-1$
- && !message.startsWith("nothing known about")) { //$NON-NLS-1$
- return super.errorLine(line, location, commandRoot, monitor);
- }
- } else {
- String serverAbortedMessage = getServerAbortedMessage(line, location);
- if (serverAbortedMessage != null) {
- // Strip the prefix from the line
- String message = serverAbortedMessage;
- if (message.startsWith("no such tag")) { //$NON-NLS-1$
- // This is reported from CVS when a tag is used on the update there are no files in the directory
- // To get the folders, the update request should be re-issued for HEAD
- return new CVSStatus(IStatus.WARNING, CVSStatus.NO_SUCH_TAG, line, commandRoot);
- } else if (message.startsWith("Numeric join") && message.endsWith("may not contain a date specifier")) { //$NON-NLS-1$ //$NON-NLS-2$
- // This error indicates a join failed because a date tag was used
- return super.errorLine(line, location, commandRoot, monitor);
- } else {
- return super.errorLine(line, location, commandRoot, monitor);
- }
- } else if (line.equals("rcsmerge: warning: conflicts during merge")) { //$NON-NLS-1$
- // There were conflicts in the merge
- return new CVSStatus(IStatus.WARNING, CVSStatus.CONFLICT, line, commandRoot);
- }
- }
- } catch (StringIndexOutOfBoundsException e) {
- // Something went wrong in the parsing of the message.
- // Return a status indicating the problem
- if (CVSProviderPlugin.getPlugin().isDebugging()) {
- System.out.println("Error parsing E line: " + line); //$NON-NLS-1$
- }
- return new CVSStatus(IStatus.ERROR, CVSStatus.ERROR_LINE_PARSE_FAILURE, line, commandRoot);
- }
- return super.errorLine(line, location, commandRoot, monitor);
- }
-
- private String stripQuotes(String filename) {
- // CVS version 12 fix - filenames are returned inside quotes
- // Fixes bug 49056
- if (filename.startsWith("`") && filename.endsWith("'")) //$NON-NLS-1$ //$NON-NLS-2$
- filename = filename.substring(1,filename.length()-1);
- return filename;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException.java
deleted file mode 100644
index b2ce58c70..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.connection;
-
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-
-public class CVSAuthenticationException extends CVSException {
-
- private static final long serialVersionUID = 1L;
-
- private int retryStatus = 0;
-
- /**
- * Code indicating that authentication can be retried after
- * prompting the user for corrected authentication information
- */
- public static final int RETRY = 1;
-
- /**
- * Code indicating that authentication should not be reattempted.
- */
- public static final int NO_RETRY = 2;
-
- /**
- * Creates a new <code>CVSAuthenticationException</code>
- *
- * @param status the status result describing this exception.
- */
- private CVSAuthenticationException(IStatus status) {
- super(status);
- }
-
- /**
- * Creates a new <code>CVSAuthenticationException</code>
- *
- * @param detail a message that describes the exception in detail.
- * @param code indicates whether authentication can be retried or not
- */
- public CVSAuthenticationException(String detail, int retryStatus) {
- this(new CVSStatus(IStatus.ERROR, CVSStatus.AUTHENTICATION_FAILURE,NLS.bind(CVSMessages.CVSAuthenticationException_detail, (new Object[] { detail })), (IResource) null)); //
- this.retryStatus = retryStatus;
- }
-
- /**
- * Creates a new <code>CVSAuthenticationException</code>
- *
- * @param detail a message that describes the exception in detail.
- * @param code indicates whether authentication can be retried or not
- * @param the location of the CVS server
- */
- public CVSAuthenticationException(String detail, int retryStatus, ICVSRepositoryLocation cvsLocation) {
- this(new CVSStatus(IStatus.ERROR, CVSStatus.AUTHENTICATION_FAILURE,NLS.bind(CVSMessages.CVSAuthenticationException_detail, (new Object[] { detail })),cvsLocation)); //
- this.retryStatus = retryStatus;
- }
-
- /**
- * Creates a new <code>CVSAuthenticationException</code>
- *
- * @param detail a message that describes the exception in detail.
- * @param code indicates whether authentication can be retried or not
- * @param the location of the CVS server
- * @param the exception
- */
- public CVSAuthenticationException(String detail, int retryStatus,ICVSRepositoryLocation cvsLocation, Exception e) {
- this(new CVSStatus(IStatus.ERROR, CVSStatus.AUTHENTICATION_FAILURE , NLS.bind(CVSMessages.CVSAuthenticationException_detail, (new Object[] { detail })), e, cvsLocation)); //
- this.retryStatus = retryStatus;
- }
-
- public int getRetryStatus() {
- return retryStatus;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException.java
deleted file mode 100644
index 7cdb14b3b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.connection;
-
-
-import java.io.InterruptedIOException;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-
-public class CVSCommunicationException extends CVSException {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Create a new <code>CVSCommunicationException</code> with the
- * given status.
- */
- private CVSCommunicationException(IStatus status) {
- super(status);
- }
- /**
- * Create a new <code>CVSCommunicationException</code> with the
- * given message.
- */
- public CVSCommunicationException(String message) {
- super(message);
- }
-
- /**
- * Create a new <code>CVSCommunicationException</code>.
- *
- * @param message a message describing the exception in detail.
- * @param the CVS server
- * @param the caught exception that has caused the communication
- * exception.
- */
- public CVSCommunicationException(String message, ICVSRepositoryLocation cvsLocation, Exception e) {
- this(new CVSStatus(IStatus.ERROR, CVSStatus.COMMUNICATION_FAILURE, message, e, cvsLocation));
- }
-
- /**
- * Create a new <code>CVSCommunicationException </code>.
- *
- * @param the caught exception that has caused the communication
- * exception.
- * @param the location of the CVS server.
- */
- public CVSCommunicationException(ICVSRepositoryLocation cvsLocation,Exception e) {
- this(getStatusFor(e,cvsLocation));
- }
-
- private static IStatus getStatusFor(Exception e,ICVSRepositoryLocation cvsLocation) {
- if (e instanceof InterruptedIOException) {
- MultiStatus status = new MultiStatus(CVSProviderPlugin.ID, 0, getMessageFor(e), e);
- status.add(new CVSStatus(IStatus.ERROR, CVSStatus.COMMUNICATION_FAILURE, CVSMessages.CVSCommunicationException_interruptCause, cvsLocation));
- status.add(new CVSStatus(IStatus.ERROR, CVSStatus.COMMUNICATION_FAILURE, CVSMessages.CVSCommunicationException_interruptSolution, cvsLocation));
- status.add(new CVSStatus(IStatus.ERROR, CVSStatus.COMMUNICATION_FAILURE, CVSMessages.CVSCommunicationException_alternateInterruptCause, cvsLocation));
- status.add(new CVSStatus(IStatus.ERROR, CVSStatus.COMMUNICATION_FAILURE, CVSMessages.CVSCommunicationException_alternateInterruptSolution, cvsLocation));
- return status;
- }
- return new CVSStatus(IStatus.ERROR,CVSStatus.COMMUNICATION_FAILURE, getMessageFor(e), e, cvsLocation);
- }
-
- public static String getMessageFor(Throwable throwable) {
- String message = Policy.getMessage(getMessageKey(throwable));
- if (message == null) {
- message = NLS.bind(CVSMessages.CVSCommunicationException_io, (new Object[] {throwable.toString()}));
- } else {
- message = NLS.bind(message, (new Object[] {throwable.getMessage()}));
- }
- return message;
- }
-
- private static String getMessageKey(Throwable t) {
- String name = t.getClass().getName();
- name = name.replace('.', '_');
- return name;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java
deleted file mode 100644
index e18d617f3..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java
+++ /dev/null
@@ -1,1258 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.connection;
-
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ILock;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.*;
-import org.eclipse.team.internal.ccvs.core.resources.*;
-import org.eclipse.team.internal.ccvs.core.util.KnownRepositories;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * This class manages a CVS repository location.
- *
- * It provides the mapping between connection method name and the
- * plugged in ICunnectionMethod.
- *
- * It parses location strings into instances.
- *
- * It provides a method to open a connection to the server along
- * with a method to validate that connections can be made.
- *
- * It manages its user info using the plugged in IUserAuthenticator
- * (unless a username and password are provided as part of the creation
- * string, in which case, no authenticator is used).
- *
- * Instances must be disposed of when no longer needed in order to
- * notify the authenticator so cached properties can be cleared
- *
- */
-public class CVSRepositoryLocation extends PlatformObject implements ICVSRepositoryLocation, IUserInfo {
-
- /**
- * The name of the preferences node in the CVS preferences that contains
- * the known repositories as its children.
- */
- public static final String PREF_REPOSITORIES_NODE = "repositories"; //$NON-NLS-1$
-
- /*
- * The name of the node in the default scope that has the default settings
- * for a repository.
- */
- private static final String DEFAULT_REPOSITORY_SETTINGS_NODE = "default_repository_settings"; //$NON-NLS-1$
-
- // Preference keys used to persist the state of the location
- public static final String PREF_LOCATION = "location"; //$NON-NLS-1$
- public static final String PREF_SERVER_ENCODING = "encoding"; //$NON-NLS-1$
-
- // server platform constants
- public static final int UNDETERMINED_PLATFORM = 0;
- public static final int CVS_SERVER = 1;
- public static final int CVSNT_SERVER = 2;
- public static final int UNSUPPORTED_SERVER = 3;
- public static final int UNKNOWN_SERVER = 4;
-
- // static variables for extension points
- private static IUserAuthenticator authenticator;
- private static IConnectionMethod[] pluggedInConnectionMethods = null;
-
- // Locks for ensuring that authentication to a host is serialized
- // so that invalid passwords do not result in account lockout
- private static Map hostLocks = new HashMap();
-
- private IConnectionMethod method;
- private String user;
- private String password;
- private String host;
- private int port;
- private String root;
- private boolean userFixed;
- private boolean passwordFixed;
- private boolean allowCaching;
-
- private int serverPlatform = UNDETERMINED_PLATFORM;
-
- public static final char COLON = ':';
- public static final char SEMICOLON = ';';
- public static final char HOST_SEPARATOR = '@';
- public static final char PORT_SEPARATOR = '#';
- public static final boolean STANDALONE_MODE = (System.getProperty("eclipse.cvs.standalone")==null) ? //$NON-NLS-1$
- false :(Boolean.valueOf(System.getProperty("eclipse.cvs.standalone")).booleanValue()); //$NON-NLS-1$
-
- // command to start remote cvs in server mode
- private static final String INVOKE_SVR_CMD = "server"; //$NON-NLS-1$
-
- // fields needed for caching the password
- public static final String INFO_PASSWORD = "org.eclipse.team.cvs.core.password";//$NON-NLS-1$
- public static final String INFO_USERNAME = "org.eclipse.team.cvs.core.username";//$NON-NLS-1$
- public static final String AUTH_SCHEME = "";//$NON-NLS-1$
- public static final URL FAKE_URL;
-
- /*
- * Fields used to create the EXT command invocation
- */
- public static final String USER_VARIABLE = "{user}"; //$NON-NLS-1$
- public static final String PASSWORD_VARIABLE = "{password}"; //$NON-NLS-1$
- public static final String HOST_VARIABLE = "{host}"; //$NON-NLS-1$
- public static final String PORT_VARIABLE = "{port}"; //$NON-NLS-1$
-
- /*
- * Field that indicates which connection method is to be used for
- * locations that use the EXT connection method.
- */
- private static String extProxy;
-
- /*
- * Field that indicates that the last connection attempt made to
- * this repository location failed due to an authentication failure.
- * When this is set, subsequent attempts should prompt before attempting to connect
- */
- private boolean previousAuthenticationFailed = false;
-
- static {
- URL temp = null;
- try {
- temp = new URL("http://org.eclipse.team.cvs.core");//$NON-NLS-1$
- } catch (MalformedURLException e) {
- // Should never fail
- }
- FAKE_URL = temp;
- }
-
- /**
- * Return the preferences node whose child nodes are teh know repositories
- * @return a preferences node
- */
- public static Preferences getParentPreferences() {
- return CVSProviderPlugin.getPlugin().getInstancePreferences().node(PREF_REPOSITORIES_NODE);
- }
-
- /**
- * Return a preferences node that contains suitabel defaults for a
- * repository location.
- * @return a preferences node
- */
- public static Preferences getDefaultPreferences() {
- Preferences defaults = new DefaultScope().getNode(CVSProviderPlugin.ID).node(DEFAULT_REPOSITORY_SETTINGS_NODE);
- defaults.put(PREF_SERVER_ENCODING, getDefaultEncoding());
- return defaults;
- }
-
- private static String getDefaultEncoding() {
- return System.getProperty("file.encoding", "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Set the proxy connection method that is to be used when a
- * repository location has the ext connection method. This is
- * usefull with the extssh connection method as it can be used to
- * kepp the sandbox compatible with the command line client.
- * @param string
- */
- public static void setExtConnectionMethodProxy(String string) {
- extProxy = string;
- }
-
- /**
- * Create a repository location instance from the given properties.
- * The supported properties are:
- *
- * connection The connection method to be used
- * user The username for the connection (optional)
- * password The password used for the connection (optional)
- * host The host where the repository resides
- * port The port to connect to (optional)
- * root The server directory where the repository is located
- * encoding The file system encoding of the server
- */
- public static CVSRepositoryLocation fromProperties(Properties configuration) throws CVSException {
- // We build a string to allow validation of the components that are provided to us
- String connection = configuration.getProperty("connection");//$NON-NLS-1$
- if (connection == null)
- connection = "pserver";//$NON-NLS-1$
- IConnectionMethod method = getPluggedInConnectionMethod(connection);
- if (method == null)
- throw new CVSException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, NLS.bind(CVSMessages.CVSRepositoryLocation_methods, (new Object[] {getPluggedInConnectionMethodNames()})), null));//
- String user = configuration.getProperty("user");//$NON-NLS-1$
- if (user.length() == 0)
- user = null;
- String password = configuration.getProperty("password");//$NON-NLS-1$
- if (user == null)
- password = null;
- String host = configuration.getProperty("host");//$NON-NLS-1$
- if (host == null)
- throw new CVSException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, CVSMessages.CVSRepositoryLocation_hostRequired, null));//
- String portString = configuration.getProperty("port");//$NON-NLS-1$
- int port;
- if (portString == null)
- port = ICVSRepositoryLocation.USE_DEFAULT_PORT;
- else
- port = Integer.parseInt(portString);
- String root = configuration.getProperty("root");//$NON-NLS-1$
- if (root == null)
- throw new CVSException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, CVSMessages.CVSRepositoryLocation_rootRequired, null));//
-
- String encoding = configuration.getProperty("encoding"); //$NON-NLS-1$
-
- return new CVSRepositoryLocation(method, user, password, host, port, root, encoding, user != null, false);
- }
-
- /**
- * Parse a location string and return a CVSRepositoryLocation.
- *
- * On failure, the status of the exception will be a MultiStatus
- * that includes the original parsing error and a general status
- * displaying the passed location and proper form. This form is
- * better for logging, etc.
- */
- public static CVSRepositoryLocation fromString(String location) throws CVSException {
- try {
- return fromString(location, false);
- } catch (CVSException e) {
- // Parsing failed. Include a status that
- // shows the passed location and the proper form
- MultiStatus error = new MultiStatus(CVSProviderPlugin.ID, IStatus.ERROR, NLS.bind(CVSMessages.CVSRepositoryLocation_invalidFormat, (new Object[] {location})), null);//
- error.merge(new CVSStatus(IStatus.ERROR, CVSMessages.CVSRepositoryLocation_locationForm));//
- error.merge(e.getStatus());
- throw new CVSException(error);
- }
- }
-
- /**
- * Parse a location string and return a CVSRepositoryLocation.
- *
- * The valid format (from the cederqvist) is:
- *
- * :method:[[user][:password]@]hostname[:[port]]/path/to/repository
- *
- * However, this does not work with CVS on NT so we use the format
- *
- * :method:[user[:password]@]hostname[#port]:/path/to/repository
- *
- * Some differences to note:
- * The : after the host/port is not optional because of NT naming including device
- * e.g. :pserver:username:password@hostname#port:D:\cvsroot
- *
- * Also parse alternative format from WinCVS, which stores connection
- * parameters such as username and hostname in method options:
- *
- * :method[;option=arg...]:other_connection_data
- *
- * e.g. :pserver;username=anonymous;hostname=localhost:/path/to/repository
- *
- * If validateOnly is true, this method will always throw an exception.
- * The status of the exception indicates success or failure. The status
- * of the exception contains a specific message suitable for displaying
- * to a user who has knowledge of the provided location string.
- * @see CVSRepositoryLocation.fromString(String)
- */
- public static CVSRepositoryLocation fromString(String location, boolean validateOnly) throws CVSException {
- String errorMessage = null;
- try {
- // Get the connection method
- errorMessage = CVSMessages.CVSRepositoryLocation_parsingMethod;
- int start = location.indexOf(COLON);
- String methodName;
- int end;
- // For parsing alternative location format
- int optionStart = location.indexOf(SEMICOLON);
- HashMap hmOptions = new HashMap();
-
- if (start == 0) {
- end = location.indexOf(COLON, start + 1);
-
- // Check for alternative location syntax
- if (optionStart != -1) {
- // errorMessage = CVSMessages.CVSRepositoryLocation_parsingMethodOptions;
- methodName = location.substring(start + 1, optionStart);
- // Save options in hash table
- StringTokenizer stOpt = new StringTokenizer(
- location.substring(optionStart+1, end),
- "=;" //$NON-NLS-1$
- );
- while (stOpt.hasMoreTokens()) {
- hmOptions.put(stOpt.nextToken(), stOpt.nextToken());
- }
- start = end + 1;
- } else {
- methodName = location.substring(start + 1, end);
- start = end + 1;
- }
- } else {
- // this could be an alternate format for ext: username:password@host:path
- methodName = "ext"; //$NON-NLS-1$
- start = 0;
- }
-
- IConnectionMethod method = getPluggedInConnectionMethod(methodName);
- if (method == null)
- throw new CVSException(new CVSStatus(IStatus.ERROR, NLS.bind(CVSMessages.CVSRepositoryLocation_methods, (new Object[] {getPluggedInConnectionMethodNames()}))));//
-
- // Get the user name and password (if provided)
- errorMessage = CVSMessages.CVSRepositoryLocation_parsingUser;
-
- end = location.indexOf(HOST_SEPARATOR, start);
- String user = null;
- String password = null;
- // if end is -1 then there is no host separator meaning that the username is not present
- // or set in options of alternative-style location string
- if (end != -1) {
- // Get the optional user and password
- user = location.substring(start, end);
- // Separate the user and password (if there is a password)
- start = user.indexOf(COLON);
- if (start != -1) {
- errorMessage = CVSMessages.CVSRepositoryLocation_parsingPassword;
- password = user.substring(start+1);
- user = user.substring(0, start);
- }
- // Set start to point after the host separator
- start = end + 1;
- } else if (optionStart != -1) {
- // alternative location string data
- // errorMessage = CVSMessages.CVSRepositoryLocation_parsingOptionsUsername;
- if (hmOptions.containsKey("username")) user = hmOptions.get("username").toString(); //$NON-NLS-1$ //$NON-NLS-2$
- // errorMessage = CVSMessages.CVSRepositoryLocation_parsingOptionsPassword;
- if (hmOptions.containsKey("password")) password = hmOptions.get("password").toString(); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Get the host (and port)
- errorMessage = CVSMessages.CVSRepositoryLocation_parsingHost;
- end= location.indexOf(COLON, start);
- int hostEnd = end;
- if (end == -1) {
- // The last colon is optional so look for the slash that starts the path
- end = location.indexOf('/', start);
- hostEnd = end;
- // Decrement the end since the slash is part of the path
- if (end != -1) end--;
- }
- String host = (optionStart != -1) ? hmOptions.get("hostname").toString() : location.substring(start, hostEnd); //$NON-NLS-1$
- int port = USE_DEFAULT_PORT;
- boolean havePort = false;
- if (hmOptions.containsKey("port")) { //$NON-NLS-1$
- port = Integer.parseInt(hmOptions.get("port").toString()); //$NON-NLS-1$
- havePort = true;
- }
- // Separate the port and host if there is a port
- start = host.indexOf(PORT_SEPARATOR);
- if (start != -1) {
- try {
- // Initially, we used a # between the host and port
- errorMessage = CVSMessages.CVSRepositoryLocation_parsingPort;
- port = Integer.parseInt(host.substring(start+1));
- host = host.substring(0, start);
- havePort = true;
- } catch (NumberFormatException e) {
- // Ignore this as the #1234 port could be part of a proxy host string
- }
- }
- if (!havePort) {
- // In the correct CVS format, the port follows the COLON
- errorMessage = CVSMessages.CVSRepositoryLocation_parsingPort;
- int index = end;
- char c = location.charAt(++index);
- String portString = new String();
- while (Character.isDigit(c)) {
- portString += c;
- c = location.charAt(++index);
- }
- if (portString.length() > 0) {
- end = index - 1;
- port = Integer.parseInt(portString);
- }
- }
-
- // Get the repository path (translating backslashes to slashes)
- errorMessage = CVSMessages.CVSRepositoryLocation_parsingRoot;
- start = end + 1;
- String root = location.substring(start);
-
- if (validateOnly)
- throw new CVSException(new CVSStatus(IStatus.OK, CVSMessages.ok));//
- return new CVSRepositoryLocation(method, user, password, host, port, root, null /* encoding */, (user != null), (password != null));
- }
- catch (IndexOutOfBoundsException e) {
- // We'll get here if anything funny happened while extracting substrings
- IStatus status = new CVSStatus(IStatus.ERROR, errorMessage);
- throw new CVSException(status);
- }
- catch (NumberFormatException e) {
- IStatus status = new CVSStatus(IStatus.ERROR, errorMessage);
- // We'll get here if we couldn't parse a number
- throw new CVSException(status);
- }
- }
-
- /**
- * Get the plugged-in user authenticator if there is one.
- * @return the plugged-in user authenticator or <code>null</code>
- */
- public static IUserAuthenticator getAuthenticator() {
- if (authenticator == null) {
- authenticator = getPluggedInAuthenticator();
- }
- return authenticator;
- }
-
- /**
- * Return the sorted array of plugged-in connection methods.
- * @return the sorted array of plugged-in connection methods
- */
- public static IConnectionMethod[] getPluggedInConnectionMethods() {
- if(pluggedInConnectionMethods==null) {
- List connectionMethods = new ArrayList();
-
- if (STANDALONE_MODE) {
- connectionMethods.add(new PServerConnectionMethod());
- } else {
- IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(CVSProviderPlugin.ID, CVSProviderPlugin.PT_CONNECTIONMETHODS).getExtensions();
- for(int i=0; i<extensions.length; i++) {
- IExtension extension = extensions[i];
- IConfigurationElement[] configs = extension.getConfigurationElements();
- if (configs.length == 0) {
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("Connection method {0} is missing required fields", new Object[] {extension.getUniqueIdentifier()}), null);//$NON-NLS-1$
- continue;
- }
- try {
- IConfigurationElement config = configs[0];
- connectionMethods.add(config.createExecutableExtension("run"));//$NON-NLS-1$
- } catch (CoreException ex) {
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("Could not instantiate connection method for {0}", new Object[] {extension.getUniqueIdentifier()}), ex);//$NON-NLS-1$
- }
- }
- }
- IConnectionMethod[] methods = (IConnectionMethod[]) connectionMethods.toArray(new IConnectionMethod[0]);
- Arrays.sort(methods, new Comparator(){
- public int compare(Object o1, Object o2) {
- if (o1 instanceof IConnectionMethod && o2 instanceof IConnectionMethod) {
- IConnectionMethod cm1 = (IConnectionMethod) o1;
- IConnectionMethod cm2 = (IConnectionMethod) o2;
- return cm1.getName().compareTo(cm2.getName());
- }
- return 0;
- }});
- pluggedInConnectionMethods = methods;
- }
- return pluggedInConnectionMethods;
- }
-
- /*
- * Return the connection method registered for the given name
- * or <code>null</code> if none is registered with the given name.
- */
- private static IConnectionMethod getPluggedInConnectionMethod(String methodName) {
- Assert.isNotNull(methodName);
- IConnectionMethod[] methods = getPluggedInConnectionMethods();
- for(int i=0; i<methods.length; i++) {
- if(methodName.equals(methods[i].getName()))
- return methods[i];
- }
- return null;
- }
-
- /*
- * Return a string containing a list of all connection methods
- * that is suitable for inclusion in an error message.
- */
- private static String getPluggedInConnectionMethodNames() {
- IConnectionMethod[] methods = getPluggedInConnectionMethods();
- StringBuffer methodNames = new StringBuffer();
- for(int i=0; i<methods.length; i++) {
- String name = methods[i].getName();
- if (i>0)
- methodNames.append(", ");//$NON-NLS-1$
- methodNames.append(name);
- }
- return methodNames.toString();
- }
-
- /*
- * Get the pluged-in authenticator from the plugin manifest.
- */
- private static IUserAuthenticator getPluggedInAuthenticator() {
- IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(CVSProviderPlugin.ID, CVSProviderPlugin.PT_AUTHENTICATOR).getExtensions();
- if (extensions.length == 0)
- return null;
- IExtension extension = extensions[0];
- IConfigurationElement[] configs = extension.getConfigurationElements();
- if (configs.length == 0) {
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("User autheticator {0} is missing required fields", (new Object[] {extension.getUniqueIdentifier()})), null);//$NON-NLS-1$
- return null;
- }
- try {
- IConfigurationElement config = configs[0];
- return (IUserAuthenticator) config.createExecutableExtension("run");//$NON-NLS-1$
- } catch (CoreException ex) {
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("Unable to instantiate user authenticator {0}", (new Object[] {extension.getUniqueIdentifier()})), ex);//$NON-NLS-1$
- return null;
- }
- }
-
- /*
- * Create a CVSRepositoryLocation from its composite parts.
- */
- private CVSRepositoryLocation(IConnectionMethod method, String user, String password, String host, int port, String root, String encoding, boolean userFixed, boolean passwordFixed) {
- this.method = method;
- this.user = user;
- this.password = password;
- this.host = host;
- this.port = port;
- this.root = root;
- // The username can be fixed only if one is provided
- if (userFixed && (user != null))
- this.userFixed = true;
- // The password can only be fixed if the username is and a password is provided
- if (userFixed && passwordFixed && (password != null))
- this.passwordFixed = true;
- if (encoding != null) {
- setEncoding(encoding);
- }
- }
-
- /*
- * Create the connection to the remote server.
- * If anything fails, an exception will be thrown and must
- * be handled by the caller.
- */
- private Connection createConnection(String password, IProgressMonitor monitor) throws CVSException {
- IConnectionMethod methodToUse = method;
- if (method.getName().equals("ext") && extProxy != null && !extProxy.equals(method.getName())) { //$NON-NLS-1$
- methodToUse = getPluggedInConnectionMethod(extProxy);
- }
- Connection connection = new Connection(this, methodToUse.createConnection(this, password));
- connection.open(monitor);
- return connection;
- }
-
- /*
- * Dispose of the receiver by clearing any cached authorization information.
- * This method shold only be invoked when the corresponding adapter is shut
- * down or a connection is being validated.
- */
- public void dispose() {
- flushCache();
- try {
- if (hasPreferences()) {
- internalGetPreferences().removeNode();
- getParentPreferences().flush();
- }
- } catch (BackingStoreException e) {
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind(CVSMessages.CVSRepositoryLocation_73, new String[] { getLocation(true) }), e);
- }
- }
-
- /*
- * Flush the keyring entry associated with the receiver
- */
- private void flushCache() {
- try {
- Platform.flushAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME);
- } catch (CoreException e) {
- // No need to report this since the location is
- // most likely being disposed.
- // Just fail silently and continue
- CVSProviderPlugin.log(e);
- }
- }
-
- /*
- * @see ICVSRepositoryLocation#getHost()
- */
- public String getHost() {
- return host;
- }
-
- /*
- * @see IRepositoryLocation#getLocation()
- *
- * The username is included if it is fixed.
- * The password is never included even if it is fixed.
- * The port is included if it is not the default port.
- */
- public String getLocation() {
- return getLocation(false);
- }
-
- public String getLocation(boolean forDisplay) {
- return COLON + method.getName() + COLON +
- (userFixed?(user +
- ((passwordFixed && !forDisplay)?(COLON + password):"")//$NON-NLS-1$
- + HOST_SEPARATOR):"") +//$NON-NLS-1$
- host + COLON +
- ((port == USE_DEFAULT_PORT)?"":(new Integer(port).toString())) + //$NON-NLS-1$
- root;
- }
-
- /*
- * @see ICVSRepositoryLocation#getMethod()
- */
- public IConnectionMethod getMethod() {
- return method;
- }
-
- /*
- * @see ICVSRepositoryLocation#getPort()
- */
- public int getPort() {
- return port;
- }
-
- /*
- * @see ICVSRepositoryLocation#getEncoding()
- */
- public String getEncoding() {
- if (hasPreferences()) {
- return internalGetPreferences().get(PREF_SERVER_ENCODING, getDefaultEncoding());
- } else {
- return getDefaultEncoding();
- }
- }
-
- /*
- * @see ICVSRepositoryLocation#setEncoding()
- */
- public void setEncoding(String encoding) {
- if (encoding == null || encoding == getDefaultEncoding()) {
- if (hasPreferences()) {
- internalGetPreferences().remove(PREF_SERVER_ENCODING);
- }
- } else {
- ensurePreferencesStored();
- internalGetPreferences().put(PREF_SERVER_ENCODING, encoding);
- flushPreferences();
- }
- }
-
- /*
- * @see ICVSRepositoryLocation#members(CVSTag, boolean, IProgressMonitor)
- */
- public ICVSRemoteResource[] members(CVSTag tag, boolean modules, IProgressMonitor progress) throws CVSException {
- try {
- if (modules) {
- return RemoteModule.getRemoteModules(this, tag, progress);
- } else {
- RemoteFolder root = new RemoteFolder(null, this, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, tag);
- ICVSRemoteResource[] resources = root.members(progress);
- // There is the off chance that there is a file in the root of the repository.
- // This is not supported by cvs so we need to make sure there are no files
- List folders = new ArrayList(resources.length);
- for (int i = 0; i < resources.length; i++) {
- ICVSRemoteResource remoteResource = resources[i];
- if (remoteResource.isContainer()) {
- folders.add(remoteResource);
- }
- }
- return (ICVSRemoteResource[]) folders.toArray(new ICVSRemoteResource[folders.size()]);
- }
- } catch (CVSException e){
- // keep current CVSException
- throw e;
- } catch(TeamException e1) {
- throw new CVSException(e1.getStatus());
- }
- }
-
- /*
- * @see ICVSRepositoryLocation#getRemoteFolder(String, CVSTag)
- */
- public ICVSRemoteFolder getRemoteFolder(String remotePath, CVSTag tag) {
- return new RemoteFolder(null, this, remotePath, tag);
- }
-
- /*
- * @see ICVSRepositoryLocation#getRemoteFile(String, CVSTag)
- */
- public ICVSRemoteFile getRemoteFile(String remotePath, CVSTag tag) {
- IPath path = new Path(null, remotePath);
- RemoteFolderTree remoteFolder = new RemoteFolderTree(null, this, path.removeLastSegments(1).toString(), tag);
- RemoteFile remoteFile = new RemoteFile(remoteFolder, Update.STATE_ADDED_LOCAL, path.lastSegment(), null, null, tag);
- remoteFolder.setChildren(new ICVSRemoteResource[] { remoteFile });
- return remoteFile;
- }
-
- /*
- * @see ICVSRepositoryLocation#getRootDirectory()
- */
- public String getRootDirectory() {
- return root;
- }
-
- /*
- * @see ICVSRepositoryLocation#getTimeout()
- *
- * For the time being, the timeout value is a system wide value
- * associated with the CVSPlugin singleton.
- */
- public int getTimeout() {
- return CVSProviderPlugin.getPlugin().getTimeout();
- }
-
- /*
- * @see ICVSRepositoryLocation#getUserInfo()
- */
- public IUserInfo getUserInfo(boolean makeUsernameMutable) {
- return new UserInfo(getUsername(), password, makeUsernameMutable ? true : isUsernameMutable());
- }
-
- /*
- * @see ICVSRepositoryLocation#getUsername()
- * @see IUserInfo#getUsername()
- */
- public String getUsername() {
- // If the username is mutable, get it from the cache if it's there
- if (user == null && isUsernameMutable()) {
- retrievePassword();
- }
- return user == null ? "" : user; //$NON-NLS-1$
- }
-
- /*
- * @see IUserInfo#isUsernameMutable()
- */
- public boolean isUsernameMutable() {
- return !userFixed;
- }
-
- /*
- * Open a connection to the repository represented by the receiver.
- * If the username or password are not fixed, openConnection will
- * use the plugged-in authenticator to prompt for the username and/or
- * password if one has not previously been provided or if the previously
- * supplied username and password are invalid.
- *
- * This method is synchronized to ensure that authentication with the
- * remote server is serialized. This is needed to avoid the situation where
- * multiple failed authentications occur and result in the remote account
- * being locked. The CVSProviderPlugin enforces that there is one instance
- * of a CVSRepositoryLocation per remote location thus this method is called
- * for any connection made to this remote location.
- */
- public Connection openConnection(IProgressMonitor monitor) throws CVSException {
- // Get the lock for the host to ensure that we are not connecting to the same host concurrently.
- Policy.checkCanceled(monitor);
- ILock hostLock;
- synchronized(hostLocks) {
- hostLock = (ILock)hostLocks.get(getHost());
- if (hostLock == null) {
- hostLock = Job.getJobManager().newLock();
- hostLocks.put(getHost(), hostLock);
- }
- }
- try {
- boolean acquired = false;
- int count = 0;
- int timeout = CVSProviderPlugin.getPlugin().getTimeout();
- while (!acquired) {
- try {
- acquired = hostLock.acquire(1000);
- } catch (InterruptedException e) {
- // Ignore
- }
- if (timeout > 0 && count > timeout) {
- throw new CVSCommunicationException(NLS.bind(CVSMessages.CVSRepositoryLocation_72, getHost()));
- }
- count++;
- Policy.checkCanceled(monitor);
- }
- // Allow two ticks in case of a retry
- monitor.beginTask(NLS.bind(CVSMessages.CVSRepositoryLocation_openingConnection, new String[] { getHost() }), 2);
- ensureLocationCached();
- boolean cacheNeedsUpdate = false;
- // If the previous connection failed, prompt before attempting to connect
- if (previousAuthenticationFailed) {
- promptForUserInfo(null);
- // The authentication information has been change so update the cache
- cacheNeedsUpdate = true;
- }
- while (true) {
- try {
- // The following will throw an exception if authentication fails
- String password = this.password;
- if (password == null) {
- // If the instance has no password, obtain it from the cache
- password = retrievePassword();
- }
- if (user == null) {
- // This is possible if the cache was cleared somehow for a location with a mutable username
- throw new CVSAuthenticationException(CVSMessages.CVSRepositoryLocation_usernameRequired, CVSAuthenticationException.RETRY, this, null);
- }
- //if (password == null)
- // password = "";//$NON-NLS-1$
- Connection connection = createConnection(password, monitor);
- if (cacheNeedsUpdate)
- updateCachedLocation();
- previousAuthenticationFailed = false;
- return connection;
- } catch (CVSAuthenticationException ex) {
- previousAuthenticationFailed = true;
- if (ex.getRetryStatus() == CVSAuthenticationException.RETRY) {
- String message = ex.getMessage();
- promptForUserInfo(message);
- // The authentication information has been change so update the cache
- cacheNeedsUpdate = true;
- } else {
- throw ex;
- }
- }
- }
- } finally {
- hostLock.release();
- monitor.done();
- }
- }
-
- /*
- * Prompt for the user authentication information (i.e. user name and password).
- */
- private void promptForUserInfo(String message) throws CVSException {
- IUserAuthenticator authenticator = getAuthenticator();
- if (authenticator == null) {
- throw new CVSAuthenticationException(CVSMessages.CVSRepositoryLocation_noAuthenticator, CVSAuthenticationException.NO_RETRY,this);//
- }
- authenticator.promptForUserInfo(this, this, message);
- }
-
- /*
- * Ensure that this location is in the known repositories list
- * and that the authentication information matches what is in the
- * cache, if this instance is not the instance in the cache.
- */
- private void ensureLocationCached() {
- String location = getLocation();
- KnownRepositories repositories = KnownRepositories.getInstance();
- if (repositories.isKnownRepository(location)) {
- try {
- // The repository is already known.
- // Ensure that the authentication information of this
- // location matches that of the known location
- setAuthenticationInformation((CVSRepositoryLocation)repositories.getRepository(location));
- } catch (CVSException e) {
- // Log the exception and continue
- CVSProviderPlugin.log(e);
- }
- } else {
- // The repository is not known so record it so any authentication
- // information the user may provide is remembered
- repositories.addRepository(this, true /* broadcast */);
- }
- }
-
- /*
- * Set the authentication information of this instance such that it matches the
- * provided instances.
- */
- private void setAuthenticationInformation(CVSRepositoryLocation other) {
- if (other != this) {
- // The instances differ so copy from the other location to this one
- if (other.getUserInfoCached()) {
- // The user info is cached for the other instance
- // so null all the values in this instance so the
- // information is obtained from the cache
- this.allowCaching = true;
- if (!userFixed) this.user = null;
- if (!passwordFixed) this.password = null;
- } else {
- // The user info is not cached for the other instance so
- // copy the authentication information into this instance
- setAllowCaching(false); /* this will clear any cahced values */
- // Only copy the username and password if they are not fixed.
- // (If they are fixed, they would be included in the location
- // identifier and therefore must already match)
- if (!other.userFixed)
- this.user = other.user;
- if (!other.passwordFixed)
- this.password = other.password;
- }
- }
- }
-
- /*
- * The connection was sucessfully made. Update the cached
- * repository location if it is a differnet instance than
- * this location.
- */
- private void updateCachedLocation() {
- try {
- CVSRepositoryLocation known = (CVSRepositoryLocation)KnownRepositories.getInstance().getRepository(getLocation());
- known.setAuthenticationInformation(this);
- } catch (CVSException e) {
- // Log the exception and continue
- CVSProviderPlugin.log(e);
- }
- }
-
- /*
- * Implementation of inherited toString()
- */
- public String toString() {
- return getLocation(true);
- }
-
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof CVSRepositoryLocation)) return false;
- return getLocation().equals(((CVSRepositoryLocation)o).getLocation());
- }
- public int hashCode() {
- return getLocation().hashCode();
- }
-
- /*
- * Return the cached password from the keyring.
- * Also, set the username of the receiver if the username is mutable
- */
- private String retrievePassword() {
- Map map = Platform.getAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME);
- if (map != null) {
- String username = (String) map.get(INFO_USERNAME);
- if (username != null && isUsernameMutable())
- setUsername(username);
- String password = (String) map.get(INFO_PASSWORD);
- if (password != null) {
- return password;
- }
- }
- return null;
- }
- /*
- * @see IUserInfo#setPassword(String)
- */
- public void setPassword(String password) {
- if (passwordFixed)
- throw new UnsupportedOperationException();
- // We set the password here but it will be cleared
- // if the user info is cached using updateCache()
- this.password = password;
- }
-
- /*
- * @see IUserInfo#setUsername(String)
- */
- public void setUsername(String user) {
- if (userFixed)
- throw new UnsupportedOperationException();
- this.user = user;
- }
-
- public void setUserMuteable(boolean muteable) {
- userFixed = !muteable;
- }
-
- public void setAllowCaching(boolean value) {
- allowCaching = value;
- if (allowCaching)
- updateCache();
- else
- flushCache();
- }
-
- public void updateCache() {
- // Nothing to cache if the password is fixed
- if (passwordFixed || ! allowCaching) return;
- // Nothing to cache if the password is null and the user is fixed
- if (password == null && userFixed) return;
- if (updateCache(user, password)) {
- // If the cache was updated, null the password field
- // so we will obtain the password from the cache when needed
- password = null;
- }
- ensurePreferencesStored();
- }
-
- /*
- * Cache the user info in the keyring. Return true if the operation
- * succeeded and false otherwise. If an error occurs, it will be logged.
- */
- private boolean updateCache(String username, String password) {
- // put the password into the Platform map
- Map map = Platform.getAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME);
- if (map == null) {
- map = new java.util.HashMap(10);
- }
- if (username != null)
- map.put(INFO_USERNAME, username);
- if (password != null)
- map.put(INFO_PASSWORD, password);
- try {
- Platform.addAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME, map);
- } catch (CoreException e) {
- // We should probably wrap the CoreException here!
- CVSProviderPlugin.log(e);
- return false;
- }
- return true;
- }
-
- /*
- * Validate that the receiver contains valid information for
- * making a connection. If the receiver contains valid
- * information, the method returns. Otherwise, an exception
- * indicating the problem is throw.
- */
- public void validateConnection(IProgressMonitor monitor) throws CVSException {
- try {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot());
- Session session = new Session(this, root, false /* output to console */);
- session.open(Policy.subMonitorFor(monitor, 50), false /* read-only */);
- try {
- IStatus status = Command.VERSION.execute(session, this, Policy.subMonitorFor(monitor, 50));
- // Log any non-ok status
- if (! status.isOK()) {
- CVSProviderPlugin.log(status);
- }
- } finally {
- session.close();
- monitor.done();
- }
- } catch (CVSException e) {
- // If the validation failed, dispose of any cached info
- dispose();
- throw e;
- }
- }
-
- /**
- * Return the server platform type. It will be one of the following:
- * UNDETERMINED_PLATFORM: The platform has not been determined
- * CVS_SERVER: The platform is regular CVS server
- * CVSNT_SERVER: The platform in CVSNT
- * If UNDETERMINED_PLATFORM is returned, the platform can be determined
- * using the Command.VERSION command.
- */
- public int getServerPlatform() {
- return serverPlatform;
- }
-
- /**
- * This method is called from Command.VERSION to set the platform type.
- */
- public void setServerPlaform(int serverType) {
- // Second, check the code of the status itself to see if it is NT
- switch (serverType) {
- case CVS_SERVER:
- case CVSNT_SERVER:
- case UNKNOWN_SERVER:
- case UNSUPPORTED_SERVER:
- serverPlatform = serverType;
- break;
- default:
- // We had an error status with no info about the server.
- // Mark it as undetermined.
- serverPlatform = UNDETERMINED_PLATFORM;
- }
- }
-
- /**
- * @see ICVSRepositoryLocation#flushUserInfo()
- */
- public void flushUserInfo() {
- flushCache();
- }
-
- /*
- * Return the command string that is to be used by the EXT connection method.
- */
- String[] getExtCommand(String password) throws IOException {
- // Get the user specified connection parameters
- String CVS_RSH = CVSProviderPlugin.getPlugin().getCvsRshCommand();
- String CVS_RSH_PARAMETERS = CVSProviderPlugin.getPlugin().getCvsRshParameters();
- String CVS_SERVER = CVSProviderPlugin.getPlugin().getCvsServer();
- if(CVS_RSH == null || CVS_SERVER == null) {
- throw new IOException(CVSMessages.EXTServerConnection_varsNotSet);
- }
-
- // If there is only one token, assume it is the command and use the default parameters and order
- if (CVS_RSH_PARAMETERS == null || CVS_RSH_PARAMETERS.length() == 0) {
- if (port != USE_DEFAULT_PORT)
- throw new IOException(CVSMessages.EXTServerConnection_invalidPort);
- return new String[] {CVS_RSH, host, "-l", user, CVS_SERVER, INVOKE_SVR_CMD}; //$NON-NLS-1$
- }
-
- // Substitute any variables for their appropriate values
- CVS_RSH_PARAMETERS = stringReplace(CVS_RSH_PARAMETERS, USER_VARIABLE, user);
- CVS_RSH_PARAMETERS = stringReplace(CVS_RSH_PARAMETERS, PASSWORD_VARIABLE, password);
- CVS_RSH_PARAMETERS = stringReplace(CVS_RSH_PARAMETERS, HOST_VARIABLE, host);
- CVS_RSH_PARAMETERS = stringReplace(CVS_RSH_PARAMETERS, PORT_VARIABLE, new Integer(port).toString());
-
- // Build the command list to be sent to the OS.
- List commands = new ArrayList();
- commands.add(CVS_RSH);
- StringTokenizer tokenizer = new StringTokenizer(CVS_RSH_PARAMETERS);
- while (tokenizer.hasMoreTokens()) {
- String next = tokenizer.nextToken();
- commands.add(next);
- }
- commands.add(CVS_SERVER);
- commands.add(INVOKE_SVR_CMD);
- return (String[]) commands.toArray(new String[commands.size()]);
- }
-
- /*
- * Replace all occurances of oldString with newString
- */
- private String stringReplace(String string, String oldString, String newString) {
- int index = string.toLowerCase().indexOf(oldString);
- if (index == -1) return string;
- return stringReplace(
- string.substring(0, index) + newString + string.substring(index + oldString.length()),
- oldString, newString);
- }
-
- /**
- * Return the server message with the prefix removed.
- * Server aborted messages typically start with
- * "cvs server: ..."
- * "cvs [server aborted]: ..."
- * "cvs rtag: ..."
- */
- public String getServerMessageWithoutPrefix(String errorLine, String prefix) {
- String message = errorLine;
- int firstSpace = message.indexOf(' ');
- if(firstSpace != -1) {
- // remove the program name and the space
- message = message.substring(firstSpace + 1);
- // Quick fix to handle changes in server message format (see Bug 45138)
- if (prefix.startsWith("[")) { //$NON-NLS-1$
- // This is the server aborted message
- // Remove the pattern "[command_name aborted]: "
- int closingBracket = message.indexOf("]: "); //$NON-NLS-1$
- if (closingBracket == -1) return null;
- // get what is inside the brackets
- String realPrefix = message.substring(1, closingBracket);
- // check that there is two words and the second word is "aborted"
- int space = realPrefix.indexOf(' ');
- if (space == -1) return null;
- if (realPrefix.indexOf(' ', space +1) != -1) return null;
- if (!realPrefix.substring(space +1).equals("aborted")) return null; //$NON-NLS-1$
- // It's a match, return the rest of the line
- message = message.substring(closingBracket + 2);
- if (message.charAt(0) == ' ') {
- message = message.substring(1);
- }
- return message;
- } else {
- // This is the server command message
- // Remove the pattern "command_name: "
- int colon = message.indexOf(": "); //$NON-NLS-1$
- if (colon == -1) return null;
- // get what is before the colon
- String realPrefix = message.substring(0, colon);
- // ensure that it is a single word
- if (realPrefix.indexOf(' ') != -1) return null;
- message = message.substring(colon + 1);
- if (message.charAt(0) == ' ') {
- message = message.substring(1);
- }
- return message;
- }
- }
- // This is not a server message with the desired prefix
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation#getUserAuthenticator()
- */
- public IUserAuthenticator getUserAuthenticator() {
- return getAuthenticator();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation#setUserAuthenticator()
- */
- public void setUserAuthenticator(IUserAuthenticator authenticator) {
- CVSRepositoryLocation.authenticator = authenticator;
- }
-
- /*
- * Return the preferences node for this repository
- */
- public Preferences getPreferences() {
- if (!hasPreferences()) {
- ensurePreferencesStored();
- }
- return internalGetPreferences();
- }
-
- private Preferences internalGetPreferences() {
- return getParentPreferences().node(getPreferenceName());
- }
-
- private boolean hasPreferences() {
- try {
- return getParentPreferences().nodeExists(getPreferenceName());
- } catch (BackingStoreException e) {
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind(CVSMessages.CVSRepositoryLocation_74, new String[] { getLocation(true) }), e);
- return false;
- }
- }
-
- /**
- * Return a unique name that identifies this location but
- * does not contain any slashes (/). Also, do not use ':'.
- * Although a valid path character, the initial core implementation
- * didn't handle it well.
- */
- private String getPreferenceName() {
- return getLocation().replace('/', '%').replace(':', '%');
- }
-
- public void storePreferences() {
- Preferences prefs = internalGetPreferences();
- // Must store at least one preference in the node
- prefs.put(PREF_LOCATION, getLocation());
- flushPreferences();
- }
-
- private void flushPreferences() {
- try {
- internalGetPreferences().flush();
- } catch (BackingStoreException e) {
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind(CVSMessages.CVSRepositoryLocation_75, new String[] { getLocation(true) }), e);
- }
- }
-
- private void ensurePreferencesStored() {
- if (!hasPreferences()) {
- storePreferences();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation#getUserInfoCached()
- */
- public boolean getUserInfoCached() {
- Map map = Platform.getAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME);
- if (map != null) {
- String password = (String) map.get(INFO_PASSWORD);
- return (password != null);
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java
deleted file mode 100644
index 1fbca6744..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.connection;
-
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-
-/**
- * Client has received an error response from the server.
- */
-public class CVSServerException extends CVSException {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Return true if the exception from the cvs server is the no tag error, and false
- * otherwise.
- */
- public boolean isNoTagException() {
- IStatus status = getStatus();
- if ( ! status.isMultiStatus())
- return false;
- IStatus[] children = ((MultiStatus)status).getChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i].getCode() == CVSStatus.NO_SUCH_TAG) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return true if the exceptions status contains any error status messages
- */
- public boolean containsErrors() {
- IStatus status = getStatus();
- if ( ! status.isMultiStatus())
- return status.getSeverity() == IStatus.ERROR;
- IStatus[] children = ((MultiStatus)status).getChildren();
- for (int i=0;i<children.length;i++) {
- if (children[i].getSeverity() == IStatus.ERROR)
- return true;
- }
- return false;
- }
-
- /** The status should have a status code of CVSStatus.SERVER_ERROR
- * @param status
- */
- public CVSServerException(IStatus status) {
- super(status);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java
deleted file mode 100644
index cf1caefc7..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Brock Janiczak (brockj@tpg.com.au) - Bug 144419 Avoid calculating encoding for each line read/written
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.connection;
-
-
-import java.io.*;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-
-/**
- * A connection to talk to a cvs server. The life cycle of a connection is
- * as follows:
- * <ul>
- * <li> constructor: creates a new connection object that wraps the given
- * repository location and connection method.
- * <li> open: opens a connection.
- * <li> send a request: use write* method or use the request stream directly.
- * <code>GetRequestStream</code> returns an output stream to directly
- * talk to the server.
- * <li> read responses: use read* methods or use the response stream directly.
- * <code>GetResponseStream</code> returns an input stream to directly
- * read output from the server.
- * <li> close: closes the connection. A closed connection can be reopened by
- * calling open again.
- * </ul>
- */
-public class Connection {
- private static final byte NEWLINE= 0xA;
-
- private IServerConnection serverConnection;
- private ICVSRepositoryLocation fCVSRoot;
- private boolean fIsEstablished;
- private InputStream fResponseStream;
- private String fServerEncoding;
- private byte[] readLineBuffer = new byte[256];
-
- public Connection(ICVSRepositoryLocation cvsroot, IServerConnection serverConnection) {
- fCVSRoot = cvsroot;
- this.serverConnection = serverConnection;
- fServerEncoding = getEncoding(fCVSRoot);
- }
-
- private static byte[] append(byte[] buffer, int index, byte b) {
- if (index >= buffer.length) {
- byte[] newBuffer= new byte[index * 2];
- System.arraycopy(buffer, 0, newBuffer, 0, buffer.length);
- buffer= newBuffer;
- }
- buffer[index]= b;
- return buffer;
- }
- /**
- * Closes the connection.
- */
- public void close() {
- if (!isEstablished())
- return;
- try {
- serverConnection.close();
- } catch (IOException ex) {
- // Generally, errors on close are of no interest.
- // However, log them if debugging is on
- if (CVSProviderPlugin.getPlugin().isDebugging()) {
- CVSProviderPlugin.log(new CVSCommunicationException(CVSMessages.Connection_cannotClose, fCVSRoot, ex));
- }
- } finally {
- fResponseStream = null;
- fIsEstablished = false;
- }
- }
- /**
- * Flushes the request stream.
- */
- public void flush() throws CVSException {
- if (!isEstablished())
- return;
- try {
- getOutputStream().flush();
- } catch(IOException e) {
- throw new CVSCommunicationException(fCVSRoot,e);
- }
- }
-
- /**
- * Returns the <code>OutputStream</code> used to send requests
- * to the server.
- */
- public OutputStream getOutputStream() {
- if (!isEstablished())
- return null;
- return serverConnection.getOutputStream();
- }
- /**
- * Returns the <code>InputStream</code> used to read responses from
- * the server.
- */
- public InputStream getInputStream() {
- if (!isEstablished())
- return null;
- if (fResponseStream == null)
- fResponseStream = serverConnection.getInputStream();
- return fResponseStream;
- }
-
- /**
- * Returns <code>true</code> if the connection is established;
- * otherwise <code>false</code>.
- */
- public boolean isEstablished() {
- return fIsEstablished;
- }
-
- /**
- * Opens the connection.
- */
- public void open(IProgressMonitor monitor) throws CVSException {
- if (isEstablished())
- return;
- try {
- serverConnection.open(monitor);
- } catch (IOException e) {
- throw new CVSCommunicationException(NLS.bind(CVSMessages.Connection_0, new String[] { fCVSRoot.getLocation(true), CVSCommunicationException.getMessageFor(e) }), fCVSRoot, e);
- }
- fIsEstablished= true;
- }
- /**
- * Reads a line from the response stream.
- */
- public String readLine() throws CVSException {
- if (!isEstablished())
- throw new CVSCommunicationException(CVSMessages.Connection_readUnestablishedConnection,fCVSRoot,null);
- try {
- InputStream in = getInputStream();
- int index = 0;
- int r;
- while ((r = in.read()) != -1) {
- if (r == NEWLINE) break;
- readLineBuffer = append(readLineBuffer, index++, (byte) r);
- }
-
- String result = new String(readLineBuffer, 0, index, fServerEncoding);
- if (Policy.isDebugProtocol()) Policy.printProtocolLine(result);
- return result;
- } catch (IOException e) {
- throw new CVSCommunicationException(fCVSRoot,e);
- }
- }
-
- static String readLine(ICVSRepositoryLocation location, InputStream in) throws IOException {
- byte[] buffer = new byte[256];
- int index = 0;
- int r;
- while ((r = in.read()) != -1) {
- if (r == NEWLINE)
- break;
- buffer = append(buffer, index++, (byte) r);
- }
-
- String result = new String(buffer, 0, index, getEncoding(location));
- if (Policy.isDebugProtocol())
- Policy.printProtocolLine(result);
- return result;
- }
-
- //---- Helper to send strings to the server ----------------------------
-
- /**
- * Sends the given string to the server.
- */
- public void write(String s) throws CVSException {
- try {
- write(s.getBytes(fServerEncoding), false);
- } catch (UnsupportedEncodingException e) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.SERVER_ERROR, e.getMessage(), e, fCVSRoot);
- throw new CVSException (status);
- }
- }
-
- /**
- * Return the encoding for the given repository location
- * @return the encoding for the given repository location
- */
- public static String getEncoding(ICVSRepositoryLocation location) {
- return location.getEncoding();
- }
-
- /**
- * Sends the given string and a newline to the server.
- */
- public void writeLine(String s) throws CVSException {
- try {
- write(s.getBytes(fServerEncoding), true);
- } catch (UnsupportedEncodingException e) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.SERVER_ERROR, e.getMessage(), e, fCVSRoot);
- throw new CVSException (status);
- }
- }
-
- void write (byte[] bytes, boolean newLine) throws CVSException {
- write(bytes, 0, bytes.length, newLine);
- }
-
- /**
- * Low level method to write a string to the server. All write* methods are
- * funneled through this method.
- */
- void write(byte[] b, int off, int len, boolean newline) throws CVSException {
- if (!isEstablished())
- throw new CVSCommunicationException(CVSMessages.Connection_writeUnestablishedConnection,fCVSRoot,null);
-
- if (Policy.isDebugProtocol())
- Policy.printProtocol(new String(b, off, len), newline);
-
- try {
- OutputStream out= getOutputStream();
- out.write(b, off, len);
- if (newline)
- out.write(NEWLINE);
-
- } catch (IOException e) {
- throw new CVSCommunicationException(fCVSRoot,e);
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java
deleted file mode 100644
index 4ab45ce82..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.connection;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.IServerConnection;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-import org.eclipse.team.internal.core.streams.PollingInputStream;
-import org.eclipse.team.internal.core.streams.PollingOutputStream;
-import org.eclipse.team.internal.core.streams.TimeoutInputStream;
-import org.eclipse.team.internal.core.streams.TimeoutOutputStream;
-
-/**
- * Implements a connection method which invokes an external tool to
- * establish the connection to the cvs server. Authentication and starting
- * of the cvs server are the responsibility of the external connection
- * tool.
- */
-public class ExtConnection implements IServerConnection {
-
- // cvs format for the repository (e.g. :extssh:user@host:/home/cvs/repo)
- private ICVSRepositoryLocation location;
- private String password;
-
- // incoming from remote host
- InputStream inputStream;
-
- // outgoing to remote host
- OutputStream outputStream;
-
- // Process spawn to run the command
- Process process;
-
- protected ExtConnection(ICVSRepositoryLocation location, String password) {
- this.location = location;
- this.password = password;
- }
-
- /**
- * Closes the connection.
- */
- public void close() throws IOException {
- try {
- if (inputStream != null) inputStream.close();
- } finally {
- inputStream = null;
- try {
- if (outputStream != null) outputStream.close();
- } finally {
- outputStream = null;
- if (process != null) process.destroy();
- }
- }
- }
-
- /**
- * Returns the <code>InputStream</code> used to read data from the
- * server.
- */
- public InputStream getInputStream() {
- return inputStream;
- }
-
- /**
- * Returns the <code>OutputStream</code> used to send data to the
- * server.
- */
- public OutputStream getOutputStream() {
- return outputStream;
- }
-
- /**
- * Opens the connection and invokes cvs in server mode.
- *
- * @see Connection.open()
- */
- public void open(IProgressMonitor monitor) throws IOException {
- String[] command = ((CVSRepositoryLocation)location).getExtCommand(password);
- boolean connected = false;
- try {
- process = Util.createProcess(command, monitor);
-
- inputStream = new PollingInputStream(new TimeoutInputStream(process.getInputStream(),
- 8192 /*bufferSize*/, 1000 /*readTimeout*/, -1 /*closeTimeout*/), location.getTimeout(), monitor);
- outputStream = new PollingOutputStream(new TimeoutOutputStream(process.getOutputStream(),
- 8192 /*buffersize*/, 1000 /*writeTimeout*/, 1000 /*closeTimeout*/), location.getTimeout(), monitor);
-
- // XXX need to do something more useful with stderr
- connected = true;
- } finally {
- if (! connected) {
- try {
- close();
- } finally {
- // Ignore any exceptions during close
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java
deleted file mode 100644
index d18e95e32..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.connection;
-
-
-import org.eclipse.team.internal.ccvs.core.*;
-
-public class ExtConnectionMethod implements IConnectionMethod {
- /**
- * @see IConnectionMethod#getName
- */
- public String getName() {
- return "ext"; //$NON-NLS-1$
- }
-
- /**
- * @see IConnectionMethod#createConnection
- */
- public IServerConnection createConnection(ICVSRepositoryLocation repositoryRoot, String password) {
- if(password==null){
- password=""; //$NON-NLS-1$
- }
- return new ExtConnection(repositoryRoot, password);
- }
-
- public void disconnect(ICVSRepositoryLocation location) {
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java
deleted file mode 100644
index a0c445202..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnection.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.connection;
-
-import java.io.*;
-import java.net.Socket;
-
-import org.eclipse.core.net.proxy.IProxyData;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jsch.core.IJSchService;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-import org.eclipse.team.internal.core.streams.*;
-
-import com.jcraft.jsch.Proxy;
-
-/**
- * A connection used to talk to an cvs pserver.
- */
-public class PServerConnection implements IServerConnection {
-
- public static final char NEWLINE= 0xA;
-
- /** default CVS pserver port */
- private static final int DEFAULT_PORT= 2401;
-
- /** error line indicators */
- private static final char ERROR_CHAR = 'E';
- private static final String ERROR_MESSAGE = "error 0";//$NON-NLS-1$
- private static final String NO_SUCH_USER = "no such user";//$NON-NLS-1$
-
- private static final char[] SCRAMBLING_TABLE=new char[] {
- 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
- 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
- 114,120,53,79,96,109,72,108,70,64,76,67,116,74,68,87,
- 111,52,75,119,49,34,82,81,95,65,112,86,118,110,122,105,
- 41,57,83,43,46,102,40,89,38,103,45,50,42,123,91,35,
- 125,55,54,66,124,126,59,47,92,71,115,78,88,107,106,56,
- 36,121,117,104,101,100,69,73,99,63,94,93,39,37,61,48,
- 58,113,32,90,44,98,60,51,33,97,62,77,84,80,85,223,
- 225,216,187,166,229,189,222,188,141,249,148,200,184,136,248,190,
- 199,170,181,204,138,232,218,183,255,234,220,247,213,203,226,193,
- 174,172,228,252,217,201,131,230,197,211,145,238,161,179,160,212,
- 207,221,254,173,202,146,224,151,140,196,205,130,135,133,143,246,
- 192,159,244,239,185,168,215,144,139,165,180,157,147,186,214,176,
- 227,231,219,169,175,156,206,198,129,164,150,210,154,177,134,127,
- 182,128,158,208,162,132,167,209,149,241,153,251,237,236,171,195,
- 243,233,253,240,194,250,191,155,142,137,245,235,163,242,178,152
- };
-
- /** Communication strings */
- private static final String BEGIN= "BEGIN AUTH REQUEST";//$NON-NLS-1$
- private static final String END= "END AUTH REQUEST";//$NON-NLS-1$
- private static final String LOGIN_OK= "I LOVE YOU";//$NON-NLS-1$
- private static final String LOGIN_FAILED= "I HATE YOU";//$NON-NLS-1$
-
- private String password;
- private ICVSRepositoryLocation cvsroot;
-
- private Socket fSocket;
-
- private InputStream inputStream;
- private OutputStream outputStream;
-
- /**
- * @see Connection#doClose()
- */
- public void close() throws IOException {
- try {
- if (inputStream != null) inputStream.close();
- } finally {
- inputStream = null;
- try {
- if (outputStream != null) outputStream.close();
- } finally {
- outputStream = null;
- try {
- if (fSocket != null) fSocket.close();
- } finally {
- fSocket = null;
- }
- }
- }
- }
-
- /**
- * @see Connection#doOpen()
- */
- public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException {
-
- monitor.subTask(CVSMessages.PServerConnection_authenticating);
- monitor.worked(1);
-
- InputStream is = null;
- OutputStream os = null;
-
- Proxy proxy = getProxy();
- if (proxy!=null) {
- String host = cvsroot.getHost();
- int port = cvsroot.getPort();
- if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) {
- port = DEFAULT_PORT;
- }
- try {
- int timeout = CVSProviderPlugin.getPlugin().getTimeout() * 1000;
- IJSchService service = CVSProviderPlugin.getPlugin().getJSchService();
- service.connect(proxy, host, port, timeout, monitor);
- } catch( Exception ex) {
- ex.printStackTrace();
- throw new IOException(ex.getMessage());
- }
- is = proxy.getInputStream();
- os = proxy.getOutputStream();
-
- } else {
- fSocket = createSocket(monitor);
- is = fSocket.getInputStream();
- os = fSocket.getOutputStream();
- }
-
- boolean connected = false;
- try {
- this.inputStream = new BufferedInputStream(new PollingInputStream(is,
- cvsroot.getTimeout(), monitor));
- this.outputStream = new PollingOutputStream(new TimeoutOutputStream(
- os, 8192 /*bufferSize*/, 1000 /*writeTimeout*/, 1000 /*closeTimeout*/),
- cvsroot.getTimeout(), monitor);
- authenticate();
- connected = true;
- } finally {
- if (! connected) cleanUpAfterFailedConnection();
- }
- }
-
- private Proxy getProxy() {
- IJSchService service = CVSProviderPlugin.getPlugin().getJSchService();
- if (service == null)
- return null;
- Proxy proxy = service.getProxyForHost(cvsroot.getHost(), IProxyData.SOCKS_PROXY_TYPE);
- if (proxy == null)
- proxy = service.getProxyForHost(cvsroot.getHost(), IProxyData.HTTPS_PROXY_TYPE);
- return proxy;
- }
-
- /**
- * @see Connection#getInputStream()
- */
- public InputStream getInputStream() {
- return inputStream;
- }
- /**
- * @see Connection#getOutputStream()
- */
- public OutputStream getOutputStream() {
- return outputStream;
- }
-
- /**
- * Creates a new <code>PServerConnection</code> for the given
- * cvs root.
- */
- PServerConnection(ICVSRepositoryLocation cvsroot, String password) {
- this.cvsroot = cvsroot;
- this.password = password;
- }
- /**
- * Does the actual authentication.
- */
- private void authenticate() throws IOException, CVSAuthenticationException {
- String scrambledPassword = scramblePassword(password);
-
- String user = cvsroot.getUsername();
- OutputStream out = getOutputStream();
-
- StringBuffer request = new StringBuffer();
- request.append(BEGIN);
- request.append(NEWLINE);
- request.append(cvsroot.getRootDirectory());
- request.append(NEWLINE);
- request.append(user);
- request.append(NEWLINE);
- request.append(scrambledPassword);
- request.append(NEWLINE);
- request.append(END);
- request.append(NEWLINE);
- out.write(request.toString().getBytes());
- out.flush();
- String line = Connection.readLine(cvsroot, getInputStream()).trim();
-
- // Return if we succeeded
- if (LOGIN_OK.equals(line))
- return;
-
- // Otherwise, determine the type of error
- if (line.length() == 0) {
- throw new IOException(CVSMessages.PServerConnection_noResponse);
- }
-
- // Accumulate a message from the error (E) stream
- String message = "";//$NON-NLS-1$
- String separator = ""; //$NON-NLS-1$
-
- if(!CVSProviderPlugin.getPlugin().isUseProxy()) {
- while (line.length() > 0 && line.charAt(0) == ERROR_CHAR) {
- if (line.length() > 2) {
- message += separator + line.substring(2);
- separator = " "; //$NON-NLS-1$
- }
- line = Connection.readLine(cvsroot, getInputStream());
- }
- } else {
- while (line.length() > 0) {
- message += separator + line;
- separator = "\n"; //$NON-NLS-1$
- line = Connection.readLine(cvsroot, getInputStream());
- }
- }
-
- // If the last line is the login failed (I HATE YOU) message, return authentication failure
- if (LOGIN_FAILED.equals(line)) {
- if (message.length() == 0) {
- throw new CVSAuthenticationException(CVSMessages.PServerConnection_loginRefused, CVSAuthenticationException.RETRY,cvsroot);
- } else {
- throw new CVSAuthenticationException(message, CVSAuthenticationException.RETRY,cvsroot);
- }
- }
-
- // Remove leading "error 0"
- if (line.startsWith(ERROR_MESSAGE))
- message += separator + line.substring(ERROR_MESSAGE.length() + 1);
- else
- message += separator + line;
- if (message.indexOf(NO_SUCH_USER) != -1)
- throw new CVSAuthenticationException(NLS.bind(CVSMessages.PServerConnection_invalidUser, (new Object[] {message})), CVSAuthenticationException.RETRY,cvsroot);
- throw new IOException(NLS.bind(CVSMessages.PServerConnection_connectionRefused, (new Object[] { message })));
- }
- /*
- * Called if there are exceptions when connecting.
- * This method makes sure that all connections are closed.
- */
- private void cleanUpAfterFailedConnection() throws IOException {
- try {
- if (inputStream != null)
- inputStream.close();
- } finally {
- try {
- if (outputStream != null)
- outputStream.close();
- } finally {
- try {
- if (fSocket != null)
- fSocket.close();
- } finally {
- fSocket = null;
- }
- }
- }
-
- }
- /**
- * Creates the actual socket
- */
- protected Socket createSocket(IProgressMonitor monitor) throws IOException {
- // Determine what port to use
- int port = cvsroot.getPort();
- if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT)
- port = DEFAULT_PORT;
- // Make the connection
- Socket result;
- try {
- result= Util.createSocket(cvsroot.getHost(), port, monitor);
- // Bug 36351: disable buffering and send bytes immediately
- result.setTcpNoDelay(true);
- } catch (InterruptedIOException e) {
- // If we get this exception, chances are the host is not responding
- throw new InterruptedIOException(NLS.bind(CVSMessages.PServerConnection_socket, (new Object[] {cvsroot.getHost()})));
- }
- result.setSoTimeout(1000); // 1 second between timeouts
- return result;
- }
-
- private String scramblePassword(String password) throws CVSAuthenticationException {
- int length = password.length();
- char[] out= new char[length];
- for (int i= 0; i < length; i++) {
- char value = password.charAt(i);
- if( value < 0 || value > 255 )
- throwInValidCharacter();
- out[i]= SCRAMBLING_TABLE[value];
- }
- return "A" + new String(out);//$NON-NLS-1$
- }
-
- private void throwInValidCharacter() throws CVSAuthenticationException {
- throw new CVSAuthenticationException(CVSMessages.PServerConnection_invalidChars, CVSAuthenticationException.RETRY, cvsroot);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnectionMethod.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnectionMethod.java
deleted file mode 100644
index d56f5b874..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/PServerConnectionMethod.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.connection;
-
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.IConnectionMethod;
-import org.eclipse.team.internal.ccvs.core.IServerConnection;
-public class PServerConnectionMethod implements IConnectionMethod {
- /**
- * @see IConnectionMethod#createConnection(ICVSRepositoryLocation, String)
- */
- public IServerConnection createConnection(ICVSRepositoryLocation location, String password) {
- if(password==null){
- password=""; //$NON-NLS-1$
- }
- return new PServerConnection(location, password);
- }
- /**
- * @see IConnectionMethod#getName()
- */
- public String getName() {
- return "pserver";//$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.IConnectionMethod#disconnect(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation)
- */
- public void disconnect(ICVSRepositoryLocation location) {
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/UserInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/UserInfo.java
deleted file mode 100644
index 98e7d0ba4..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/UserInfo.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.connection;
-
-
-import org.eclipse.team.internal.ccvs.core.IUserInfo;
-
-/**
- * @version 1.0
- * @author
- */
-public class UserInfo implements IUserInfo {
-
- private String username;
- private String password;
- private boolean isUsernameMutable;
-
- protected UserInfo(String username, String password, boolean isUsernameMutable) {
- this.username = username;
- this.password = password;
- this.isUsernameMutable = isUsernameMutable;
- }
-
- /*
- * @see IUserInfo#getUsername()
- */
- public String getUsername() {
- return username;
- }
-
- protected String getPassword() {
- return password;
- }
-
- /*
- * @see IUserInfo#isUsernameMutable()
- */
- public boolean isUsernameMutable() {
- return isUsernameMutable;
- }
-
- /*
- * @see IUserInfo#setPassword(String)
- */
- public void setPassword(String password) {
- this.password = password;
- }
-
- /*
- * @see IUserInfo#setUsername(String)
- */
- public void setUsername(String username) {
- this.username = username;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileHistory.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileHistory.java
deleted file mode 100644
index 2ee46b6dd..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileHistory.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.team.internal.ccvs.core.filehistory;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.history.IFileHistoryProvider;
-import org.eclipse.team.core.history.IFileRevision;
-import org.eclipse.team.core.history.provider.FileHistory;
-import org.eclipse.team.internal.ccvs.core.*;
-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.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-
-public class CVSFileHistory extends FileHistory {
-
- public static final int REFRESH_LOCAL = 1;
- public static final int REFRESH_REMOTE = 2;
-
- public static final int REFRESH_ALL = REFRESH_LOCAL | REFRESH_REMOTE;
-
- private final ICVSFile cvsFile;
- //used to hold all revisions (changes based on filtering)
- protected IFileRevision[] revisions;
- //used to hold all of the remote revisions
- protected IFileRevision[] remoteRevisions;
- //used to hold all of the local revisions
- protected IFileRevision[] localRevisions;
- protected boolean includeLocalRevisions;
- protected boolean includeRemoteRevisions;
- protected boolean includesExists;
- protected boolean refetchRevisions;
-
- private int flag;
-
- /*
- * Creates a new CVSFile history that will fetch remote revisions by default.
- */
- public CVSFileHistory(ICVSFile file) {
- Assert.isNotNull(file);
- this.cvsFile = file;
- this.includeLocalRevisions = false;
- this.includeRemoteRevisions = true;
- this.refetchRevisions = true;
- this.flag = 0;
- }
-
- /*
- *
- * Creates a new CVSFile history that will fetch remote revisions by default.
- * The flag passed can be IFileHistoryProvider.SINGLE_REVISION or IFileHistoryProvider.SINGLE_LINE_OF_DESCENT
- */
- public CVSFileHistory(ICVSFile file, int flag) {
- Assert.isNotNull(file);
- this.cvsFile = file;
- this.includeLocalRevisions = false;
- this.includeRemoteRevisions = true;
- this.refetchRevisions = true;
- this.flag = flag;
- }
-
- public IFileRevision[] getFileRevisions() {
- if (revisions == null)
- return new IFileRevision[0];
- return revisions;
- }
-
- /**
- * Refreshes the revisions for this CVS file. It may or may not contact the server to get new revisions.
- *
- * @param monitor a progress monitor
- */
- public void refresh(int flags, IProgressMonitor monitor) throws TeamException {
- if (flags == CVSFileHistory.REFRESH_LOCAL) {
- fetchLocalOnly(monitor);
- return;
- }
-
- if (refetchRevisions) {
- monitor.beginTask(NLS.bind(CVSMessages.CVSFileHistory_0, cvsFile.getRepositoryRelativePath()), 300);
- try {
- ILogEntry[] entries = cvsFile
- .getLogEntries(new SubProgressMonitor(monitor, 200));
-
- if (entries.length == 0){
- //Get the parent folder
- ICVSFolder folder = cvsFile.getParent();
- if (folder.isManaged()){
- String remoteFolderLocation = folder.getRemoteLocation(folder);
- if (remoteFolderLocation != null) {
- String remoteFileName = remoteFolderLocation.concat(Session.SERVER_SEPARATOR + cvsFile.getName());
- //Create remote file
- CVSTeamProvider pro = (CVSTeamProvider) RepositoryProvider.getProvider(cvsFile.getIResource().getProject());
- if (pro != null){
- CVSWorkspaceRoot root = pro.getCVSWorkspaceRoot();
- CVSRepositoryLocation location = CVSRepositoryLocation.fromString(root.getRemoteLocation().getLocation(false));
- RemoteFile remFile = RemoteFile.create(remoteFileName, location);
- entries=remFile.getLogEntries(monitor);
- }
- }
- }
- }
-
- if (flag == IFileHistoryProvider.SINGLE_REVISION) {
- String revisionNumber = cvsFile.getSyncInfo().getRevision();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].getRevision().equals(revisionNumber)) {
- remoteRevisions = new IFileRevision[] {new CVSFileRevision(entries[i])};
- revisions = new IFileRevision[1];
- //copy over remote revisions
- System.arraycopy(remoteRevisions, 0, revisions, 0, remoteRevisions.length);
- break;
- }
- }
-
- } else if (flag == IFileHistoryProvider.SINGLE_LINE_OF_DESCENT) {
- CVSTag tempTag = cvsFile.getSyncInfo().getTag();
- ArrayList entriesOfInterest = new ArrayList();
- for (int i = 0; i < entries.length; i++) {
- CVSTag[] tags = entries[i].getTags();
- for (int j = 0; j < tags.length; j++) {
- if (tags[j].getType() == tempTag.getType()) {
- if (tempTag.getType() == CVSTag.BRANCH && tempTag.getName().equals(tags[j].getName())) {
- entriesOfInterest.add(entries[i]);
- break;
- } else {
- entriesOfInterest.add(entries[i]);
- break;
- }
- }
-
- }
- }
-
- //always fetch the remote revisions, just filter them out from the returned array
- remoteRevisions = new IFileRevision[entriesOfInterest.size()];
- Iterator iter = entriesOfInterest.iterator();
- int i = 0;
- while (iter.hasNext()) {
- remoteRevisions[i++] = new CVSFileRevision((ILogEntry) iter.next());
- }
-
- //copy over remote revisions
- revisions = new IFileRevision[remoteRevisions.length];
- System.arraycopy(remoteRevisions, 0, revisions, 0, remoteRevisions.length);
-
- } else {
- localRevisions = new IFileRevision[0];
- //always fetch the local revisions, just filter them out from the returned array if not wanted
- IResource localResource = cvsFile.getIResource();
- includesExists = false;
- if (localResource != null && localResource instanceof IFile) {
- //get the local revisions
- IFileState[] localHistoryState;
- try {
- localHistoryState = ((IFile) localResource).getHistory(new SubProgressMonitor(monitor, 100));
- localRevisions = convertToFileRevision(localHistoryState, new SubProgressMonitor(monitor, 100));
- includesExists = (localRevisions.length > 0);
- } catch (CoreException e) {
- TeamException.asTeamException(e);
- }
- }
-
- //always fetch the remote revisions, just filter them out from the returned array
- remoteRevisions = new IFileRevision[entries.length];
- for (int i = 0; i < entries.length; i++) {
- remoteRevisions[i] = new CVSFileRevision(entries[i]);
- }
-
- revisions = new IFileRevision[0];
- arrangeRevisions();
- }
- } finally {
- monitor.done();
- }
- } else {
- //don't refetch revisions just return revisions with local revisions as requested
- arrangeRevisions();
- }
-
- }
-
- private void arrangeRevisions() {
- if (revisions != null) {
- if (includeLocalRevisions && includeRemoteRevisions) {
- //Local + Remote mode
- revisions = new IFileRevision[remoteRevisions.length + localRevisions.length];
- //copy over remote revisions
- System.arraycopy(remoteRevisions, 0, revisions, 0, remoteRevisions.length);
- //copy over local revisions
- System.arraycopy(localRevisions, 0, revisions, remoteRevisions.length, localRevisions.length);
- } else if (includeLocalRevisions) {
- //Local mode only
- revisions = new IFileRevision[localRevisions.length];
- //copy over local revisions
- System.arraycopy(localRevisions, 0, revisions, 0, localRevisions.length);
- } else if (includeRemoteRevisions) {
- //Remote mode and fall through for Local + Remote mode where no Locals exist
- revisions = new IFileRevision[remoteRevisions.length];
- //copy over remote revisions
- System.arraycopy(remoteRevisions, 0, revisions, 0, remoteRevisions.length);
- }
- }
- }
-
- public IFileRevision getFileRevision(String id) {
- IFileRevision[] revisions = getFileRevisions();
- for (int i = 0; i < revisions.length; i++) {
- if (revisions[i].getContentIdentifier().equals(id))
- return revisions[i];
- }
- return null;
- }
-
- public IFileRevision[] getContributors(IFileRevision revision) {
-
- IFileRevision[] revisions = getFileRevisions();
-
- //the predecessor is the file with a timestamp that is the largest timestamp
- //from the set of all timestamps smaller than the root file's timestamp
- IFileRevision fileRevision = null;
- for (int i = 0; i < revisions.length; i++) {
- if (((CVSFileRevision) revisions[i]).isPredecessorOf(revision)) {
- //no revision has been set as of yet
- if (fileRevision == null)
- fileRevision = revisions[i];
- //this revision is a predecessor - now check to see if it comes
- //after the current predecessor, if it does make it the current predecessor
- if (revisions[i].getTimestamp() > fileRevision.getTimestamp()) {
- fileRevision = revisions[i];
- }
- }
- }
- if (fileRevision == null)
- return new IFileRevision[0];
- return new IFileRevision[] {fileRevision};
- }
-
- public IFileRevision[] getTargets(IFileRevision revision) {
- IFileRevision[] revisions = getFileRevisions();
-
- //the predecessor is the file with a timestamp that is the largest timestamp
- //from the set of all timestamps smaller than the root file's timestamp
- ArrayList directDescendents = new ArrayList();
-
- for (int i = 0; i < revisions.length; i++) {
- if (((CVSFileRevision) revisions[i]).isDescendentOf(revision)) {
- directDescendents.add(revisions[i]);
- }
- }
- return (IFileRevision[]) directDescendents.toArray(new IFileRevision[directDescendents.size()]);
- }
-
- private IFileRevision[] convertToFileRevision(IFileState[] localRevisions, IProgressMonitor monitor) {
- boolean modified = false;
- try {
- modified = cvsFile.isModified(monitor);
- } catch (CVSException e) {
- }
-
- IFile localFile = (IFile) cvsFile.getIResource();
- boolean localFileExists = (localFile != null && localFile.exists());
- int arrayLength = 0;
- if (modified && localFileExists)
- arrayLength++;
-
- arrayLength += localRevisions.length;
-
- IFileRevision[] fileRevisions = new IFileRevision[arrayLength];
- for (int i = 0; i < localRevisions.length; i++) {
- IFileState localFileState = localRevisions[i];
- CVSLocalFileRevision localRevision = new CVSLocalFileRevision(localFileState);
- fileRevisions[i] = localRevision;
- }
-
- if (modified && localFileExists) {
- CVSLocalFileRevision currentFile = new CVSLocalFileRevision(localFile);
- CVSFileHistoryProvider provider = new CVSFileHistoryProvider();
- currentFile.setBaseRevision(provider.getWorkspaceFileRevision(localFile));
- fileRevisions[localRevisions.length] = currentFile;
- }
-
- return fileRevisions;
- }
-
- public void includeLocalRevisions(boolean flag) {
- this.includeLocalRevisions = flag;
- }
-
- public boolean getIncludesExists() {
- return includesExists;
- }
-
- public void setRefetchRevisions(boolean refetch) {
- this.refetchRevisions = refetch;
- }
-
- public void includeRemoteRevisions(boolean flag) {
- this.includeRemoteRevisions = flag;
- }
-
- public void fetchLocalOnly(IProgressMonitor monitor) {
- try{
- localRevisions = new IFileRevision[0];
- //always fetch the local revisions, just filter them out from the returned array if not wanted
- IResource localResource = cvsFile.getIResource();
- includesExists = false;
- if (localResource != null && localResource instanceof IFile) {
- //get the local revisions
- IFileState[] localHistoryState = ((IFile) localResource).getHistory(new SubProgressMonitor(monitor, 100));
- localRevisions = convertToFileRevision(localHistoryState, new SubProgressMonitor(monitor, 100));
- includesExists = (localRevisions.length > 0);
- }
-
- if (remoteRevisions == null)
- remoteRevisions = new IFileRevision[0];
- revisions = new IFileRevision[0];
- arrangeRevisions();
- } catch (CoreException ex){
- //nothing to do - calling getFileRevisions() when revisions is null will result in
- //revisions returning an empty array
- } finally {
- monitor.done();
- }
- }
-
- public boolean isInitialized() {
- return revisions != null;
- }
-
- public boolean isIncludeLocal() {
- return includeLocalRevisions;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileHistoryProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileHistoryProvider.java
deleted file mode 100644
index c5f358984..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileHistoryProvider.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.team.internal.ccvs.core.filehistory;
-
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.history.*;
-import org.eclipse.team.core.history.provider.FileHistoryProvider;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry;
-import org.eclipse.team.internal.ccvs.core.filesystem.CVSFileStore;
-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.syncinfo.ResourceSyncInfo;
-
-public class CVSFileHistoryProvider extends FileHistoryProvider {
-
- /**
- * see <code>org.eclipse.team.core.IFileHistoryProvider</code>
- */
- public IFileHistory getFileHistoryFor(IResource resource, int flags, IProgressMonitor monitor) {
- ICVSRemoteResource remoteResource;
- try {
- monitor.beginTask(null, 100);
- if ((flags == IFileHistoryProvider.SINGLE_REVISION) || ((flags == IFileHistoryProvider.SINGLE_LINE_OF_DESCENT))) {
- remoteResource = CVSWorkspaceRoot.getRemoteResourceFor(resource);
- monitor.worked(40);
- CVSFileHistory remoteFile = null;
- if (remoteResource instanceof ICVSFile) {
- remoteFile = new CVSFileHistory((ICVSFile) remoteResource, flags);
- remoteFile.refresh(CVSFileHistory.REFRESH_ALL, monitor);
- }
- return remoteFile;
- } else {
- // TODO need to complete the revision
- remoteResource = CVSWorkspaceRoot.getRemoteResourceFor(resource);
- monitor.worked(40);
- CVSFileHistory remoteFile = null;
- if (remoteResource instanceof ICVSFile) {
- remoteFile = new CVSFileHistory((ICVSFile) remoteResource);
- remoteFile.refresh(CVSFileHistory.REFRESH_ALL, monitor);
- }
- return remoteFile;
- }
- } catch (CVSException e) {
- } catch (TeamException e) {
- } finally {
- monitor.done();
- }
-
- return null;
- }
-
- public IFileRevision getWorkspaceFileRevision(IResource resource) {
-
- ICVSRemoteResource remoteResource;
- try {
- remoteResource = CVSWorkspaceRoot.getRemoteResourceFor(resource);
- if (remoteResource != null &&
- remoteResource instanceof RemoteFile){
- ResourceSyncInfo syncInfo = remoteResource.getSyncInfo();
- LogEntry cvsEntry = new LogEntry((RemoteFile) remoteResource, syncInfo.getRevision(), "", null,"","", new CVSTag[0]); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- return new CVSFileRevision(cvsEntry);
- }
- } catch (CVSException e) {
- }
-
- return null;
- }
-
- public IFileHistory getFileHistoryFor(IFileStore store, int flags, IProgressMonitor monitor) {
- if (store instanceof CVSFileStore) {
-
- CVSFileStore fileStore = (CVSFileStore) store;
- ICVSRemoteFile file = fileStore.getCVSURI().toFile();
- if (file != null){
- try{
- if ((flags == IFileHistoryProvider.SINGLE_REVISION) || ((flags == IFileHistoryProvider.SINGLE_LINE_OF_DESCENT))) {
- CVSFileHistory history = new CVSFileHistory(file, flags);
- history.refresh(CVSFileHistory.REFRESH_ALL, monitor);
- return history;
- } else{
- CVSFileHistory history = new CVSFileHistory(file);
- history.refresh(CVSFileHistory.REFRESH_ALL, monitor);
- return history;
- } } catch (TeamException ex){}
- }
- }
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileRevision.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileRevision.java
deleted file mode 100644
index d01eb5d31..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileRevision.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.team.internal.ccvs.core.filehistory;
-
-import java.net.URI;
-
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.history.IFileRevision;
-import org.eclipse.team.core.history.ITag;
-import org.eclipse.team.core.history.provider.FileRevision;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-
-public class CVSFileRevision extends FileRevision implements IAdaptable {
-
- protected ILogEntry entry;
-
- public CVSFileRevision(ILogEntry entry) {
- this.entry = entry;
- }
-
- public long getTimestamp() {
- return entry.getDate().getTime();
- }
-
- public String getAuthor() {
- return entry.getAuthor();
- }
-
- public String getComment() {
- return entry.getComment();
- }
-
- public boolean isPredecessorOf(IFileRevision revision) {
- long compareRevisionTime = revision.getTimestamp();
- return (this.getTimestamp() < compareRevisionTime);
- }
-
- public boolean isDescendentOf(IFileRevision revision) {
- long compareRevisionTime = revision.getTimestamp();
- return (this.getTimestamp() > compareRevisionTime);
- }
-
- public IStorage getStorage(IProgressMonitor monitor) throws TeamException {
- RemoteFile remoteFile = (RemoteFile) entry.getRemoteFile();
- return remoteFile.getStorage(monitor);
- }
-
- public String getName(){
- return entry.getRemoteFile().getName();
- }
-
- public String getContentIdentifier() {
- return entry.getRevision();
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof CVSFileRevision){
- CVSFileRevision objRevision = (CVSFileRevision) obj;
- ICVSRemoteFile remFile = objRevision.getCVSRemoteFile();
- if (remFile.equals(this.getCVSRemoteFile()) &&
- objRevision.getContentIdentifier().equals(this.getContentIdentifier()))
- return true;
- }
- return false;
- }
-
- public URI getURI() {
- ICVSRemoteFile file = entry.getRemoteFile();
- return ((RemoteFile)file).toCVSURI().toURI();
- }
-
- public ITag[] getTags() {
- return entry.getTags();
- }
-
- public boolean exists() {
- return !entry.isDeletion();
- }
-
- public ICVSRemoteFile getCVSRemoteFile(){
- return entry.getRemoteFile();
- }
-
- public boolean isPropertyMissing() {
- //If we have an author and a comment then we consider this revision complete
- if (entry.getAuthor() == null)
- return true;
-
- return false;
- }
-
- public IFileRevision withAllProperties(IProgressMonitor monitor) throws CoreException {
- return new CVSFileRevision(getCVSRemoteFile().getLogEntry(monitor));
- }
-
- public Object getAdapter(Class adapter) {
- if (adapter == ICVSFile.class)
- return getCVSRemoteFile();
- if (adapter == IResourceVariant.class)
- return getCVSRemoteFile();
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSLocalFileRevision.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSLocalFileRevision.java
deleted file mode 100644
index 2e174d4ea..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSLocalFileRevision.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.filehistory;
-
-import org.eclipse.core.filesystem.URIUtil;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.core.history.LocalFileRevision;
-
-/**
- * This subclass is used exclusively for displaying a LocalFileRevision
- * in a CVSHistoryPage. This class was required to link local file revisions
- * to the CVSHistoryPageSource through the use of the adapter mechanism.
- *
- * @since 3.2
- */
-public class CVSLocalFileRevision extends LocalFileRevision implements IAdaptable {
-
- public CVSLocalFileRevision(IFile file) {
- super(file);
- }
-
- public CVSLocalFileRevision(IFileState fileState) {
- super(fileState);
- }
-
- public Object getAdapter(Class adapter) {
- if (adapter == ICVSFile.class)
- return CVSWorkspaceRoot.getCVSFileFor(ResourcesPlugin.getWorkspace().getRoot().getFile(URIUtil.toPath(getURI())));
-
- return null;
- }
-
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSResourceVariantFileRevision.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSResourceVariantFileRevision.java
deleted file mode 100644
index b8a663fc9..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSResourceVariantFileRevision.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.filehistory;
-
-import java.net.URI;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.history.IFileRevision;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-import org.eclipse.team.internal.core.mapping.ResourceVariantFileRevision;
-
-public class CVSResourceVariantFileRevision extends ResourceVariantFileRevision {
-
- public CVSResourceVariantFileRevision(IResourceVariant variant) {
- super(variant);
- }
-
- public boolean isPropertyMissing() {
- return true;
- }
-
- public IFileRevision withAllProperties(IProgressMonitor monitor) throws CoreException {
- return new CVSFileRevision(getCVSRemoteFile().getLogEntry(monitor));
- }
-
- private ICVSRemoteFile getCVSRemoteFile() {
- return (ICVSRemoteFile)getVariant();
- }
-
- public URI getURI() {
- return ((RemoteFile)getCVSRemoteFile()).toCVSURI().toURI();
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSFileStore.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSFileStore.java
deleted file mode 100644
index bed2e4437..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSFileStore.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.filesystem;
-
-import java.io.InputStream;
-import java.net.URI;
-
-import org.eclipse.core.filesystem.IFileInfo;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.filesystem.provider.FileInfo;
-import org.eclipse.core.filesystem.provider.FileStore;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.variants.CachedResourceVariant;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-
-public class CVSFileStore extends FileStore {
-
-
- private final CVSURI uri;
- private IFileInfo info;
-
- public CVSFileStore(CVSURI uri, IFileInfo info) {
- this.uri = uri;
- this.info = info;
- }
-
- public boolean canReturnFullTree() {
- return true;
- }
-
- public String[] childNames(int options, IProgressMonitor monitor) throws CoreException {
- monitor = Policy.monitorFor(monitor);
- IFileInfo[] infos = childInfos(options, monitor);
- String[] names = new String[infos.length];
- for (int i = 0; i < infos.length; i++) {
- names[i] = infos[i].getName();
- }
- return names;
- }
-
- public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException {
- monitor = Policy.monitorFor(monitor);
- if (info != null && !info.isDirectory()) {
- return new IFileInfo[0];
- }
- ICVSRemoteFolder folder = uri.toFolder();
- ICVSResource[] children = folder.fetchChildren(monitor);
-
- IFileInfo[] childInfos = new IFileInfo[children.length];
- for (int i = 0; i < children.length; i++) {
- ICVSResource child = children[i];
- IFileInfo info = getFileInfo(child, monitor);
- childInfos[i] = info;
- }
- return childInfos;
- }
-
- public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException {
- monitor = Policy.monitorFor(monitor);
- IFileInfo[] infos = childInfos(options, monitor);
- IFileStore[] children = new IFileStore[infos.length];
- for (int i = 0; i < infos.length; i++) {
- children[i] = getChild(infos[i]);
- }
- return children;
- }
-
- private IFileStore getChild(IFileInfo info) {
- return new CVSFileStore(uri.append(info.getName()), info);
- }
-
- public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException {
- monitor = Policy.monitorFor(monitor);
-
- if (isStickyRevision()) {
- ICVSRemoteFile file = uri.toFile();
- return getFileInfo(file, monitor);
- }
- ICVSRemoteFolder folder = uri.getParentFolder();
-
- if (folder == null) {
- // this is the repo root so return an info that indicates this
- FileInfo info = new FileInfo();
- info.setExists(true);
- info.setName(uri.getRepositoryName());
- info.setDirectory(true);
- }
- ICVSResource[] children = folder.fetchChildren(monitor);
- ICVSResource resource = null;
- for (int i = 0; i < children.length; i++) {
- ICVSResource child = children[i];
- if (child.getName().equals(getName())) {
- resource = child;
- break;
- }
- }
- return getFileInfo(resource, monitor);
- }
-
- private boolean isStickyRevision() {
- String revision = uri.getRevision();
- CVSTag tag = uri.getTag();
- if (revision == null)
- return false;
- if (tag == null)
- return false;
- return revision.equals(tag.getName());
- }
-
- private IFileInfo getFileInfo(ICVSResource resource, IProgressMonitor monitor) throws TeamException {
- monitor = Policy.monitorFor(monitor);
- if (resource == null)
- return null;
- FileInfo info = new FileInfo();
- info.setExists(true);
- info.setName(resource.getName());
- if (!resource.isFolder()) {
- ICVSRemoteFile file = (ICVSRemoteFile) resource;
- // Avoid a round trip by looking for the file in the cache
- if (file instanceof RemoteFile) {
- RemoteFile remote = (RemoteFile) file;
- CachedResourceVariant variant = remote.getCachedHandle();
- if (variant instanceof ICVSRemoteFile) {
- file = (ICVSRemoteFile) variant;
- }
- }
- ILogEntry entry = file.getLogEntry(monitor);
- info.setLastModified(entry.getDate().getTime());
- } else {
- info.setLastModified(0);
- info.setDirectory(true);
- }
- return info;
- }
-
- public IFileStore getChild(String name) {
- if (info != null && !info.isDirectory()) {
- return null;
- }
- return new CVSFileStore(uri.append(name), null);
- }
-
- public IFileStore getChild(IPath path) {
- return new CVSFileStore(uri.append(path), null);
- }
-
-
- public String getName() {
- return uri.getLastSegment();
- }
-
- public IFileStore getParent() {
- if (uri.isRepositoryRoot()) {
- return null;
- }
- return new CVSFileStore(uri.removeLastSegment(), null);
- }
-
- public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException {
- monitor = Policy.monitorFor(monitor);
- ICVSRemoteFile file = uri.toFile();
- IStorage storage = ((IResourceVariant) file).getStorage(monitor);
- return storage.getContents();
- }
-
- public URI toURI() {
- return uri.toURI();
- }
-
- public CVSURI getCVSURI() {
- return uri;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSFileSystem.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSFileSystem.java
deleted file mode 100644
index 93b65eee7..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSFileSystem.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.filesystem;
-import java.net.URI;
-import java.util.HashMap;
-
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.filesystem.provider.FileSystem;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.internal.ccvs.core.CVSMessages;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTree;
-
-public class CVSFileSystem extends FileSystem {
-
-
- private CVSFileTree cvsTree;
-
- public CVSFileSystem() {
- super();
- }
-
- public IFileStore getStore(URI uri) {
- return new CVSFileStore(CVSURI.fromUri(uri), null);
- }
-
- public boolean canReturnFullTree(){
- return true;
- }
-
- public CVSFileTree getFullTree(URI uri, IProgressMonitor monitor){
- try{
- monitor.beginTask(CVSMessages.CVSFileSystem_FetchTree, 100);
- //always return new tree
- //monitor.subTask(NLS.bind(message, binding));
- if (cvsTree != null)
- return cvsTree;
-
- return this.refreshTree(uri, monitor);
- }
- finally{
- monitor.done();
- }
- }
-
-
- public CVSFileTree refreshTree(URI uri, IProgressMonitor monitor){
- CVSURI cvsURI = CVSURI.fromUri(uri);
-
- //Make sure that we're building the tree from the topmost level - keep cycling until you hit null
- ICVSRemoteFolder folder = cvsURI.getProjectURI().toFolder();
-
- try {
- RemoteLogger logger = new RemoteLogger(folder);
-
- RemoteFolderTree remoteTree = logger.fetchTree(new SubProgressMonitor(monitor,80));
- HashMap folderMap = logger.getFolderMap();
- HashMap logMap = logger.getLogMap();
- folderMap.put(folder.getName(), remoteTree);
- //Save tree
- cvsTree = new CVSFileTree(new CVSFileStore(cvsURI, null), cvsURI, remoteTree, folderMap, logMap);
-
- return cvsTree;
- } catch (CoreException e) {
- CVSProviderPlugin.log(e);
- return null;
- }
-
-
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSFileTree.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSFileTree.java
deleted file mode 100644
index 0dc031d5a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSFileTree.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.filesystem;
-
-import java.util.HashMap;
-
-import org.eclipse.core.filesystem.IFileInfo;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.filesystem.provider.FileInfo;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTree;
-
-public class CVSFileTree {
-
- private RemoteFolderTree remoteTree;
- //HashMap of RemoteFolders used to speed up look up
- private HashMap remoteFolders;
- private HashMap logMap;
- private CVSURI baseURI;
-
- public CVSFileTree(IFileStore treeRoot, CVSURI uri, RemoteFolderTree remoteTree, HashMap remoteFolders, HashMap logMap) {
- this.remoteTree = remoteTree;
- this.baseURI = uri;
- this.remoteFolders = remoteFolders;
- this.logMap = logMap;
- }
-
- public IFileStore[] getChildrenFileStores(IFileStore store) {
- CVSURI cvsUri = CVSURI.fromUri(store.toURI());
- RemoteFolderTree folderTree = (RemoteFolderTree) remoteFolders.get(cvsUri.getProjectStrippedPath().toString());
-
- if (folderTree == null)
- return null;
-
- ICVSRemoteResource[] remoteResources = folderTree.getChildren();
- IFileStore[] fileStore = new IFileStore[remoteResources.length];
- for (int i = 0; i < remoteResources.length; i++) {
- IFileInfo fileInfo;
- try {
- fileInfo = getFileInfo((ICVSResource) remoteResources[i], new NullProgressMonitor());
- fileStore[i] = new CVSFileStore(baseURI.append(fileInfo.getName()), fileInfo);
- } catch (TeamException e) {}
- }
- return fileStore;
- }
-
- private IFileInfo getFileInfo(ICVSResource resource, IProgressMonitor monitor) throws TeamException {
- monitor = Policy.monitorFor(monitor);
- if (resource == null)
- return null;
- FileInfo info = new FileInfo();
- info.setExists(true);
- info.setName(resource.getName());
- if (!resource.isFolder()) {
- ICVSRemoteFile file = (ICVSRemoteFile) resource;
- //TODO: how to handle entries that are not found
- ILogEntry entry = (ILogEntry) logMap.get(file);
- //ILogEntry entry = file.getLogEntry(monitor);
- info.setLastModified(entry.getDate().getTime());
- } else {
- info.setLastModified(0);
- info.setDirectory(true);
- }
- return info;
- }
-
- public IFileInfo[] getChildrenFileInfos(IFileStore store) {
-
- CVSURI cvsUri = CVSURI.fromUri(store.toURI());
- RemoteFolderTree folderTree = (RemoteFolderTree) remoteFolders.get(cvsUri.getProjectStrippedPath().toString());
-
- if (folderTree == null)
- return null;
-
- ICVSRemoteResource[] remoteResources = folderTree.getChildren();
- IFileInfo[] fileInfos = new IFileInfo[remoteResources.length];
- for (int i = 0; i < remoteResources.length; i++) {
- IFileInfo fileInfo;
- try {
- fileInfo = getFileInfo((ICVSResource) remoteResources[i], new NullProgressMonitor());
- fileInfos[i] = fileInfo;
- } catch (TeamException e) {}
- }
- return fileInfos;
- }
-
- public IFileInfo getFileInfo(IFileStore store) {
- ICVSRemoteFolder folder=null;
- String resourceName = null;
- CVSURI cvsUri = CVSURI.fromUri(store.toURI());
-
- folder = cvsUri.getParentFolder();
- resourceName = cvsUri.getLastSegment();
-
- if (folder.getName().equals(ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME)) {
- // this is the repository root so return an info that indicates this
- FileInfo info = new FileInfo();
- info.setExists(true);
- info.setName(resourceName);
- info.setDirectory(true);
- return info;
- }
- try {
- RemoteFolderTree remoteFolder = (RemoteFolderTree) remoteFolders.get(folder.getName());
-
- if (remoteFolder == null){
- String repoPath = folder.getRepositoryRelativePath();
- IPath repoPath2 = new Path(repoPath);
- repoPath2 = repoPath2.removeFirstSegments(1);
- remoteFolder = (RemoteFolderTree) remoteFolders.get(repoPath2.toString());
- }
-
- //ok, we tried a short cut, but it wasn't meant to be so look at the entire tree
- if (remoteFolder == null)
- remoteFolder = remoteTree;
-
-
- ICVSRemoteResource[] children =remoteFolder.getChildren();
- ICVSResource resource = null;
- for (int i = 0; i < children.length; i++) {
- ICVSResource child = children[i];
- if (child.getName().equals(resourceName)) {
- resource = child;
- break;
- }
- }
- return getFileInfo(resource, new NullProgressMonitor());
- } catch (CoreException e) {
- CVSProviderPlugin.log(e);
- return null;
- }
- }
-
-
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSURI.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSURI.java
deleted file mode 100644
index 5a54ed54f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSURI.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.filesystem;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-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.ResourceSyncInfo;
-
-public class CVSURI {
-
- private static final String SCHEME = "cvs"; //$NON-NLS-1$
- private final ICVSRepositoryLocation repository;
- private final IPath path;
- private final CVSTag tag;
- private final String revision;
-
- /**
- * Convert the given URI to a CVSURI. There are two supported formats: the
- * original opaque format and a newer hierarchical format.
- * <ul>
- * <li>cvs://[:]method:user[:password]@host:[port]/root/path#project/path[,tagName]</li>
- * <li>cvs://_method_user[_password]~host_[port]!root!path/project/path[?<version,branch,date,revision>=tagName]</li>
- * </ul>
- * @param uri the URI
- * @return a CVS URI
- */
- public static CVSURI fromUri(URI uri) {
- try {
- ICVSRepositoryLocation repository = getRepository(uri);
- if (repository != null) {
- IPath path = new Path(null, uri.getPath());
- CVSTag tag = getTag(uri);
- String revision = getRevision(uri);
- return new CVSURI(repository, path, tag, revision);
- } else {
- repository = getOldRepository(uri);
- IPath path = getOldPath(uri);
- CVSTag tag = getOldTag(uri);
- return new CVSURI(repository, path, tag);
- }
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- throw new IllegalArgumentException(NLS.bind(CVSMessages.CVSURI_InvalidURI, new String[] {uri.toString(), e.getMessage()}));
- }
- }
-
- private static CVSTag getTag(URI uri) {
- String query = uri.getQuery();
- if (query == null)
- return null;
- StringTokenizer tokens = new StringTokenizer(query, ","); //$NON-NLS-1$
- while (tokens.hasMoreTokens()) {
- String token = tokens.nextToken();
- int index = token.indexOf('=');
- if (index != -1) {
- String type = token.substring(0, index);
- String value = token.substring(index + 1);
- if (value.length() > 0) {
- int tagType = getTagType(type);
- if (tagType != -1)
- return new CVSTag(value, tagType);
- }
- }
- }
- return null;
- }
-
- private static String getRevision(URI uri) {
- String query = uri.getQuery();
- if (query == null)
- return null;
- StringTokenizer tokens = new StringTokenizer(query, ","); //$NON-NLS-1$
- while (tokens.hasMoreTokens()) {
- String token = tokens.nextToken();
- int index = token.indexOf('=');
- if (index != -1) {
- String type = token.substring(0, index);
- String value = token.substring(index + 1);
- if (type.equals("revision") && isValidRevision(value)) { //$NON-NLS-1$
- return value;
- }
- }
- }
- return null;
- }
-
- private static boolean isValidRevision(String value) {
- return value.matches("\\d+\\.\\d+(?:\\.\\d+)*"); //$NON-NLS-1$
- }
-
- private static int getTagType(String type) {
- if (type.equalsIgnoreCase("version")) //$NON-NLS-1$
- return CVSTag.VERSION;
- if (type.equalsIgnoreCase("branch")) //$NON-NLS-1$
- return CVSTag.BRANCH;
- if (type.equalsIgnoreCase("date")) //$NON-NLS-1$
- return CVSTag.DATE;
- return -1;
- }
-
- private static ICVSRepositoryLocation getRepository(URI uri) throws CVSException {
- String authority = uri.getAuthority();
- if (authority.indexOf('/') != -1)
- return null;
- if (authority.indexOf('!') == -1)
- return null;
- authority = decodeAuthority(authority);
- return CVSRepositoryLocation.fromString(authority);
- }
-
- private static CVSTag getOldTag(URI uri) {
- String f = uri.getFragment();
- int i = f.indexOf(',');
- if (i == -1) {
- return CVSTag.DEFAULT;
- }
-
- return CVSTag.DEFAULT;//just use HEAD for now (name, CVSTag.BRANCH);
- }
-
- private static IPath getOldPath(URI uri) {
- String path = uri.getFragment();
- int i = path.indexOf(',');
- if (i != -1) {
- path = path.substring(0, i);
- }
- return new Path(path);
- }
-
- private static ICVSRepositoryLocation getOldRepository(URI uri) throws CVSException {
- String ssp = uri.getSchemeSpecificPart();
- if (!ssp.startsWith(":")) { //$NON-NLS-1$
- ssp = ":" + ssp; //$NON-NLS-1$
- }
- return CVSRepositoryLocation.fromString(ssp);
- }
-
- public CVSURI(ICVSRepositoryLocation repository, IPath path, CVSTag tag) {
- this(repository, path, tag, null);
- }
-
- public CVSURI(ICVSRepositoryLocation repository, IPath path, CVSTag tag, String revision) {
- this.repository = repository;
- this.path = path;
- this.tag = tag;
- if (revision != null && !revision.equals(ResourceSyncInfo.ADDED_REVISION))
- this.revision = revision;
- else
- this.revision = null;
- }
-
- public CVSURI append(String name) {
- return new CVSURI(repository, path.append(name), tag);
- }
-
- public CVSURI append(IPath childPath) {
- return new CVSURI(repository, path.append(childPath), tag);
- }
-
- public String getLastSegment() {
- return path.lastSegment();
- }
-
- public URI toURI() {
- try {
- String authority = repository.getLocation(false);
- authority = ensureRegistryBasedAuthority(authority);
- String pathString = path.toString();
- if (!pathString.startsWith("/")) { //$NON-NLS-1$
- pathString = "/" + pathString; //$NON-NLS-1$
- }
- String query = null;
- if (tag != null && tag.getType() != CVSTag.HEAD) {
- query = getQueryType(tag) + "=" + tag.getName(); //$NON-NLS-1$
- }
- if (revision != null) {
- String string = "revision=" + revision; //$NON-NLS-1$
- if (query == null) {
- query = string;
- } else {
- query = query + "," + string; //$NON-NLS-1$
- }
- }
- return new URI(SCHEME, authority, pathString, query, null);
- } catch (URISyntaxException e) {
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("An error occurred while creating a URI for {0} {1}", repository, path), e); //$NON-NLS-1$
- throw new IllegalStateException(e.getMessage());
- }
- }
-
- /*
- * Ensure that the authority will not be confused with a
- * server based authority. To do this, we need to convert
- * any /, : and @ to another form.
- */
- private String ensureRegistryBasedAuthority(String authority) {
- // Encode / so the authority doesn't conflict with the path
- authority = encode('/', '!', authority);
- // Encode @ to avoid URI interpreting the authority as a server based authority
- authority = encode('@', '~', authority);
- // Encode : to avoid URI interpreting the authority as a server based authority
- authority = encode(':', '_', authority);
- return authority;
- }
-
- private static String decodeAuthority(String authority) {
- authority = decode('/', '!', authority);
- authority = decode('@', '~', authority);
- authority = decode(':', '_', authority);
- return authority;
- }
-
- private String encode(char charToEncode, char encoding, String string) {
- // First, escape any occurrences of the encoding character
- String result = string.replaceAll(new String(new char[] { encoding }), new String(new char[] { encoding, encoding }));
- // Convert / to ! to avoid URI parsing part of the authority as the path
- return result.replace(charToEncode, encoding);
- }
-
- private static String decode(char encodedChar, char encoding, String string) {
- // Convert the encoded char back
- String reuslt = string.replace(encoding, encodedChar);
- // Convert any double occurrences of the encoded char back to the encoding
- return reuslt.replaceAll(new String(new char[] { encodedChar, encodedChar }), new String(new char[] { encoding }));
- }
-
- private static String getQueryType(CVSTag tag) {
- switch (tag.getType()) {
- case CVSTag.BRANCH:
- return "branch"; //$NON-NLS-1$
- case CVSTag.DATE:
- return "date"; //$NON-NLS-1$
- }
- return "version"; //$NON-NLS-1$
- }
-
- public boolean isRepositoryRoot() {
- return path.segmentCount() == 0;
- }
-
- public CVSURI removeLastSegment() {
- return new CVSURI(repository, path.removeLastSegments(1), tag);
- }
-
- public ICVSRemoteFolder getParentFolder() {
- return removeLastSegment().toFolder();
- }
-
- public String getRepositoryName() {
- return repository.toString();
- }
-
- public CVSURI getProjectURI(){
- return new CVSURI(repository, path.uptoSegment(1), tag);
- }
-
- public ICVSRemoteFolder toFolder() {
- return new RemoteFolder(null, repository, path.toString(), tag);
- }
-
- public ICVSRemoteFile toFile() {
- // TODO: What about keyword mode?
- return RemoteFile.create(path.toString(), repository, tag, revision);
- }
-
- public String toString() {
- return "[Path: "+this.path.toString()+" Tag: "+tag.getName()+ " Repo: " +repository.getRootDirectory() +"]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- public IPath getPath(){
- return path;
- }
-
- public IPath getProjectStrippedPath() {
- if (path.segmentCount() > 1)
- return path.removeFirstSegments(1);
-
- return path;
- }
-
- public ICVSRepositoryLocation getRepository() {
- return repository;
- }
-
- public CVSTag getTag() {
- return tag;
- }
-
- public String getRevision() {
- return revision;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/LogEntryCache.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/LogEntryCache.java
deleted file mode 100644
index ba922666f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/LogEntryCache.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/**
- *
- */
-package org.eclipse.team.internal.ccvs.core.filesystem;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ILogEntry;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ILogEntryListener;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-class LogEntryCache implements ILogEntryListener {
-
- /*
- * Cache of all log entries
- */
- private Map entries = new HashMap(); /* Map String:remoteFilePath->Map (String:revision -> ILogEntry) */
-
- Map internalGetLogEntries(String path) {
- return (Map) entries.get(path);
- }
-
- /**
- * Return all the log entries at the given path
- * @param path the file path
- * @return the log entries for the file
- */
- public ILogEntry[] getLogEntries(String path) {
- Map map = internalGetLogEntries(path);
- return (ILogEntry[]) map.values().toArray(new ILogEntry[map.values().size()]);
- }
-
- ILogEntry internalGetLogEntry(String path, String revision) {
- Map fileEntries = internalGetLogEntries(path);
- if (fileEntries != null) {
- return (ILogEntry) fileEntries.get(revision);
- }
- return null;
- }
-
- public String[] getCachedFilePaths() {
- return (String[]) entries.keySet().toArray(new String[entries.size()]);
- }
-
- /**
- * Return the log entry that for the given resource
- * or <code>null</code> if no entry was fetched or the
- * resource is not a file.
- * @param getFullPath(resource) the resource
- * @return the log entry or <code>null</code>
- */
- public synchronized ILogEntry getLogEntry(ICVSRemoteResource resource) {
- if (resource instanceof ICVSRemoteFile) {
- try {
- String path = getFullPath(resource);
- String revision = ((ICVSRemoteFile) resource).getRevision();
- return internalGetLogEntry(path, revision);
- } catch (TeamException e) {
- // Log and return null
- }
- }
- return null;
- }
-
- /**
- * Return the log entries that were fetched for the given resource
- * or an empty list if no entry was fetched.
- * @param getFullPath(resource) the resource
- * @return the fetched log entries or an empty list is none were found
- */
- public synchronized ILogEntry[] getLogEntries(ICVSRemoteResource resource) {
- Map fileEntries = internalGetLogEntries(getFullPath(resource));
- if (fileEntries != null) {
- return (ILogEntry[]) fileEntries.values().toArray(new ILogEntry[fileEntries.size()]);
- }
- return new ILogEntry[0];
- }
-
- /*
- * Return the full path that uniquely identifies the resource
- * accross repositories. This path include the repository and
- * resource path but does not include the revision so that
- * all log entries for a file can be retrieved.
- */
- String getFullPath(ICVSRemoteResource resource) {
- return Util.appendPath(resource.getRepository().getLocation(false), resource.getRepositoryRelativePath());
- }
-
- public synchronized void clearEntries() {
- entries.clear();
- }
-
- public synchronized ICVSRemoteFile getImmediatePredecessor(ICVSRemoteFile file) throws TeamException {
- ILogEntry[] allLogs = getLogEntries(file);
- String revision = file.getRevision();
- // First decrement the last digit and see if that revision exists
- String predecessorRevision = getPredecessorRevision(revision);
- ICVSRemoteFile predecessor = findRevison(allLogs, predecessorRevision);
- // If nothing was found, try to fond the base of a branch
- if (predecessor == null && isBrancheRevision(revision)) {
- predecessorRevision = getBaseRevision(revision);
- predecessor = findRevison(allLogs, predecessorRevision);
- }
- // If that fails, it is still possible that there is a revision.
- // This can happen if the revision has been manually set.
- if (predecessor == null) {
- // We don't search in this case since this is costly and would be done
- // for any file that is new as well.
- }
- return predecessor;
- }
-
- /*
- * Find the given revision in the list of log entries.
- * Return null if the revision wasn't found.
- */
- ICVSRemoteFile findRevison(ILogEntry[] allLogs, String predecessorRevision) throws TeamException {
- for (int i = 0; i < allLogs.length; i++) {
- ILogEntry entry = allLogs[i];
- ICVSRemoteFile file = entry.getRemoteFile();
- if (file.getRevision().equals(predecessorRevision)) {
- return file;
- }
- }
- return null;
- }
-
- /*
- * Decrement the trailing digit by one.
- */
- String getPredecessorRevision(String revision) {
- int digits[] = Util.convertToDigits(revision);
- digits[digits.length - 1]--;
- StringBuffer buffer = new StringBuffer(revision.length());
- for (int i = 0; i < digits.length; i++) {
- buffer.append(Integer.toString(digits[i]));
- if (i < digits.length - 1) {
- buffer.append('.');
- }
- }
- return buffer.toString();
- }
-
- /*
- * Return true if there are more than 2 digits in the revision number
- * (i.e. the revision is on a branch)
- */
- boolean isBrancheRevision(String revision) {
- return Util.convertToDigits(revision).length > 2;
- }
-
- /*
- * Remove the trailing revision digits such that the
- * returned revision is shorter than the given revision
- * and is an even number of digits long
- */
- String getBaseRevision(String revision) {
- int digits[] = Util.convertToDigits(revision);
- int length = digits.length - 1;
- if (length % 2 == 1) {
- length--;
- }
- StringBuffer buffer = new StringBuffer(revision.length());
- for (int i = 0; i < length; i++) {
- buffer.append(Integer.toString(digits[i]));
- if (i < length - 1) {
- buffer.append('.');
- }
- }
- return buffer.toString();
- }
-
- /**
- * Remove any entries for the remote resources
- * @param resource the remote resource
- */
- public synchronized void clearEntries(ICVSRemoteResource resource) {
- String remotePath = getFullPath(resource);
- entries.remove(remotePath);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.ILogEntryListener#addEntry(org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry)
- */
- public void handleLogEntryReceived(ILogEntry entry) {
- ICVSRemoteFile file = entry.getRemoteFile();
- String fullPath = getFullPath(file);
- String revision = entry.getRevision();
- Map fileEntries = internalGetLogEntries(fullPath);
- if (fileEntries == null) {
- fileEntries = new HashMap();
- entries.put(fullPath, fileEntries);
- }
- fileEntries.put(revision, entry);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/RLogTreeBuilder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/RLogTreeBuilder.java
deleted file mode 100644
index 1aaa3ac18..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/RLogTreeBuilder.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/**
- *
- */
-package org.eclipse.team.internal.ccvs.core.filesystem;
-
-import java.util.HashMap;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTree;
-
-class RLogTreeBuilder {
-
- private ICVSRepositoryLocation location;
- private RemoteFolderTree tree;
- private CVSTag tag;
- private HashMap folderMap;
- private HashMap logMap;
- private LogEntryCache cache;
-
- public RLogTreeBuilder(ICVSRepositoryLocation location, CVSTag tag, LogEntryCache cache) {
- this.tag = tag;
- this.location = location;
- this.cache = cache;
- reset();
- }
-
- public RemoteFolderTree getTree() {
- return tree;
- }
-
- /**
- * Reset the builder to prepare for a new build
- */
- public void reset() {
- folderMap = new HashMap(16);
- logMap = new HashMap(16);
- tree = new RemoteFolderTree(null, location, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, tag);
- tree.setChildren(new ICVSRemoteResource[0]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener.IFileDiffListener#newFile(java.lang.String, java.lang.String)
- */
- public void newFile(IPath remoteFilePath, ICVSRemoteFile remoteFile) {
- try {
- addFile(tree, tag, remoteFile, remoteFilePath);
- } catch (CVSException e) {
- }
- }
-
- private void addFile(RemoteFolderTree tree, CVSTag tag, ICVSRemoteFile file, IPath filePath) throws CVSException {
- RemoteFolderTree parent = (RemoteFolderTree) getFolder(tree, tag, filePath.removeLastSegments(1), Path.EMPTY);
- addChild(parent, file);
- }
-
- private void addChild(RemoteFolderTree tree, ICVSRemoteResource resource) {
- //get the log entry info for this file and save it
- logMap.put(resource, cache.getLogEntry(resource));
-
- ICVSRemoteResource[] children = tree.getChildren();
- ICVSRemoteResource[] newChildren;
- if (children == null) {
- newChildren = new ICVSRemoteResource[] {resource};
- } else {
- newChildren = new ICVSRemoteResource[children.length + 1];
- System.arraycopy(children, 0, newChildren, 0, children.length);
- newChildren[children.length] = resource;
- }
- tree.setChildren(newChildren);
- }
-
- /*
- * Get the folder at the given path in the given tree, creating any missing folders as needed.
- */
- private ICVSRemoteFolder getFolder(RemoteFolderTree tree, CVSTag tag, IPath remoteFolderPath, IPath parentPath) throws CVSException {
- if (remoteFolderPath.segmentCount() == 0)
- return tree;
- String name = remoteFolderPath.segment(0);
- ICVSResource child;
- IPath childPath = parentPath.append(name);
- if (tree.childExists(name)) {
- child = tree.getChild(name);
- } else {
- child = new RemoteFolderTree(tree, tree.getRepository(), childPath.toString(), tag);
- //Save this folder in hash map
- folderMap.put(childPath.toString(), child);
- ((RemoteFolderTree) child).setChildren(new ICVSRemoteResource[0]);
- addChild(tree, (ICVSRemoteResource) child);
- }
- return getFolder((RemoteFolderTree) child, tag, remoteFolderPath.removeFirstSegments(1), childPath);
- }
-
- public HashMap getFolderMap() {
- return folderMap;
- }
-
- public HashMap getLogMap() {
- return logMap;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/RemoteLogger.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/RemoteLogger.java
deleted file mode 100644
index ef76314ce..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/RemoteLogger.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.filesystem;
-
-import java.util.HashMap;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.*;
-import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry;
-import org.eclipse.team.internal.ccvs.core.client.listeners.LogListener;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTree;
-
-public class RemoteLogger {
-
- static final String DEAD_STATE = "dead"; //$NON-NLS-1$
-
- private ICVSRemoteFolder remoteFolder;
- private LogEntryCache cache;
-
- private RLogTreeBuilder treeBuilder;
-
- public RemoteLogger(ICVSRemoteFolder folder) {
- this.remoteFolder = folder;
- }
-
- private void getRemoteChildren(CVSTag tag, IProgressMonitor monitor) {
- Session session = new Session(this.remoteFolder.getRepository(), this.remoteFolder, false /* output to console */);
- try {
- // Build the local options
- this.cache = new LogEntryCache();
- LogListener listener = new LogListener(cache);
-
- Command.LocalOption[] localOptions = getLocalOptions(tag, null);
- try {
- session.open(Policy.subMonitorFor(monitor, 10));
- RLog rlog = new RLog();
- rlog.execute(session, Command.NO_GLOBAL_OPTIONS, localOptions, new ICVSRemoteResource[] {this.remoteFolder}, listener, Policy.subMonitorFor(monitor, 90));
- } catch (CVSException e) {
- }
- } finally {
- session.close();
- }
- }
-
- public ICVSResource[] fetchChildren(IProgressMonitor monitor) throws CVSException, TeamException {
- return fetchTree(monitor).getChildren();
- }
-
- public HashMap getFolderMap() {
- return treeBuilder.getFolderMap();
- }
-
- public RemoteFolderTree fetchTree(IProgressMonitor monitor) throws CVSException, TeamException {
- try{
- monitor.beginTask(null, 100);
- CVSTag tag = this.remoteFolder.getTag();
- if (tag == null)
- tag = CVSTag.DEFAULT;
-
- getRemoteChildren(tag, new SubProgressMonitor(monitor,70));
-
- final ICVSRemoteFolder project = this.remoteFolder;
- //Get the entry paths
- String[] entry = this.cache.getCachedFilePaths();
-
- treeBuilder = new RLogTreeBuilder(project.getRepository(), tag, cache);
- for (int i = 0; i < entry.length; i++) {
- ILogEntry[] logEntry = this.cache.getLogEntries(entry[i]);
-
- //might not have state if this a branch entry
- if (logEntry[0].getState() != null && logEntry[0].getState().equals(DEAD_STATE))
- continue;
-
- ICVSRemoteFile remoteFile = logEntry[0].getRemoteFile();
- //if the current folder tag is a branch tag, we need to take the extra step
- //of making sure that the file's revision number has been set appropriately
- if (tag.getType() == CVSTag.BRANCH && remoteFile.getRevision().equals(LogListener.BRANCH_REVISION))
- verifyRevision(tag, logEntry[0], remoteFile);
-
- IPath logPath = new Path(null, remoteFile.getRepositoryRelativePath());
- if (logPath.segmentCount() > 0) {
- //trim everything up to the project segment
- String[] pathSegments = logPath.segments();
- int index;
- String projectName = project.getName();
- for (index = 0; index < pathSegments.length; index++) {
- if (pathSegments[index].equals(projectName))
- break;
- }
- logPath = logPath.removeFirstSegments(index + 1);
- }
- treeBuilder.newFile(logPath, remoteFile);
- }
-
- return treeBuilder.getTree();
- }
- finally{
- monitor.done();
- }
- }
-
- protected Command.LocalOption[] getLocalOptions(CVSTag tag1, CVSTag tag2) {
- if (tag1 != null && tag2 != null) {
- return new Command.LocalOption[] {RLog.NO_TAGS, RLog.ONLY_INCLUDE_CHANGES, RLog.makeTagOption(tag1, tag2)};
- } else if (tag1 != null) {
- if (tag1.getType() == CVSTag.HEAD || tag1.getType() == CVSTag.VERSION)
- return new Command.LocalOption[] {RLog.NO_TAGS, RLog.ONLY_INCLUDE_CHANGES, RLog.getCurrentTag(tag1)};
-
- if (tag1.getType() == CVSTag.DATE)
- return new Command.LocalOption[] {RLog.NO_TAGS, RLog.ONLY_INCLUDE_CHANGES, RLog.REVISIONS_ON_DEFAULT_BRANCH, RLog.getCurrentTag(tag1)};
- //branch tag
- return new Command.LocalOption[] {RLog.getCurrentTag(tag1)};
- } else {
- return new Command.LocalOption[] {RLog.NO_TAGS, RLog.ONLY_INCLUDE_CHANGES};
- }
- }
-
- private void verifyRevision(CVSTag tag, ILogEntry entry, ICVSRemoteFile remoteFile) throws CVSException {
- if (entry instanceof LogEntry) {
- LogEntry logEntry = (LogEntry) entry;
- String[] allBranchRevisions = logEntry.getBranchRevisions();
- CVSTag[] allCVSTags = entry.getTags();
- for (int i = 0; i < allCVSTags.length; i++) {
- if (allCVSTags[i].equals(tag)) {
- //get the revision number stored for this tag
- ((RemoteFile) remoteFile).setRevision(allBranchRevisions[i]);
- break;
- }
- }
- }
- }
-
- public HashMap getLogMap() {
- return treeBuilder.getLogMap();
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/CVSActiveChangeSet.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/CVSActiveChangeSet.java
deleted file mode 100644
index c13190e9c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/CVSActiveChangeSet.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.mapping;
-
-import org.eclipse.team.internal.core.subscribers.ActiveChangeSet;
-import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
-
-public class CVSActiveChangeSet extends ActiveChangeSet {
-
- public CVSActiveChangeSet(ActiveChangeSetManager manager, String title) {
- super(manager, title);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/CVSActiveChangeSetCollector.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/CVSActiveChangeSetCollector.java
deleted file mode 100644
index 2191645c1..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/CVSActiveChangeSetCollector.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.mapping;
-
-import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.internal.core.subscribers.ActiveChangeSet;
-import org.eclipse.team.internal.core.subscribers.SubscriberChangeSetManager;
-
-/**
- * The CVS Active change set manager
- */
-public class CVSActiveChangeSetCollector extends SubscriberChangeSetManager {
-
- public CVSActiveChangeSetCollector(Subscriber subscriber) {
- super(subscriber);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager#doCreateSet(java.lang.String)
- */
- protected ActiveChangeSet doCreateSet(String name) {
- return new CVSActiveChangeSet(this, name);
- }
-
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/CVSCheckedInChangeSet.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/CVSCheckedInChangeSet.java
deleted file mode 100644
index e0029e76f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/CVSCheckedInChangeSet.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.mapping;
-
-import com.ibm.icu.text.DateFormat;
-import java.util.Date;
-
-import org.eclipse.team.internal.ccvs.core.ILogEntry;
-import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry;
-import org.eclipse.team.internal.core.subscribers.DiffChangeSet;
-
-public class CVSCheckedInChangeSet extends DiffChangeSet {
-
- private final ILogEntry entry;
-
- public CVSCheckedInChangeSet(ILogEntry entry) {
- this.entry = entry;
- Date date = entry.getDate();
- String comment = LogEntry.flattenText(entry.getComment());
- if (date == null) {
- setName("["+entry.getAuthor()+ "] " + comment); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- String dateString = DateFormat.getDateTimeInstance().format(date);
- setName("["+entry.getAuthor()+ "] (" + dateString +") " + comment); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
- public String getAuthor() {
- return entry.getAuthor();
- }
-
- public Date getDate() {
- return entry.getDate();
- }
-
- public String getComment() {
- return entry.getComment();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/ChangeSetAdapterFactory.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/ChangeSetAdapterFactory.java
deleted file mode 100644
index 6371c28d3..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/ChangeSetAdapterFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.mapping;
-
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.runtime.IAdapterFactory;
-
-public class ChangeSetAdapterFactory implements IAdapterFactory {
-
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (adaptableObject instanceof CVSActiveChangeSet && adapterType == ResourceMapping.class) {
- CVSActiveChangeSet cs = (CVSActiveChangeSet) adaptableObject;
- return new ChangeSetResourceMapping(cs);
- }
- if (adaptableObject instanceof CVSCheckedInChangeSet && adapterType == ResourceMapping.class) {
- CVSCheckedInChangeSet cs = (CVSCheckedInChangeSet) adaptableObject;
- return new ChangeSetResourceMapping(cs);
- }
- if (adaptableObject instanceof UnassignedDiffChangeSet && adapterType == ResourceMapping.class) {
- UnassignedDiffChangeSet cs = (UnassignedDiffChangeSet) adaptableObject;
- return new ChangeSetResourceMapping(cs);
- }
- return null;
- }
-
- public Class[] getAdapterList() {
- return new Class[] { ResourceMapping.class };
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/ChangeSetModelProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/ChangeSetModelProvider.java
deleted file mode 100644
index ae32d20af..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/ChangeSetModelProvider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.mapping;
-
-import org.eclipse.core.resources.mapping.ModelProvider;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.internal.core.TeamPlugin;
-
-public class ChangeSetModelProvider extends ModelProvider {
-
- public static final String ID = "org.eclipse.team.cvs.core.changeSetModel"; //$NON-NLS-1$
- private static ChangeSetModelProvider provider;
-
- public ChangeSetModelProvider() {
- super();
- }
-
- public static ChangeSetModelProvider getProvider() {
- if (provider == null) {
- try {
- provider = (ChangeSetModelProvider)ModelProvider.getModelProviderDescriptor(ChangeSetModelProvider.ID).getModelProvider();
- } catch (CoreException e) {
- TeamPlugin.log(e);
- }
- }
- return provider;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/ChangeSetResourceMapping.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/ChangeSetResourceMapping.java
deleted file mode 100644
index 12ffd74d4..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/ChangeSetResourceMapping.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.mapping;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.mapping.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.core.subscribers.DiffChangeSet;
-
-public class ChangeSetResourceMapping extends ResourceMapping {
-
- private final DiffChangeSet changeSet;
-
- public ChangeSetResourceMapping(DiffChangeSet changeSet) {
- this.changeSet = changeSet;
- }
-
- public Object getModelObject() {
- return changeSet;
- }
-
- public String getModelProviderId() {
- return ChangeSetModelProvider.ID;
- }
-
- public IProject[] getProjects() {
- Set result = new HashSet();
- IResource[] resources = changeSet.getResources();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- result.add(resource.getProject());
- }
- return (IProject[]) result.toArray(new IProject[result.size()]);
- }
-
- public ResourceTraversal[] getTraversals(ResourceMappingContext context,
- IProgressMonitor monitor) throws CoreException {
- IResource[] resources = changeSet.getResources();
- if (resources.length == 0) {
- return new ResourceTraversal[0];
- }
- return new ResourceTraversal[] {
- new ResourceTraversal(resources, IResource.DEPTH_ZERO, IResource.NONE)
- };
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/UnassignedDiffChangeSet.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/UnassignedDiffChangeSet.java
deleted file mode 100644
index 44d8bf150..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/mapping/UnassignedDiffChangeSet.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.mapping;
-
-import org.eclipse.team.internal.core.subscribers.DiffChangeSet;
-
-public class UnassignedDiffChangeSet extends DiffChangeSet {
-
- public UnassignedDiffChangeSet(String name) {
- super(name);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
deleted file mode 100644
index 6270f969b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
+++ /dev/null
@@ -1,262 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-ok=ok
-
-AbstractStructureVisitor_sendingFolder=Processing {0}
-AbstractStructureVisitor_sendingFile=Processing {0}
-AbstractStructureVisitor_noRemote=Unable to determine remote location for resource
-
-CVSAuthenticationException_detail=Authentication error: {0}
-CVSCommunicationException_io=CVS communication error: {0}
-CVSCommunicationException_interruptCause=The most likely cause of the interrupt is either an intermittent network failure or a communications timeout.
-CVSCommunicationException_interruptSolution=The CVS communications timeout can be adjusted in the Team/CVS preferences.
-CVSResourceVariantTree_GettingSyncInfoError=An error occurred processing the remote meta-data for folder {0}
-CVSCommunicationException_alternateInterruptCause=Another possible cause is the improper configuration of the "ext" connection method.
-CVSCommunicationException_alternateInterruptSolution=The "ext" connection method can be configured on the Team/CVS/EXT Connection Method preference page
-CVSStatus_messageWithRoot={0}: {1}
-
-CVSTag_nullName=Name must not be null
-CVSTag_emptyName=Name must not be empty
-CVSTag_beginName=Name must start with a letter
-CVSFileHistory_0=Refreshing history for {0}
-CVSTag_badCharName=Name must not contain spaces or the characters `$,.:;@|'
-
-CVSWorkspaceRoot_notCVSFolder=The CVS synchronization information for {0} has become corrupt or does not exist
-
-java_io_IOException=I/O exception occurred: {0}
-java_io_EOFException=End of file encountered: {0}
-java_io_FileNotFoundException=File not found: {0}
-java_io_InterruptedIOException=I/O has been interrupted.
-java_net_UnknownHostException=Cannot locate host: {0}
-java_net_ConnectException=Cannot connect to host: {0}
-java_net_SocketException=Socket Exception: {0}
-java_net_NoRouteToHostException={0}
-
-Connection_cannotClose=Cannot close connection
-Connection_readUnestablishedConnection=Failure due to attempt to read from a closed connection
-Connection_writeUnestablishedConnection=Failure due to attempt to write to a closed connection
-Connection_0=Could not connect to {0}: {1}
-
-PServerConnection_invalidChars=Invalid characters in password
-PServerConnection_loginRefused=Incorrect user name or password
-PServerConnection_invalidUser={0}
-PServerConnection_socket=Cannot connect to host: {0}
-PServerConnection_connectionRefused=Connection refused: {0}
-PServerConnection_noResponse=No response from server
-PServerConnection_authenticating=Authenticating using pserver
-
-CVSProviderPlugin_unknownStateFileVersion=Could not read CVS state file: unknown version ''{0}''.
-
-CVSProvider_ioException=I/O Exception occurred on the state file
-CVSFileSystem_FetchTree=Fetching folder structure
-CVSProvider_errorLoading=Error loading state
-CVSProvider_infoMismatch=Provided CVS information does not match that on disk for project {0}
-
-CVSTeamProvider_noFolderInfo=Project {0} does not contain CVS folder meta-information
-CVSTeamProvider_invalidResource=Resource {0} is not a child of project {1}
-CVSTeamProvider_typesDiffer=Error retrieving remote resource tree. Local and remote resource types differ for {0}
-CVSTeamProviderType_0=Auto-sharing imported CVS projects
-CVSTeamProvider_settingKSubst=Setting keyword substitution mode
-CVSTeamProvider_cleanLineDelimitersException=Exception occurred while cleaning line delimiters
-CVSTeamProvider_changingKeywordComment=*** keyword substitution change ***
-CVSTeamProvider_errorGettingFetchProperty=Could not get "fetch new directory" property for project ''{0}''.
-CVSTeamProvider_errorSettingFetchProperty=Could not set "fetch new directory" property for project ''{0}''.
-CVSTeamProvider_overlappingRemoteFolder=Cannot create linked resource ''{0}'' because a folder of the same name exists remotely.
-CVSTeamProvider_overlappingFileDeletion=Cannot create linked resource ''{0}'' because a deletion for the file of that name has not been committed.
-CVSTeamProvider_errorGettingWatchEdit=Could not get "watch/edit" property for project ''{0}''.
-CVSTeamProvider_errorSettingWatchEdit=Could not set "watch/edit" property for project ''{0}''.
-CVSTeamProvider_errorAddingFileToDiff=An I/O error occurred adding file ''{0}'' to the patch output.
-CVSTeamProvider_updatingFolder=Updating {0}
-
-CVSCoreFileModificationValidator_editJob = Performing CVS Edit
-
-ResourceDeltaVisitor_visitError=Error while processing resource deltas
-
-EclipseResource_invalidResourceClass=Two different implementations of ICVSResource used
-
-RemoteResource_invalidOperation=Invalid operation performed on remote resource
-RemoteFolder_invalidChild=Resource {0} is not a child of folder {1}
-RemoteFolder_errorFetchingRevisions=Error fetching file revisions
-RemoteFolder_errorFetchingMembers=One or more error occurred fetching the members of a remote folder
-RemoteFolder_doesNotExist=Folder {0} does not exist remotely or you do not have permission to access it
-
-RemoteFolderTreeBuilder_buildingBase=Collecting local synchronization information
-RemoteFolderTreeBuilder_0=Resource {0} is no longer mapped to CVS.
-RemoteFolderTreeBuilder_receivingDelta=Receiving delta for {0}
-RemoteFolderTreeBuilder_receivingRevision=Receiving revision for {0}
-RemoteFolderTreeBuilder_missingParent=An error has occurred processing file ''{0} {1}''
-RemoteFolderTreeBuild_folderDeletedFromServer=Folder ''{0}'' has been deleted from the server.
-
-Session_badInt="Malformed file transmission received"
-Session_receiving=Receiving file: {0}
-Session_transfer={0} ({1}K of {2}K bytes)
-Session_transferNoSize={0}
-Session_calculatingCompressedSize=Calculating compressed size: {0}
-Session_0=cvs client: {0}
-Session_sending=Sending file: {0}
-
-Command_receivingResponses=Receiving server response
-Command_warnings=The following warnings were reported while performing the "cvs {0}" command.
-Command_serverError=The server reported an error while performing the "cvs {0}" command.
-Command_noMoreInfoAvailable=The server did not provide any additional information.
-Command_unsupportedResponse=Unknown response received from cvs server: {0} {1}
-Command_argumentNotManaged=Argument {0} is not managed
-Command_invalidTag=HEAD is not a valid tag
-Command_noOpenSession=The CVS command cannot be issued because there is no connection available
-Command_seriousServerError=The server reported an error: {0}
-
-Add_invalidParent=Error during add command. Parent of {0} is not managed.
-
-Commit_syncInfoMissing=The commit operation succeeded. However, committed file ''{0}'' no longer has CVS synchronization information.
-Commit_timestampReset=The modification timestamp was changed for ''{0}'' but the contents match that of the server. The timestamp has been reset.
-
-Diff_serverError=The server reported an error while performing the "cvs diff" command which may only indicate that a difference exists.
-
-Tag_notVersionOrBranchError=Error applying tag: the tag provided is not a version or branch tag.
-
-ModTimeHandler_invalidFormat=The server modification time {0} is in an unknown format
-UpdateListener_0=An unmergable conflict has occurred for binary file {0}. Revision {1} has been loaded and overwritten local changes have been saved in file {2}
-RemovedHandler_invalid=Invalid removed response received from CVS server for {0}
-RemovedHandler_0=An error occurred removing resource {0}
-CheckInHandler_checkedIn= Receiving confirmation for file {0}.
-
-KSubstOption__kb_short=Binary
-KSubstOption__kb_long=Binary (-kb)
-KSubstOption__ko_short=ASCII -ko
-KSubstOption__ko_long=ASCII without keyword substitution (-ko)
-KSubstOption__kkv_short=ASCII -kkv
-KSubstOption__kkv_long=ASCII with keyword expansion (-kkv)
-KSubstOption__kkvl_short=ASCII -kkvl
-KSubstOption__kkvl_long=ASCII with keyword expansion and locker (-kkvl)
-KSubstOption__kv_short=ASCII -kv
-KSubstOption__kv_long=ASCII with keyword replacement (-kv)
-KSubstOption__kk_short=ASCII -kk
-KSubstOption__kk_long=ASCII with keyword compression (-kk)
-KSubstOption_unknown_short=Unknown {0}
-KSubstOption_unknown_long=Unknown ({0})
-
-AdminKSubstListener_expectedRCSFile=Expected RCS file {0} to end in '',v''
-AdminKSubstListener_commandRootNotManaged=Local root for this command is not managed
-AdminKSubstListener_expectedChildOfCommandRoot=Expected RCS file {0} to be a child of remote root for this command {1}
-
-CVSRepositoryLocation_locationForm=Location must have form ':methodname:[user[:password]@]host:[port]/path/to/cvsroot'
-CVSRepositoryLocation_methods=Only the following methods are supported: {0}
-CVSRepositoryLocation_parsingMethod=Error in connection method specification
-CVSRepositoryLocation_parsingUser=Error in user name specification
-CVSRepositoryLocation_parsingPassword=Error in password specification
-CVSRepositoryLocation_parsingHost=Error in host specification
-CVSRepositoryLocation_parsingPort=Error in port specification
-CVSRepositoryLocation_parsingRoot=Error in repository root directory specification
-CVSRepositoryLocation_invalidFormat=Invalid CVS repository location format: {0}
-CVSRepositoryLocation_openingConnection=Opening connection to {0}
-CVSRepositoryLocation_usernameRequired=A username is required to make a connection
-CVSRepositoryLocation_hostRequired=A host name is required to make a connection
-CVSRepositoryLocation_rootRequired=A root path is required to make a connection
-CVSRepositoryLocation_noAuthenticator=No CVS authenticator is registered
-
-
-Util_timeout=A timeout occurred connecting to host {0}
-Util_processTimeout=A timeout occurred executing command ''{0}''
-Util_truncatedPath=...{0}
-
-ResourceSyncInfo_malformedSyncBytes=Malformed entry line bytes encountered: {0}
-Malformed_entry_line___11=Malformed entry line:
-Malformed_entry_line__missing_name___12=Malformed entry line, missing name:
-Malformed_entry_line__missing_revision___13=Malformed entry line, missing revision:
-FolderSyncInfo_Maleformed_root_4=Malformed root
-FolderSyncInfo_InvalidSyncInfoBytes=Invalid folder sync info bytes: ''{0}''
-SyncFileWriter_baseNotAvailable=Could not restore the base contents of ''{0}'' from the local cache.
-BaseRevInfo_malformedEntryLine=Malformed entry line ''{0}'' for base revision information file.
-
-
-EXTServerConnection_invalidPort=A port cannot be specified for the ext connection method.
-EXTServerConnection_varsNotSet=Cannot run external ext program because CVS_RSH and CVS_SERVER variables are not initialized.
-
-CVSRemoteSyncElement_rootDiffers=Error mapping local folder {0} to repository {1}. It is already managed by repository {2}.
-CVSRemoteSyncElement_repositoryDiffers=Error mapping local folder {0} to remote folder {1}. It is already mapped to {2}.
-Util_Internal_error__resource_does_not_start_with_root_3=Internal error, resource does not start with root
-
-CVSProvider_Scrubbing_local_project_1=Scrubbing local project
-CVSProvider_Scrubbing_projects_1=Scrubbing projects
-CVSProvider_Creating_projects_2=Creating projects
-
-EclipseFile_Problem_deleting_resource=Problem deleting resource: {0}. {1}
-EclipseFile_Problem_accessing_resource=Problem accessing resource: {0}. {1} Perform a Refresh.
-EclipseFile_Problem_writing_resource=Problem writing resource ''{0}''. {1}
-EclipseFolder_problem_creating=Problem creating folder: {0}. {1}
-EclipseFolder_isModifiedProgress=Determining if {0} has outgoing changes...
-
-EclipseSynchronizer_UpdatingSyncEndOperation=Updating CVS synchronization information...
-EclipseSynchronizer_UpdatingSyncEndOperationCancelled=Operation cancelled: updating CVS synchronization information...
-EclipseSynchronizer_NotifyingListeners=Notifying of CVS changes...
-EclipseSynchronizer_ErrorSettingFolderSync=Cannot set folder sync info on {0}
-EclipseSynchronizer_ErrorSettingResourceSync=Cannot set resource sync info on {0}
-EclipseSynchronizer_ErrorSettingIgnorePattern=Cannot set ignored pattern on {0}
-EclipseSynchronizer_ErrorCommitting=Errors saving CVS synchronization information to disk. Please fix the problems listed below and then update the affected resources from the CVS repository.
-EclipseSynchronizer_folderSyncInfoMissing=CVS synchronization information could not be found for folder ''{0}''
-
-SyncFileChangeListener_errorSettingTeamPrivateFlag=Error setting team-private flag on resource
-
-RemoteFile_getContents=Retrieving remote file contents
-RemoteFile_getLogEntries=Retrieving log entries
-RemoteFolder_exists=Checking if resource exists remotely
-RemoteFolder_getMembers=Retrieving children of remote folder
-RemoteModule_getRemoteModules=Retrieving remote modules
-RemoteModule_invalidDefinition=Invalid module definition ''{0}'' received from ''{1}''.
-
-
-Version_unsupportedVersion=Host ''{0}'' is running unsupported CVS version {1}. Although most functionality works, use version 1.11.1p1 or later for full support.
-Version_unknownVersionFormat=Host ''{0}'' is running ''{1}'' which is an unknown version to the workbench. Although most functionality may work, use version 1.11.1p1 or later for full support.
-Version_versionNotValidRequest=Unable to determine server version. Host ''{0}'' does not support the ''cvs version'' command. Although most functionality works, use version 1.11.1p1 or later for full support.
-
-LogListener_invalidRevisionFormat=Invalid revision format ''{1}'' for tag ''{0}''.
-
-NotifyInfo_MalformedLine=Invalid Notify format: ''{0}''
-NotifyInfo_MalformedNotificationType=Invalid notification type in line: ''{0}''
-NotifyInfo_MalformedNotifyDate=Invalid date format in line: ''{0}''
-
-ResourceSynchronizer_missingParentBytesOnGet=Synchronization bytes are missing for parent of resource ''{1}'' in synchronization partner ''{0}'' on get.
-ResourceSynchronizer_missingParentBytesOnSet=Synchronization bytes are missing for parent of resource ''{1}'' in synchronization partner ''{0}'' on set.
-CVSAnnotateBlock_4=lines
-CVSAnnotateBlock_5=line
-CVSAnnotateBlock_6={0} {1} ({2} {3})
-CVSURI_InvalidURI=Invalid uri {0}: {1}
-CVSMergeSubscriber_2=CVS Merge ''{0} to {1}''
-CVSProviderPlugin_20=CVS Workspace
-CRLFDetectInputStream_0=CVS file {0} either contains invalid line endings on the server (CR/LF instead of just LF) or is a binary file that is not marked as -kb.
-DeferredResourceChangeHandler_0=Reconciling CVS state changes
-DeferredResourceChangeHandler_1=Errors occurred handling ignore file (.cvsignore) changes. Some resources may not be decorated properly.
-CVSWorkspaceRoot_11=The parent folder of managed file {0} does not have sync info associated with it.
-RemoveEntryHandler_2=Remove-entry received and ignored from CVS server for existing file {0}.
-ServerMessageLineMatcher_5=Variable in template is not of the correct format: {0}
-ServerMessageLineMatcher_6=There are additional groups above those defining variables in template: {0}
-ServerMessageLineMatcher_7=Expected variable {0} in {1} but it is not present.
-CVSSyncInfo_7=Invalid attempt to make file {0} in-sync. This operation can only be sed on folders.
-CVSSyncInfo_8=Invalid attempt to make outgoing resource {0} in-sync. This operation only applies to incoming or conflicting changes.
-CVSSyncInfo_9=Cannot make {0} in-sync because its parent is not under CVS control.
-CVSSyncInfo_10=Cannot make {0} in-sync because there is no corresponding remote.
-CVSCompareSubscriber_2=CVS Compare ''{0}''
-AnnotateListener_3=Skipping binary file
-AnnotateListener_4=Cannot annotate a binary file.
-CVSWorkspaceSubscriber_1=Calculating synchronization state for {0}
-CVSWorkspaceSubscriber_2=An error occurred calculating the synchronization state for {0}: {1}
-KnownRepositories_0=Error restoring CVS repositories
-CVSRepositoryLocation_72=Connection to {0} timed out while waiting for another thread to make a connection to the same host
-CVSRepositoryLocation_73=Error clearing preferences for CVS repository location {0}
-CVSRepositoryLocation_74=Error retrieving preferences for CVS repository location {0}
-CVSRepositoryLocation_75=Error flushing preferences for CVS repository location {0}
-SyncFileWriter_0=An invalid entry was found in the CVS/Entries file for folder {0}. The entry has been ignored.
-ResponseHandler_0=Could not create resource {0}: {1}
-EclipseFolder_0=Disconnecting {0}.
-LogEntry_0=/
-PrepareForReplaceVisitor_DeletedFileWithoutHistoryCannotBeRestoredWhileRevertToBase=Deleted file does not have history and cannot be restored with BASE tag.
-PrepareForReplaceVisitor_FileCannotBeReplacedWithBase=File {0} cannot be replaced with BASE.
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSEntryLineTag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSEntryLineTag.java
deleted file mode 100644
index fe13636de..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSEntryLineTag.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.internal.ccvs.core.*;
-
-public class CVSEntryLineTag extends CVSTag {
-
- /*
- * This is the format of a date as it appears in the entry line. The date in an entry
- * line is always in GMT.
- */
- private static final String ENTRY_LINE_DATE_TAG_FORMAT = "yyyy.MM.dd.HH.mm.ss"; //$NON-NLS-1$
-
- /*
- * This is a formatter that will translate dates to and from text as it appears in the entry line
- */
- private static SimpleDateFormat entryLineDateTagFormatter = new SimpleDateFormat(ENTRY_LINE_DATE_TAG_FORMAT, Locale.US);
-
- /*
- * Convert the tag name as it appears as an argument to a command
- * into the format that appears in the entry line of a folder or file
- */
- private static String getNameInInternalFormat(CVSTag tag) {
- if(tag.getType() == DATE){
- String s = ensureEntryLineFormat(tag.getName());
- if(s != null){
- return s;
- }
- }
- return tag.getName();
- }
-
- /*
- * Helper for converting the tag name as it appears as an argument to a command
- * into the format that appears in the entry line of a folder or file
- */
- private static synchronized String ensureEntryLineFormat(String text){
- if(text.length() == ENTRY_LINE_DATE_TAG_FORMAT.length()) return text;
- Date date = tagNameToDate(text);
- if (date == null) return text;
- entryLineDateTagFormatter.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$
- return entryLineDateTagFormatter.format(date);
- }
-
- static synchronized public Date entryLineToDate(String text){
- try {
- entryLineDateTagFormatter.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$
- return entryLineDateTagFormatter.parse(text);
- } catch (ParseException e) {
- CVSProviderPlugin.log(new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, "Tag name " + text + " is not of the expected format " + ENTRY_LINE_DATE_TAG_FORMAT, e)); //$NON-NLS-1$ //$NON-NLS-2$
- return null;
- }
- }
-
- /*
- * The parameter tag must not be null.
- */
- public CVSEntryLineTag(CVSTag tag) {
- super(getNameInInternalFormat(tag), tag.getType());
- }
-
- public CVSEntryLineTag(String entryLineTag) {
- switch (entryLineTag.charAt(0)) {
- case 'T' : type = BRANCH; break;
- case 'N' : type = VERSION; break;
- case 'D' : type = DATE; break;
- default: type = HEAD;
- }
- name = entryLineTag.substring(1);
- }
- /*
- * Returns the tag name
- */
- public String getName() {
- if (getType() == DATE) {
- // Use same format as CVSTag when the name is requested
- Date date = asDate();
- if(date != null){
- return dateToTagName(date);
- }
- }
- return name;
- }
- /*
- * Returns the tag type
- */
- public int getType() {
- return type;
- }
-
- public String toEntryLineFormat(boolean useSamePrefixForBranchAndTag) {
- if (type == BRANCH || (type == VERSION && useSamePrefixForBranchAndTag))
- return "T" + name;//$NON-NLS-1$
- else if (type == VERSION)
- return "N" + name;//$NON-NLS-1$
- else if (type == DATE)
- return "D" + name;//$NON-NLS-1$
- return "";//$NON-NLS-1$
- }
-
- /*
- * For debugging purposes.
- */
- public String toString() {
- return toEntryLineFormat(false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.CVSTag#asDate()
- */
- public Date asDate() {
- return entryLineToDate(name);
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java
deleted file mode 100644
index 032b5b229..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-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.KnownRepositories;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * This class provides static methods for checking out projects from a repository
- * into the local workspace and for converting IResources into CVSRespources
- * and sync trees.
- * Instances of this class represent a local workspace root (i.e. a project).
- */
-public class CVSWorkspaceRoot {
-
- private ICVSFolder localRoot;
-
- public CVSWorkspaceRoot(IContainer resource){
- this.localRoot = getCVSFolderFor(resource);
- }
-
- /**
- * Set the sharing for a project to enable it to be used with the CVSTeamProvider.
- * This method ensure that the repository in the FolderSyncInfo is known and that
- * the project is mapped to a CVS repository provider. It does not modify the sync
- * info associated with the project's resources in any way.
- */
- public static void setSharing(IProject project, FolderSyncInfo info, IProgressMonitor monitor) throws TeamException {
-
- // Ensure provided info matches that of the project
- ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project);
- FolderSyncInfo folderInfo = folder.getFolderSyncInfo();
- if ( ! info.equals(folderInfo)) {
- throw new CVSException(new CVSStatus(IStatus.ERROR, NLS.bind(CVSMessages.CVSProvider_infoMismatch, new String[] { project.getName() })));
- }
-
- // Ensure that the repository location format is supported
- String root = info.getRoot();
- // This will try to create a repository location for the root.
- // If it fails, an exception is thrown.
- KnownRepositories.getInstance().getRepository(root);
-
- // Register the project with Team
- RepositoryProvider.map(project, CVSProviderPlugin.getTypeId());
- }
-
- public static ICVSFolder getCVSFolderFor(IContainer resource) {
- return new EclipseFolder(resource);
- }
-
-
- public static ICVSFile getCVSFileFor(IFile resource) {
- return new EclipseFile(resource);
- }
-
-
- public static ICVSResource getCVSResourceFor(IResource resource) {
- if (resource.getType() == IResource.FILE)
- return getCVSFileFor((IFile) resource);
- else
- return getCVSFolderFor((IContainer) resource);
- }
-
- public static ICVSRemoteResource getRemoteResourceFor(IResource resource) throws CVSException {
- ICVSResource managed = getCVSResourceFor(resource);
- return getRemoteResourceFor(managed);
- }
-
- public static ICVSRemoteResource getRemoteResourceFor(ICVSResource resource) throws CVSException {
- if (resource.isFolder()) {
- ICVSFolder folder = (ICVSFolder)resource;
- FolderSyncInfo syncInfo = folder.getFolderSyncInfo();
- if (syncInfo != null) {
- return new RemoteFolder(null, KnownRepositories.getInstance().getRepository(syncInfo.getRoot()), syncInfo.getRepository(), syncInfo.getTag());
- }
- } else {
- if (resource.isManaged()) {
- RemoteFolder parent = (RemoteFolder)getRemoteResourceFor(resource.getParent());
- if (parent == null) {
- // This could be caused by another thread changing the state in the
- // instant between when we did the managed check and we obtained the
- // parent handle. If this is the case, isManaged should return false
- // now. If it doesn't, then we should log an error.
- if (resource.isManaged()) {
- CVSProviderPlugin.log(new CVSStatus(IStatus.ERROR,CVSStatus.ERROR, NLS.bind(CVSMessages.CVSWorkspaceRoot_11, new String[] { Util.getFullestPath(resource) }),resource.getIResource()));
- }
- } else {
- return RemoteFile.getBase(parent, (ICVSFile)resource);
- }
- }
- }
- return null;
- }
-
- /*
- * Helper method that uses the parent of a local resource that has no base to ensure that the resource
- * wasn't added remotely by a third party
- */
- private static ICVSRemoteResource getRemoteTreeFromParent(IResource resource, ICVSResource managed, CVSTag tag, IProgressMonitor progress) throws TeamException {
- // If the parent isn't mapped to CVS, there's nothing we can do
- ICVSFolder parent = managed.getParent();
- FolderSyncInfo syncInfo = parent.getFolderSyncInfo();
- if (syncInfo == null) {
- // The parent is managed so just indicate that there is no remote
- return null;
- }
- ICVSRepositoryLocation location = KnownRepositories.getInstance().getRepository(parent.getFolderSyncInfo().getRoot());
- 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(IStatus.ERROR, CVSStatus.ERROR, NLS.bind(CVSMessages.CVSTeamProvider_typesDiffer, new String[] { resource.getFullPath().toString() }), resource));
- }
- return remote;
- }
-
- /**
- * Return the remote tree that corresponds to the given local resource. Return
- * <code>null</code> if the remote tree doesn't exist remotely or if the local
- * resource is not mapped to a remote (i.e. is not managed by CVS).
- *
- * @param resource the local resource
- * @param tag the tag to be queried remotely
- * @param cacheFileContentsHint hint which indicates whether file contents will be required
- * @param depth the depth
- * @param progress
- * @return the remote tree or <code>null</code>
- * @throws TeamException
- */
- public static ICVSRemoteResource getRemoteTree(IResource resource, CVSTag tag, boolean cacheFileContentsHint, int depth, IProgressMonitor progress) throws TeamException {
- ICVSResource managed = CVSWorkspaceRoot.getCVSResourceFor(resource);
- ICVSRemoteResource remote = CVSWorkspaceRoot.getRemoteResourceFor(resource);
- if (remote == null) {
- progress.beginTask(null, 100);
- remote = getRemoteTreeFromParent(resource, managed, tag, Policy.subMonitorFor(progress, 50));
- if (cacheFileContentsHint && remote != null && remote instanceof RemoteFile) {
- RemoteFile file = (RemoteFile)remote;
- // get the storage for the file to ensure that the contents are cached
- file.getStorage(Policy.subMonitorFor(progress, 50));
- }
- progress.done();
- } else if(resource.getType() == IResource.FILE) {
- ICVSRepositoryLocation location = remote.getRepository();
- if (cacheFileContentsHint) {
- remote = UpdateContentCachingService.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFile)managed, tag, progress);
- } else {
- remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFile)managed, tag, progress);
- }
- } else {
- ICVSRepositoryLocation location = remote.getRepository();
- if (cacheFileContentsHint) {
- remote = UpdateContentCachingService.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, depth, progress);
- } else {
- remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress);
- }
- }
- return remote;
- }
-
- public static boolean hasRemote(IResource resource) {
- try {
- ICVSResource cvsResource = getCVSResourceFor(resource);
- int type = resource.getType();
- if(type!=IResource.FILE) {
- if(type==IResource.PROJECT) {
- return ((ICVSFolder)cvsResource).isCVSFolder();
- } else {
- return cvsResource.isManaged();
- }
- } else {
- byte[] syncBytes = ((ICVSFile)cvsResource).getSyncBytes();
- if(syncBytes!=null) {
- return !ResourceSyncInfo.isAddition(syncBytes);
- } else {
- return false;
- }
- }
- } catch(CVSException e) {
- return false;
- }
- }
-
- public ICVSRepositoryLocation getRemoteLocation() throws CVSException {
- FolderSyncInfo info = localRoot.getFolderSyncInfo();
- if (info == null) {
- IStatus status = new CVSStatus(IStatus.ERROR,CVSStatus.RESOURCE_SYNC_INFO_ERROR,NLS.bind(CVSMessages.CVSWorkspaceRoot_notCVSFolder, new String[] { localRoot.getName() }),localRoot);
- throw new CVSException(status);
- }
- return KnownRepositories.getInstance().getRepository(info.getRoot());
- }
-
- public ICVSFolder getLocalRoot() {
- return localRoot;
- }
-
-
- /**
- * Return true if the resource is part of a link (i.e. a linked resource or
- * one of it's children.
- *
- * @param container
- * @return boolean
- */
- public static boolean isLinkedResource(IResource resource) {
- return resource.isLinked(IResource.CHECK_ANCESTORS);
- }
-
- /**
- * A resource is considered shared
- * @param resource
- * @return boolean
- */
- public static boolean isSharedWithCVS(IResource resource) throws CVSException {
- if (!resource.isAccessible()) return false;
- if(isLinkedResource(resource)) return false;
-
- if(RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) == null) {
- return false;
- }
-
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- if (cvsResource.isManaged()) return true;
- if (!cvsResource.exists()) return false;
- if (cvsResource.isFolder() && ((ICVSFolder) cvsResource).isCVSFolder()) return true;
- if (cvsResource.isIgnored()) return false;
- return cvsResource.getParent().isCVSFolder();
- }
-
- /**
- * Return whether the given container is an orphaned subtree. An orphaned subtree
- * is folder (i.e. non-project) that is a CVS folder but is not managed and is not
- * a linked resource. To know if the resource is a descendant of an orphaned subtree,
- * the client must invoked this method for each ancestor of a resource.
- * @param container the container being tested
- * @return whether the container is an orphaned CVS folder
- * @throws CVSException
- */
- public static boolean isOrphanedSubtree(IContainer container) throws CVSException {
- ICVSFolder mFolder = CVSWorkspaceRoot.getCVSFolderFor(container);
- return (mFolder.isCVSFolder()
- && ! mFolder.isManaged()
- && mFolder.getIResource().getType() == IResource.FOLDER
- && !isLinkedResource(container));
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
deleted file mode 100644
index 6065ea692..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
+++ /dev/null
@@ -1,633 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Red Hat Incorporated - is/setExecutable() code
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
-
-/**
- * Represents handles to CVS resource on the local file system. Synchronization
- * information is taken from the CVS subdirectories.
- */
-public class EclipseFile extends EclipseResource implements ICVSFile {
-
- private static final String TEMP_FILE_EXTENSION = ".tmp";//$NON-NLS-1$
- private static final IPath PROJECT_META_DATA_PATH = new Path(".project");//$NON-NLS-1$
-
- /**
- * Create a handle based on the given local resource.
- */
- protected EclipseFile(IFile file) {
- super(file);
- }
-
- /*
- * @see ICVSResource#delete()
- */
- public void delete() throws CVSException {
- try {
- ((IFile)resource).delete(false /*force*/, true /*keepHistory*/, null);
- } catch(CoreException e) {
- throw CVSException.wrapException(resource, NLS.bind(CVSMessages.EclipseFile_Problem_deleting_resource, new String[] { resource.getFullPath().toString(), e.getStatus().getMessage() }), e); //
- }
- }
-
- public long getSize() {
- return getIOFile().length();
- }
-
- public InputStream getContents() throws CVSException {
- try {
- return getIFile().getContents();
- } catch (CoreException e) {
- throw CVSException.wrapException(resource, NLS.bind(CVSMessages.EclipseFile_Problem_accessing_resource, new String[] { resource.getFullPath().toString(), e.getStatus().getMessage() }), e); //
- }
- }
-
- /*
- * @see ICVSFile#getTimeStamp()
- */
- public Date getTimeStamp() {
- long timestamp = getIFile().getLocalTimeStamp();
- if( timestamp == IResource.NULL_STAMP) {
- // If there is no file, return the same timestamp as ioFile.lastModified() would
- return new Date(0L);
- }
- return new Date((timestamp/1000)*1000);
- }
-
- /*
- * @see ICVSFile#setTimeStamp(Date)
- */
- public void setTimeStamp(Date date) throws CVSException {
- long time;
- if (date == null) {
- time = System.currentTimeMillis();
- } else {
- time = date.getTime();
- }
- EclipseSynchronizer.getInstance().setTimeStamp(this, time);
- }
-
- /*
- * @see ICVSResource#isFolder()
- */
- public boolean isFolder() {
- return false;
- }
-
- /*
- * @see ICVSFile#isModified()
- */
- public boolean isModified(IProgressMonitor monitor) throws CVSException {
-
- // ignore the monitor, there is no valuable progress to be shown when
- // calculating the dirty state for files. It is relatively fast.
-
- if (!exists()) {
- return getSyncBytes() != null;
- }
- int state = EclipseSynchronizer.getInstance().getModificationState(getIFile());
-
- if (state != UNKNOWN) {
- boolean dirty = state != CLEAN;
- // Check to make sure that cached state is the real state.
- // They can be different if deltas happen in the wrong order.
- if (dirty == isDirty()) {
- return dirty;
- }
- }
-
- // nothing cached, need to manually check (and record)
- byte[] syncBytes = getSyncBytes();
- if (syncBytes == null && isIgnored()) return false;
- // unmanaged files are reported as modified
- return EclipseSynchronizer.getInstance().setModified(this, UNKNOWN);
- }
-
- /*
- * @see ICVSResource#accept(ICVSResourceVisitor)
- */
- public void accept(ICVSResourceVisitor visitor) throws CVSException {
- visitor.visitFile(this);
- }
-
- /*
- * @see ICVSResource#accept(ICVSResourceVisitor, boolean)
- */
- public void accept(ICVSResourceVisitor visitor, boolean recurse) throws CVSException {
- visitor.visitFile(this);
- }
-
- /*
- * This is to be used by the Copy handler. The filename of the form .#filename
- */
- public void copyTo(String filename) throws CVSException {
- try {
- IPath targetPath = new Path(null, filename);
- IFile targetFile = getIFile().getParent().getFile(targetPath);
- if (targetFile.exists()) {
- // There is a file in the target location.
- // Delete it and keep the history just in case
- targetFile.delete(false /* force */, true /* keep history */, null);
- }
- getIFile().copy(targetPath, true /*force*/, null);
- } catch(CoreException e) {
- throw new CVSException(e.getStatus());
- }
- }
-
- /*
- * @see ICVSResource#getRemoteLocation()
- */
- public String getRemoteLocation(ICVSFolder stopSearching) throws CVSException {
- return getParent().getRemoteLocation(stopSearching) + SEPARATOR + getName();
- }
-
- /*
- * @see ICVSFile#setReadOnly()
- */
- public void setContents(InputStream stream, int responseType, boolean keepLocalHistory, IProgressMonitor monitor) throws CVSException {
- try {
- IFile file = getIFile();
- if (PROJECT_META_DATA_PATH.equals(file.getFullPath().removeFirstSegments(1))) {
- responseType = UPDATED;
- }
- switch (responseType) {
- case UPDATED:
- if (resource.exists()) {
- file.setContents(stream, false /*force*/, true /*keep history*/, monitor);
- break;
- }
- case CREATED: // creating a new file so it should not exist locally
- file.create(stream, false /*force*/, monitor);
- break;
- case MERGED: // merging contents into a file that exists locally
- // Ensure we don't leave the file in a partially written state
- IFile tempFile = file.getParent().getFile(new Path(null, file.getName() + TEMP_FILE_EXTENSION));
- monitor.beginTask(null, 100);
- if (tempFile.exists())
- tempFile.delete(true /* force */, Policy.subMonitorFor(monitor, 25));
- tempFile.create(stream, true /*force*/, Policy.subMonitorFor(monitor, 25));
- file.delete(false /* force */, true /* keep history */, Policy.subMonitorFor(monitor, 25));
- tempFile.move(new Path(null, file.getName()), false /*force*/, true /*history*/, Policy.subMonitorFor(monitor, 25));
- monitor.done();
- break;
- case UPDATE_EXISTING: // creating a new file so it should exist locally
- file.setContents(stream, false /*force*/, true /*keep history*/, monitor);
- break;
- }
- } catch(CoreException e) {
- String message = null;
- if (e.getStatus().getCode() == IResourceStatus.FAILED_READ_LOCAL) {
- // This error indicates that Core couldn't read from the server stream
- // The real reason will be in the message of the wrapped exception
- Throwable t = e.getStatus().getException();
- if (t != null) message = t.getMessage();
- }
- if (message == null) message = e.getMessage();
- throw CVSException.wrapException(resource, NLS.bind(CVSMessages.EclipseFile_Problem_writing_resource, new String[] { resource.getFullPath().toString(), message }), e);
- }
- }
-
- /*
- * @see ICVSFile#setReadOnly()
- */
- public void setReadOnly(boolean readOnly) throws CVSException {
- ResourceAttributes attributes = resource.getResourceAttributes();
- if (attributes != null) {
- attributes.setReadOnly(readOnly);
- try {
- resource.setResourceAttributes(attributes);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
- }
-
- /*
- * @see ICVSFile#isReadOnly()
- */
- public boolean isReadOnly() throws CVSException {
- return getIFile().isReadOnly();
- }
-
- /*
- * @see ICVSFile#setExecutable()
- */
- public void setExecutable(boolean executable) throws CVSException {
- ResourceAttributes attributes = resource.getResourceAttributes();
- if (attributes != null) {
- attributes.setExecutable(executable);
- try {
- resource.setResourceAttributes(attributes);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
- }
-
- /*
- * @see ICVSFile#isExectuable()
- */
- public boolean isExecutable() throws CVSException {
- ResourceAttributes attributes = resource.getResourceAttributes();
- if (attributes != null) {
- return attributes.isExecutable();
- } else {
- return false;
- }
- }
-
- /*
- * Typecasting helper
- */
- public IFile getIFile() {
- return (IFile)resource;
- }
-
- /*
- * To allow accessing size and timestamp for the underlying java.io.File
- */
- private File getIOFile() {
- IPath location = resource.getLocation();
- if(location!=null) {
- return location.toFile();
- }
- return null;
- }
- /**
- * @see ICVSFile#getLogEntries(IProgressMonitor)
- */
- public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws TeamException {
-
- // try fetching log entries only when the file's project is accessible
- // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=190434
- if (getIResource() == null
- || !getIResource().getProject().isAccessible())
- return new ILogEntry[0];
-
- byte[] syncBytes = getSyncBytes();
- if(syncBytes != null && !ResourceSyncInfo.isAddition(syncBytes)) {
- ICVSRemoteResource remoteFile = CVSWorkspaceRoot.getRemoteResourceFor(resource);
- if (remoteFile != null)
- return ((ICVSRemoteFile)remoteFile).getLogEntries(monitor);
- }
- return new ILogEntry[0];
- }
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#setNotifyInfo(NotifyInfo)
- */
- public void setNotifyInfo(NotifyInfo info) throws CVSException {
- if (isManaged()) {
- EclipseSynchronizer.getInstance().setNotifyInfo(resource, info);
- // On an edit, the base should be cached
- // On an unedit, the base should be restored (and cleared?)
- // On a commit, the base should be cleared
- }
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#getNotifyInfo()
- */
- public NotifyInfo getNotifyInfo() throws CVSException {
- if (isManaged()) {
- return EclipseSynchronizer.getInstance().getNotifyInfo(resource);
- }
- return null;
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#setNotifyInfo(NotifyInfo)
- */
- public void setBaserevInfo(BaserevInfo info) throws CVSException {
- if (isManaged()) {
- if (info == null) {
- EclipseSynchronizer.getInstance().deleteBaserevInfo(resource);
- EclipseSynchronizer.getInstance().deleteFileFromBaseDirectory(getIFile(), null);
- } else
- EclipseSynchronizer.getInstance().setBaserevInfo(resource, info);
- }
- }
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#getNotifyInfo()
- */
- public BaserevInfo getBaserevInfo() throws CVSException {
- if (isManaged()) {
- return EclipseSynchronizer.getInstance().getBaserevInfo(resource);
- }
- return null;
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#checkout(int)
- */
- public void edit(final int notifications, boolean notifyForWritable, IProgressMonitor monitor) throws CVSException {
- if (!notifyForWritable && !isReadOnly()) return;
- run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- byte[] syncBytes = getSyncBytes();
- if (syncBytes == null || ResourceSyncInfo.isAddition(syncBytes)) return;
-
- // convert the notifications to internal form
- char[] internalFormat;
- if (notifications == NO_NOTIFICATION) {
- internalFormat = null;
- } else if (notifications == NOTIFY_ON_ALL) {
- internalFormat = NotifyInfo.ALL;
- } else {
- List notificationCharacters = new ArrayList();
- if ((notifications & NOTIFY_ON_EDIT) >0)
- notificationCharacters.add(new Character(NotifyInfo.EDIT));
- if ((notifications & NOTIFY_ON_UNEDIT) >0)
- notificationCharacters.add(new Character(NotifyInfo.UNEDIT));
- if ((notifications & NOTIFY_ON_COMMIT) >0)
- notificationCharacters.add(new Character(NotifyInfo.COMMIT));
- internalFormat = new char[notificationCharacters.size()];
- for (int i = 0; i < internalFormat.length; i++) {
- internalFormat[i] = ((Character)notificationCharacters.get(i)).charValue();
- }
- }
-
- // record the notification
- NotifyInfo notifyInfo = new NotifyInfo(getName(), NotifyInfo.EDIT, new Date(), internalFormat);
- setNotifyInfo(notifyInfo);
-
- // Only record the base if the file is not modified
- if (!isModified(null)) {
- EclipseSynchronizer.getInstance().copyFileToBaseDirectory(getIFile(), monitor);
- setBaserevInfo(new BaserevInfo(getName(), ResourceSyncInfo.getRevision(syncBytes)));
- }
-
- try {
- // allow editing
- setReadOnly(false);
- } catch (CVSException e) {
- // Just log and keep going
- CVSProviderPlugin.log(e);
- }
- }
- }, monitor);
-
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#uncheckout()
- */
- public void unedit(IProgressMonitor monitor) throws CVSException {
- if (isReadOnly()) return;
- run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- // record the notification
- NotifyInfo info = getNotifyInfo();
- if (info != null && info.getNotificationType() == NotifyInfo.EDIT) {
- info = null;
- } else {
- info = new NotifyInfo(getName(), NotifyInfo.UNEDIT, new Date(), null);
- }
- setNotifyInfo(info);
-
- if (isModified(null)) {
- ResourceSyncInfo syncInfo = getSyncInfo();
- BaserevInfo baserevInfo = getBaserevInfo();
- EclipseSynchronizer.getInstance().restoreFileFromBaseDirectory(getIFile(), monitor);
- // reset any changes that may have been merged from the server
- if (!syncInfo.getRevision().equals(baserevInfo.getRevision())) {
- MutableResourceSyncInfo newInfo = syncInfo.cloneMutable();
- newInfo.setRevision(baserevInfo.getRevision());
- newInfo.setTimeStamp(getTimeStamp());
- newInfo.setDeleted(false);
- setSyncInfo(newInfo, ICVSFile.CLEAN);
- } else {
- // an unedited file is no longer modified
- EclipseSynchronizer.getInstance().setModified(EclipseFile.this, CLEAN);
- }
- } else {
- // We still need to report a state change
- setSyncBytes(getSyncBytes(), ICVSFile.CLEAN);
- }
- setBaserevInfo(null);
-
- try {
- // prevent editing
- setReadOnly(true);
- } catch (CVSException e) {
- // Just log and keep going
- CVSProviderPlugin.log(e);
- }
- }
- }, monitor);
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#notificationCompleted()
- */
- public void notificationCompleted() throws CVSException {
- EclipseSynchronizer.getInstance().deleteNotifyInfo(resource);
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#getPendingNotification()
- */
- public NotifyInfo getPendingNotification() throws CVSException {
- return getNotifyInfo();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#checkedIn(java.lang.String)
- */
- public void checkedIn(String entryLine, boolean commit) throws CVSException {
- ResourceSyncInfo oldInfo = getSyncInfo();
- ResourceSyncInfo newInfo = null;
- int modificationState = ICVSFile.CLEAN;
- if (entryLine == null) {
- // cvs commit: the file contents matched the server contents so no entry line was sent
- if (oldInfo == null) return;
- // We should never make the timestamp go backwards so we'll set
- // the entry line timestamp to match that of the file
- if(! oldInfo.isAdded()) {
- MutableResourceSyncInfo mutable = oldInfo.cloneMutable();
- mutable.setTimeStamp(getTimeStamp(), true /* clear merged */);
- newInfo = mutable;
- }
- // (modified = false) the file will be no longer modified
- } else if (oldInfo == null) {
- // cvs add: addition of a file
- newInfo = new ResourceSyncInfo(entryLine, null);
- // an added file should show up as modified
- modificationState = ICVSFile.DIRTY;
- } else {
- // cvs commit: commit of a changed file
- // cvs update: update of a file whose contents match the server contents
- Date timeStamp;
- if (commit) {
- // This is a commit. Put the file timestamp in the entry
- timeStamp = getTimeStamp();
- } else {
- // This is an update. We need to change the tiemstamp in the
- // entry file to match the file timestamp returned by Java
- timeStamp = oldInfo.getTimeStamp();
- if (timeStamp == null) {
- timeStamp = getTimeStamp();
- } else {
- // First, set the timestamp of the file to the timestamp from the entry
- // There is a chance this will do nothing as the call to Java on some
- // file systems munges the timestamps
- setTimeStamp(timeStamp);
- // To compensate for the above, reset the timestamp in the entry
- // to match the timestamp in the file
- timeStamp = getTimeStamp();
- }
- }
- newInfo = new ResourceSyncInfo(entryLine, timeStamp);
-
- }
- //see bug 106876
- if (newInfo != null){
- CVSTag tag = newInfo.getTag();
- if(tag != null && CVSEntryLineTag.BASE.getName().equals(tag.getName())){
- newInfo = newInfo.cloneMutable();
- ((MutableResourceSyncInfo)newInfo).setTag(oldInfo.getTag());
- }
- setSyncInfo(newInfo, modificationState);
- }
- clearCachedBase();
- }
-
- private void clearCachedBase() throws CVSException {
- BaserevInfo base = getBaserevInfo();
- if (base != null) {
- setBaserevInfo(null);
- try {
- setReadOnly(true);
- } catch (CVSException e) {
- // Just log and keep going
- CVSProviderPlugin.log(e);
- }
- } else {
- // Check to see if watch-edit is enabled for the project
- CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId());
- if (provider != null && provider.isWatchEditEnabled()) {
- try {
- setReadOnly(true);
- } catch (CVSException e) {
- // Just log and keep going
- CVSProviderPlugin.log(e);
- }
- }
- }
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSResource#unmanage(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void unmanage(IProgressMonitor monitor) throws CVSException {
- run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- EclipseFile.super.unmanage(monitor);
- clearCachedBase();
- }
- }, monitor);
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#isEdited()
- */
- public boolean isEdited() throws CVSException {
- return EclipseSynchronizer.getInstance().isEdited(getIFile());
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSResource#setSyncInfo(org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo)
- */
- public void setSyncInfo(ResourceSyncInfo info, int modificationState) throws CVSException {
- setSyncBytes(info.getBytes(), info, modificationState);
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.resources.EclipseResource#setSyncBytes(byte[], int)
- */
- public void setSyncBytes(byte[] syncBytes, int modificationState) throws CVSException {
- setSyncBytes(syncBytes, null, modificationState);
- }
-
- /*
- * @see org.eclipse.team.internal.ccvs.core.resources.EclipseResource#setSyncBytes(byte[], int)
- */
- private void setSyncBytes(byte[] syncBytes, ResourceSyncInfo info, int modificationState) throws CVSException {
- Assert.isNotNull(syncBytes);
- setSyncBytes(syncBytes);
- EclipseSynchronizer.getInstance().setModified(this, modificationState);
- }
-
- public void handleModification(boolean forAddition) throws CVSException {
- if (isIgnored()) {
- // Special case handling for when a resource passes from the un-managed state
- // to the ignored state (e.g. ignoring the ignore file). Parent dirty state must be
- // recalculated but since the resource's end state is ignored there is a lot of code
- // in the plugin that simply disregards the change to the resource.
- // There may be a better was of handling resources that transition from un-managed to
- // ignored but for now this seems like the safest change.
- if(! resource.isDerived()) {
- EclipseSynchronizer.getInstance().setModified(this, CLEAN);
- }
- return;
- }
- // set the modification state to what it really is and return true if the modification state changed
- EclipseSynchronizer.getInstance().setModified(this, UNKNOWN);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.ICVSResource#getRepositoryRelativePath()
- */
- public String getRepositoryRelativePath() throws CVSException {
- if (!isManaged()) return null;
- String parentPath = getParent().getRepositoryRelativePath();
- if (parentPath == null) return null;
- return parentPath + Session.SERVER_SEPARATOR + getName();
- }
-
- protected boolean isDirty() throws CVSException {
- boolean dirty;
- byte[] syncBytes = getSyncBytes();
- if (syncBytes == null) {
- dirty = exists();
- } else {
- // isMerged() must be called because when a file is updated and merged by the cvs server the timestamps
- // are equal. Merged files should however be reported as dirty because the user should take action and commit
- // or review the merged contents.
- if(ResourceSyncInfo.isAddition(syncBytes) || ResourceSyncInfo.isMerge(syncBytes) || !exists()) {
- dirty = true;
- } else {
- // TODO: non-optimal as ResourceSyncInfo is created each time
- ResourceSyncInfo info = new ResourceSyncInfo(syncBytes);
- dirty = !getTimeStamp().equals(info.getTimeStamp());
- }
- }
- return dirty;
- }
-
-}
-
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java
deleted file mode 100644
index b11d631d9..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * Implements the ICVSFolder interface on top of an
- * instance of the ICVSFolder interface
- *
- * @see ICVSFolder
- */
-class EclipseFolder extends EclipseResource implements ICVSFolder {
-
- protected EclipseFolder(IContainer container) {
- super(container);
- }
-
- /**
- * @see ICVSFolder#members(int)
- */
- public ICVSResource[] members(int flags) throws CVSException {
- final List result = new ArrayList();
- IResource[] resources = EclipseSynchronizer.getInstance().members((IContainer)resource);
- boolean includeFiles = (((flags & FILE_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
- boolean includeFolders = (((flags & FOLDER_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
- boolean includeManaged = (((flags & MANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0));
- boolean includeUnmanaged = (((flags & UNMANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0));
- boolean includeIgnored = ((flags & IGNORED_MEMBERS) != 0);
- boolean includeExisting = (((flags & EXISTING_MEMBERS) != 0) || ((flags & (EXISTING_MEMBERS | PHANTOM_MEMBERS)) == 0));
- boolean includePhantoms = (((flags & PHANTOM_MEMBERS) != 0) || ((flags & (EXISTING_MEMBERS | PHANTOM_MEMBERS)) == 0));
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- int type = resource.getType();
- if ((includeFiles && (type==IResource.FILE))
- || (includeFolders && (type==IResource.FOLDER))) {
- boolean exists = resource.exists();
- if ((includeExisting && exists) || (includePhantoms && !exists)) {
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- boolean includeResource = false;
- if ((includeManaged && includeUnmanaged && includeIgnored)) {
- includeResource = true;
- } else {
- boolean isManaged = cvsResource.isManaged();
- if (isManaged && includeManaged) {
- includeResource = true;
- } else if (exists) {
- boolean isIgnored = cvsResource.isIgnored();
- if (isIgnored && includeIgnored) {
- includeResource = true;
- } else if (! isManaged && ! isIgnored && includeUnmanaged) {
- includeResource = true;
- }
- }
- }
- if (includeResource) {
- result.add(cvsResource);
- }
- }
- }
- }
- return (ICVSResource[]) result.toArray(new ICVSResource[result.size()]);
- }
-
- /**
- * @see ICVSFolder#createFolder(String)
- */
- public ICVSFolder getFolder(String name) throws CVSException {
- if ((CURRENT_LOCAL_FOLDER.equals(name)) || ((CURRENT_LOCAL_FOLDER + SEPARATOR).equals(name)))
- return this;
- IPath path = new Path(null, name);
- if(resource.getType()==IResource.ROOT && path.segmentCount()==1) {
- return new EclipseFolder(((IWorkspaceRoot)resource).getProject(name));
- } else {
- return new EclipseFolder(((IContainer)resource).getFolder(path));
- }
- }
-
- /**
- * @see ICVSFolder#createFile(String)
- */
- public ICVSFile getFile(String name) throws CVSException {
- return new EclipseFile(((IContainer)resource).getFile(new Path(null, name)));
- }
-
- /**
- * @see ICVSFolder#mkdir()
- */
- public void mkdir() throws CVSException {
- ISchedulingRule rule = null;
- try {
- rule = EclipseSynchronizer.getInstance().beginBatching(resource, null);
- 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);
- // We need to signal the creation to the synchronizer immediately because
- // we may do additional CVS operations on the folder before the next delta
- // occurs.
- EclipseSynchronizer.getInstance().created(getIResource());;
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(resource, NLS.bind(CVSMessages.EclipseFolder_problem_creating, new String[] { resource.getFullPath().toString(), e.getStatus().getMessage() }), e);
- } finally {
- if (rule != null)
- EclipseSynchronizer.getInstance().endBatching(rule, null);
- }
- }
-
- /**
- * @see ICVSResource#isFolder()
- */
- public boolean isFolder() {
- return true;
- }
-
- /**
- * @see ICVSFolder#acceptChildren(ICVSResourceVisitor)
- */
- public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException {
-
- // Visit files and then folders
- ICVSResource[] subFiles = members(FILE_MEMBERS);
- for (int i=0; i<subFiles.length; i++) {
- subFiles[i].accept(visitor);
- }
- ICVSResource[] subFolders = members(FOLDER_MEMBERS);
- for (int i=0; i<subFolders.length; i++) {
- subFolders[i].accept(visitor);
- }
- }
-
- /**
- * @see ICVSResource#accept(ICVSResourceVisitor)
- */
- public void accept(ICVSResourceVisitor visitor) throws CVSException {
- visitor.visitFolder(this);
- }
-
- /**
- * @see ICVSResource#accept(ICVSResourceVisitor, boolean)
- */
- public void accept(ICVSResourceVisitor visitor, boolean recurse) throws CVSException {
- visitor.visitFolder(this);
- ICVSResource[] resources;
- if (recurse) {
- resources = members(ICVSFolder.ALL_MEMBERS);
- } else {
- resources = members(ICVSFolder.FILE_MEMBERS);
- }
- for (int i = 0; i < resources.length; i++) {
- resources[i].accept(visitor, recurse);
- }
- }
-
- /**
- * @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 {
- if (resource.getType() != IResource.ROOT && !resource.getProject().isAccessible()) {
- return null;
- }
- return EclipseSynchronizer.getInstance().getFolderSync((IContainer)resource);
- }
-
- /*
- * @see ICVSFolder#setFolderInfo(FolderSyncInfo)
- */
- public void setFolderSyncInfo(final FolderSyncInfo folderInfo) throws CVSException {
- // ignore folder sync on the root (i.e. CVSROOT/config/TopLevelAdmin=yes but we just ignore it)
- if (resource.getType() == IResource.ROOT) return;
- run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- EclipseSynchronizer synchronizer = EclipseSynchronizer.getInstance();
- synchronizer.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.
- byte[] newSyncBytes = new ResourceSyncInfo(getName()).getBytes();
- byte[] oldSyncBytes = getSyncBytes();
- // only set the bytes if the new differes from the old.
- // this avoids unnecessary saving of sync files
- if (oldSyncBytes == null || ! Util.equals(newSyncBytes, oldSyncBytes))
- setSyncBytes(newSyncBytes);
- }
- }, null);
-
- }
-
- /*
- * @see ICVSFolder#isCVSFolder()
- */
- public boolean isCVSFolder() throws CVSException {
- return EclipseSynchronizer.getInstance().getFolderSync((IContainer)resource) != null;
- }
-
- /*
- * @see ICVSResource#unmanage()
- */
- public void unmanage(IProgressMonitor monitor) throws CVSException {
- run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- recursiveUnmanage((IContainer) resource, Policy.subMonitorFor(monitor, 99));
- EclipseFolder.super.unmanage(Policy.subMonitorFor(monitor, 1));
- monitor.done();
- }
- }, Policy.subMonitorFor(monitor, 99));
- }
-
- /* private */ static void recursiveUnmanage(IContainer container, IProgressMonitor monitor) {
- try {
- monitor.beginTask(null, 10);
- monitor.subTask(NLS.bind(CVSMessages.EclipseFolder_0, new String[] {container.getFullPath().toString() }));
- EclipseSynchronizer.getInstance().deleteFolderSync(container);
-
- IResource[] members = container.members(true);
- for (int i = 0; i < members.length; i++) {
- monitor.worked(1);
- IResource resource = members[i];
- if (resource.getType() == IResource.FILE) {
- ResourceAttributes attrs = resource.getResourceAttributes();
- if (attrs != null && attrs.isReadOnly()) {
- attrs.setReadOnly(false);
- resource.setResourceAttributes(attrs);
- }
- } else {
- recursiveUnmanage((IContainer) resource, monitor);
- }
- }
- } catch (CoreException e) {
- // Just ignore and continue
- } finally {
- monitor.done();
- }
- }
-
- /*
- * @see ICVSResource#isIgnored()
- */
- public boolean isIgnored() throws CVSException {
- if(isCVSFolder()) {
- return false;
- }
- return super.isIgnored();
- }
-
- /*
- * @see ICVSFolder#getChild(String)
- */
- public ICVSResource getChild(String namedPath) throws CVSException {
- if (namedPath.equals(Session.CURRENT_LOCAL_FOLDER)) {
- return this;
- }
- IPath path = new Path(null, namedPath);
- if(path.segmentCount()==0) {
- return this;
- }
- IResource child = ((IContainer)resource).findMember(path, true /* include phantoms */);
- if(child!=null) {
- if(child.getType()==IResource.FILE) {
- return new EclipseFile((IFile)child);
- } else {
- return new EclipseFolder((IContainer)child);
- }
- }
- return null;
- }
-
- /**
- * @see ICVSFolder#fetchChildren(IProgressMonitor)
- */
- public ICVSResource[] fetchChildren(IProgressMonitor monitor) throws CVSException {
- return members(FILE_MEMBERS | FOLDER_MEMBERS);
- }
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSResource#delete()
- */
- public void delete() throws CVSException {
- if (!exists()) return;
- try {
- resource.delete(false /*force*/, null);
- } catch(CoreException e) {
- throw new CVSException(e.getStatus());
- }
- }
-
- /**
- * Assumption this is only called from decorator and isIgnored() is purposely
- * ommitted here for performance reasons.
- */
- public boolean isModified(IProgressMonitor monitor) throws CVSException {
- try {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(NLS.bind(CVSMessages.EclipseFolder_isModifiedProgress, new String[] { resource.getFullPath().toString() }), 1000);
-
- IContainer container = (IContainer)getIResource();
-
- if(RepositoryProvider.getProvider(container.getProject(), CVSProviderPlugin.getTypeId()) == null) {
- return false;
- }
-
- // Added optimization to avoid loading sync info if possible
- // This will place a modified indicator on non-cvs folders
- // (i.e. the call to getModifiedState will cache a session property)
- int state = EclipseSynchronizer.getInstance().getModificationState(getIResource());
-
- boolean modified;
- if (state == ICVSFile.UNKNOWN) {
-
- if (!isCVSFolder() && container.getType() == IResource.FOLDER) {
- return container.exists();
- }
-
- // We have no cached info for the folder. We'll need to check directly,
- // caching as go. This will recursively determined the modified state
- // for all child resources until a modified child is found.
- modified = calculateAndSaveChildModificationStates(monitor);
- EclipseSynchronizer.getInstance().setModified(this, modified);
- } else {
- modified = (state == ICVSFile.DIRTY);
- }
- return modified;
- } finally {
- monitor.done();
- }
- }
-
- public void handleModification(boolean forAddition) throws CVSException {
- // For non-additions, we are only interested in sync info changes
- if (isIgnored() || !forAddition) return;
-
- // the folder is an addition.
- FolderSyncInfo info = getFolderSyncInfo();
- // if the folder has sync info, it was handled is setFolderInfo
- // otherwise, flush the ancestors to recalculate
- if (info == null) {
- EclipseSynchronizer.getInstance().setDirtyIndicator(getIResource(), true);
- }
- }
-
- /**
- * Determines the modification state of the receiver by examining it's children.
- * This method may result in modification state being cached with the children but
- * does not cache it for the receiver.
- */
- private boolean calculateAndSaveChildModificationStates(IProgressMonitor monitor) throws CVSException {
- ICVSResource[] children = members(ALL_UNIGNORED_MEMBERS);
-
- for (int i = 0; i < children.length; i++) {
- ICVSResource resource = children[i];
- if (resource.isModified(null)) {
- // if a child resource is dirty consider the parent dirty as well, there
- // is no need to continue checking other siblings.
- return true;
- }
- monitor.worked(1);
- }
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.ICVSResource#getRepositoryRelativePath()
- */
- public String getRepositoryRelativePath() throws CVSException {
- FolderSyncInfo info = getFolderSyncInfo();
- if (info == null) return null;
- // The REPOSITORY property of the folder info is the repository relative path
- return info.getRepository();
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java
deleted file mode 100644
index 5c3b3c642..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.Team;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-
-/**
- * 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, Comparable {
-
- // The separator that must be used when creating CVS resource paths. Never use
- // the platform default separator 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());
- if (result.length() == 0) return CURRENT_LOCAL_FOLDER;
- return result;
- } catch (ClassCastException e) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, CVSMessages.EclipseResource_invalidResourceClass, e, root);
- throw new CVSException(status);
- }
- }
-
- /*
- * @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() throws CVSException {
- // a managed resource is never ignored
- if(isManaged() || resource.getType()==IResource.ROOT || resource.getType()==IResource.PROJECT) {
- return false;
- }
-
- // If the resource is a derived or linked resource, it is ignored
- if (resource.isDerived() || resource.isLinked()) {
- return true;
- }
-
- // always ignore CVS
- String name = getName();
- if (name.equals("CVS")) return true; //$NON-NLS-1$
-
- // check the global ignores from Team
- if (Team.isIgnoredHint(resource)) return true;
-
- // check ignore patterns from the .cvsignore file.
- if(EclipseSynchronizer.getInstance().isIgnored(resource)) {
- return true;
- }
-
- // check the parent, if the parent is ignored or mapped to CVSROOT/Emptydir
- // then this resource is ignored also
- ICVSFolder parent = getParent();
- if(parent==null) return false;
- if (parent.isIgnored()) return true;
- FolderSyncInfo info = parent.getFolderSyncInfo();
- if (info == null) return false;
- return info.isVirtualDirectory();
- }
-
- /*
- * @see ICVSResource#setIgnoredAs(String)
- */
- public void setIgnoredAs(final String pattern) throws CVSException {
- run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- EclipseSynchronizer.getInstance().addIgnored(resource.getParent(), pattern);
- }
- }, null);
- }
-
- /*
- * @see ICVSResource#isManaged()
- */
- public boolean isManaged() throws CVSException {
- return isManaged(getSyncBytes());
- }
-
- /*
- * Helper method that captures the sematics of isManaged given a ResourceSyncInfo
- */
- public boolean isManaged(byte[] syncBytes) {
- return syncBytes != null;
- }
-
- /**
- * 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 org.eclipse.team.internal.ccvs.core.ICVSFile#getSyncBytes()
- */
- public byte[] getSyncBytes() throws CVSException {
- return EclipseSynchronizer.getInstance().getSyncBytes(getIResource());
- }
-
- /*
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#setSyncBytes(byte[])
- */
- public void setSyncBytes(byte[] syncBytes) throws CVSException {
- if (getParent().isCVSFolder()) {
- EclipseSynchronizer.getInstance().setSyncBytes(getIResource(), syncBytes);
- }
- }
-
- /*
- * @see ICVSResource#getSyncInfo()
- */
- public ResourceSyncInfo getSyncInfo() throws CVSException {
- return EclipseSynchronizer.getInstance().getResourceSync(resource);
- }
-
- /*
- * Implement the hashcode on the underlying strings, like it is done in the equals.
- */
- public int hashCode() {
- return getPath().hashCode();
- }
-
- /*
- * Give the pathname back
- */
- public String toString() {
- return getPath();
- }
-
- /*
- * @see ICVSResource#unmanage()
- */
- public void unmanage(IProgressMonitor monitor) throws CVSException {
- EclipseSynchronizer.getInstance().deleteResourceSync(resource);
- }
-
- /*
- * @see Comparable#compareTo(Object)
- */
- public int compareTo(Object arg0) {
- EclipseResource other = (EclipseResource)arg0;
- return resource.getFullPath().toString().compareTo(other.resource.getFullPath().toString());
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSResource#getIResource()
- */
- public IResource getIResource() {
- return resource;
- }
-
- /**
- * Called by a resource change listener when a resource is changed or added. This allows
- * CVS resources to adjust any internal state based on the change.
- *
- * @param forAddition modification is an addition
- * @throws CVSException
- */
- public abstract void handleModification(boolean forAddition) throws CVSException;
-
- public void run(final ICVSRunnable job, IProgressMonitor monitor) throws CVSException {
- final CVSException[] error = new CVSException[1];
- try {
- // Do not use a scheduling rule in the workspace run since one
- // will be obtained by the EclipseSynchronizer
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- try {
- EclipseSynchronizer.getInstance().run(getIResource(), job, monitor);
- } catch(CVSException e) {
- error[0] = e;
- }
- }
- }, null /* no rule */, 0, monitor);
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- if(error[0]!=null) {
- throw error[0];
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java
deleted file mode 100644
index 2659291e6..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java
+++ /dev/null
@@ -1,1932 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Matt McCutchen <hashproduct+eclipse@gmail.com> - Bug 181546 [Sync Info] Eclipse writes Entries-less metadata in recreated pruned dir
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ReentrantLock.CVSThreadInfo;
-import org.eclipse.team.internal.ccvs.core.util.*;
-import org.eclipse.team.internal.core.subscribers.BatchingLock.IFlushOperation;
-import org.eclipse.team.internal.core.subscribers.BatchingLock.ThreadInfo;
-import org.osgi.framework.Bundle;
-
-/**
- * A synchronizer is responsible for managing synchronization information for local
- * CVS resources.
- *
- * This class is thread safe but only allows one thread to modify the cache at a time. It
- * doesn't support fine grain locking on a resource basis. Lock ordering between the workspace
- * lock and the synchronizer lock is guaranteed to be deterministic. That is, the workspace
- * lock is *always* acquired before the synchronizer lock. This protects against possible
- * deadlock cases where the synchronizer lock is acquired before a workspace lock.
- *
- * Special processing has been added for linked folders and their childen so
- * that their CVS meta files are never read or written.
- *
- * IMPORTANT NOTICE: It is the responsibility of the clients of EclipseSynchronizer
- * to ensure that they have wrapped operations that may modify the workspace in
- * an IWorkspaceRunnable. If this is not done, deltas may fore at inopertune times
- * and corrupt the sync info. The wrapping could be done within the synchronizer
- * itself but would require the creation of an inner class for each case that requires
- * it.
- *
- * @see ResourceSyncInfo
- * @see FolderSyncInfo
- */
-public class EclipseSynchronizer implements IFlushOperation {
- private static final String IS_DIRTY_INDICATOR = SyncInfoCache.IS_DIRTY_INDICATOR;
- private static final String NOT_DIRTY_INDICATOR = SyncInfoCache.NOT_DIRTY_INDICATOR;
- private static final String RECOMPUTE_INDICATOR = SyncInfoCache.RECOMPUTE_INDICATOR;
-
- // the cvs eclipse synchronizer is a singleton
- private static EclipseSynchronizer instance;
-
- // track resources that have changed in a given operation
- private ILock lock = Job.getJobManager().newLock();
- private ReentrantLock resourceLock = new ReentrantLock();
-
- private SynchronizerSyncInfoCache synchronizerCache = new SynchronizerSyncInfoCache();
- private SessionPropertySyncInfoCache sessionPropertyCache = new SessionPropertySyncInfoCache(synchronizerCache);
-
- /*
- * Package private constructor to allow specialized subclass for handling folder deletions
- */
- EclipseSynchronizer() {
- }
-
- /**
- * Returns the singleton instance of the synchronizer.
- */
- public static EclipseSynchronizer getInstance() {
- if(instance==null) {
- instance = new EclipseSynchronizer();
- }
- return instance;
- }
-
- public SyncInfoCache getSyncInfoCacheFor(IResource resource) {
- if (resource.exists() && resource.isLocal(IResource.DEPTH_ZERO)) {
- return sessionPropertyCache;
- } else {
- return synchronizerCache;
- }
- }
-
- private boolean isValid(IResource resource) {
- return resource.exists() || synchronizerCache.isPhantom(resource);
- }
-
- /**
- * Sets the folder sync info for the specified folder.
- * The folder must exist and must not be the workspace root.
- *
- * @param folder the folder
- * @param info the folder sync info, must not be null
- * @see #getFolderSync, #deleteFolderSync
- */
- public void setFolderSync(IContainer folder, FolderSyncInfo info) throws CVSException {
- Assert.isNotNull(info); // enforce the use of deleteFolderSync
- // ignore folder sync on the root (i.e. CVSROOT/config/TopLevelAdmin=yes but we just ignore it)
- if (folder.getType() == IResource.ROOT) return;
- if (!isValid(folder)) {
- // This means that the folder doesn't exist and is not a phantom
- // Allow the set if the parent is a CVS folder since
- // this can occur when creating phantom folders
- if (getFolderSync(folder.getParent()) == null) {
- IStatus status = new CVSStatus(IStatus.ERROR, TeamException.UNABLE,
- NLS.bind(CVSMessages.EclipseSynchronizer_ErrorSettingFolderSync, new String[] { folder.getFullPath().toString() }),folder);
- throw new CVSException(status);
- }
- }
- ISchedulingRule rule = null;
- try {
- rule = beginBatching(folder, null);
- try {
- beginOperation();
- // get the old info
- FolderSyncInfo oldInfo = getFolderSync(folder);
- // set folder sync and notify
- getSyncInfoCacheFor(folder).setCachedFolderSync(folder, info, true);
- // if the sync info changed from null, we may need to adjust the ancestors
- if (oldInfo == null) {
- adjustDirtyStateRecursively(folder, RECOMPUTE_INDICATOR);
- }
- folderChanged(folder);
- } finally {
- endOperation();
- }
- } finally {
- if (rule != null) endBatching(rule, null);
- }
- }
-
- /**
- * Gets the folder sync info for the specified folder.
- *
- * @param folder the folder
- * @return the folder sync info associated with the folder, or null if none.
- * @see #setFolderSync, #deleteFolderSync
- */
- public FolderSyncInfo getFolderSync(IContainer folder) throws CVSException {
- if (folder.getType() == IResource.ROOT || !isValid(folder)) return null;
- // Do a check outside the lock for any folder sync info
- FolderSyncInfo info = getSyncInfoCacheFor(folder).getCachedFolderSync(folder, false /* not thread safe */);
- if (info != null)
- return info;
- try {
- beginOperation();
- cacheFolderSync(folder);
- return getSyncInfoCacheFor(folder).getCachedFolderSync(folder, true /* thread safe */);
- } finally {
- endOperation();
- }
- }
-
- /**
- * Deletes the folder sync for the specified folder and the resource sync
- * for all of its children. Does not recurse.
- *
- * @param folder the folder
- * @see #getFolderSync, #setFolderSync
- */
- public void deleteFolderSync(IContainer folder) throws CVSException {
- if (folder.getType() == IResource.ROOT || !isValid(folder)) return;
- ISchedulingRule rule = null;
- try {
- rule = beginBatching(folder, null);
- try {
- beginOperation();
- // iterate over all children with sync info and prepare notifications
- // this is done first since deleting the folder sync may remove a phantom
- cacheResourceSyncForChildren(folder, true /* can modify workspace */);
- IResource[] children = folder.members(true);
- for (int i = 0; i < children.length; i++) {
- IResource resource = children[i];
- resourceChanged(resource);
- // delete resource sync for all children
- getSyncInfoCacheFor(resource).setCachedSyncBytes(resource, null, true);
- }
- // delete folder sync
- getSyncInfoCacheFor(folder).setCachedFolderSync(folder, null, true);
- folderChanged(folder);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- endOperation();
- }
- } finally {
- if (rule != null) endBatching(rule, null);
- }
- }
-
- private void folderChanged(IContainer folder) {
- resourceLock.folderChanged(folder);
- }
-
- private void resourceChanged(IResource resource) {
- resourceLock.resourceChanged(resource);
- }
-
- /**
- * Sets the resource sync info for the specified resource.
- * The parent folder must exist and must not be the workspace root.
- *
- * @param resource the resource
- * @param info the resource sync info, must not be null
- * @see #getResourceSync, #deleteResourceSync
- */
- public void setResourceSync(IResource resource, ResourceSyncInfo info) throws CVSException {
- Assert.isNotNull(info); // enforce the use of deleteResourceSync
- IContainer parent = resource.getParent();
- if (parent == null || parent.getType() == IResource.ROOT || !isValid(parent)) {
- IStatus status = new CVSStatus(IStatus.ERROR, TeamException.UNABLE,
- NLS.bind(CVSMessages.EclipseSynchronizer_ErrorSettingResourceSync, new String[] { resource.getFullPath().toString() }), resource);
- throw new CVSException(status);
- }
- ISchedulingRule rule = null;
- try {
- rule = beginBatching(resource, null);
- try {
- beginOperation();
- // cache resource sync for siblings, set for self, then notify
- cacheResourceSyncForChildren(parent, true /* can modify workspace */);
- setCachedResourceSync(resource, info);
- resourceChanged(resource);
- } finally {
- endOperation();
- }
- } finally {
- if (rule != null) endBatching(rule, null);
- }
- }
-
- /**
- * Gets the resource sync info for the specified folder.
- *
- * @param resource the resource
- * @return the resource sync info associated with the resource, or null if none.
- * @see #setResourceSync, #deleteResourceSync
- */
- public ResourceSyncInfo getResourceSync(IResource resource) throws CVSException {
- byte[] info = getSyncBytes(resource);
- if (info == null) return null;
- return new ResourceSyncInfo(info);
- }
-
- /**
- * Gets the resource sync info for the specified folder.
- *
- * @param resource the resource
- * @return the resource sync info associated with the resource, or null if none.
- * @see #setResourceSync, #deleteResourceSync
- */
- public byte[] getSyncBytes(IResource resource) throws CVSException {
- IContainer parent = resource.getParent();
- if (parent == null || parent.getType() == IResource.ROOT || !isValid(parent)) return null;
- // Do a quick check outside the lock to see if there are sync butes for the resource.
- byte[] info = getSyncInfoCacheFor(resource).getCachedSyncBytes(resource, false /* not thread safe */);
- if (info != null)
- return info;
- try {
- beginOperation();
- // cache resource sync for siblings, then return for self
- try {
- cacheResourceSyncForChildren(parent, false /* cannot modify workspace */);
- } catch (CVSException e) {
- if (isCannotModifySynchronizer(e) || isResourceNotFound(e)) {
- // We will resort to loading the sync info for the requested resource from disk
- byte[] bytes = getSyncBytesFromDisk(resource);
- if (!resource.exists() && bytes != null && !ResourceSyncInfo.isDeletion(bytes)) {
- bytes = ResourceSyncInfo.convertToDeletion(bytes);
- }
- return bytes;
- } else {
- throw e;
- }
- }
- return getCachedSyncBytes(resource);
- } finally {
- endOperation();
- }
- }
-
- /**
- * Sets the resource sync info for the specified resource.
- * The parent folder must exist and must not be the workspace root.
- *
- * @param resource the resource
- * @param info the resource sync info, must not be null
- * @see #getResourceSync, #deleteResourceSync
- */
- public void setSyncBytes(IResource resource, byte[] syncBytes) throws CVSException {
- Assert.isNotNull(syncBytes); // enforce the use of deleteResourceSync
- IContainer parent = resource.getParent();
- if (parent == null || parent.getType() == IResource.ROOT || !isValid(parent)) {
- IStatus status = new CVSStatus(IStatus.ERROR, TeamException.UNABLE,
- NLS.bind(CVSMessages.EclipseSynchronizer_ErrorSettingResourceSync, new String[] { resource.getFullPath().toString() }),resource);
- throw new CVSException(status);
- }
- ISchedulingRule rule = null;
- try {
- rule = beginBatching(resource, null);
- try {
- beginOperation();
- // cache resource sync for siblings, set for self, then notify
- cacheResourceSyncForChildren(parent, true /* can modify workspace */);
- setCachedSyncBytes(resource, syncBytes);
- resourceChanged(resource);
- } finally {
- endOperation();
- }
- } finally {
- if (rule != null) endBatching(rule, null);
- }
- }
-
- /**
- * Deletes the resource sync info for the specified resource, if it exists.
- *
- * @param resource the resource
- * @see #getResourceSync, #setResourceSync
- */
- public void deleteResourceSync(IResource resource) throws CVSException {
- IContainer parent = resource.getParent();
- if (parent == null || parent.getType() == IResource.ROOT || !isValid(parent)) return;
- ISchedulingRule rule = null;
- try {
- rule = beginBatching(resource, null);
- try {
- beginOperation();
- // cache resource sync for siblings, delete for self, then notify
- cacheResourceSyncForChildren(parent, true /* can modify workspace */);
- if (getCachedSyncBytes(resource) != null) { // avoid redundant notifications
- setCachedSyncBytes(resource, null);
- clearDirtyIndicator(resource);
- resourceChanged(resource);
- }
- } finally {
- endOperation();
- }
- } finally {
- if (rule != null) endBatching(rule, null);
- }
- }
-
- /**
- * @param resource
- */
- private void clearDirtyIndicator(IResource resource) throws CVSException {
- getSyncInfoCacheFor(resource).flushDirtyCache(resource);
- adjustDirtyStateRecursively(resource.getParent(), RECOMPUTE_INDICATOR);
- }
-
- /**
- * Gets the array of ignore patterns for the specified folder.
- *
- * @param folder the folder
- * @return the patterns, or an empty array if none
- * @see #addIgnored
- */
- public boolean isIgnored(IResource resource) throws CVSException {
- if (resource.getType() == IResource.ROOT ||
- resource.getType() == IResource.PROJECT ||
- ! resource.exists()) {
- return false;
- }
- IContainer parent = resource.getParent();
- FileNameMatcher matcher = sessionPropertyCache.getFolderIgnores(parent, false /* not thread safe */);
- if (matcher == null) {
- try {
- beginOperation();
- matcher = cacheFolderIgnores(parent);
- } finally {
- endOperation();
- }
- }
- return matcher.match(resource.getName());
- }
-
- /**
- * Adds a pattern to the set of ignores for the specified folder.
- *
- * @param folder the folder
- * @param pattern the pattern
- */
- public void addIgnored(IContainer folder, String pattern) throws CVSException {
- if (folder.getType() == IResource.ROOT || ! folder.exists()) {
- IStatus status = new CVSStatus(IStatus.ERROR, TeamException.UNABLE,
- NLS.bind(CVSMessages.EclipseSynchronizer_ErrorSettingIgnorePattern, new String[] { folder.getFullPath().toString() }),folder);
- throw new CVSException(status);
- }
- ISchedulingRule rule = null;
- try {
- rule = beginBatching(folder.getFile(new Path(SyncFileWriter.IGNORE_FILE)), null);
- try {
- beginOperation();
- String[] ignores = SyncFileWriter.readCVSIgnoreEntries(folder);
- if (ignores != null) {
- // verify that the pattern has not already been added
- for (int i = 0; i < ignores.length; i++) {
- if (ignores[i].equals(pattern)) return;
- }
- // add the pattern
- String[] oldIgnores = ignores;
- ignores = new String[oldIgnores.length + 1];
- System.arraycopy(oldIgnores, 0, ignores, 0, oldIgnores.length);
- ignores[oldIgnores.length] = pattern;
- } else {
- ignores = new String[] { pattern };
- }
- setCachedFolderIgnores(folder, ignores);
- SyncFileWriter.writeCVSIgnoreEntries(folder, ignores);
- // broadcast changes to unmanaged children - they are the only candidates for being ignored
- List possibleIgnores = new ArrayList();
- accumulateNonManagedChildren(folder, possibleIgnores);
- ResourceStateChangeListeners.getListener().resourceSyncInfoChanged((IResource[])possibleIgnores.toArray(new IResource[possibleIgnores.size()]));
- } finally {
- endOperation();
- }
- } finally {
- if (rule != null) endBatching(rule, null);
- }
- }
-
- /**
- * Returns the members of this folder including deleted resources with sync info,
- * but excluding special resources such as CVS subdirectories.
- *
- * @param folder the container to list
- * @return the array of members
- */
- public IResource[] members(IContainer folder) throws CVSException {
- if (! isValid(folder)) return new IResource[0];
- try {
- beginOperation();
- if (folder.getType() != IResource.ROOT) {
- // ensure that the sync info is cached so any required phantoms are created
- cacheResourceSyncForChildren(folder, false);
- }
- } catch (CVSException e) {
- if (!isCannotModifySynchronizer(e) && !isResourceNotFound(e)) {
- throw e;
- }
- } finally {
- endOperation();
- }
- try {
-
- return synchronizerCache.members(folder);
-
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- private boolean isCannotModifySynchronizer(CVSException e) {
- // IResourceStatus.WORKSPACE_LOCKED can occur if the resource sync is loaded
- // during the POST_CHANGE delta phase.
- // CVSStatus.FAILED_TO_CACHE_SYNC_INFO can occur if the resource sync is loaded
- // when no scheduling rule is held.
- return (e.getStatus().getCode() == IResourceStatus.WORKSPACE_LOCKED
- || e.getStatus().getCode() == CVSStatus.FAILED_TO_CACHE_SYNC_INFO);
- }
-
- private boolean isResourceNotFound(CVSException e) {
- return e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND;
- }
-
- /**
- * Begins a batch of operations in order to optimize sync file writing.
- * The provided scheduling rule indicates the resources
- * that the resources affected by the operation while the returned scheduling rule
- * is the rule obtained by the lock. It may differ from the provided rule as it must
- * encompass any sync files that may change as a result of the operation.
- */
- public ISchedulingRule beginBatching(ISchedulingRule resourceRule, IProgressMonitor monitor) {
- return resourceLock.acquire(resourceRule, this /* IFlushOperation */, monitor);
- }
-
- /**
- * Ends a batch of operations. The provided rule must be the one that was returned
- * by the corresponding call to beginBatching.
- * <p>
- * Progress cancellation is ignored while writting the cache to disk. This
- * is to ensure cache to disk consistency.
- * </p>
- *
- * @param monitor the progress monitor, may be null
- * @exception CVSException with a status with code <code>COMMITTING_SYNC_INFO_FAILED</code>
- * if all the CVS sync information could not be written to disk.
- */
- public void endBatching(ISchedulingRule rule, IProgressMonitor monitor) throws CVSException {
- try {
- resourceLock.release(rule, monitor);
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /* (non-Javadoc)
- *
- * Callback which is invoked when the batching resource lock is released
- * or when a flush is requested (see beginBatching(IResource)).
- *
- * @see org.eclipse.team.internal.ccvs.core.syncinfo.ReentrantLock.IRunnableOnExit#run(org.eclipse.team.internal.ccvs.core.syncinfo.ReentrantLock.ThreadInfo, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void flush(final ThreadInfo info, IProgressMonitor monitor) throws CVSException {
- if (info != null && !info.isEmpty()) {
- try {
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor pm) throws CoreException {
- IStatus status = commitCache(info, pm);
- if (!status.isOK()) {
- throw new CVSException(status);
- }
- }
- }, null, 0 /* no flags */, monitor);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
- }
-
- /*
- * Begin an access to the internal data structures of the synchronizer
- */
- private void beginOperation() {
- try {
- // Do not try to acquire the lock if the resources tree is locked
- // The reason for this is that during the resource delta phase (i.e. when the tree is locked)
- // the workspace lock is held. If we obtain our lock, there is
- // a chance of dealock. It is OK if we don't as we are still protected
- // by scheduling rules and the workspace lock.
- if (ResourcesPlugin.getWorkspace().isTreeLocked()) return;
- } catch (RuntimeException e) {
- // If we are not active, throw a cancel. Otherwise, propogate it.
- // (see bug 78303)
- if (Platform.getBundle(CVSProviderPlugin.ID).getState() == Bundle.ACTIVE) {
- throw e;
- } else {
- throw new OperationCanceledException();
- }
- }
- lock.acquire();
- }
-
- /*
- * End an access to the internal data structures of the synchronizer
- */
- private void endOperation() {
- try {
- // See beginOperation() for a description of why the lock is not obtained when the tree is locked
- if (ResourcesPlugin.getWorkspace().isTreeLocked()) return;
- } catch (RuntimeException e) {
- // If we are not active, throw a cancel. Otherwise, propogate it.
- // (see bug 78303)
- if (Platform.getBundle(CVSProviderPlugin.ID).getState() == Bundle.ACTIVE) {
- throw e;
- } else {
- throw new OperationCanceledException();
- }
- }
- lock.release();
- }
-
- /**
- * Flush the sync information from the in-memory cache to disk and purge
- * the entries from the cache.
- * <p>
- * Recursively flushes the sync information for all resources
- * below the root to disk and purges the entries from memory
- * so that the next time it is accessed it will be retrieved from disk.
- * May flush more sync information than strictly needed, but never less.
- * </p>
- *
- * @param root the root of the subtree to purge
- * @param deep purge sync from child folders
- * @param monitor the progress monitor, may be null
- */
- public void flush(IContainer root, boolean deep, IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 10);
- ISchedulingRule rule = null;
- try {
- rule = beginBatching(root, Policy.subMonitorFor(monitor, 1));
- try {
- beginOperation();
- try {
- // Flush changes to disk
- resourceLock.flush(Policy.subMonitorFor(monitor, 8));
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- } finally {
- // Purge the in-memory cache
- sessionPropertyCache.purgeCache(root, deep);
- }
- } finally {
- endOperation();
- }
- } finally {
- if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 1));
- monitor.done();
- }
- }
-
- public void deconfigure(final IProject project, IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- ISchedulingRule rule = null;
- try {
- rule = beginBatching(project, Policy.subMonitorFor(monitor, 10));
- // Flush the sync info
- flush(project, true /* deep */, Policy.subMonitorFor(monitor, 80));
-
- purgeDirtyCache(project, Policy.subMonitorFor(monitor, 5));
-
- // forget about pruned folders however the top level pruned folder will have resource sync (e.g.
- // a line in the Entry file). As a result the folder is managed but is not a CVS folder.
- synchronizerCache.purgeCache(project, true);
- } finally {
- if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 5));
- monitor.done();
- }
- }
-
- /**
- * Called to notify the synchronizer that meta files have changed on disk, outside
- * of the workbench. The cache will be flushed for this folder and it's immediate
- * children and appropriate state change events are broadcasts to state change
- * listeners.
- */
- public void ignoreFilesChanged(IContainer[] roots) throws CVSException {
- for (int i = 0; i < roots.length; i++) {
- IContainer container = roots[i];
- if (container.exists()) {
- ISchedulingRule rule = null;
- try {
- Set changed = new HashSet();
- rule = beginBatching(container, null);
- try {
- beginOperation();
-
- // Record the previous ignore pattterns
- FileNameMatcher oldIgnores = null;
- if (sessionPropertyCache.isFolderSyncInfoCached(container)) {
- oldIgnores = cacheFolderIgnores(container);
- }
-
- // Purge the cached state for direct children of the container
- changed.addAll(Arrays.asList(
- sessionPropertyCache.purgeCache(container, oldIgnores == null /*flush deeply if the old patterns are not known*/)));
-
- // Purge the state for any children of previously ignored containers
- if (oldIgnores != null) {
- FileNameMatcher newIgnores = cacheFolderIgnores(container);
- try {
- IResource[] members = container.members();
- for (int j = 0; j < members.length; j++) {
- IResource resource = members[j];
- if (resource.getType() == IResource.FOLDER) {
- String name = resource.getName();
- if (oldIgnores.match(name) && !newIgnores.match(name)) {
- changed.addAll(Arrays.asList(
- sessionPropertyCache.purgeCache((IContainer)resource, true /*flush deeply*/)));
- }
- }
- }
- } catch (CoreException e) {
- // Just log and continue
- CVSProviderPlugin.log(e);
- }
- }
- } finally {
- endOperation();
- }
- if (!changed.isEmpty()) {
- ResourceStateChangeListeners.getListener().resourceSyncInfoChanged(
- (IResource[]) changed.toArray(new IResource[changed.size()]));
- }
- } finally {
- if (rule != null) endBatching(rule, null);
- }
- }
- }
- }
-
- public void syncFilesChangedExternally(IContainer[] changedMetaFiles, IFile[] externalDeletions) throws CVSException {
- List changed = new ArrayList();
- for (int i = 0; i < changedMetaFiles.length; i++) {
- IContainer container = changedMetaFiles[i];
- if (!isWithinActiveOperationScope(container)) {
- changed.addAll(Arrays.asList(
- sessionPropertyCache.purgeCache(container, false /*don't flush children*/)));
- }
- }
- for (int i = 0; i < externalDeletions.length; i++) {
- IFile file = externalDeletions[i];
- if (!isWithinActiveOperationScope(file)) {
- sessionPropertyCache.purgeCache(file.getParent(), false /*don't flush children*/);
- changed.add(file);
- }
- }
- if (!changed.isEmpty()) {
- ResourceStateChangeListeners.getListener().externalSyncInfoChange(
- (IResource[]) changed.toArray(new IResource[changed.size()]));
- }
- }
-
- /*
- * The resource is about to be deleted by the move delete hook.
- * In all cases (except when the resource doesn't exist), this method
- * will indicate that the dirty state of the parent needs to be recomputed.
- * For managed resources, it will move the cached sync info from the session
- * property cache into the sycnrhonizer cache, purging the session cache.
- * @param resource the resource about to be deleted.
- * <p>
- * Note taht this method is not recursive. Hence, for managed resources
- *
- * @returns whether children need to be prepared
- * @throws CVSException
- */
- /* private */ boolean prepareForDeletion(IResource resource) throws CVSException {
- if (!resource.exists()) return false;
- ISchedulingRule rule = null;
- try {
- rule = beginBatching(resource, null);
- try {
- beginOperation();
- // Flush the dirty info for the resource and it's ancestors.
- // Although we could be smarter, we need to do this because the
- // deletion may fail.
- adjustDirtyStateRecursively(resource, RECOMPUTE_INDICATOR);
- if (resource.getType() == IResource.FILE) {
- byte[] syncBytes = getSyncBytes(resource);
- if (syncBytes != null) {
- if (ResourceSyncInfo.isAddition(syncBytes)) {
- deleteResourceSync(resource);
- } else {
- syncBytes = convertToDeletion(syncBytes);
- synchronizerCache.setCachedSyncBytes(resource, syncBytes, true);
- }
- sessionPropertyCache.purgeResourceSyncCache(resource);
- resourceChanged(resource);
- }
- return false;
- } else {
- IContainer container = (IContainer)resource;
- if (container.getType() == IResource.PROJECT) {
- synchronizerCache.flush((IProject)container);
- return false;
- } else {
- // Move the folder sync info into phantom space
- FolderSyncInfo info = getFolderSync(container);
- if (info == null) return false;
- synchronizerCache.setCachedFolderSync(container, info, true);
- folderChanged(container);
- // move the resource sync as well
- byte[] syncBytes = getSyncBytes(resource);
- synchronizerCache.setCachedSyncBytes(resource, syncBytes, true);
- sessionPropertyCache.purgeResourceSyncCache(container);
- sessionPropertyCache.purgeCache(container, false);
- return true;
- }
- }
- } finally {
- endOperation();
- }
- } finally {
- if (rule != null) endBatching(rule, null);
- }
- }
-
- /**
- * The resource has been deleted. Make sure any cached state is cleared.
- * This is needed because the move/delete hook is not invoked in all situations
- * (e.g. external deletion).
- *
- * @param resource
- * @throws CVSException
- */
- protected void handleDeleted(IResource resource) throws CVSException {
- if (resource.exists()) return;
- try {
- beginOperation();
- adjustDirtyStateRecursively(resource, RECOMPUTE_INDICATOR);
- } finally {
- endOperation();
- }
- }
-
- /**
- * Prepare for the deletion of the target resource from within
- * the move/delete hook. The method is invoked by both the
- * deleteFile/Folder methods and for the source resource
- * of moveFile/Folder. This method will move the cached sync info
- * into the phantom (ISynchronizer) cache so that outgoing deletions
- * and known remote folders are preserved.
- *
- * @param resource
- * @param monitor
- * @throws CVSException
- */
- public void prepareForDeletion(IResource resource, IProgressMonitor monitor) throws CVSException {
- // Move sync info to phantom space for the resource and all it's children
- monitor = Policy.monitorFor(monitor);
- try {
- beginOperation();
- monitor.beginTask(null, 100);
- try {
- resource.accept(new IResourceVisitor() {
- public boolean visit(IResource innerResource) throws CoreException {
- try {
- return prepareForDeletion(innerResource);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- throw new CoreException(e.getStatus());
- }
- }
- });
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- } finally {
- endOperation();
- monitor.done();
- }
- }
-
- /**
- * If not already cached, loads and caches the resource sync for the children of the container.
- * Folder must exist and must not be the workspace root.
- *
- * @param container the container
- */
- private void cacheResourceSyncForChildren(IContainer container, boolean canModifyWorkspace) throws CVSException {
- // don't try to load if the information is already cached
- if (! getSyncInfoCacheFor(container).isResourceSyncInfoCached(container)) {
- // load the sync info from disk
- byte[][] infos;
- // do not load the sync info for resources that are linked
- if (isLinkedResource(container)) {
- infos = null;
- } else {
- infos = SyncFileWriter.readAllResourceSync(container);
- }
- try {
- if (infos != null) {
- for (int i = 0; i < infos.length; i++) {
- byte[] syncBytes = infos[i];
- IPath name = new Path(null, getName(syncBytes));
- IResource resource;
- if (isFolder(syncBytes)) {
- resource = container.getFolder(name);
- } else {
- resource = container.getFile(name);
- }
- getSyncInfoCacheFor(resource).setCachedSyncBytes(resource, syncBytes, canModifyWorkspace);
- }
- }
- getSyncInfoCacheFor(container).setResourceSyncInfoCached(container);
- } catch (CVSException e) {
- if (Policy.DEBUG_METAFILE_CHANGES) {
- System.err.println("Failed to cache Entries for folder " + container.getFullPath()); //$NON-NLS-1$
- }
- throw e;
- }
- }
- }
-
- /**
- * If not already cached, loads and caches the folder sync for the
- * container. Folder must exist and must not be the workspace root.
- *
- * @param container the container
- */
- private void cacheFolderSync(IContainer container) throws CVSException {
- // don't try to load if the information is already cached
- if (! getSyncInfoCacheFor(container).isFolderSyncInfoCached(container)) {
- // load the sync info from disk
- FolderSyncInfo info;
- // do not load the sync info for resources that are linked
- if (isLinkedResource(container)) {
- info = null;
- } else {
- info = SyncFileWriter.readFolderSync(container);
- }
- getSyncInfoCacheFor(container).setCachedFolderSync(container, info, false);
- }
- }
-
- private boolean isLinkedResource(IResource resource) {
- return CVSWorkspaceRoot.isLinkedResource(resource);
- }
-
- /**
- * Load the sync info for the given resource from disk
- * @param resource
- * @return byte[]
- */
- private byte[] getSyncBytesFromDisk(IResource resource) throws CVSException {
- byte[][] infos = SyncFileWriter.readAllResourceSync(resource.getParent());
- if (infos == null) return null;
- for (int i = 0; i < infos.length; i++) {
- byte[] syncBytes = infos[i];
- if (resource.getName().equals(getName(syncBytes))) {
- return syncBytes;
- }
- }
- return null;
- }
-
- /**
- * Commits the cache after a series of operations.
- *
- * Will return STATUS_OK unless there were problems writting sync
- * information to disk. If an error occurs a multistatus is returned
- * with the list of reasons for the failures. Failures are recovered,
- * and all changed resources are given a chance to be written to disk.
- *
- * @param monitor the progress monitor, may be null
- */
- /* internal use only */ IStatus commitCache(ThreadInfo threadInfo, IProgressMonitor monitor) {
- if (threadInfo.isEmpty()) {
- return SyncInfoCache.STATUS_OK;
- }
- List errors = new ArrayList();
- try {
- /*** prepare operation ***/
- // find parents of changed resources
- IResource[] changedResources = threadInfo.getChangedResources();
- IContainer[] changedFolders;
- if (threadInfo instanceof CVSThreadInfo) {
- changedFolders = ((CVSThreadInfo)threadInfo).getChangedFolders();
- } else {
- changedFolders = new IContainer[0];
- }
- Set dirtyParents = new HashSet();
- for (int i = 0; i < changedResources.length; i++) {
- IResource resource = changedResources[i];
- IContainer folder = resource.getParent();
- dirtyParents.add(folder);
- }
-
- monitor = Policy.monitorFor(monitor);
- int numDirty = dirtyParents.size();
- int numResources = changedFolders.length + numDirty;
- monitor.beginTask(null, numResources);
- if(monitor.isCanceled()) {
- monitor.subTask(CVSMessages.EclipseSynchronizer_UpdatingSyncEndOperationCancelled);
- } else {
- monitor.subTask(CVSMessages.EclipseSynchronizer_UpdatingSyncEndOperation);
- }
-
- /*** write sync info to disk ***/
- // folder sync info changes
- for (int i = 0; i < changedFolders.length; i++) {
- IContainer folder = changedFolders[i];
- if (folder.exists() && folder.getType() != IResource.ROOT) {
- try {
- beginOperation();
- FolderSyncInfo info = sessionPropertyCache.getCachedFolderSync(folder, true);
- // Do not write the folder sync for linked resources
- if (info == null) {
- // deleted folder sync info since we loaded it
- // (but don't overwrite the sync info for linked folders
- if (!isLinkedResource(folder))
- SyncFileWriter.deleteFolderSync(folder);
- dirtyParents.remove(folder);
- } else {
- // modified or created new folder sync info since we loaded it
- SyncFileWriter.writeFolderSync(folder, info);
- }
- } catch(CVSException e) {
- try {
- sessionPropertyCache.purgeCache(folder, true /* deep */);
- } catch(CVSException pe) {
- errors.add(pe.getStatus());
- }
- errors.add(e.getStatus());
- } finally {
- endOperation();
- }
- }
- monitor.worked(1);
- }
-
- // update progress for parents we will skip because they were deleted
- monitor.worked(numDirty - dirtyParents.size());
-
- // resource sync info changes
- for (Iterator it = dirtyParents.iterator(); it.hasNext();) {
- IContainer folder = (IContainer) it.next();
- if (folder.exists() && folder.getType() != IResource.ROOT) {
- // write sync info for all children in one go
- try {
- beginOperation();
- List infos = new ArrayList();
- IResource[] children = folder.members(true);
- for (int i = 0; i < children.length; i++) {
- IResource resource = children[i];
- byte[] syncBytes = getSyncBytes(resource);
- if (syncBytes != null) {
- infos.add(syncBytes);
- }
- }
- // do not overwrite the sync info for linked resources
- if (infos.size() > 0 || !isLinkedResource(folder))
- SyncFileWriter.writeAllResourceSync(folder,
- (byte[][]) infos.toArray(new byte[infos.size()][]));
- } catch(CVSException e) {
- try {
- sessionPropertyCache.purgeCache(folder, false /* depth 1 */);
- } catch(CVSException pe) {
- errors.add(pe.getStatus());
- }
- errors.add(e.getStatus());
- } catch (CoreException e) {
- try {
- sessionPropertyCache.purgeCache(folder, false /* depth 1 */);
- } catch(CVSException pe) {
- errors.add(pe.getStatus());
- }
- errors.add(e.getStatus());
- } finally {
- endOperation();
- }
- }
- monitor.worked(1);
- }
-
- /*** broadcast events ***/
- monitor.subTask(CVSMessages.EclipseSynchronizer_NotifyingListeners);
- Set allChanges = new HashSet();
- allChanges.addAll(Arrays.asList(changedResources));
- allChanges.addAll(Arrays.asList(changedFolders));
- allChanges.addAll(dirtyParents);
- IResource[] resources = (IResource[]) allChanges.toArray(
- new IResource[allChanges.size()]);
- broadcastResourceStateChanges(resources);
- if ( ! errors.isEmpty()) {
- MultiStatus status = new MultiStatus(CVSProviderPlugin.ID,
- CVSStatus.COMMITTING_SYNC_INFO_FAILED,
- CVSMessages.EclipseSynchronizer_ErrorCommitting,
- null);
- for (int i = 0; i < errors.size(); i++) {
- status.merge((IStatus)errors.get(i));
- }
- return status;
- }
- return SyncInfoCache.STATUS_OK;
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Broadcasts the resource state changes for the given resources to CVS Provider Plugin
- */
- void broadcastResourceStateChanges(IResource[] resources) {
- if (resources.length > 0) {
- ResourceStateChangeListeners.getListener().resourceSyncInfoChanged(resources);
- }
- }
-
- /**
- * Returns the resource sync info for the resource; null if none.
- * Parent must exist and must not be the workspace root.
- * The resource sync info for the children of the parent container MUST ALREADY BE CACHED.
- *
- * @param resource the resource
- * @return the resource sync info for the resource, or null
- * @see #cacheResourceSyncForChildren
- */
- private byte[] getCachedSyncBytes(IResource resource) throws CVSException {
- return getSyncInfoCacheFor(resource).getCachedSyncBytes(resource, true);
- }
-
- /**
- * Returns the resource sync info for the resource; null if none.
- * Parent must exist and must not be the workspace root.
- * The resource sync info for the children of the parent container MUST ALREADY BE CACHED.
- *
- * @param resource the resource
- * @return the resource sync info for the resource, or null
- * @see #cacheResourceSyncForChildren
- */
- private void setCachedSyncBytes(IResource resource, byte[] syncBytes) throws CVSException {
- getSyncInfoCacheFor(resource).setCachedSyncBytes(resource, syncBytes, true);
- resourceChanged(resource);
- }
-
- /**
- * Sets the resource sync info for the resource; if null, deletes it. Parent
- * must exist and must not be the workspace root. The resource sync info for
- * the children of the parent container MUST ALREADY BE CACHED.
- *
- * @param resource the resource
- * @param info the new resource sync info
- * @see #cacheResourceSyncForChildren
- */
- private void setCachedResourceSync(IResource resource, ResourceSyncInfo info) throws CVSException {
- //todo
- byte[] syncBytes = null;
- if (info != null) syncBytes = info.getBytes();
- getSyncInfoCacheFor(resource).setCachedSyncBytes(resource, syncBytes, true);
- }
-
- /**
- * If not already cached, loads and caches the folder ignores sync for the container.
- * Folder must exist and must not be the workspace root.
- *
- * @param container the container
- * @return the folder ignore patterns, or an empty array if none
- */
- private FileNameMatcher cacheFolderIgnores(IContainer container) throws CVSException {
- return sessionPropertyCache.getFolderIgnores(container, true);
- }
-
- /**
- * Sets the array of folder ignore patterns for the container, must not be null.
- * Folder must exist and must not be the workspace root.
- *
- * @param container the container
- * @param ignores the array of ignore patterns
- */
- private void setCachedFolderIgnores(IContainer container, String[] ignores) throws CVSException {
- sessionPropertyCache.setCachedFolderIgnores(container, ignores);
- }
-
- /*
- * Recursively adds to the possibleIgnores list all children of the given
- * folder that can be ignored. This method may only be invoked when a
- * schedling rule for the given foldr is held and when the CVs sync lock is
- * held.
- *
- * @param folder the folder to be searched
- * @param possibleIgnores the list of IResources that can be ignored
- */
- private void accumulateNonManagedChildren(IContainer folder, List possibleIgnores) throws CVSException {
- try {
- cacheResourceSyncForChildren(folder, true /* can modify workspace */);
- IResource[] children = folder.members();
- List folders = new ArrayList();
- // deal with all files first and then folders to be otimized for caching scheme
- for (int i = 0; i < children.length; i++) {
- IResource child = children[i];
- if(getCachedSyncBytes(child)==null) {
- possibleIgnores.add(child);
- }
- if(child.getType()!=IResource.FILE) {
- folders.add(child);
- }
- }
- for (Iterator iter = folders.iterator(); iter.hasNext();) {
- IContainer child = (IContainer) iter.next();
- accumulateNonManagedChildren(child, possibleIgnores);
- }
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Add the entry to the CVS/Notify file. We are not initially concerned with efficiency
- * since edit/unedit are typically issued on a small set of files.
- *
- * XXX If there was a previous notify entry for the resource, it is replaced. This is
- * probably not the proper behavior (see EclipseFile).
- *
- * A value of null for info indicates that any entry for the given
- * resource is to be removed from the Notify file.
- *
- * @param resource
- * @param info
- */
- public void setNotifyInfo(IResource resource, NotifyInfo info) throws CVSException {
- NotifyInfo[] infos = SyncFileWriter.readAllNotifyInfo(resource.getParent());
- if (infos == null) {
- // if the file is empty and we are removing an entry, just return;
- if (info == null) return;
- infos = new NotifyInfo[] { info };
- } else {
- Map infoMap = new HashMap();
- for (int i = 0; i < infos.length; i++) {
- NotifyInfo notifyInfo = infos[i];
- infoMap.put(notifyInfo.getName(), notifyInfo);
- }
- if (info == null) {
- // if the info is null, remove the entry
- infoMap.remove(resource.getName());
- } else {
- // add the new entry to the list
- infoMap.put(info.getName(), info);
- }
-
- NotifyInfo[] newInfos = new NotifyInfo[infoMap.size()];
- int i = 0;
- for (Iterator iter = infoMap.values().iterator(); iter.hasNext();) {
- newInfos[i++] = (NotifyInfo) iter.next();
- }
- infos = newInfos;
- }
- SyncFileWriter.writeAllNotifyInfo(resource.getParent(), infos);
- }
-
- /**
- * Method getNotifyInfo.
- * @param resource
- * @return NotifyInfo
- */
- public NotifyInfo getNotifyInfo(IResource resource) throws CVSException {
- NotifyInfo[] infos = SyncFileWriter.readAllNotifyInfo(resource.getParent());
- if (infos == null) return null;
- for (int i = 0; i < infos.length; i++) {
- NotifyInfo notifyInfo = infos[i];
- if (notifyInfo.getName().equals(resource.getName())) {
- return notifyInfo;
- }
- }
- return null;
- }
-
- /**
- * Method deleteNotifyInfo.
- * @param resource
- */
- public void deleteNotifyInfo(IResource resource) throws CVSException {
- NotifyInfo[] infos = SyncFileWriter.readAllNotifyInfo(resource.getParent());
- if (infos == null) return;
- Map infoMap = new HashMap();
- for (int i = 0; i < infos.length; i++) {
- NotifyInfo notifyInfo = infos[i];
- infoMap.put(notifyInfo.getName(), notifyInfo);
- }
- infoMap.remove(resource.getName());
- NotifyInfo[] newInfos = new NotifyInfo[infoMap.size()];
- int i = 0;
- for (Iterator iter = infoMap.values().iterator(); iter.hasNext();) {
- newInfos[i++] = (NotifyInfo) iter.next();
- }
- SyncFileWriter.writeAllNotifyInfo(resource.getParent(), newInfos);
- }
-
- /**
- * Add the entry to the CVS/Baserev file. We are not initially concerned
- * with efficiency since edit/unedit are typically issued on a small set of
- * files.
- *
- * XXX If there was a previous notify entry for the resource, it is replaced. This is
- * probably not the proper behavior (see EclipseFile).
- *
- * @param resource
- * @param info
- */
- public void setBaserevInfo(IResource resource, BaserevInfo info) throws CVSException {
- BaserevInfo[] infos = SyncFileWriter.readAllBaserevInfo(resource.getParent());
- if (infos == null) {
- infos = new BaserevInfo[] { info };
- } else {
- Map infoMap = new HashMap();
- for (int i = 0; i < infos.length; i++) {
- infoMap.put(infos[i].getName(), infos[i]);
- }
- infoMap.put(info.getName(), info);
- BaserevInfo[] newInfos = new BaserevInfo[infoMap.size()];
- int i = 0;
- for (Iterator iter = infoMap.values().iterator(); iter.hasNext();) {
- newInfos[i++] = (BaserevInfo) iter.next();
- }
- infos = newInfos;
- }
- SyncFileWriter.writeAllBaserevInfo(resource.getParent(), infos);
- }
-
- /**
- * Method getBaserevInfo.
- * @param resource
- * @return BaserevInfo
- */
- public BaserevInfo getBaserevInfo(IResource resource) throws CVSException {
- BaserevInfo[] infos = SyncFileWriter.readAllBaserevInfo(resource.getParent());
- if (infos == null) return null;
- for (int i = 0; i < infos.length; i++) {
- BaserevInfo info = infos[i];
- if (info.getName().equals(resource.getName())) {
- return info;
- }
- }
- return null;
- }
-
- /**
- * Method deleteNotifyInfo.
- * @param resource
- */
- public void deleteBaserevInfo(IResource resource) throws CVSException {
- BaserevInfo[] infos = SyncFileWriter.readAllBaserevInfo(resource.getParent());
- if (infos == null) return;
- Map infoMap = new HashMap();
- for (int i = 0; i < infos.length; i++) {
- infoMap.put(infos[i].getName(), infos[i]);
- }
- infoMap.remove(resource.getName());
- BaserevInfo[] newInfos = new BaserevInfo[infoMap.size()];
- int i = 0;
- for (Iterator iter = infoMap.values().iterator(); iter.hasNext();) {
- newInfos[i++] = (BaserevInfo) iter.next();
- }
- SyncFileWriter.writeAllBaserevInfo(resource.getParent(), newInfos);
- }
-
- public void copyFileToBaseDirectory(final IFile file, IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- ISchedulingRule rule = null;
- try {
- rule = beginBatching(file, Policy.subMonitorFor(monitor, 10));
- ResourceSyncInfo info = getResourceSync(file);
- // The file must exist remotely and locally
- if (info == null || info.isAdded() || info.isDeleted())
- return;
- SyncFileWriter.writeFileToBaseDirectory(file, Policy.subMonitorFor(monitor, 80));
- resourceChanged(file);
- } finally {
- if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 10));
- monitor.done();
- }
- }
-
- public void restoreFileFromBaseDirectory(final IFile file, IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- ISchedulingRule rule = null;
- try {
- rule = beginBatching(file, Policy.subMonitorFor(monitor, 10));
- ResourceSyncInfo info = getResourceSync(file);
- // The file must exist remotely
- if (info == null || info.isAdded())
- return;
- SyncFileWriter.restoreFileFromBaseDirectory(file, Policy.subMonitorFor(monitor, 80));
- resourceChanged(file);
- } finally {
- if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 10));
- monitor.done();
- }
- }
-
- public void deleteFileFromBaseDirectory(final IFile file, IProgressMonitor monitor) throws CVSException {
- ResourceSyncInfo info = getResourceSync(file);
- // The file must exist remotely
- if (info == null || info.isAdded())
- return;
- SyncFileWriter.deleteFileFromBaseDirectory(file, monitor);
- }
-
- /**
- * Method isSyncInfoLoaded returns true if all the sync info for the
- * provided resources is loaded into the internal cache.
- *
- * @param resources
- * @param i
- * @return boolean
- */
- public boolean isSyncInfoLoaded(IResource[] resources, int depth) throws CVSException {
- // get the folders involved
- IContainer[] folders = getParentFolders(resources, depth);
- // for all folders that have a CVS folder, ensure the sync info is cached
- for (int i = 0; i < folders.length; i++) {
- IContainer parent = folders[i];
- if (!getSyncInfoCacheFor(parent).isSyncInfoLoaded(parent)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Method ensureSyncInfoLoaded loads all the relevent sync info into the cache.
- * This method can only be invoked when the workspace is open for modification.
- * in other words it cannot be invoked from inside a POST_CHANGE delta listener.
- * @param resources
- * @param i
- * @return Object
- */
- public void ensureSyncInfoLoaded(IResource[] resources, int depth) throws CVSException {
- // get the folders involved
- IContainer[] folders = getParentFolders(resources, depth);
- // Cache the sync info for all the folders
- for (int i = 0; i < folders.length; i++) {
- IContainer parent = folders[i];
- ISchedulingRule rule = null;
- try {
- rule = beginBatching(parent, null);
- try {
- beginOperation();
- cacheResourceSyncForChildren(parent, true /* can modify workspace */);
- cacheFolderSync(parent);
- cacheFolderIgnores(parent);
- } finally {
- endOperation();
- }
- } finally {
- if (rule != null) endBatching(rule, null);
- }
- }
- }
-
- /*
- * Collect the projects and parent folders of the resources since
- * thats were the sync info is kept.
- */
- private IContainer[] getParentFolders(IResource[] resources, int depth) throws CVSException {
- final Set folders = new HashSet();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- folders.add(resource.getProject());
- if (resource.getType() != IResource.PROJECT) {
- folders.add(resource.getParent());
- }
- // use the depth to gather child folders when appropriate
- if (depth != IResource.DEPTH_ZERO) {
- try {
- resource.accept(new IResourceVisitor() {
- public boolean visit(IResource innerResource) throws CoreException {
- if (innerResource.getType() == IResource.FOLDER)
- folders.add(innerResource);
- // let the depth determine who we visit
- return true;
- }
- }, depth, false);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
- }
- return (IContainer[]) folders.toArray(new IContainer[folders.size()]);
- }
-
- /**
- * Perform sync info batching within the context of the given resource
- * scheduling rule while running the given ICVSRunnable.
- * @param runnable
- * @param monitor
- * @throws CVSException
- */
- public void run(ISchedulingRule resourceRule, ICVSRunnable runnable, IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- ISchedulingRule rule = beginBatching(resourceRule, Policy.subMonitorFor(monitor, 1));
- try {
- runnable.run(Policy.subMonitorFor(monitor, 98));
- } finally {
- if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 1));
- monitor.done();
- }
- }
-
- /**
- * Method isEdited returns true if a "cvs edit" was performed on the given
- * file and no commit or unedit has yet been performed.
- * @param iResource
- * @return boolean
- */
- public boolean isEdited(IFile resource) {
- return SyncFileWriter.isEdited(resource);
- }
-
- /* package */ void adjustDirtyStateRecursively(IResource resource, String indicator) throws CVSException {
- if (resource.getType() == IResource.ROOT) return;
- try {
- beginOperation();
-
- if (getSyncInfoCacheFor(resource).cachesDirtyState()) {
- if (indicator == getDirtyIndicator(resource)) {
- return;
- }
- getSyncInfoCacheFor(resource).setDirtyIndicator(resource, indicator);
- }
-
- if (Policy.DEBUG_DIRTY_CACHING) {
- debug(resource, indicator, "adjusting dirty state"); //$NON-NLS-1$
- }
-
- IContainer parent = resource.getParent();
- if(indicator == NOT_DIRTY_INDICATOR) {
- adjustDirtyStateRecursively(parent, RECOMPUTE_INDICATOR);
- }
-
- if(indicator == RECOMPUTE_INDICATOR) {
- adjustDirtyStateRecursively(parent, RECOMPUTE_INDICATOR);
- }
-
- if(indicator == IS_DIRTY_INDICATOR) {
- adjustDirtyStateRecursively(parent, indicator);
- }
- } finally {
- endOperation();
- }
- }
-
- protected String getDirtyIndicator(IResource resource) throws CVSException {
- // Do a check outside the lock for the dirty indicator
- String indicator = getSyncInfoCacheFor(resource).getDirtyIndicator(resource, false /* not thread safe */);
- if (indicator != null)
- return indicator;
- try {
- beginOperation();
- return getSyncInfoCacheFor(resource).getDirtyIndicator(resource, true);
- } finally {
- endOperation();
- }
- }
-
- /*
- * Mark the given resource as either modified or clean using a persistant
- * property. Do nothing if the modified state is already what we want.
- * Return true if the modification state was changed.
- */
- protected void setDirtyIndicator(IResource resource, boolean modified) throws CVSException {
- String indicator = modified ? IS_DIRTY_INDICATOR : NOT_DIRTY_INDICATOR;
- // set the dirty indicator and adjust the parent accordingly
- adjustDirtyStateRecursively(resource, indicator);
- }
-
- /**
- * Method getName.
- * @param syncBytes
- */
- private String getName(byte[] syncBytes) throws CVSException {
- return ResourceSyncInfo.getName(syncBytes);
- }
-
- /**
- * Method isFolder.
- * @param syncBytes
- * @return boolean
- */
- private boolean isFolder(byte[] syncBytes) {
- return ResourceSyncInfo.isFolder(syncBytes);
- }
-
- /**
- * Method convertToDeletion.
- * @param syncBytes
- * @return byte[]
- */
- private byte[] convertToDeletion(byte[] syncBytes) throws CVSException {
- return ResourceSyncInfo.convertToDeletion(syncBytes);
- }
-
- static public void debug(IResource resource, String indicator, String string) {
- String di = EclipseSynchronizer.IS_DIRTY_INDICATOR;
- if(indicator == EclipseSynchronizer.IS_DIRTY_INDICATOR) {
- di = "dirty"; //$NON-NLS-1$
- } else if(indicator == EclipseSynchronizer.NOT_DIRTY_INDICATOR) {
- di = "clean"; //$NON-NLS-1$
- } else {
- di = "needs recomputing"; //$NON-NLS-1$
- }
- System.out.println("["+string + ":" + di + "] " + resource.getFullPath()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- /**
- * @param file
- * @return int
- */
- public int getModificationState(IResource resource) throws CVSException {
- String indicator = getDirtyIndicator(resource);
- if (Policy.DEBUG_DIRTY_CACHING) {
- debug(resource, indicator, "getModificationState"); //$NON-NLS-1$
- }
- if (indicator == null || indicator == RECOMPUTE_INDICATOR) {
- return ICVSFile.UNKNOWN;
- } else if (indicator == IS_DIRTY_INDICATOR) {
- return ICVSFile.DIRTY;
- } else if (indicator == NOT_DIRTY_INDICATOR) {
- return ICVSFile.CLEAN;
- } else {
- return ICVSFile.UNKNOWN;
- }
- }
-
- /**
- * Return whether the resource is within the scope of a currently active
- * CVS operation.
- * @param resource
- * @return
- */
- public boolean isWithinActiveOperationScope(IResource resource) {
- return resourceLock.isWithinActiveOperationScope(resource);
- }
-
- /**
- * Set the timestamp of the given file and set it to be CLEAN. It is
- * assumed that this method is only invoked to reset the file timestamp
- * to the timestamp that is in the CVS/Entries file.
- * @param file
- * @param time
- * @throws CVSException
- */
- public void setTimeStamp(EclipseFile cvsFile, long time) throws CVSException {
- ISchedulingRule rule = null;
- IFile file = (IFile)cvsFile.getIResource();
- try {
- rule = beginBatching(file, null);
- try {
- beginOperation();
- try {
- file.setLocalTimeStamp(time);
- setModified(cvsFile, ICVSFile.CLEAN);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- resourceChanged(file);
- } finally {
- endOperation();
- }
- } finally {
- if (rule != null) endBatching(rule, null);
- }
- }
-
- /**
- * React to a resource that was just moved by the move/delete hook.
- * @param resource the resource that was moved (at its new location)
- */
- public void postMove(IResource resource) throws CVSException {
- try {
- beginOperation();
- if (resource.getType() == IResource.FILE) {
- // Purge any copied sync info so true sync info will
- // be obtained from the synchronizer cache
- sessionPropertyCache.purgeResourceSyncCache(resource);
- } else {
- IContainer container = (IContainer)resource;
- // Purge any copied sync info
- sessionPropertyCache.purgeCache(container, true /* deep */);
- // Dirty all resources so old sync info will be rewritten to disk
- try {
- container.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if (getSyncBytes(resource) != null) {
- resourceChanged(resource);
- }
- if (resource.getType() != IResource.FILE) {
- if (getFolderSync((IContainer)resource) != null) {
- folderChanged((IContainer)resource);
- return true;
- }
- }
- return false;
- }
- });
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- // Flush the sync info to disk
- flush(container, true /* deep */, null);
- }
- } finally {
- endOperation();
- }
- }
-
- /**
- * This method is to be invoked only from the move/delete hook. It's purpose
- * is to obtain the sync look in order to prevent other threads from accessing
- * sync info while the move/delete is taking place.
- * @param runnable
- * @param monitor
- * @throws CVSException
- */
- public void performMoveDelete(ICVSRunnable runnable, IProgressMonitor monitor) throws CVSException {
- ISchedulingRule rule = null;
- try {
- monitor.beginTask(null, 100);
- rule = beginBatching(null, null);
- try {
- beginOperation();
- runnable.run(Policy.subMonitorFor(monitor, 95));
- } finally {
- endOperation();
- }
- } finally {
- if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 5));
- monitor.done();
- }
- }
-
- /**
- * Compute the modification state for the given file. If the modificationState is
- * ICVSFile.UNKNOWN, it is computed. However, if it is CLEAN or DIRTY,
- * it is set accordingly. CLEAN or DIRTY can only be used if the caller is protected
- * from resource modifications (either by a scheduling rule or inside a delta handler).
- * @param file
- * @param modificationState
- * @return true if the file is dirty
- */
- public boolean setModified(EclipseFile cvsFile, int modificationState) throws CVSException {
- try {
- beginOperation();
- boolean dirty;
- if (modificationState == ICVSFile.UNKNOWN) {
- dirty = cvsFile.isDirty();
- } else {
- dirty = modificationState == ICVSFile.DIRTY;
- }
- setDirtyIndicator(cvsFile.getIResource(), dirty);
- return dirty;
- } finally {
- endOperation();
- }
-
- }
-
- /**
- * Set the modified state of the folder. This method can be called when no resource locks are
- * held. It will check the cached modification state of all the folder's children before setting.
- * If the states of the children do not match, the state for the folder is not cached.
- * @param folder
- * @param modified
- */
- public void setModified(ICVSFolder cvsFolder, boolean modified) throws CVSException {
- try {
- beginOperation();
- IContainer folder = (IContainer)cvsFolder.getIResource();
- // The drop out condition for clean or dirty are the opposite.
- // (i.e. if modified and a dirty is found we can set the indicator
- // and if not modified and a dirty or unknown is found we cannot set the indicator)
- boolean okToSet = !modified;
- // Obtain the children while we're locked to ensure some were not added or changed
- ICVSResource[] children = cvsFolder.members(ICVSFolder.ALL_UNIGNORED_MEMBERS);
- for (int i = 0; i < children.length; i++) {
- IResource resource = children[i].getIResource();
- if (modified) {
- if (getDirtyIndicator(resource) == IS_DIRTY_INDICATOR) {
- okToSet = true;
- break;
- }
- } else {
- if (getDirtyIndicator(resource) != NOT_DIRTY_INDICATOR) {
- okToSet = false;
- break;
- }
- }
- }
- if (okToSet) {
- setDirtyIndicator(folder, modified);
- }
- } finally {
- endOperation();
- }
- }
-
- public boolean wasPhantom(IResource resource) {
- if (resource.exists()) {
- try {
- return (synchronizerCache.getCachedSyncBytes(resource, true) != null
- || (resource.getType() == IResource.FOLDER
- && synchronizerCache.hasCachedFolderSync((IContainer)resource)));
- } catch (CVSException e) {
- // Log and assume resource is not a phantom
- CVSProviderPlugin.log(e);
- }
- }
- return false;
- }
-
- /**
- * Method called from background handler when resources that are mapped to CVS are recreated
- * @param resources
- * @param monitor
- * @throws CVSException
- */
- public void resourcesRecreated(IResource[] resources, IProgressMonitor monitor) throws CVSException {
- if (resources.length == 0) return;
- ISchedulingRule rule = null;
- ISchedulingRule projectsRule = getProjectRule(resources);
- try {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- rule = beginBatching(projectsRule, monitor);
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- try {
- created(resource);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- }
- } finally {
- if (rule != null) endBatching(rule, Policy.subMonitorFor(monitor, 5));
- monitor.done();
- }
- }
-
- private ISchedulingRule getProjectRule(IResource[] resources) {
- HashSet set = new HashSet();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- set.add(resource.getProject());
- }
- IProject[] projects = (IProject[]) set.toArray(new IProject[set.size()]);
- if (projects.length == 1) {
- return projects[0];
- }
- return new MultiRule(projects);
- }
-
- protected void created(IResource resource) throws CVSException {
- try {
- beginOperation();
- if (resource.exists()) {
- restoreResourceSync(resource);
- if (resource.getType() == IResource.FOLDER) {
- restoreFolderSync((IFolder)resource);
- }
- }
- } finally {
- endOperation();
- }
- }
-
- /*
- * Restore the folder sync info for the given folder
- */
- private void restoreFolderSync(IFolder folder) throws CVSException {
- try {
- // set the dirty count using what was cached in the phantom it
- beginOperation();
- FolderSyncInfo folderInfo = synchronizerCache.getCachedFolderSync(folder, true);
- if (folderInfo != null) {
- // There is folder sync info to restore
- if (folder.getFolder(SyncFileWriter.CVS_DIRNAME).exists()) {
- // There is already a CVS subdirectory which indicates that
- // either the folder was recreated by an external tool or that
- // a folder with CVS information was copied from another location.
- // To know the difference, we need to compare the folder sync info.
- // If they are mapped to the same root and repository then just
- // purge the phantom info. Otherwise, keep the original sync info.
-
- // Get the new folder sync info
- FolderSyncInfo newFolderInfo = getFolderSync(folder);
- if (newFolderInfo.getRoot().equals(folderInfo.getRoot())
- && newFolderInfo.getRepository().equals(folderInfo.getRepository())) {
- // The folder is the same so use what is on disk.
- // Fall through to ensure that the Root and Repository files exist
- } else {
- // The folder is mapped to a different location.
- // Purge new resource sync before restoring from phantom
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder);
- ICVSResource[] children = cvsFolder.members(ICVSFolder.MANAGED_MEMBERS);
- for (int i = 0; i < children.length; i++) {
- ICVSResource resource = children[i];
- deleteResourceSync(resource.getIResource());
- }
- }
- }
-
- // set the sync info using what was cached in the phantom
- setFolderSync(folder, folderInfo);
- // purge the dirty cache so any old persisted dirty state is purged
- sessionPropertyCache.purgeDirtyCache(folder);
- // Indicate that a member has changed so the entries file gets written (see bug 181546)
- IResource[] members = members(folder);
- IResource changedResource = null;
- for (int i = 0; i < members.length; i++) {
- IResource resource = members[i];
- if (getSyncBytes(resource) != null) {
- changedResource = resource;
- break;
- }
- }
- if (changedResource == null) {
- changedResource = folder.getFile("dummy"); //$NON-NLS-1$
- }
- resourceChanged(changedResource);
- }
- } finally {
- try {
- endOperation();
- } finally {
- synchronizerCache.flush(folder);
- }
- }
- }
-
- /*
- * Restore the resource sync info for the given resource.
- */
- private void restoreResourceSync(IResource resource) throws CVSException {
- try {
- beginOperation();
- byte[] syncBytes = synchronizerCache.getCachedSyncBytes(resource, true);
- if (syncBytes != null) {
- if (!ResourceSyncInfo.isFolder(syncBytes)) {
- syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes);
- }
- byte[] newBytes = getSyncBytes(resource);
- if (newBytes != null && !ResourceSyncInfo.isFolder(newBytes)) {
- newBytes = ResourceSyncInfo.convertFromDeletion(newBytes);
- }
- if (newBytes == null || Util.equals(syncBytes, newBytes)) {
- // only move the sync info if there is no new sync info
- setSyncBytes(resource, syncBytes);
- }
- }
- } finally {
- try {
- endOperation();
- } finally {
- synchronizerCache.setCachedSyncBytes(resource, null, true);
- }
- }
- }
-
- private void purgeDirtyCache(IProject project, IProgressMonitor monitor) throws CVSException {
- sessionPropertyCache.purgeDirtyCache(project);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileContentCachingService.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileContentCachingService.java
deleted file mode 100644
index 884c448ab..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileContentCachingService.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-
-/**
- * This class can be used to fetch and cache file contents for remote files.
- */
-public class FileContentCachingService {
-
- String[] fileDiffs;
- private CVSRepositoryLocation repository;
- private ICVSFolder remoteRoot;
-
- public static RemoteFolderTree buildRemoteTree(CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag, IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(null, 100);
- try {
- RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, root, tag);
- RemoteFolderTree tree = builder.buildTree(new ICVSResource[] { root }, Policy.subMonitorFor(monitor, 50));
- FileContentCachingService service = new FileContentCachingService(repository, tree, builder.getFileDiffs());
- service.cacheFileContents(Policy.subMonitorFor(monitor, 50));
- return tree;
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Fetch and cache the file contents for the specified files.
- * @param root the root folder for the files being fetched
- * @param filePaths the root relative file paths
- * @param monitor
- * @throws CVSException
- */
- public static void fetchFileContents(RemoteFolderTree root, String[] filePaths, IProgressMonitor monitor) throws CVSException {
- FileContentCachingService service = new FileContentCachingService((CVSRepositoryLocation)root.getRepository(), root, filePaths);
- service.cacheFileContents(monitor);
- }
-
- public static RemoteFile buildRemoteTree(CVSRepositoryLocation repository, ICVSFile file, CVSTag tag, IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(null, 100);
- try {
- RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, file.getParent(), tag);
- RemoteFile remote = builder.buildTree(file, monitor);
- if (builder.getFileDiffs().length > 0) {
- // Getting the storage of the file will cache the contents
- remote.getStorage(Policy.subMonitorFor(monitor, 50));
- }
- return remote;
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- } finally {
- monitor.done();
- }
- }
-
- public FileContentCachingService(CVSRepositoryLocation repository, RemoteFolderTree tree, String[] fileDiffs) {
- this.repository = repository;
- this.remoteRoot = tree;
- this.fileDiffs = fileDiffs;
- }
-
- private void cacheFileContents(IProgressMonitor monitor) throws CVSException {
- String[] files = getUncachedFiles();
- if (files.length == 0) return;
- // Fetch the file contents for all out-of-sync files by running an update
- // on the remote tree passing the known changed files as arguments
- monitor.beginTask(null, 10 + files.length * 100);
- Policy.checkCanceled(monitor);
- Session session = new Session(repository, remoteRoot, false);
- session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */);
- try {
- Policy.checkCanceled(monitor);
- IStatus status = Command.UPDATE.execute(session,
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] { Update.IGNORE_LOCAL_CHANGES },
- files,
- null,
- Policy.subMonitorFor(monitor, files.length * 100));
- if (!status.isOK()) {
- // No big deal but log the problem anyway
- CVSProviderPlugin.log (new CVSException(status));
- }
- } finally {
- session.close();
- monitor.done();
- }
- }
-
- /*
- * Only return those file in the diff list that exist remotely and whose contents are not already cached
- */
- private String[] getUncachedFiles() {
- if (fileDiffs.length == 0) return fileDiffs;
- List existing = new ArrayList();
- for (int i = 0; i < fileDiffs.length; i++) {
- String filePath = fileDiffs[i];
- try {
- ICVSFile file = remoteRoot.getFile(filePath);
- if (file instanceof RemoteFile) {
- if (!((RemoteFile)file).isContentsCached()) {
- existing.add(filePath);
- }
- }
- } catch (CVSException e) {
- // The child does not exists so exclude it
- }
- }
- return (String[]) existing.toArray(new String[existing.size()]);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileModificationManager.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileModificationManager.java
deleted file mode 100644
index 86af9ac51..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileModificationManager.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.util.ResourceStateChangeListeners;
-
-/**
- * This class performs several functions related to determining the modified
- * status of files under CVS control. First, it listens for change delta's for
- * files and brodcasts them to all listeners. It also registers as a save
- * participant so that deltas generated before the plugin are loaded are not
- * missed. Secondly, it listens for CVS resource state change events and uses
- * these to properly mark files and folders as modified.
- */
-public class FileModificationManager implements IResourceChangeListener {
-
- private static final QualifiedName UPDATE_TIMESTAMP = new QualifiedName(CVSProviderPlugin.ID, "update-timestamp"); //$NON-NLS-1$
-
- /* private */Set modifiedResources = new HashSet();
-
- // consider the following changes types and ignore the others (e.g. marker and description changes are ignored)
- protected int INTERESTING_CHANGES = IResourceDelta.CONTENT |
- IResourceDelta.MOVED_FROM |
- IResourceDelta.MOVED_TO |
- IResourceDelta.OPEN |
- IResourceDelta.REPLACED |
- IResourceDelta.TYPE;
-
- /**
- * Listen for file modifications and fire modification state changes
- *
- * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- try {
- event.getDelta().accept(new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) {
- IResource resource = delta.getResource();
-
- if (resource.getType()==IResource.PROJECT) {
- IProject project = (IProject)resource;
- if (!project.isAccessible()) {
- return false;
- }
- if ((delta.getFlags() & IResourceDelta.OPEN) != 0) {
- return false;
- }
- if (RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()) == null) {
- return false;
- }
- }
-
- if (resource.getType()==IResource.FILE && delta.getKind() == IResourceDelta.CHANGED && resource.exists()) {
- int flags = delta.getFlags();
- if((flags & INTERESTING_CHANGES) != 0) {
- resourceChanged(resource, false);
- }
- } else if (delta.getKind() == IResourceDelta.ADDED) {
- resourceChanged(resource, true);
- } else if (delta.getKind() == IResourceDelta.REMOVED) {
- try {
- EclipseSynchronizer.getInstance().handleDeleted(resource);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- modifiedResources.add(resource);
- }
-
- return true;
- }
- });
- if (!modifiedResources.isEmpty()) {
- ResourceStateChangeListeners.getListener().resourceModified(
- (IResource[])modifiedResources.toArray(new IResource[modifiedResources.size()]));
- modifiedResources.clear();
- }
- } catch (CoreException e) {
- CVSProviderPlugin.log(e);
- }
-
- }
-
- /**
- * Method updated flags the objetc as having been modfied by the updated
- * handler. This flag is read during the resource delta to determine whether
- * the modification made the file dirty or not.
- *
- * @param mFile
- */
- public void updated(ICVSFile mFile) {
- try {
- if (mFile instanceof EclipseFile) {
- IFile file = (IFile)mFile.getIResource();
- file.setSessionProperty(UPDATE_TIMESTAMP, new Long(file.getModificationStamp()));
- }
- } catch (CoreException e) {
- CVSProviderPlugin.log(e);
- }
- }
-
- /*
- * Handle added and changed resources by signaling the change to the corresponding
- * CVS resource and recording the change for broadcast to interested listeners.
- */
- /* private */void resourceChanged(IResource resource, boolean addition) {
- if (isCleanUpdate(resource)) return;
- try {
- EclipseResource cvsResource = (EclipseResource)CVSWorkspaceRoot.getCVSResourceFor(resource);
- if (!cvsResource.isIgnored()) {
- cvsResource.handleModification(addition);
- modifiedResources.add(resource);
- }
- // see bug 170743
- // ignored .cvsignore should always be clean and do not affect the path
- if(cvsResource.getName().equals(".cvsignore") && cvsResource.isIgnored()){ //$NON-NLS-1$
- EclipseSynchronizer.getInstance().setModified((EclipseFile) cvsResource, ICVSFile.CLEAN);
- modifiedResources.add(resource);
- }
- } catch (CVSException e) {
- // Log the exception and continue
- CVSProviderPlugin.log(e);
- }
- }
-
- /**
- * If the file was the result of a clean update, the cached timestamp will
- * be removed.
- *
- * @param resource
- * @return boolean
- */
- private boolean isCleanUpdate(IResource resource) {
- if(resource.getType() != IResource.FILE) return false;
- long modStamp = resource.getModificationStamp();
- Long whenWeWrote;
- try {
- whenWeWrote = (Long)resource.getSessionProperty(UPDATE_TIMESTAMP);
- resource.setSessionProperty(UPDATE_TIMESTAMP, null);
- } catch(CoreException e) {
- CVSProviderPlugin.log(e);
- whenWeWrote = null;
- }
- return (whenWeWrote!=null && whenWeWrote.longValue() == modStamp);
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
deleted file mode 100644
index bd7062dbd..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
+++ /dev/null
@@ -1,680 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Red Hat Incorporated - is/setExecutable() code
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.*;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.history.IFileRevision;
-import org.eclipse.team.core.variants.CachedResourceVariant;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.*;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ILogEntryListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.LogListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.filehistory.CVSResourceVariantFileRevision;
-import org.eclipse.team.internal.ccvs.core.filesystem.CVSURI;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
-
-/**
- * This class provides the implementation of ICVSRemoteFile and IManagedFile for
- * use by the repository and sync view.
- */
-public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
-
- /*
- * Listener for accumulating the entries fetched using the "cvs log" command
- */
- private final class LogEntryListener implements ILogEntryListener {
- private final List entries = new ArrayList();
- public void handleLogEntryReceived(ILogEntry entry) {
- if (entry.getRemoteFile().getRepositoryRelativePath().equals(getRepositoryRelativePath())) {
- entries.add(entry);
- }
- }
- public ILogEntry[] getEntries() {
- return (ILogEntry[])entries.toArray(new ILogEntry[entries.size()]);
- }
- }
-
- // sync info in byte form
- private byte[] syncBytes;
- // cache the log entry for the remote file
- private ILogEntry entry;
- // state that indicates that the handle is actively fetching content
- private boolean fetching = false;
- // executable bit
- private boolean executable = false;
-
- /**
- * Static method which creates a file as a single child of its parent.
- * This should only be used when one is only interested in the file alone.
- *
- * The returned RemoteFile represents the base of the local resource.
- * If the local resource does not have a base, then null is returned
- * even if the resource does exists remotely (e.g. created by another party).
- */
- public static RemoteFile getBase(RemoteFolder parent, ICVSFile managed) throws CVSException {
- Assert.isNotNull(parent, "A parent folder must be provided for file " + managed.getName()); //$NON-NLS-1$
- byte[] syncBytes = managed.getSyncBytes();
- if ((syncBytes == null) || ResourceSyncInfo.isAddition(syncBytes)) {
- // Either the file is unmanaged or has just been added (i.e. doesn't necessarily have a remote)
- return null;
- }
- if (ResourceSyncInfo.isDeletion(syncBytes)) {
- syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes);
- }
- RemoteFile file = new RemoteFile(parent, syncBytes);
- parent.setChildren(new ICVSRemoteResource[] {file});
- return file;
- }
-
- /**
- * This method is used by the CVS subscribers to create file handles.
- */
- public static RemoteFile fromBytes(IResource local, byte[] bytes, byte[] parentBytes) throws CVSException {
- Assert.isNotNull(bytes);
- Assert.isTrue(local.getType() == IResource.FILE);
- RemoteFolder parent = RemoteFolder.fromBytes(local.getParent(), parentBytes);
- RemoteFile file = new RemoteFile(parent, bytes);
- parent.setChildren(new ICVSRemoteResource[] {file});
- return file;
- }
-
- /**
- * Create a remote file handle for the given file path that is relative to the
- * given location.
- */
- public static RemoteFile create(String filePath, ICVSRepositoryLocation location) {
- return create(filePath, location, null, null);
- }
-
- /**
- * Create a remote file handle for the given file path that is relative to the
- * given location.
- */
- public static RemoteFile create(String filePath, ICVSRepositoryLocation location, CVSTag tag, String revision) {
- Assert.isNotNull(filePath);
- Assert.isNotNull(location);
- IPath path = new Path(null, filePath);
- if (tag != null && revision != null && tag.getName().equals(revision))
- tag = null;
- RemoteFolder parent = new RemoteFolder(null /* parent */, location, path.removeLastSegments(1).toString(), tag /* tag */);
- RemoteFile file = new RemoteFile(parent, Update.STATE_NONE, path.lastSegment(), revision /* revision */, null /* keyword mode */, tag /* tag */);
- parent.setChildren(new ICVSRemoteResource[] {file});
- return file;
- }
-
- /**
- * Constructor for RemoteFile that should be used when nothing is know about the
- * file ahead of time.
- * @param parent the folder that is the parent of the file
- * @param workspaceSyncState the workspace state (use Update.STATE_NONE if unknown)
- * @param name the name of the file
- * @param revision revision of the file or <code>null</code> if the revision is not known
- * @param keywordMode keyword mode of the file or <code>null</code> if the mode is not known
- * @param tag tag for the file
- */
- public RemoteFile(RemoteFolder parent, int workspaceSyncState, String name, String revision, KSubstOption keywordMode, CVSTag tag) {
- this(parent, name, workspaceSyncState, getSyncBytes(name, revision, keywordMode, tag));
- }
-
- private static byte[] getSyncBytes(String name, String revision, KSubstOption keywordMode, CVSTag tag) {
- if (revision == null) {
- revision = ResourceSyncInfo.ADDED_REVISION;
- }
- if (keywordMode == null) {
- // Always use a blank mode for remote files so that
- // the proper mode will be obtained when the contents
- // are fetched
- keywordMode = KSubstOption.fromMode(""); //$NON-NLS-1$
- }
- MutableResourceSyncInfo newInfo = new MutableResourceSyncInfo(name, revision);
- newInfo.setKeywordMode(keywordMode);
- newInfo.setTag(tag);
- return newInfo.getBytes();
- }
-
- public RemoteFile(RemoteFolder parent, byte[] syncBytes) throws CVSException {
- this(parent, Update.STATE_NONE, syncBytes);
- }
-
- /* package */ RemoteFile(RemoteFolder parent, int workspaceSyncState, byte[] syncBytes) throws CVSException {
- this(parent, ResourceSyncInfo.getName(syncBytes), workspaceSyncState, syncBytes);
- }
-
- private RemoteFile(RemoteFolder parent, String name, int workspaceSyncState, byte[] syncBytes) {
- super(parent, name);
- this.syncBytes = syncBytes;
- setWorkspaceSyncState(workspaceSyncState);
- }
-
- /**
- * @see ICVSResource#accept(ICVSResourceVisitor)
- */
- public void accept(ICVSResourceVisitor visitor) throws CVSException {
- visitor.visitFile(this);
- }
-
- /**
- * @see ICVSResource#accept(ICVSResourceVisitor, boolean)
- */
- public void accept(ICVSResourceVisitor visitor, boolean recurse) throws CVSException {
- visitor.visitFile(this);
- }
-
- /**
- * @see ICVSRemoteFile#getContents()
- */
- public InputStream getContents(IProgressMonitor monitor) throws CVSException {
- try {
- return getStorage(monitor).getContents();
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- protected void fetchContents(IProgressMonitor monitor) throws TeamException {
- try {
- aboutToReceiveContents(getSyncBytes());
- internalFetchContents(monitor);
- // If the fetch succeeded but no contents were cached from the server
- // than we can assume that the remote file has no contents.
- if (!isContentsCached()) {
- setContents(new ByteArrayInputStream(new byte[0]), monitor);
- }
- } finally {
- doneReceivingContents();
- }
- }
-
- private void internalFetchContents(IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(CVSMessages.RemoteFile_getContents, 100);
- monitor.subTask(CVSMessages.RemoteFile_getContents);
- if (getRevision().equals(ResourceSyncInfo.ADDED_REVISION)) {
- // The revision of the remote file is not known so we need to use the tag to get the status of the file
- CVSTag tag = getSyncInfo().getTag();
- if (tag == null) tag = CVSTag.DEFAULT;
- RemoteFolderMemberFetcher fetcher = new RemoteFolderMemberFetcher((RemoteFolder)getParent(), tag);
- fetcher.updateFileRevisions(new ICVSFile[] { this }, Policy.subMonitorFor(monitor, 10));
- }
- Session session = new Session(getRepository(), parent, false /* create backups */);
- session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */);
- try {
- IStatus status = Command.UPDATE.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] {
- Update.makeTagOption(new CVSTag(getRevision(), CVSTag.VERSION)),
- Update.IGNORE_LOCAL_CHANGES },
- new ICVSResource[] { this },
- null,
- Policy.subMonitorFor(monitor, 80));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- session.close();
- monitor.done();
- }
- }
-
- /*
- * @see ICVSRemoteFile#getLogEntry(IProgressMonitor)
- */
- public ILogEntry getLogEntry(IProgressMonitor monitor) throws CVSException {
- if (entry == null) {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(CVSMessages.RemoteFile_getLogEntries, 100);
- Session session = new Session(getRepository(), parent, false /* output to console */);
- session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */);
- try {
- try {
- LogEntryListener listener = new LogEntryListener();
- IStatus status = Command.LOG.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] {
- Log.makeRevisionOption(getRevision())},
- new ICVSResource[] { RemoteFile.this },
- new LogListener(RemoteFile.this, listener),
- Policy.subMonitorFor(monitor, 90));
- ILogEntry[] entries = listener.getEntries();
- if (entries.length == 1) {
- entry = entries[0];
- }
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- monitor.done();
- }
- } finally {
- session.close();
- }
- }
- return entry;
- }
-
- /**
- * @see ICVSRemoteFile#getLogEntries()
- */
- public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(CVSMessages.RemoteFile_getLogEntries, 100);
- Session session = new Session(getRepository(), parent, false /* output to console */);
- session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */);
- try {
- QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
- try {
- CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
- LogEntryListener listener = new LogEntryListener();
- IStatus status = Command.LOG.execute(
- session,
- Command.NO_GLOBAL_OPTIONS, Command.NO_LOCAL_OPTIONS,
- new ICVSResource[] { RemoteFile.this }, new LogListener(RemoteFile.this, listener),
- Policy.subMonitorFor(monitor, 90));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- return listener.getEntries();
- } finally {
- CVSProviderPlugin.getPlugin().setQuietness(quietness);
- monitor.done();
- }
- } finally {
- session.close();
- }
- }
-
- /**
- * @see ICVSRemoteFile#getRevision()
- */
- public String getRevision() {
- try {
- return ResourceSyncInfo.getRevision(syncBytes);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- return ResourceSyncInfo.ADDED_REVISION;
- }
- }
-
- private KSubstOption getKeywordMode() {
- try {
- return ResourceSyncInfo.getKeywordMode(syncBytes);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- return KSubstOption.getDefaultTextMode();
- }
- }
-
- /*
- * Get a different revision of the remote file.
- *
- * We must also create a new parent since the child is accessed through the parent from within CVS commands.
- * Therefore, we need a new parent so that we can fetch the contents of the remote file revision
- */
- public RemoteFile toRevision(String revision) {
- RemoteFolder newParent = new RemoteFolder(null, parent.getRepository(), parent.getRepositoryRelativePath(), parent.getTag());
- RemoteFile file = new RemoteFile(newParent, getWorkspaceSyncState(), getName(), revision, getKeywordMode(), CVSTag.DEFAULT);
- newParent.setChildren(new ICVSRemoteResource[] {file});
- return file;
- }
-
- /**
- * @see ICVSFile#getSyncInfo()
- */
- public ResourceSyncInfo getSyncInfo() {
- try {
- return new ResourceSyncInfo(syncBytes);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- return null;
- }
- }
-
- /**
- * @see ICVSResource#getRemoteLocation(ICVSFolder)
- */
- public String getRemoteLocation(ICVSFolder stopSearching) throws CVSException {
- return parent.getRemoteLocation(stopSearching) + Session.SERVER_SEPARATOR + getName();
- }
-
- /**
- * Get the remote path for the receiver relative to the repository location path
- */
- public String getRepositoryRelativePath() {
- String parentPath = parent.getRepositoryRelativePath();
- return parentPath + Session.SERVER_SEPARATOR + getName();
- }
-
- /**
- * Return the server root directory for the repository
- */
- public ICVSRepositoryLocation getRepository() {
- return parent.getRepository();
- }
-
- /**
- * @see IManagedFile#setFileInfo(FileProperties)
- */
- public void setSyncInfo(ResourceSyncInfo fileInfo, int modificationState) {
- setSyncBytes(fileInfo.getBytes(),modificationState);
- }
-
- /**
- * Set the revision for this remote file.
- *
- * @param revision to associated with this remote file
- */
- public void setRevision(String revision) throws CVSException {
- syncBytes = ResourceSyncInfo.setRevision(syncBytes, revision);
- }
-
- public InputStream getContents() throws CVSException {
- if (!fetching) {
- // Return the cached contents
- if (isContentsCached()) {
- try {
- InputStream cached = getCachedContents();
- if (cached != null) {
- return cached;
- }
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- }
- }
- }
- // There was nothing cached so return an empty stream.
- // This is done to allow the contents to be fetched
- // (i.e. update sends empty contents and real contents are sent back)
- return new ByteArrayInputStream(new byte[0]);
- }
-
- protected InputStream getCachedContents() throws TeamException {
- if (isHandleCached()) {
- RemoteFile file = (RemoteFile)getCachedHandle();
- if (file != null) {
- byte[] newSyncBytes = file.getSyncBytes();
- if (newSyncBytes != null) {
- // Make sure the sync bytes match the content that is being accessed
- syncBytes = newSyncBytes;
- }
- }
- }
- return super.getCachedContents();
- }
-
- public void setContents(InputStream stream, int responseType, boolean keepLocalHistory, IProgressMonitor monitor) throws CVSException {
- try {
- setContents(stream, monitor);
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /*
- * @see ICVSFile#setReadOnly(boolean)
- */
- public void setReadOnly(boolean readOnly) {
- // RemoteFiles are always read only
- }
-
- /*
- * @see ICVSFile#isReadOnly()
- */
- public boolean isReadOnly() {
- return true;
- }
-
- /*
- * @see ICVSFile#getTimeStamp()
- */
- public Date getTimeStamp() {
- return getSyncInfo().getTimeStamp();
- }
-
- /*
- * @see ICVSFile#setTimeStamp(Date)
- */
- public void setTimeStamp(Date date) {
- // RemoteFiles are not muttable so do not support timestamp changes
- }
-
- /**
- * @see ICVSFile#moveTo(String)
- */
- public void copyTo(String mFile) {
- // Do nothing
- }
-
- /*
- * @see IRemoteResource#members(IProgressMonitor)
- */
- public ICVSRemoteResource[] members(IProgressMonitor progress) {
- return new ICVSRemoteResource[0];
- }
-
- /*
- * @see IRemoteResource#isContainer()
- */
- public boolean isContainer() {
- return false;
- }
-
- /*
- * @see ICVSResource#isFolder()
- */
- public boolean isFolder() {
- return false;
- }
-
- /*
- * @see ICVSResource#tag(CVSTag, LocalOption[], IProgressMonitor)
- *
- * The revision of the remote file is used as the base for the tagging operation
- */
- public IStatus tag(final CVSTag tag, final LocalOption[] localOptions, IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- Session session = new Session(getRepository(), getParent(), true /* output to console */);
- session.open(Policy.subMonitorFor(monitor, 10), true /* open for modification */);
- try {
- return Command.RTAG.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- localOptions,
- new CVSTag(getRevision(), CVSTag.VERSION),
- tag,
- new ICVSRemoteResource[] { RemoteFile.this },
- Policy.subMonitorFor(monitor, 90));
- } finally {
- session.close();
- }
- }
-
- public boolean equals(Object target) {
- if (this == target)
- return true;
- if (!(target instanceof RemoteFile))
- return false;
- RemoteFile remote = (RemoteFile) target;
- return super.equals(target) && remote.getRevision().equals(getRevision());
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#checkout(int)
- */
- public void edit(int notifications, boolean notifyForWritable, IProgressMonitor monitor) {
- // do nothing
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#uncheckout()
- */
- public void unedit(IProgressMonitor monitor) {
- // do nothing
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#notificationCompleted()
- */
- public void notificationCompleted() {
- // do nothing
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#getPendingNotification()
- */
- public NotifyInfo getPendingNotification() {
- return null;
- }
-
- /**
- * @see RemoteResource#forTag(ICVSRemoteFolder, CVSTag)
- */
- public ICVSRemoteResource forTag(ICVSRemoteFolder parent, CVSTag tag) {
- return new RemoteFile((RemoteFolder)parent, getWorkspaceSyncState(), getName(), getRevision(), getKeywordMode(), tag);
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSRemoteResource#forTag(org.eclipse.team.internal.ccvs.core.CVSTag)
- */
- public ICVSRemoteResource forTag(CVSTag tag) {
- RemoteFolderTree remoteFolder = new RemoteFolderTree(null, getRepository(),
- ((ICVSRemoteFolder)getParent()).getRepositoryRelativePath(),
- tag);
- RemoteFile remoteFile = (RemoteFile)forTag(remoteFolder, tag);
- remoteFolder.setChildren(new ICVSRemoteResource[] { remoteFile });
- return remoteFile;
- }
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#committed(org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo)
- */
- public void checkedIn(String info, boolean commit) {
- // do nothing
- }
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#isEdited()
- */
- public boolean isEdited() {
- return false;
- }
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#getSyncBytes()
- */
- public byte[] getSyncBytes() {
- return syncBytes;
- }
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#setSyncBytes(byte[])
- */
- public void setSyncBytes(byte[] syncBytes, int modificationState) {
- if (fetching) {
- RemoteFile file = (RemoteFile)getCachedHandle();
- if (file == null) {
- cacheHandle();
- } else if (file != this) {
- file.setSyncBytes(syncBytes, modificationState);
- }
- }
- this.syncBytes = syncBytes;
- }
-
- public String toString() {
- return super.toString() + " " + getRevision(); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.IRemoteResource#getContentIdentifier()
- */
- public String getContentIdentifier() {
- return getRevision();
- }
-
- /**
- * Callback which indicates that the remote file is about to receive contents that should be cached
- * @param entryLine
- */
- public void aboutToReceiveContents(byte[] entryLine) {
- setSyncBytes(entryLine, ICVSFile.CLEAN);
- fetching = true;
- }
-
- /**
- * The contents for the file have already been provided.
- */
- public void doneReceivingContents() {
- fetching = false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.synchronize.ResourceVariant#isContentsCached()
- */
- public boolean isContentsCached() {
- // Made public for use by FileContentCachingService
- return super.isContentsCached();
- }
-
- /**
- * Cache the contents of the given IFile as the contents for this remote file handle.
- * The caller must ensure that the local file is mapped to the same revision and is
- * not modified since it was loaded from CVS.
- * @param file
- * @throws CoreException
- * @throws TeamException
- */
- public void setContents(IFile file, IProgressMonitor monitor) throws TeamException, CoreException {
- setContents(file.getContents(), monitor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#setExecutable(boolean)
- */
- public void setExecutable(boolean executable) throws CVSException {
- // store executable bit;
- this.executable = executable;
- RemoteFile file = (RemoteFile)getCachedHandle();
- if (file != this) {
- file.setExecutable(executable);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#isExecutable()
- */
- public boolean isExecutable() throws CVSException {
- // return executable bit
- return executable;
- }
-
- public CachedResourceVariant getCachedHandle() {
- return super.getCachedHandle();
- }
-
- public Object getAdapter(Class adapter) {
- if (adapter == IFileRevision.class)
- return new CVSResourceVariantFileRevision(this);
- return super.getAdapter(adapter);
- }
-
- public CVSURI toCVSURI() {
- ResourceSyncInfo info = getSyncInfo();
- return new CVSURI(getRepository(), new Path(getRepositoryRelativePath()), info.getTag(), info.getRevision());
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java
deleted file mode 100644
index 4d20bf497..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java
+++ /dev/null
@@ -1,598 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.*;
-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.IUpdateMessageListener;
-import org.eclipse.team.internal.ccvs.core.client.listeners.UpdateListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
-import org.eclipse.team.internal.ccvs.core.util.KnownRepositories;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * This class provides the implementation of ICVSRemoteFolder
- *
- * The parent of the RemoteFolder represents the folders parent in a local configuration.
- * For instance, the parent may correspond to the remote parent or may be a folder in the
- * same repository that has no physical relationship to the RemoteFolder (resulting from the use
- * of a module definition, for instance). A RemoteFolder may not have a parent, indicating that it is
- * the root of the local configuration it represents.
- *
- * A RemoteFolder has the following:
- * A name in the folder's local configuration
- *
- */
-public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, ICVSFolder {
-
- protected static final int CHILD_DOES_NOT_EXIST = 1000;
-
- protected FolderSyncInfo folderInfo;
- private ICVSRemoteResource[] children;
- private ICVSRepositoryLocation repository;
-
- public static RemoteFolder fromBytes(IResource local, byte[] bytes) throws CVSException {
- Assert.isNotNull(bytes);
- Assert.isTrue(local.getType() != IResource.FILE);
- FolderSyncInfo syncInfo = FolderSyncInfo.getFolderSyncInfo(bytes);
- return new RemoteFolder(null, local.getName(), KnownRepositories.getInstance().getRepository(syncInfo.getRoot()), syncInfo.getRepository(), syncInfo.getTag(), syncInfo.getIsStatic());
- }
-
- /**
- * Constructor for RemoteFolder.
- */
- public RemoteFolder(RemoteFolder parent, ICVSRepositoryLocation repository, String repositoryRelativePath, CVSTag tag) {
- this(parent,
- repositoryRelativePath == null ? "" : Util.getLastSegment(repositoryRelativePath), //$NON-NLS-1$
- repository,
- repositoryRelativePath,
- tag,
- false);
- }
-
- public RemoteFolder(RemoteFolder parent, String name, ICVSRepositoryLocation repository, String repositoryRelativePath, CVSTag tag, boolean isStatic) {
- super(parent, name);
- if (repository != null) {
- this.folderInfo = new FolderSyncInfo(repositoryRelativePath.toString(), repository.getLocation(false), tag, isStatic);
- }
- this.repository = repository;
- }
-
- /**
- * @see ICVSResource#accept(ICVSResourceVisitor)
- */
- public void accept(ICVSResourceVisitor visitor) throws CVSException {
- visitor.visitFolder(this);
- }
-
- /**
- * @see ICVSResource#accept(ICVSResourceVisitor, boolean)
- */
- public void accept(ICVSResourceVisitor visitor, boolean recurse) throws CVSException {
- visitor.visitFolder(this);
- ICVSResource[] resources;
- if (recurse) {
- resources = members(ICVSFolder.ALL_MEMBERS);
- } else {
- resources = members(ICVSFolder.FILE_MEMBERS);
- }
- for (int i = 0; i < resources.length; i++) {
- resources[i].accept(visitor, recurse);
- }
- }
-
- /*
- * @see ICVSRemoteResource#exists(IProgressMonitor)
- */
- public boolean exists(IProgressMonitor monitor) throws TeamException {
- try {
- members(monitor);
- return true;
- } catch (CVSException e) {
- if (e.getStatus().getCode() == CVSStatus.DOES_NOT_EXIST) {
- return false;
- } else {
- throw e;
- }
- }
- }
-
- /*
- * Check whether the given resource is a child of the receiver remotely
- */
- protected boolean exists(ICVSRemoteResource child, IProgressMonitor monitor) throws CVSException {
- return exists(child, getTag(), monitor);
- }
-
- /*
- * Check whether the child exists for the given tag. This additional method is required because
- * CVS will signal an error if a folder only contains subfolders when a tag is used. If we get this
- * error and we're looking for a folder, we need to reissue the command without a tag.
- */
- protected boolean exists(final ICVSRemoteResource child, CVSTag tag, IProgressMonitor monitor) throws CVSException {
- final IProgressMonitor progress = Policy.monitorFor(monitor);
- progress.beginTask(CVSMessages.RemoteFolder_exists, 100);
- try {
- // Create the listener for remote files and folders
- final boolean[] exists = new boolean[] {true};
- final IUpdateMessageListener listener = new IUpdateMessageListener() {
- public void directoryInformation(ICVSFolder parent, String path, boolean newDirectory) {
- exists[0] = true;
- }
- public void directoryDoesNotExist(ICVSFolder parent, String path) {
- exists[0] = false;
- }
- public void fileInformation(int type, ICVSFolder parent, String filename) {
- // We can't set exists true here as we may get a conflict on a deleted file.
- // i.e. remote files are always communicated to the server as modified.
- if (type == Update.STATE_ADDED_LOCAL)
- exists[0] = false;
- }
- public void fileDoesNotExist(ICVSFolder parent, String filename) {
- exists[0] = false;
- }
- };
-
- // Build the local options
- final List localOptions = new ArrayList();
- localOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
- if (tag != null && tag.getType() != CVSTag.HEAD)
- localOptions.add(Update.makeTagOption(tag));
-
- // Retrieve the children and any file revision numbers in a single connection
- // Perform a "cvs -n update -d -r tagName folderName" with custom message and error handlers
- boolean retry = false;
- Session session = new Session(getRepository(), this, false /* output to console */);
- session.open(Policy.subMonitorFor(progress, 10), false /* read-only */);
- try {
- IStatus status = Command.UPDATE.execute(
- session,
- new GlobalOption[] { Command.DO_NOT_CHANGE },
- (LocalOption[]) localOptions.toArray(new LocalOption[localOptions.size()]),
- new ICVSResource[] { child }, new UpdateListener(listener),
- Policy.subMonitorFor(progress, 70));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- CVSServerException e = new CVSServerException(status);
- if (e.isNoTagException() && child.isContainer()) {
- retry = true;
- } else {
- if (e.containsErrors()) {
- throw e;
- }
- }
- }
- } finally {
- session.close();
- }
-
- // We now know that this is an exception caused by a cvs bug.
- // If the folder has no files in it (just subfolders) CVS does not respond with the subfolders...
- // Workaround: Retry the request with no tag to get the directory names (if any)
- if (retry) {
- Policy.checkCanceled(progress);
- return exists(child, null, Policy.subMonitorFor(progress, 20));
- }
- return exists[0];
- } finally {
- progress.done();
- }
- }
-
- /**
- * @see ICVSRemoteFolder#getMembers()
- */
- public ICVSRemoteResource[] getMembers(IProgressMonitor monitor) throws TeamException {
- return getMembers(getTag(), monitor);
- }
-
- /**
- * This method gets the members for a given tag and returns them.
- * During the execution of this method, the instance variable children
- * will be used to contain the children. However, the variable is reset
- * and the result returned. Thus, instances of RemoteFolder do not
- * persist the children. Subclasses (namely RemoteFolderTree) may
- * persist the children.
- */
- protected ICVSRemoteResource[] getMembers(CVSTag tag, IProgressMonitor monitor) throws CVSException {
- // Fetch the children
- RemoteFolderMemberFetcher fetcher = new RemoteFolderMemberFetcher(this, tag);
- fetcher.fetchMembers(Policy.monitorFor(monitor));
- // children is assigned in the InternalRemoteFolderMembersFetcher
- return children;
- }
-
- /**
- * @see ICVSFolder#members(int)
- */
- public ICVSResource[] members(int flags) throws CVSException {
- final List result = new ArrayList();
- ICVSRemoteResource[] resources = getChildren();
- if (children == null) {
- return new ICVSResource[0];
- }
- // RemoteFolders never have phantom members
- if ((flags & EXISTING_MEMBERS) == 0 && (flags & PHANTOM_MEMBERS) == PHANTOM_MEMBERS) {
- return new ICVSResource[0];
- }
- boolean includeFiles = (((flags & FILE_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
- boolean includeFolders = (((flags & FOLDER_MEMBERS) != 0) || ((flags & (FILE_MEMBERS | FOLDER_MEMBERS)) == 0));
- boolean includeManaged = (((flags & MANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0));
- boolean includeUnmanaged = (((flags & UNMANAGED_MEMBERS) != 0) || ((flags & (MANAGED_MEMBERS | UNMANAGED_MEMBERS | IGNORED_MEMBERS)) == 0));
- boolean includeIgnored = ((flags & IGNORED_MEMBERS) != 0);
- for (int i = 0; i < resources.length; i++) {
- ICVSResource cvsResource = resources[i];
- if ((includeFiles && ( ! cvsResource.isFolder()))
- || (includeFolders && (cvsResource.isFolder()))) {
- boolean isManaged = cvsResource.isManaged();
- boolean isIgnored = cvsResource.isIgnored();
- if ((isManaged && includeManaged)|| (isIgnored && includeIgnored)
- || ( ! isManaged && ! isIgnored && includeUnmanaged)) {
- result.add(cvsResource);
- }
-
- }
- }
- return (ICVSResource[]) result.toArray(new ICVSResource[result.size()]);
- }
-
- /**
- * @see ICVSFolder#getFolder(String)
- */
- public ICVSFolder getFolder(String name) throws CVSException {
- if (name.equals(Session.CURRENT_LOCAL_FOLDER) || name.equals(Session.CURRENT_LOCAL_FOLDER + Session.SERVER_SEPARATOR))
- return this;
- ICVSResource child = getChild(name);
- if (child.isFolder())
- return (ICVSFolder)child;
- IStatus status = new CVSStatus(IStatus.ERROR, CHILD_DOES_NOT_EXIST, NLS.bind(CVSMessages.RemoteFolder_invalidChild, new String[] { name, getName() }),child.getIResource());
- throw new CVSException(status);
- }
-
- /**
- * @see ICVSFolder#getFile(String)
- */
- public ICVSFile getFile(String name) throws CVSException {
- ICVSResource child = getChild(name);
- if (!child.isFolder())
- return (ICVSFile)child;
- IStatus status = new CVSStatus(IStatus.ERROR, CHILD_DOES_NOT_EXIST, NLS.bind(CVSMessages.RemoteFolder_invalidChild, new String[] { name, getName() }),child.getIResource());
- throw new CVSException(status);
- }
-
- public LocalOption[] getLocalOptions() {
- return Command.NO_LOCAL_OPTIONS;
- }
-
- public String getRepositoryRelativePath() {
- // The REPOSITORY property of the folder info is the repository relative path
- return getFolderSyncInfo().getRepository();
- }
-
- /**
- * @see ICVSResource#getRelativePath(ICVSFolder)
- */
- public String getRelativePath(ICVSFolder ancestor) throws CVSException {
- // Check to see if the receiver is the ancestor
- if (ancestor == this) return Session.CURRENT_LOCAL_FOLDER;
- // Otherwise, we need a parent to continue
- if (parent == null) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, NLS.bind(CVSMessages.RemoteFolder_invalidChild, new String[] { getName(), ancestor.getName() }),this);
- throw new CVSException(status);
- }
- return super.getRelativePath(ancestor);
- }
-
- public ICVSRepositoryLocation getRepository() {
- return repository;
- }
-
- /**
- * @see ICVSRemoteFolder#isExpandable()
- */
- public boolean isExpandable() {
- return true;
- }
-
- /**
- * @see ICVSResource#isFolder()
- */
- public boolean isFolder() {
- return true;
- }
-
- /**
- * @see ICVSFolder#childExists(String)
- */
- public boolean childExists(String path) {
- try {
- return getChild(path) != null;
- } catch (CVSException e) {
- return false;
- }
- }
-
- /**
- * @see ICVSFolder#getChild(String)
- *
- * This getChild is geared to work with the Command hierarchy. Therefore it only returns
- * children that were previously fetched by a call to getMembers(). If the request child
- * does not exist, an exception is thrown.
- */
- public ICVSResource getChild(String path) throws CVSException {
- if (path.equals(Session.CURRENT_LOCAL_FOLDER) || path.length() == 0)
- return this;
- if (path.indexOf(Session.SERVER_SEPARATOR) != -1) {
- IPath p = new Path(null, path);
- try {
- return ((RemoteFolder)getChild(p.segment(0))).getChild(p.removeFirstSegments(1).toString());
- } catch (CVSException e) {
- // regenerate the exception to give as much info as possible
- IStatus status = new CVSStatus(IStatus.ERROR, CHILD_DOES_NOT_EXIST, NLS.bind(CVSMessages.RemoteFolder_invalidChild, new String[] { path, getName() }),e,repository);
- throw new CVSException(status);
- }
- } else {
- ICVSRemoteResource[] children = getChildren();
- if (children == null){
- IStatus status = new CVSStatus(IStatus.ERROR, CHILD_DOES_NOT_EXIST, NLS.bind(CVSMessages.RemoteFolder_invalidChild, new String[] { path, getName() }),repository);
- throw new CVSException(status);
- }
- for (int i=0;i<children.length;i++) {
- if (children[i].getName().equals(path))
- return children[i];
- }
- }
- IStatus status = new CVSStatus(IStatus.ERROR, CHILD_DOES_NOT_EXIST, NLS.bind(CVSMessages.RemoteFolder_invalidChild, new String[] { path, getName() }),repository);
- throw new CVSException(status);
- }
-
- /**
- * @see ICVSFolder#mkdir()
- */
- public void mkdir() throws CVSException {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSMessages.RemoteResource_invalidOperation);
- throw new CVSException(status);
- }
-
- /**
- * @see ICVSFolder#flush(boolean)
- */
- public void flush(boolean deep) {
- }
-
- /**
- * @see ICVSFolder#getFolderInfo()
- */
- public FolderSyncInfo getFolderSyncInfo() {
- return folderInfo;
- }
-
- /**
- * @see ICVSResource#getRemoteLocation(ICVSFolder)
- */
- public String getRemoteLocation(ICVSFolder stopSearching) throws CVSException {
- if (folderInfo == null) {
- return Util.appendPath(parent.getRemoteLocation(stopSearching), getName());
- }
- return folderInfo.getRemoteLocation();
- }
-
- /**
- * @see ICVSFolder#isCVSFolder()
- */
- public boolean isCVSFolder() {
- return folderInfo != null;
- }
-
- /**
- * @see ICVSFolder#acceptChildren(ICVSResourceVisitor)
- */
- public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSMessages.RemoteResource_invalidOperation);
- throw new CVSException(status);
- }
-
- /*
- * @see IRemoteResource#isContainer()
- */
- public boolean isContainer() {
- return true;
- }
-
- /*
- * @see IRemoteResource#members(IProgressMonitor)
- */
- public ICVSRemoteResource[] members(IProgressMonitor progress) throws TeamException {
- return getMembers(progress);
- }
-
- /*
- * Answers the immediate cached children of this remote folder or null if the remote folder
- * handle has not yet queried the server for the its children.
- */
- public ICVSRemoteResource[] getChildren() {
- return children;
- }
- /*
- * This allows subclass to set the children
- */
- protected void setChildren(ICVSRemoteResource[] children) {
- this.children = children;
- }
- /*
- * @see ICVSRemoteFolder#setTag(String)
- */
- public void setTag(CVSTag tag) {
- MutableFolderSyncInfo newInfo = folderInfo.cloneMutable();
- newInfo.setTag(tag);
- setFolderSyncInfo(newInfo);
- }
-
- /*
- * @see ICVSRemoteFolder#getTag()
- */
- public CVSTag getTag() {
- if (folderInfo == null) return null;
- return folderInfo.getTag();
- }
- /*
- * @see ICVSFolder#setFolderInfo(FolderSyncInfo)
- */
- public void setFolderSyncInfo(FolderSyncInfo folderInfo) {
- this.folderInfo = folderInfo.asImmutable();
- }
-
- /*
- * @see ICVSFolder#run(ICVSRunnable, IProgressMonitor)
- */
- public void run(ICVSRunnable job, IProgressMonitor monitor) throws CVSException {
- job.run(monitor);
- }
-
- /*
- * @see ICVSFolder#tag(CVSTag, LocalOption[], IProgressMonitor)
- */
- public IStatus tag(final CVSTag tag, final LocalOption[] localOptions, IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- Session session = new Session(getRepository(), this, true /* output to console */);
- session.open(Policy.subMonitorFor(monitor, 10), true /* open for modification */);
- try {
- return Command.RTAG.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- localOptions,
- folderInfo.getTag(),
- tag,
- new ICVSRemoteResource[] { RemoteFolder.this },
- Policy.subMonitorFor(monitor, 90));
- } finally {
- session.close();
- }
- }
-
- /**
- * @see ICVSFolder#fetchChildren(IProgressMonitor)
- */
- public ICVSResource[] fetchChildren(IProgressMonitor monitor) throws CVSException {
- try {
- return getMembers(monitor);
- } catch(TeamException e) {
- throw new CVSException(e.getStatus());
- }
- }
-
- public boolean equals(Object target) {
- if ( ! super.equals(target)) return false;
- RemoteFolder folder = (RemoteFolder)target;
- // A simple folder is never equal to a defined module
- if (folder.isDefinedModule() != isDefinedModule()) return false;
- CVSTag tag1 = getTag();
- CVSTag tag2 = folder.getTag();
- if (tag1 == null) tag1 = CVSTag.DEFAULT;
- if (tag2 == null) tag2 = CVSTag.DEFAULT;
- return tag1.equals(tag2);
- }
-
- /**
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- CVSTag tag = getTag();
- if (tag == null) tag = CVSTag.DEFAULT;
- return super.hashCode() | tag.getName().hashCode();
- }
-
- /*
- * The given root must be an ancestor of the receiver (or the receiver)
- * and the path of the receiver must be a prefix of the provided path.
- */
- protected IPath getRelativePathFromRootRelativePath(ICVSFolder root, IPath path) throws CVSException {
- // If the root is the receiver, then the path is already relative to the receiver
- if (root == this) {
- return path;
- }
- Assert.isTrue( ! path.isEmpty());
- return getRelativePathFromRootRelativePath((ICVSFolder)root.getChild(path.segment(0)), path.removeFirstSegments(1));
- }
-
- /**
- * @see ICVSRemoteFolder#forTag(CVSTag)
- */
- public ICVSRemoteResource forTag(ICVSRemoteFolder parent, CVSTag tagName) {
- return new RemoteFolder((RemoteFolder)parent, getName(), repository, folderInfo.getRepository(), tagName, folderInfo.getIsStatic());
- }
-
- /**
- * @see ICVSRemoteFolder#forTag(CVSTag)
- */
- public ICVSRemoteResource forTag(CVSTag tagName) {
- return (ICVSRemoteFolder)forTag(null, tagName);
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder#isDefinedModule()
- */
- public boolean isDefinedModule() {
- return false;
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.resources.RemoteResource#getSyncInfo()
- */
- public ResourceSyncInfo getSyncInfo() {
- return new ResourceSyncInfo(getName());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.resources.RemoteResource#getSyncBytes()
- */
- public byte[] getSyncBytes() {
- try {
- return folderInfo.getBytes();
- } catch (CVSException e) {
- // This shouldn't even happen
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.sync.IRemoteResource#getContentIdentifier()
- */
- public String getContentIdentifier() {
- return getTag().getName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.ICVSResource#isManaged()
- */
- public boolean isManaged() {
- return super.isManaged() && isCVSFolder();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.synchronize.ResourceVariant#fetchContents(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void fetchContents(IProgressMonitor monitor) throws TeamException {
- // This should not get called for folders
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderMemberFetcher.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderMemberFetcher.java
deleted file mode 100644
index 320330596..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderMemberFetcher.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.*;
-import org.eclipse.team.internal.ccvs.core.client.listeners.*;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * Fetch the children for the given parent folder. When fetchMembers is invoked,
- * the children of the folder will be fecthced from the server and assigned to
- * the children of the parent folder.
- */
-public class RemoteFolderMemberFetcher implements IUpdateMessageListener, IStatusListener {
-
- private final RemoteFolder parentFolder;
- private CVSTag tag;
-
- List folders = new ArrayList(); // RemoteFolder
- List files = new ArrayList(); // RemoteFile
- boolean exists = true;
- List exceptions = new ArrayList(); // CVSException
-
- protected RemoteFolderMemberFetcher(RemoteFolder parentFolder, CVSTag tag) {
- this.tag = tag;
- this.parentFolder = parentFolder;
- }
-
- /**
- * Fetch the members for a given tag and returns them.
- * During the execution of this method, the instance variable children
- * will be used to contain the children. However, the variable is reset
- * and the result returned. Thus, instances of RemoteFolder do not
- * persist the children. Subclasses (namely RemoteFolderTree) may
- * persist the children.
- */
- public void fetchMembers(IProgressMonitor monitor) throws CVSException {
- fetchMembers(monitor, tag);
- }
- public void fetchMembers(IProgressMonitor monitor, CVSTag tag) throws CVSException {
- final IProgressMonitor progress = Policy.monitorFor(monitor);
- progress.beginTask(CVSMessages.RemoteFolder_getMembers, 100);
- try {
- // Update the parent folder children so there are no children
- updateParentFolderChildren();
- // Perform an update to retrieve the child files and folders
- IStatus status = performUpdate(Policy.subMonitorFor(progress, 50), tag);
- // Update the parent folder with the new children
- updateParentFolderChildren();
- Policy.checkCanceled(monitor);
-
- // Handle any errors that were identified by the listener
- performErrorCheck(status, CVSMessages.RemoteFolder_errorFetchingMembers);
-
- // Get the revision numbers for the files
- ICVSFile[] remoteFiles = getFiles();
- if (remoteFiles.length > 0) {
- updateFileRevisions(remoteFiles, Policy.subMonitorFor(progress, 50));
- } else {
- progress.worked(50);
- }
- } catch (CVSServerException e) {
- if ( ! e.isNoTagException() && e.containsErrors())
- throw e;
- if (tag == null)
- throw e;
- // we now know that this is an exception caused by a cvs bug.
- // if the folder has no files in it (just subfolders) cvs does not respond with the subfolders...
- // workaround: retry the request with no tag to get the directory names (if any)
- Policy.checkCanceled(progress);
- fetchMembers(Policy.subMonitorFor(progress, 50), null);
- } finally {
- progress.done();
- }
- }
-
- protected IStatus performUpdate(IProgressMonitor progress, CVSTag tag) throws CVSException {
- progress.beginTask(null, 100);
- Session session = new Session(parentFolder.getRepository(), parentFolder, false /* output to console */);
- session.open(Policy.subMonitorFor(progress, 10), false /* read-only */);
- try {
- // Build the local options
- final List localOptions = new ArrayList();
- localOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
- if (tag != null) localOptions.add(Update.makeTagOption(tag));
-
- return Command.UPDATE.execute(
- session,
- new GlobalOption[] { Command.DO_NOT_CHANGE },
- (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]),
- new ICVSResource[] { parentFolder },
- new UpdateListener(this),
- Policy.subMonitorFor(progress, 90));
- } finally {
- session.close();
- }
- }
-
- protected void updateFileRevisions(final ICVSFile[] files, IProgressMonitor monitor) throws CVSException {
-
- // Perform a "cvs status..." with a listener
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
- try {
- CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
- Session session = new Session(parentFolder.getRepository(), parentFolder, false /* output to console */);
- session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */);
- try {
- IStatus status = Command.STATUS.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- files,
- new StatusListener(this),
- Policy.subMonitorFor(monitor, 90));
- performErrorCheck(status, CVSMessages.RemoteFolder_errorFetchingRevisions);
- // TODO: Ensure all files have a revision?
- } finally {
- session.close();
- }
- } finally {
- CVSProviderPlugin.getPlugin().setQuietness(quietness);
- }
- }
-
- private void performErrorCheck(IStatus status, String errorTitle) throws CVSException {
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- // Only throw the exception if no files or folders were found
- if (folders.size() + files.size() == 0) {
- throw new CVSServerException(status);
- } else {
- CVSProviderPlugin.log(new CVSServerException(status));
- }
- }
- if (!exists) {
- IStatus notExistStatus = new CVSStatus(IStatus.ERROR, CVSStatus.DOES_NOT_EXIST, NLS.bind(CVSMessages.RemoteFolder_doesNotExist, new String[] { this.parentFolder.getRepositoryRelativePath() }), parentFolder);
- throw new CVSException(notExistStatus);
- }
-
- // Report any internal exceptions that occured fetching the members
- if ( ! exceptions.isEmpty()) {
- if (exceptions.size() == 1) {
- throw (CVSException)exceptions.get(0);
- } else {
- MultiStatus multi = new MultiStatus(CVSProviderPlugin.ID, 0, errorTitle, null);
- for (int i = 0; i < exceptions.size(); i++) {
- multi.merge(((CVSException)exceptions.get(i)).getStatus());
- }
- throw new CVSException(multi);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.IUpdateMessageListener#directoryInformation(org.eclipse.team.internal.ccvs.core.ICVSFolder, java.lang.String, boolean)
- */
- public void directoryInformation(ICVSFolder commandRoot, String stringPath, boolean newDirectory) {
- try {
- IPath path = this.parentFolder.getRelativePathFromRootRelativePath(commandRoot, new Path(null, stringPath));
- if (path.segmentCount() == 1) {
- String pathName = path.lastSegment();
- if (!pathName.equals(".")) { //$NON-NLS-1$
- recordFolder(path.lastSegment());
- }
- }
- } catch (CVSException e) {
- exceptions.add(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.IUpdateMessageListener#directoryDoesNotExist(org.eclipse.team.internal.ccvs.core.ICVSFolder, java.lang.String)
- */
- public void directoryDoesNotExist(ICVSFolder parent, String stringPath) {
- try {
- IPath path = this.parentFolder.getRelativePathFromRootRelativePath(parent, new Path(null, stringPath));
- if (path.isEmpty()) {
- parentDoesNotExist();
- }
- } catch (CVSException e) {
- exceptions.add(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.IUpdateMessageListener#fileInformation(int, org.eclipse.team.internal.ccvs.core.ICVSFolder, java.lang.String)
- */
- public void fileInformation(int type, ICVSFolder parent, String filename) {
- try {
- IPath filePath = new Path(null, filename);
- filePath = this.parentFolder.getRelativePathFromRootRelativePath(parent, filePath);
- if( filePath.segmentCount() == 1 ) {
- String properFilename = filePath.lastSegment();
- recordFile(properFilename);
- }
- } catch (CVSException e) {
- exceptions.add(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.IUpdateMessageListener#fileDoesNotExist(org.eclipse.team.internal.ccvs.core.ICVSFolder, java.lang.String)
- */
- public void fileDoesNotExist(ICVSFolder parent, String filename) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.IStatusListener#fileStatus(org.eclipse.team.internal.ccvs.core.ICVSFolder, java.lang.String, java.lang.String)
- */
- public void fileStatus(ICVSFolder commandRoot, String path, String remoteRevision) {
- if (remoteRevision == IStatusListener.FOLDER_REVISION)
- // Ignore any folders
- return;
- try {
- ((RemoteFile)parentFolder.getChild(Util.getLastSegment(path))).setRevision(remoteRevision);
- } catch (CVSException e) {
- exceptions.add(e);
- }
- }
-
- /**
- * This method is invoked for each child folder as the reponses are being recieved from
- * the server. Default behavior is to record the folder for later retrieval using <code>getChilren()</code>.
- * Subclasses may override but should invoke the inherited method to ensure the folder gets recorded.
- * @param name the name of the child folder
- */
- protected RemoteFolder recordFolder(String name) {
- RemoteFolder folder = new RemoteFolder(
- parentFolder,
- parentFolder.getRepository(),
- Util.appendPath(parentFolder.getRepositoryRelativePath(), name),
- tag);
- folders.add(folder);
- return folder;
- }
-
- /**
- * This method is invoked for each child file as the reponses are being recieved from
- * the server. Default behavior is to record the file for later retrieval using <code>getChildren()</code>.
- * Subclasses may override but should invoke the inherited method to ensure the file gets recorded.
- * This is important because the file revisions for any files are fetched subsequent to the fecthing
- * of the children.
- * @param name the name of the child folder
- */
- protected RemoteFile recordFile(String name) {
- RemoteFile file = new RemoteFile(
- parentFolder,
- Update.STATE_NONE,
- name,
- null, /* revision unknown */
- null, /* keyword mode unknown */
- tag);
- files.add(file);
- return file;
- }
-
- /**
- * This method is invoked to indicate that the parent beig queried for children
- * does not exist. Subclasses may override to get early notification of this but
- * should still invoke the inherited method.
- */
- protected void parentDoesNotExist() {
- exists = false;
- }
-
- /**
- * Update the parent folder such that it's children are the
- * children that have been fecthed by the reciever.
- */
- protected void updateParentFolderChildren() {
- parentFolder.setChildren(getFetchedChildren());
- }
-
- /**
- * Return the child files fetched from the server.
- * @return
- */
- protected ICVSFile[] getFiles() {
- return (ICVSFile[]) files.toArray(new ICVSFile[files.size()]);
- }
-
- /**
- * Return an array of all fecthed children.
- * @return
- */
- public ICVSRemoteResource[] getFetchedChildren() {
- ICVSRemoteResource[] resources = new ICVSRemoteResource[folders.size() + files.size()];
- int count = 0;
- for (Iterator iter = folders.iterator(); iter.hasNext();) {
- ICVSRemoteResource resource = (ICVSRemoteResource) iter.next();
- resources[count++] = resource;
- }
- for (Iterator iter = files.iterator(); iter.hasNext();) {
- ICVSRemoteResource resource = (ICVSRemoteResource) iter.next();
- resources[count++] = resource;
- }
- return resources;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderSandbox.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderSandbox.java
deleted file mode 100644
index 37799ed0a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderSandbox.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-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.connection.CVSRepositoryLocation;
-
-/**
- * This specialized remote folder supports the creation of a cached sandbox.
- */
-public class RemoteFolderSandbox extends RemoteFolder {
-
- public RemoteFolderSandbox(RemoteFolder parent, ICVSRepositoryLocation repository, String repositoryRelativePath, CVSTag tag) {
- super(parent, repository, repositoryRelativePath, tag);
- setChildren(new ICVSRemoteResource[0]);
- }
-
- public RemoteFolderSandbox(RemoteFolder parent, String name, CVSRepositoryLocation repository, String repositoryRelativePath, CVSEntryLineTag tag, boolean isStatic) {
- super(parent, name, repository, repositoryRelativePath, tag, isStatic);
- setChildren(new ICVSRemoteResource[0]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.ICVSFolder#getFile(java.lang.String)
- */
- public ICVSFile getFile(String name) throws CVSException {
- try {
- return super.getFile(name);
- } catch (CVSException e) {
- if (e.getStatus().getCode() == CHILD_DOES_NOT_EXIST) {
- IPath path = new Path(null, name);
- String fileName = path.lastSegment();
- RemoteFolderSandbox parent = getParentFolder(path);
- RemoteFile file = new RemoteFile(parent, Update.STATE_NONE, fileName, null, null, getTag());
- parent.addChild(file);
- return file;
- }
- throw e;
- }
- }
-
- private void addChild(RemoteResource resource) {
- ICVSRemoteResource[] children = getChildren();
- ICVSRemoteResource[] newChildren = new ICVSRemoteResource[children.length + 1];
- System.arraycopy(children, 0, newChildren, 0, children.length);
- newChildren[children.length] = resource;
- setChildren(newChildren);
- }
-
- private RemoteFolderSandbox getParentFolder(IPath path) throws CVSException {
- IPath parentPath = path.removeLastSegments(1);
- String parentString;
- if (parentPath.isEmpty()) {
- parentString = Session.CURRENT_LOCAL_FOLDER;
- } else {
- parentString = path.removeLastSegments(1).toString();
- }
- RemoteFolderSandbox parent = (RemoteFolderSandbox)getFolder(parentString);
- return parent;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.ICVSFolder#getFolder(java.lang.String)
- */
- public ICVSFolder getFolder(String name) throws CVSException {
- try {
- return super.getFolder(name);
- } catch (CVSException e) {
- if (e.getStatus().getCode() == CHILD_DOES_NOT_EXIST) {
- IPath path = new Path(null, name);
- RemoteFolderSandbox parent = getParentFolder(path);
- String repoPath = new Path(null, parent.getRepositoryRelativePath()).append(path.lastSegment()).removeTrailingSeparator().toString();
- RemoteFolderSandbox folder = new RemoteFolderSandbox(parent, getRepository(), repoPath, getTag());
- parent.addChild(folder);
- return folder;
- }
- throw e;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.resources.RemoteFolder#getMembers(org.eclipse.core.runtime.IProgressMonitor)
- */
- public ICVSRemoteResource[] getMembers(IProgressMonitor monitor) throws TeamException {
- return getChildren();
- }
-
- /*
- * @see ICVSFolder#acceptChildren(ICVSResourceVisitor)
- */
- public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException {
- ICVSRemoteResource[] children = getChildren();
- if (children == null) return;
- for (int i=0; i<children.length; i++) {
- ((ICVSResource)children[i]).accept(visitor);
- }
- }
-
- public void remove(RemoteFile file) {
- ICVSRemoteResource[] children = getChildren();
- ArrayList results = new ArrayList();
- for (int i = 0; i < children.length; i++) {
- if (children[i] != file){
- results.add(children[i]);
- }
- }
- setChildren((ICVSRemoteResource[]) results.toArray(new ICVSRemoteResource[results.size()]));
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java
deleted file mode 100644
index 95ca71be3..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.KnownRepositories;
-
-/**
- * Whereas the RemoteFolder class provides access to a remote hierarchy using
- * lazy retrieval via <code>getMembers()</code>, the RemoteFolderTree will force
- * a recursive retrieval of the remote hierarchy in one round trip.
- */
-public class RemoteFolderTree extends RemoteFolder {
-
- public static RemoteFolderTree fromBytes(RemoteFolderTree parent, IResource local, byte[] bytes) throws CVSException {
- Assert.isNotNull(bytes);
- Assert.isTrue(local.getType() != IResource.FILE);
- FolderSyncInfo syncInfo = FolderSyncInfo.getFolderSyncInfo(bytes);
- return new RemoteFolderTree(parent, local.getName(), KnownRepositories.getInstance().getRepository(syncInfo.getRoot()), syncInfo.getRepository(), syncInfo.getTag(), syncInfo.getIsStatic());
- }
-
- public RemoteFolderTree(RemoteFolder parent, ICVSRepositoryLocation repository, String repositoryRelativePath, CVSTag tag) {
- super(parent, repository, repositoryRelativePath, tag);
- }
-
- public RemoteFolderTree(RemoteFolder parent, String name, ICVSRepositoryLocation repository, String repositoryRelativePath, CVSTag tag) {
- this(parent, name, repository, repositoryRelativePath, tag, false);
- }
-
- public RemoteFolderTree(RemoteFolder parent, String name, ICVSRepositoryLocation repository, String repositoryRelativePath, CVSTag tag, boolean isStatic) {
- super(parent, name, repository, repositoryRelativePath, tag, isStatic);
- }
-
- /*
- * Override of inherited method which persists the children
- */
- public ICVSRemoteResource[] getMembers(CVSTag tagName, IProgressMonitor monitor) throws CVSException {
- if (getChildren() == null)
- setChildren(super.getMembers(tagName, monitor));
- return getChildren();
- }
-
- /*
- * This method is public to allow access by the RemoteFolderTreeBuilder utility class.
- * No other external classes should use this method.
- */
- public void setChildren(ICVSRemoteResource[] children) {
- super.setChildren(children);
- }
-
- /*
- * @see ICVSFolder#acceptChildren(ICVSResourceVisitor)
- */
- public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException {
- ICVSRemoteResource[] children = getChildren();
- if (children == null) return;
- for (int i=0; i<children.length; i++) {
- ((ICVSResource)children[i]).accept(visitor);
- }
- }
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java
deleted file mode 100644
index a2735beca..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java
+++ /dev/null
@@ -1,822 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-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.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.*;
-import org.eclipse.team.internal.ccvs.core.client.listeners.*;
-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;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/*
- * This class is responsible for building a remote tree that shows the repository
- * state of a locally loaded folder tree.
- *
- * It is used as follows
- *
- * RemoteFolderTreeBuilder.buildRemoteTree(CVSRepositoryLocation, IManagedFolder, String, IProgressMonitor);
- *
- * The provider IManagedFolder can be a local resource or a RemoteFolderTree that
- * that was previously built.
- */
-public class RemoteFolderTreeBuilder {
-
- private static final int MAX_REVISION_FETCHES_PER_CONNECTION = 1024;
-
- private Map fileDeltas;
- private List changedFiles;
- private Map remoteFolderTable;
-
- private ICVSFolder root;
- private RemoteFolderTree remoteRoot;
- private CVSRepositoryLocation repository;
-
- private CVSTag tag;
-
- private LocalOption[] updateLocalOptions;
-
- private boolean rootDoesNotExist = 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();
-
- private boolean newFolderExist = false;
-
- 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;
- }
- }
-
-
- /* package */ 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();
- 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 RemoteFolder 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);
- subProgress.subTask(NLS.bind(CVSMessages.RemoteFolderTreeBuilder_buildingBase, new String[] { root.getName() }));
- 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(new ICVSResource[] { root }, monitor);
- }
- public static RemoteFile buildRemoteTree(CVSRepositoryLocation repository, ICVSFile file, CVSTag tag, IProgressMonitor monitor) throws CVSException {
- RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, file.getParent(), tag);
- return builder.buildTree(file, monitor);
- }
-
- /* package */ RemoteFolderTree buildTree(ICVSResource[] resources, IProgressMonitor monitor) throws CVSException {
-
- // Make sure that the cvs commands are not quiet during this operations
- QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
- try {
- CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
-
- monitor.beginTask(null, 100);
-
- // 1st Connection: Use local state to determine delta with server
- if (!fetchDelta(resources, Policy.subMonitorFor(monitor, 75))) {
- return null;
- }
-
- // 2nd Connection: Build remote tree from above delta using 2nd connection to fetch unknown directories
- // NOTE: Multiple commands may be issued over this connection.
- fetchNewDirectories(Policy.subMonitorFor(monitor, 10));
-
- // 3rd+ Connection: Used to fetch file status in groups of 1024
- fetchFileRevisions(Policy.subMonitorFor(monitor, 15));
-
- return remoteRoot;
-
- } finally {
- CVSProviderPlugin.getPlugin().setQuietness(quietness);
- monitor.done();
- }
- }
-
- private boolean fetchDelta(ICVSResource[] resources, IProgressMonitor monitor) throws CVSException {
-
- // Get the arguments from the files
- ArrayList arguments = new ArrayList();
- for (int i = 0; i < resources.length; i++) {
- ICVSResource resource = resources[i];
- arguments.add(resource.getRelativePath(root));
- }
-
- // Use local state to determine delta with server
- monitor.beginTask(null, 100);
- Policy.checkCanceled(monitor);
- Session session = new Session(repository, root, false);
- session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */);
- try {
- Policy.checkCanceled(monitor);
- fetchDelta(session, (String[]) arguments.toArray(new String[arguments.size()]), Policy.subMonitorFor(monitor, 90));
- if (rootDoesNotExist) {
- // We cannot handle the case where a project (i.e. the top-most CVS folder)
- // has been deleted directly on the sever (i.e. deleted using rm -rf)
- if (root.isCVSFolder() && ! root.isManaged()) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, NLS.bind(CVSMessages.RemoteFolderTreeBuild_folderDeletedFromServer, new String[] { root.getFolderSyncInfo().getRepository() }),root);
- throw new CVSException(status);
- } else {
- return false;
- }
- }
- } finally {
- session.close();
- monitor.done();
- }
- return true;
- }
-
- private void fetchNewDirectories(IProgressMonitor monitor) throws CVSException {
- // Build remote tree from the fetched delta using a new connection to fetch unknown directories
- // NOTE: Multiple commands may be issued over this connection.
- monitor.beginTask(null, 100);
- Session session;
- FolderSyncInfo folderSyncInfo = root.getFolderSyncInfo();
- if (folderSyncInfo == null) {
- // We've lost the mapping in the local workspace.
- // This could be due to the project being deleted.
- if (root.exists()) {
- IResource resource = root.getIResource();
- String path;
- if (resource == null) {
- path = root.getName();
- } else {
- path = resource.getFullPath().toString();
- }
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, NLS.bind(CVSMessages.RemoteFolderTreeBuilder_0, new String[] { path }), root);
- throw new CVSException(status);
- } else {
- // Just return. The remote tree will be null
- return;
- }
- }
- remoteRoot =
- new RemoteFolderTree(null, root.getName(), repository,
- folderSyncInfo.getRepository(),
- tagForRemoteFolder(root, tag));
- if (newFolderExist) {
- // New folders will require a connection for fetching their members
- session = new Session(repository, remoteRoot, false);
- session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */);
- } else {
- session = null;
- }
- try {
- // Set up an infinite progress monitor for the recursive build
- IProgressMonitor subProgress = Policy.infiniteSubMonitorFor(monitor, 90);
- subProgress.beginTask(null, 512);
- // Build the remote tree
- buildRemoteTree(session, root, remoteRoot, "", subProgress); //$NON-NLS-1$
- } finally {
- if (session != null) {
- session.close();
- }
- monitor.done();
- }
- }
-
- private void fetchFileRevisions(IProgressMonitor monitor) throws CVSException {
- // 3rd+ Connection: Used to fetch file status in groups of 1024
- if (remoteRoot != null && !changedFiles.isEmpty()) {
- String[] allChangedFiles = (String[])changedFiles.toArray(new String[changedFiles.size()]);
- int iterations = (allChangedFiles.length / MAX_REVISION_FETCHES_PER_CONNECTION)
- + (allChangedFiles.length % MAX_REVISION_FETCHES_PER_CONNECTION == 0 ? 0 : 1);
- for (int i = 0; i < iterations ; i++) {
- int length = Math.min(MAX_REVISION_FETCHES_PER_CONNECTION,
- allChangedFiles.length - (MAX_REVISION_FETCHES_PER_CONNECTION * i));
- String buffer[] = new String[length];
- System.arraycopy(allChangedFiles, i * MAX_REVISION_FETCHES_PER_CONNECTION, buffer, 0, length);
- Session session = new Session(repository, remoteRoot, false);
- session.open(Policy.subMonitorFor(monitor, 1), false /* read-only */);
- try {
- fetchFileRevisions(session, buffer, Policy.subMonitorFor(monitor, 2));
- } finally {
- session.close();
- }
- }
- }
- }
-
- /* package */ RemoteFile buildTree(ICVSFile file, IProgressMonitor monitor) throws CVSException {
- QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
- try {
- CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
-
- monitor.beginTask(null, 100);
-
- // Query the server to see if there is a delta available
- Policy.checkCanceled(monitor);
- Session session = new Session(repository, root, false);
- session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */);
- try {
- Policy.checkCanceled(monitor);
- fetchDelta(session, new String[] { file.getName() }, Policy.subMonitorFor(monitor, 50));
- if (rootDoesNotExist) {
- return null;
- }
- } finally {
- session.close();
- }
- // Create a parent for the remote resource
- remoteRoot =
- new RemoteFolderTree(null, root.getName(), repository,
- root.getFolderSyncInfo().getRepository(),
- tagForRemoteFolder(root, tag));
- // Create the remote resource (using the delta if there is one)
- RemoteFile remoteFile;
- Map deltas = (Map)fileDeltas.get(""); //$NON-NLS-1$
- if (deltas == null || deltas.isEmpty()) {
- // If the file is an addition, return null as the remote
- // Note: If there was a conflicting addition, the delta would not be empty
- byte[] syncBytes = file.getSyncBytes();
- if ( syncBytes == null || ResourceSyncInfo.isAddition(syncBytes)) {
- return null;
- }
- remoteFile = new RemoteFile(remoteRoot, syncBytes);
- } else {
- DeltaNode d = (DeltaNode)deltas.get(file.getName());
- if (d.getRevision() == DELETED) {
- return null;
- }
- remoteFile = new RemoteFile(remoteRoot,
- d.getSyncState(),
- file.getName(),
- null, /* the revision will be retrieved from the server */
- getKeywordMode(file), /* use the same keyword mode a the local file */
- tagForRemoteFolder(remoteRoot, tag));
- }
- // Add the resource to its parent
- remoteRoot.setChildren(new ICVSRemoteResource[] {remoteFile});
- // If there was a delta, fetch the new revision
- if (!changedFiles.isEmpty()) {
- // Add the remote folder to the remote folder lookup table (used to update file revisions)
- recordRemoteFolder(remoteRoot);
- session = new Session(repository, remoteRoot, false);
- session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */);
- try {
- fetchFileRevisions(session, (String[])changedFiles.toArray(new String[changedFiles.size()]), Policy.subMonitorFor(monitor, 20));
- } finally {
- session.close();
- }
- }
- return remoteFile;
-
- } finally {
- CVSProviderPlugin.getPlugin().setQuietness(quietness);
- monitor.done();
- }
- }
-
- private Command.KSubstOption getKeywordMode(ICVSFile file) throws CVSException {
- if (file == null) return null;
- byte[] syncBytes = file.getSyncBytes();
- if (syncBytes == null) return null;
- return ResourceSyncInfo.getKeywordMode(syncBytes);
- }
-
- /*
- * 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
- */
- RemoteFolder buildBaseTree(RemoteFolder parent, ICVSFolder local, IProgressMonitor monitor) throws CVSException {
-
- Policy.checkCanceled(monitor);
-
- // Create a remote folder tree corresponding to the local resource
- FolderSyncInfo folderSyncInfo = local.getFolderSyncInfo();
- if (folderSyncInfo == null) return null;
- RemoteFolder remote = createRemoteFolder(local, parent, folderSyncInfo);
-
- // Create a List to contain the created children
- List children = new ArrayList();
-
- // Build the child folders corresponding to local folders base
- ICVSResource[] folders = local.members(ICVSFolder.FOLDER_MEMBERS);
- for (int i=0;i<folders.length;i++) {
- ICVSFolder folder = (ICVSFolder)folders[i];
- if (folder.isManaged() && folder.isCVSFolder()) {
- monitor.worked(1);
- RemoteFolder tree = buildBaseTree(remote, folder, monitor);
- if (tree != null)
- children.add(tree);
- }
- }
-
- // Build the child files corresponding to local files base
- ICVSResource[] files = local.members(ICVSFolder.FILE_MEMBERS);
- for (int i=0;i<files.length;i++) {
- ICVSFile file = (ICVSFile)files[i];
- byte[] syncBytes = file.getSyncBytes();
- // if there is no sync info then there is no base
- if (syncBytes==null)
- continue;
- // There is no remote if the file was added
- if (ResourceSyncInfo.isAddition(syncBytes))
- continue;
- // If the file was deleted locally, we need to generate a new sync info without the delete flag
- if (ResourceSyncInfo.isDeletion(syncBytes)) {
- syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes);
- }
- children.add(createRemoteFile(remote, syncBytes));
- monitor.worked(1);
- }
-
- // Remove any folders that are phantoms locally if they have no children
- if (children.isEmpty() && isPruneEmptyDirectories() && !local.exists())
- return null;
-
- // Add the children to the remote folder tree
- remote.setChildren((ICVSRemoteResource[])children.toArray(new ICVSRemoteResource[children.size()]));
-
- return remote;
- }
-
- protected RemoteFile createRemoteFile(RemoteFolder remote, byte[] syncBytes) throws CVSException {
- return new RemoteFile(remote, syncBytes);
- }
-
- protected RemoteFolder createRemoteFolder(ICVSFolder local, RemoteFolder parent, FolderSyncInfo folderSyncInfo) {
- return new RemoteFolderTree(parent, local.getName(), repository, folderSyncInfo.getRepository(), folderSyncInfo.getTag());
- }
-
- /*
- * 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, String localPath, IProgressMonitor monitor) throws CVSException {
-
- Policy.checkCanceled(monitor);
-
- // Add the remote folder to the remote folder lookup table (used to update file revisions)
- recordRemoteFolder(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 building the remote children
- if (local != null) {
- // Build the child folders corresponding to local folders
- ICVSResource[] folders = local.members(ICVSFolder.FOLDER_MEMBERS);
- for (int i=0;i<folders.length;i++) {
- ICVSFolder folder = (ICVSFolder)folders[i];
- DeltaNode d = (DeltaNode)deltas.get(folder.getName());
- if (folder.isCVSFolder() && ! isOrphanedSubtree(folder) && (d==null || d.getRevision() != DELETED)) {
- children.put(folders[i].getName(),
- new RemoteFolderTree(remote, folders[i].getName(), repository,
- folder.getFolderSyncInfo().getRepository(),
- tagForRemoteFolder(folder,tag)));
- }
- }
- // Build the child files corresponding to local files
- ICVSResource[] files = local.members(ICVSFolder.FILE_MEMBERS);
- for (int i=0;i<files.length;i++) {
- ICVSFile file = (ICVSFile)files[i];
-
- DeltaNode d = (DeltaNode)deltas.get(file.getName());
- byte[] syncBytes = file.getSyncBytes();
- // if there is no sync info then there isn't a remote file for this local file on the
- // server.
- if (syncBytes==null)
- continue;
- // There is no remote if the file was added and we didn't get a conflict (C) indicator from the server
- if (ResourceSyncInfo.isAddition(syncBytes) && 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 (ResourceSyncInfo.isDeletion(syncBytes) && d==null)
- continue;
-
- int type = d==null ? Update.STATE_NONE : d.getSyncState();
- children.put(file.getName(), new RemoteFile(remote, type, syncBytes));
- }
- }
-
- // 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) {
- children.put(name, new RemoteFolderTree(remote, repository,
- Util.appendPath(remote.getRepositoryRelativePath(), name),
- tagForRemoteFolder(remote, tag)));
- } else if (revision == ADDED) {
- children.put(name, new RemoteFile(remote,
- d.getSyncState(),
- name,
- null, /* the revision will be fetched later */
- null, /* there's no way to know the remote keyword mode */
- 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,
- null, /* the revision will be fetched later */
- getKeywordMode((ICVSFile)children.get(name)), /* get the keyword mode from the local file*/
- 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, Util.appendPath(localPath, name), monitor);
- // Record any children that are empty
- if (isPruneEmptyDirectories() && remoteFolder.getChildren().length == 0) {
- // Prune if the local folder is also empty.
- if (localFolder == null || (localFolder.members(ICVSFolder.ALL_EXISTING_MEMBERS).length == 0))
- emptyChildren.add(remoteFolder);
- else {
- // Also prune if the tag we are fetching is not HEAD and differs from the tag of the local folder
- FolderSyncInfo info = localFolder.getFolderSyncInfo();
- if (tag != null && info != null && ! tag.equals(CVSTag.DEFAULT) && ! tag.equals(info.getTag()))
- emptyChildren.add(remoteFolder);
- }
- }
- }
- }
-
- // Prune any empty child folders
- if (isPruneEmptyDirectories() && !emptyChildren.isEmpty()) {
- List newChildren = new ArrayList();
- newChildren.addAll(Arrays.asList(remote.getChildren()));
- newChildren.removeAll(emptyChildren);
- remote.setChildren((ICVSRemoteResource[])newChildren.toArray(new ICVSRemoteResource[newChildren.size()]));
-
- }
- }
-
- /*
- * This method fetches the delta between the local state and the remote state of the resource tree
- * and records the deltas in the fileDeltas instance variable
- *
- * Returns the list of changed files
- */
- private List fetchDelta(Session session, String[] arguments, final IProgressMonitor monitor) throws CVSException {
-
- // Create an listener that will accumulate new and removed files and folders
- IUpdateMessageListener listener = new IUpdateMessageListener() {
- public void directoryInformation(ICVSFolder root, String 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(NLS.bind(CVSMessages.RemoteFolderTreeBuilder_receivingDelta, new String[] { Util.toTruncatedPath(path, 3) }));
- }
- }
- public void directoryDoesNotExist(ICVSFolder root, String path) {
- // Record removed directory with parent so it can be removed when building the parent
- if (path.length() == 0) {
- rootDoesNotExist = true;
- } else {
- recordDelta(path, DELETED, Update.STATE_NONE);
- monitor.subTask(NLS.bind(CVSMessages.RemoteFolderTreeBuilder_receivingDelta, new String[] { Util.toTruncatedPath(path, 3) }));
- }
- }
- public void fileInformation(int type, ICVSFolder root, String filename) {
- // Cases that do not require action are:
- // case 'A' : = A locally added file that does not exists remotely
- // case '?' : = A local file that has not been added and does not exists remotely
- // case 'M' : = A locally modified file that has not been modified remotely
- switch(type) {
- case Update.STATE_MERGEABLE_CONFLICT :
- case Update.STATE_CONFLICT :
- // We have an remote change to a modified local file
- // The change could be a local change conflicting with a remote deletion.
- // If so, the deltas may already have a DELETED for the file.
- // We shouldn't override this DELETED
- Map deltas = (Map)fileDeltas.get(Util.removeLastSegment(filename));
- DeltaNode d = deltas != null ? (DeltaNode)deltas.get(Util.getLastSegment(filename)) : 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(filename, UNKNOWN, type);
- monitor.subTask(NLS.bind(CVSMessages.RemoteFolderTreeBuilder_receivingDelta, new String[] { Util.toTruncatedPath(filename, 3) }));
- break;
- }
- }
- public void fileDoesNotExist(ICVSFolder root, String filename) {
- recordDelta(filename, DELETED, Update.STATE_NONE);
- monitor.subTask(NLS.bind(CVSMessages.RemoteFolderTreeBuilder_receivingDelta, new String[] { Util.toTruncatedPath(filename, 3) }));
- }
- };
-
- // 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.SYNCUPDATE.execute(session,
- new GlobalOption[] { Command.DO_NOT_CHANGE },
- updateLocalOptions,
- arguments,
- new UpdateListener(listener),
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- CVSServerException e = new CVSServerException(status);
- if (e.isNoTagException()) {
- // This error indicates that the complete subtree
- // being fetched does not have any files for the tag being queried
- rootDoesNotExist = true;
- } else if (e.containsErrors()) {
- // Log the error
- CVSProviderPlugin.log(e);
- }
- }
- 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, String localPath, final IProgressMonitor monitor) throws CVSException {
-
- // Create an listener that will accumulate new files and folders
- IUpdateMessageListener listener = new IUpdateMessageListener() {
- public void directoryInformation(ICVSFolder root, String 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(NLS.bind(CVSMessages.RemoteFolderTreeBuilder_receivingDelta, new String[] { Util.toTruncatedPath(path, 3) }));
- }
- }
- public void directoryDoesNotExist(ICVSFolder root, String path) {
- }
- public void fileInformation(int type, ICVSFolder root, String filename) {
- // NOTE: Check path prefix
- changedFiles.add(filename);
- recordDelta(filename, ADDED, type);
- monitor.subTask(NLS.bind(CVSMessages.RemoteFolderTreeBuilder_receivingDelta, new String[] { Util.toTruncatedPath(filename, 3) }));
- }
- public void fileDoesNotExist(ICVSFolder root, String filename) {
- }
- };
-
- // NOTE: Should use the path relative to the remoteRoot
- IStatus status = Command.UPDATE.execute(session,
- new GlobalOption[] { Command.DO_NOT_CHANGE },
- updateLocalOptions,
- new String[] { localPath },
- new UpdateListener(listener),
- Policy.subMonitorFor(monitor, 1));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- 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 },
- 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 List exceptions = new ArrayList();
- IStatusListener listener = new IStatusListener() {
- public void fileStatus(ICVSFolder root, String path, String remoteRevision) {
- try {
- updateRevision(path, remoteRevision);
- monitor.subTask(NLS.bind(CVSMessages.RemoteFolderTreeBuilder_receivingRevision, new String[] { Util.toTruncatedPath(path, 3) }));
- } catch (CVSException e) {
- exceptions.add(e);
- }
- }
- };
-
- // Perform a "cvs status..." with a custom message handler
- IStatus status = Command.STATUS.execute(session,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- fileNames,
- new StatusListener(listener),
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
-
- // Report any exceptions that occurred fetching the revisions
- if ( ! exceptions.isEmpty()) {
- if (exceptions.size() == 1) {
- throw (CVSException)exceptions.get(0);
- } else {
- MultiStatus multi = new MultiStatus(CVSProviderPlugin.ID, 0, CVSMessages.RemoteFolder_errorFetchingRevisions, null);
- for (int i = 0; i < exceptions.size(); i++) {
- multi.merge(((CVSException)exceptions.get(i)).getStatus());
- }
- throw new CVSException(multi);
- }
- }
- }
-
- protected boolean isPruneEmptyDirectories() {
- return false;
- }
- /*
- * 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 revision of UNKNOWN indicates that the revision has not been fetched
- * from the repository yet.
- */
- private void recordDelta(String path, String revision, int syncState) {
- if (revision == FOLDER) {
- newFolderExist = true;
- }
- String parent = Util.removeLastSegment(path);
- Map deltas = (Map)fileDeltas.get(parent);
- if (deltas == null) {
- deltas = new HashMap();
- fileDeltas.put(parent, deltas);
- }
- String name = Util.getLastSegment(path);
- deltas.put(name, new DeltaNode(name, revision, syncState));
- }
-
- private void updateRevision(String path, String revision) throws CVSException {
- RemoteFolderTree folder = getRecoredRemoteFolder(Util.removeLastSegment(path));
- if (folder == null) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, NLS.bind(CVSMessages.RemoteFolderTreeBuilder_missingParent, new String[] { path.toString(), revision }), root);
- throw new CVSException(status);
- }
- ((RemoteFile)folder.getFile(Util.getLastSegment(path))).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 parent 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(ICVSFolder mFolder) throws CVSException {
- return mFolder.isCVSFolder() && ! mFolder.isManaged() && ! mFolder.equals(root) && mFolder.getParent().isCVSFolder();
- }
-
- private void recordRemoteFolder(RemoteFolderTree remote) throws CVSException {
- String path = remote.getFolderSyncInfo().getRemoteLocation();
- remoteFolderTable.put(Util.asPath(path), remote);
- }
-
- private RemoteFolderTree getRecoredRemoteFolder(String path) {
- return (RemoteFolderTree)remoteFolderTable.get(Util.asPath(path));
- }
-
- /**
- * This method returns an array of the files that differ between the local and remote trees.
- * The files are represented as a String that contains the path to the file in the remote or local trees.
- * @return an array of differing files
- */
- public String[] getFileDiffs() {
- return (String[]) changedFiles.toArray(new String[changedFiles.size()]);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java
deleted file mode 100644
index dbd669d4f..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-
-public class RemoteModule extends RemoteFolder {
-
- private String label;
- private ICVSRemoteResource[] referencedModules;
- private LocalOption[] localOptions;
- private boolean expandable;
-
- public static RemoteModule[] getRemoteModules(ICVSRepositoryLocation repository, CVSTag tag, IProgressMonitor monitor) throws TeamException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(CVSMessages.RemoteModule_getRemoteModules, 100);
- try {
- RemoteModule[] modules;
- Session s = new Session(repository, getRemoteRootFolder(repository), false);
- s.open(Policy.subMonitorFor(monitor, 10), false /* read-only */);
- try {
- modules = Command.CHECKOUT.getRemoteModules(s, tag, Policy.subMonitorFor(monitor, 90));
- } finally {
- s.close();
- }
- return modules;
- } finally {
- monitor.done();
- }
- }
-
- private static ICVSFolder getRemoteRootFolder(ICVSRepositoryLocation repository) {
- return new RemoteFolder(null, repository, "/", null); //$NON-NLS-1$
- }
-
- /**
- * Create a set of RemoteModules from the provided module definition strings returned from the server
- *
- * At the moment, we are very restrictive on the types of modules we support.
- */
- public static RemoteModule[] createRemoteModules(String[] moduleDefinitionStrings, ICVSRepositoryLocation repository, CVSTag tag) {
-
- Map modules = new HashMap();
- Map referencedModulesTable = new HashMap();
- Map moduleAliases = new HashMap();
-
- // First pass: Create the remote module instances based on remote mapping
- for (int i = 0; i < moduleDefinitionStrings.length; i++) {
-
- // Read the module name
- StringTokenizer tokenizer = new StringTokenizer(moduleDefinitionStrings[i]);
- String moduleName = tokenizer.nextToken();
- List localOptionsList;
- String next;
- try {
- // Read the options associated with the module
- localOptionsList = new ArrayList();
- next = tokenizer.nextToken();
- while (next.charAt(0) == '-') {
- switch (next.charAt(1)) {
- case 'a': // alias
- localOptionsList.add(Checkout.ALIAS);
- break;
- case 'l': // don't recurse
- localOptionsList.add(Command.DO_NOT_RECURSE);
- break;
- case 'd': // directory
- localOptionsList.add(Checkout.makeDirectoryNameOption(tokenizer.nextToken()));
- break;
- case 'e':
- case 'i':
- case 'o':
- case 't':
- case 'u': // Ignore any programs
- tokenizer.nextToken();
- break;
- case 's': // status
- localOptionsList.add(Checkout.makeStatusOption(tokenizer.nextToken()));
- break;
- default: // unanticipated option. Ignore it and go on
- }
- next = tokenizer.nextToken();
- }
- } catch (NoSuchElementException e) {
- // There is an invalid entry in the modules file. Log it and continue
- CVSProviderPlugin.log(IStatus.WARNING, NLS.bind(CVSMessages.RemoteModule_invalidDefinition, new String[] { moduleDefinitionStrings[i], repository.getLocation(true) }), null);
- continue;
- }
- LocalOption[] localOptions = (LocalOption[]) localOptionsList.toArray(new LocalOption[localOptionsList.size()]);
-
- if (Checkout.ALIAS.isElementOf(localOptions)) {
-
- if (localOptions.length > 1) {
- // XXX This is an error condition that needs to be reported
- }
-
- // An alias expands to one or more modules or paths
- List expansions = new ArrayList(10);
- expansions.add(next);
- while (tokenizer.hasMoreTokens())
- expansions.add(tokenizer.nextToken());
-
- moduleAliases.put(moduleName, expansions.toArray(new String[expansions.size()]));
- modules.put(moduleName, new RemoteModule(moduleName, null, repository, null, localOptions, tag, true));
-
- } else {
-
- // The module definition may have a leading directory which can be followed by some files
- if (!(next.charAt(0) == '&')) {
- String directory = next;
- List files = new ArrayList();
- while (tokenizer.hasMoreTokens() && (next.charAt(0) != '&')) {
- next = tokenizer.nextToken() ;
- if ((next.charAt(0) != '&'))
- files.add(next);
- }
- RemoteModule remoteModule = new RemoteModule(moduleName, null, repository, directory, localOptions, tag, ! files.isEmpty());
- modules.put(moduleName, remoteModule);
- if ( ! files.isEmpty()) {
- ICVSRemoteResource[] children = new ICVSRemoteResource[files.size()];
- for (int j = 0; j < children.length; j++) {
- children[j] = new RemoteFile(remoteModule, Update.STATE_NONE, (String)files.get(j), null, null, tag);
- remoteModule.setChildren(children);
- }
- }
- } else {
- modules.put(moduleName, new RemoteModule(moduleName, null, repository, null, localOptions, tag, true));
- }
-
- // Record any referenced modules so that can be cross-referenced below
- if (next.charAt(0) == '&') {
- List children = new ArrayList(10);
- children.add(next);
- while (tokenizer.hasMoreTokens())
- children.add(tokenizer.nextToken());
- referencedModulesTable.put(moduleName, children.toArray(new String[children.size()]));
- }
- }
- }
-
- // Second pass: Cross reference aliases to modules
- // XXX Aliases can reference other aliases which confuses the expansion!
- Iterator iter = moduleAliases.keySet().iterator();
- while (iter.hasNext()) {
- String moduleName = (String)iter.next();
- RemoteModule module = (RemoteModule)modules.get(moduleName);
- String[] expansion = (String[])moduleAliases.get(moduleName);
- List referencedFolders = new ArrayList();
- boolean expandable = true;
- for (int i = 0; i < expansion.length; i++) {
- if (expansion[i].charAt(0) == '!') {
- // XXX Unsupported for now
- expandable = false;
- } else {
- IPath path = new Path(null, expansion[i]);
- if (path.segmentCount() > 1) {
- // XXX Unsupported for now
- expandable = false;
- } else {
- RemoteModule child = (RemoteModule)modules.get(expansion[i]);
- if (child == null) {
- referencedFolders.add(new RemoteFolder(null, repository, path.toString(), tag));
- } else {
- // Need to check if the child is a module alias
- if (child.isAlias()) {
- // XXX Unsupported for now
- expandable = false;
- } else {
- referencedFolders.add(child);
- }
- }
- }
- }
- }
- if (expandable) {
- //TODO: Make module static??
- module.setChildren((ICVSRemoteResource[]) referencedFolders.toArray(new ICVSRemoteResource[referencedFolders.size()]));
- } else {
- module.setExpandable(false);
- }
- }
-
- // Third pass: Cross reference remote modules where necessary
- iter = modules.keySet().iterator();
- while (iter.hasNext()) {
- String moduleName = (String)iter.next();
- String[] children = (String[])referencedModulesTable.get(moduleName);
- if (children != null) {
- RemoteModule module = (RemoteModule)modules.get(moduleName);
- List referencedFolders = new ArrayList();
- boolean expandable = true;
- for (int i = 0; i < children.length; i++) {
- RemoteModule child = (RemoteModule)modules.get(children[i].substring(1));
- if (child == null) {
- // invalid module definition
- expandable = false;
- } else if (child.isAlias()) {
- // Include alias children in-line
- expandable = false;
-// referencedFolders.addAll(Arrays.asList(child.getChildren()));
- } else {
- // XXX not expandable if child has local directory option (-d)
- if (Command.findOption(child.getLocalOptions(), "-d") != null) { //$NON-NLS-1$
- expandable = false;
- } else {
- referencedFolders.add(child);
- }
- }
- }
- if (expandable) {
- module.setReferencedModules((ICVSRemoteResource[]) referencedFolders.toArray(new ICVSRemoteResource[referencedFolders.size()]));
- } else {
- module.setExpandable(false);
- }
- }
- }
-
- return (RemoteModule[])modules.values().toArray(new RemoteModule[modules.size()]);
- }
-
- public RemoteModule(String label, RemoteFolder parent, ICVSRepositoryLocation repository, String repositoryRelativePath, LocalOption[] localOptions, CVSTag tag, boolean isStatic) {
- super(parent,
- label,
- repository,
- repositoryRelativePath == null ? FolderSyncInfo.VIRTUAL_DIRECTORY : repositoryRelativePath,
- tag,
- isStatic);
- this.localOptions = localOptions;
- this.label = label;
- this.expandable = true;
- }
-
- public LocalOption[] getLocalOptions() {
- return localOptions;
- }
- /*
- * Override of inherited getMembers in order to combine the physical members with any referenced modules
- */
- public ICVSRemoteResource[] getMembers(CVSTag tagName, IProgressMonitor monitor) throws CVSException {
-
- if ( ! expandable) return new ICVSRemoteResource[0];
-
- ICVSRemoteResource[] physicalChildren;
- if ( folderInfo.getIsStatic()) {
- physicalChildren = getChildren();
- } else {
- physicalChildren = super.getMembers(tagName, monitor);
- }
- ICVSRemoteResource[] allChildren;
- if (referencedModules != null && referencedModules.length > 0) {
- if (physicalChildren == null) {
- allChildren = referencedModules;
- } else {
- // Combine two sets of children
- allChildren = new ICVSRemoteResource[physicalChildren.length + referencedModules.length];
- for (int i = 0; i < physicalChildren.length; i++) {
- allChildren[i] = physicalChildren[i];
- }
- for (int i = 0; i < referencedModules.length; i++) {
- allChildren[i + physicalChildren.length] = referencedModules[i];
- }
- }
- } else if (physicalChildren != null) {
- allChildren = physicalChildren;
- } else {
- allChildren = new ICVSRemoteResource[0];
- }
- return allChildren;
- }
-
- private void setReferencedModules(ICVSRemoteResource[] referencedModules) {
- this.referencedModules = referencedModules;
- }
-
- public boolean isAlias() {
- return Checkout.ALIAS.isElementOf(localOptions);
- }
-
- /**
- * @see ICVSRemoteFolder#isExpandable()
- */
- public boolean isExpandable() {
- return expandable;
- }
-
- private void setExpandable(boolean expandable) {
- this.expandable = expandable;
- }
-
- /**
- * @see ICVSRemoteFolder#forTag(CVSTag)
- */
- public ICVSRemoteResource forTag(ICVSRemoteFolder parent, CVSTag tagName) {
- RemoteModule r = new RemoteModule(label, (RemoteFolder)parent, getRepository(), folderInfo.getRepository(), localOptions, tagName, folderInfo.getIsStatic());
- r.setExpandable(expandable);
- if (folderInfo.getIsStatic()) {
- ICVSRemoteResource[] children = getChildren();
- if (children != null) {
- List taggedChildren = new ArrayList(children.length);
- for (int i = 0; i < children.length; i++) {
- ICVSRemoteResource resource = children[i];
- taggedChildren.add(((RemoteResource)resource).forTag(r, tagName));
- }
- r.setChildren((ICVSRemoteResource[]) taggedChildren.toArray(new ICVSRemoteResource[taggedChildren.size()]));
- }
- }
- if (referencedModules != null) {
- List taggedModules = new ArrayList(referencedModules.length);
- for (int i = 0; i < referencedModules.length; i++) {
- RemoteModule module = (RemoteModule)referencedModules[i];
- taggedModules.add(module.forTag(r, tagName));
- }
- r.setReferencedModules((ICVSRemoteResource[]) taggedModules.toArray(new ICVSRemoteResource[taggedModules.size()]));
- }
- return r;
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder#isDefinedModule()
- */
- public boolean isDefinedModule() {
- return true;
- }
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object arg0) {
- if (arg0 instanceof RemoteModule) {
- RemoteModule module = (RemoteModule) arg0;
- return (getName().equals(module.getName()) && super.equals(module));
- }
- return false;
- }
-
- /**
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return super.hashCode() | getName().hashCode();
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFolder#getChild(java.lang.String)
- */
- public ICVSResource getChild(String path) throws CVSException {
- if (path.equals(Session.CURRENT_LOCAL_FOLDER) || path.length() == 0)
- return this;
- // If the path is one segment and it's a referenced module, return the module
- // Note: the overriden method will extract the first segment from a multi segment
- // path and re-invoke this method so we only need to check for one segment here
- // and use the inherited method in the other cases
- if (referencedModules != null) {
- if (path.indexOf(Session.SERVER_SEPARATOR) == -1) {
- for (int i=0;i<referencedModules.length;i++) {
- if (referencedModules[i].getName().equals(path))
- return referencedModules[i];
- }
- }
- }
- return super.getChild(path);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java
deleted file mode 100644
index ca7196d9d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.variants.CachedResourceVariant;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * The purpose of this class and its subclasses is to implement the corresponding
- * ICVSRemoteResource interfaces for the purpose of communicating information about
- * resources that reside in a CVS repository but have not necessarily been loaded
- * locally.
- */
-public abstract class RemoteResource extends CachedResourceVariant implements ICVSRemoteResource {
-
- protected RemoteFolder parent;
- protected String name;
-
- // relative synchronization state calculated by server of this remote file compare to the current local
- // workspace copy.
- private int workspaceSyncState = Update.STATE_NONE;
-
- /**
- * Constructor for RemoteResource.
- */
- public RemoteResource(RemoteFolder parent, String name) {
- this.parent = parent;
- this.name = name;
- }
-
- /*
- * @see ICVSRemoteResource#getName()
- */
- public String getName() {
- return name;
- }
-
- /*
- * @see ICVSResource#getRelativePath(ICVSFolder)
- */
- public String getRelativePath(ICVSFolder ancestor) throws CVSException {
- return Util.appendPath(parent.getRelativePath(ancestor), getName());
- }
-
- /*
- * @see ICVSRemoteResource#getParent()
- */
- public ICVSRemoteResource getRemoteParent() {
- return parent;
- }
-
- public abstract String getRepositoryRelativePath();
-
- public abstract ICVSRepositoryLocation getRepository();
-
- public int getWorkspaceSyncState() {
- return workspaceSyncState;
- }
-
- public void setWorkspaceSyncState(int workspaceSyncState) {
- this.workspaceSyncState = workspaceSyncState;
- }
-
- /*
- * @see ICVSResource#delete()
- */
- public void delete() {
- // For now, do nothing but we could provide this in the future.
- }
-
- /*
- * @see ICVSResource#exists()
- *
- * This method is used by the Command framework so it must return true so that
- * the proper information gets sent to the server. (i.e. it is used to fake that
- * the file exists locally so cvs commands can be used to retrieve information about
- * the remote resource from the server)
- */
- public boolean exists() {
- return true;
- }
-
- /*
- * @see ICVSRemoteResource#exists(IProgressMonitor)
- */
- public boolean exists(IProgressMonitor monitor) throws TeamException {
- return parent.exists(this, monitor);
- }
-
- /*
- * @see ICVSResource#getParent()
- */
- public ICVSFolder getParent() {
- return parent;
- }
-
- /*
- * @see ICVSResource#isIgnored()
- */
- public boolean isIgnored() {
- return false;
- }
-
- /*
- * @see ICVSResource#isManaged()
- */
- public boolean isManaged() {
- return parent != null;
- }
-
- public boolean isModified(IProgressMonitor monitor) throws CVSException {
- // it is safe to always consider a remote file handle as modified. This will cause any
- // CVS command to fetch new contents from the server.
- return true;
- }
-
- /*
- * @see ICVSResource#unmanage()
- */
- public void unmanage(IProgressMonitor monitor) throws CVSException {
- // do nothing
- }
-
- /*
- * @see ICVSResource#getSyncInfo()
- */
- public abstract ResourceSyncInfo getSyncInfo();
-
- public boolean equals(Object target) {
- if (this == target)
- return true;
- if (!(target instanceof RemoteResource))
- return false;
- RemoteResource remote = (RemoteResource) target;
- return remote.isContainer() == isContainer()
- && remote.getRepository().equals(getRepository())
- && remote.getRepositoryRelativePath().equals(getRepositoryRelativePath());
- }
-
- /*
- * @see ICVSResource#setIgnoredAs(String)
- */
- public void setIgnoredAs(String pattern) throws CVSException {
- // ensure that clients are not trying to set sync info on remote handles.
- Assert.isTrue(false);
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.ICVSResource#getIResource()
- */
- public IResource getIResource() {
- return null;
- }
-
- /**
- * Return a copy of the receiver that is associated with the given tag. The parent
- * should be a copy of the receiver's parent which has been copied to the same tag.
- *
- * @param parent
- * @param tagName
- * @return ICVSRemoteFolder
- */
- public abstract ICVSRemoteResource forTag(ICVSRemoteFolder parent, CVSTag tagName);
-
- /**
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return getRepositoryRelativePath().hashCode();
- }
-
- /**
- * Method which returns an array of bytes that can be used to recreate the remote handle.
- * To recreate the remote handle, invoke the <code>fromBytes</code> method on either
- * RemoteFolder or RemoteFile.
- *
- * TODO: It would be nice to have a method on RmeoteResource to recreate the handles
- * but the file requires the bytes for the parent folder since this folder may not
- * exist locally.
- *
- * @return
- */
- abstract public byte[] getSyncBytes();
-
- public String toString() {
- return "Remote " + (isContainer() ? "Folder: " : "File: ") + getName(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.synchronize.ResourceVariant#getUniquePath()
- */
- public String getCachePath() {
- ICVSRepositoryLocation location = getRepository();
- IPath path = new Path(null, location.getHost());
- path = path.append(location.getRootDirectory());
- path = path.append(parent.getRepositoryRelativePath());
- path = path.append(getName() + ' ' + getContentIdentifier());
- return path.toString();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.synchronize.ResourceVariant#getCacheId()
- */
- protected String getCacheId() {
- return CVSProviderPlugin.ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.IResourceVariant#asBytes()
- */
- public byte[] asBytes() {
- return getSyncBytes();
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SessionPropertySyncInfoCache.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SessionPropertySyncInfoCache.java
deleted file mode 100644
index 7b9586a8b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SessionPropertySyncInfoCache.java
+++ /dev/null
@@ -1,489 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.internal.ccvs.core.*;
-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.FileNameMatcher;
-import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter;
-
-/**
- * This cache uses session properties to hold the bytes representing the sync
- * info. In addition when the workbench closes or a project is closed, the dirty
- * state for all cvs managed folders are persisted using the resource's plugin
- * synchronizer.
- */
-/*package*/ class SessionPropertySyncInfoCache extends SyncInfoCache implements ISaveParticipant {
-
- // key used on a folder to indicate that the resource sync has been cahced for it's children
- private static final QualifiedName RESOURCE_SYNC_CACHED_KEY = new QualifiedName(CVSProviderPlugin.ID, "resource-sync-cached"); //$NON-NLS-1$
- private static final Object RESOURCE_SYNC_CACHED = new Object();
-
- /*package*/ static final FileNameMatcher NULL_IGNORES = new FileNameMatcher();
- private static final FolderSyncInfo NULL_FOLDER_SYNC_INFO = new FolderSyncInfo("dummy-repo", "dummy-root", null, false); //$NON-NLS-1$ //$NON-NLS-2$
-
- private QualifiedName FOLDER_DIRTY_STATE_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-dirty-state-cached"); //$NON-NLS-1$
-
- // defer to the sychronizer if there is no sync info
- // (i.e. for those cases where a deleted resource is recreated)
- private SynchronizerSyncInfoCache synchronizerCache;
-
- /*package*/ SessionPropertySyncInfoCache(SynchronizerSyncInfoCache synchronizerCache) {
- this.synchronizerCache = synchronizerCache;
- try {
- // this save participant is removed when the plugin is shutdown.
- ResourcesPlugin.getWorkspace().addSaveParticipant(CVSProviderPlugin.getPlugin(), this);
- ISynchronizer synchronizer = ResourcesPlugin.getWorkspace().getSynchronizer();
- synchronizer.add(FOLDER_DIRTY_STATE_KEY);
- } catch (CoreException e) {
- CVSProviderPlugin.log(e);
- }
- }
-
- /**
- * If not already cached, loads and caches the folder ignores sync for the container.
- * Folder must exist and must not be the workspace root.
- *
- * @param container the container
- * @return the folder ignore patterns, or an empty array if none
- */
- /*package*/ FileNameMatcher getFolderIgnores(IContainer container, boolean threadSafeAccess) throws CVSException {
- // don't try to load if the information is already cached
- FileNameMatcher matcher = (FileNameMatcher)safeGetSessionProperty(container, IGNORE_SYNC_KEY);
- if (threadSafeAccess && matcher == null) {
- // read folder ignores and remember it
- String[] ignores = SyncFileWriter.readCVSIgnoreEntries(container);
- if (ignores == null) {
- matcher = NULL_IGNORES;
- } else {
- matcher = new FileNameMatcher(ignores);
- }
- safeSetSessionProperty(container, IGNORE_SYNC_KEY, matcher);
- }
- return matcher;
- }
-
- /* package */ boolean isIgnoresCached(IContainer container) throws CVSException {
- return safeGetSessionProperty(container, IGNORE_SYNC_KEY) != null;
- }
-
- /*package*/ boolean isFolderSyncInfoCached(IContainer container) throws CVSException {
- Object info = safeGetSessionProperty(container, FOLDER_SYNC_KEY);
- if (info == null){
- // Defer to the synchronizer in case the folder was recreated
- info = synchronizerCache.getCachedFolderSync(container, true);
- }
- return info != null;
- }
-
- /*package*/ boolean isResourceSyncInfoCached(IContainer container) throws CVSException {
- return safeGetSessionProperty(container, RESOURCE_SYNC_CACHED_KEY) != null;
- }
-
- /*package*/ void setResourceSyncInfoCached(IContainer container) throws CVSException {
- safeSetSessionProperty(container, RESOURCE_SYNC_CACHED_KEY, RESOURCE_SYNC_CACHED);
- }
-
- /**
- * Returns the folder sync info for the container; null if none.
- * Folder must exist and must not be the workspace root.
- * The folder sync info for the container MUST ALREADY BE CACHED.
- * @param container the container
- * @param threadSafeAccess if false, the return value can only be used if not null
- * @return the folder sync info for the folder, or null if none.
- * @see #cacheFolderSync
- */
- FolderSyncInfo getCachedFolderSync(IContainer container, boolean threadSafeAccess) throws CVSException {
- FolderSyncInfo info = (FolderSyncInfo)safeGetSessionProperty(container, FOLDER_SYNC_KEY);
- // If we are not thread safe, just return whatever was found in the session property
- if (!threadSafeAccess)
- return info == NULL_FOLDER_SYNC_INFO ? null : info;
- if (info == null) {
- // Defer to the synchronizer in case the folder was recreated
- info = synchronizerCache.getCachedFolderSync(container, true);
- if (info != null) {
- safeSetSessionProperty(container, FOLDER_SYNC_KEY, info);
- }
- }
- if (info == null) {
- // There should be sync info but it was missing. Report the error.
- // Only report the error is the folder is not derived (see bug 97023)
- if (container.exists() && !container.isDerived()){
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, NLS.bind(CVSMessages.EclipseSynchronizer_folderSyncInfoMissing, new String[] { container.getFullPath().toString() }), container);
- throw new CVSException(status);
- }
- }
- if (info == NULL_FOLDER_SYNC_INFO) return null;
- return info;
- }
-
- /**
- * Purges the cache recursively for all resources beneath the container.
- * There must not be any pending uncommitted changes.
- * @return the resources whose sync info was flushed
- */
- /*package*/ IResource[] purgeCache(IContainer container, boolean deep) throws CVSException {
- if (! container.exists()) return new IResource[0];
- try {
- Set flushed = new HashSet();
- if (container.getType() != IResource.ROOT) {
- safeSetSessionProperty(container, IGNORE_SYNC_KEY, null);
- safeSetSessionProperty(container, FOLDER_SYNC_KEY, null);
- safeSetSessionProperty(container, RESOURCE_SYNC_CACHED_KEY, null);
- flushed.add(container);
- EclipseSynchronizer.getInstance().adjustDirtyStateRecursively(container, RECOMPUTE_INDICATOR);
- }
- IResource[] members = container.members();
- for (int i = 0; i < members.length; i++) {
- IResource resource = members[i];
- purgeResourceSyncCache(resource);
- flushed.add(resource);
- if (deep && resource.getType() != IResource.FILE) {
- IResource[] flushedChildren = purgeCache((IContainer) resource, deep);
- flushed.addAll(Arrays.asList(flushedChildren));
- }
- }
- return (IResource[]) flushed.toArray(new IResource[flushed.size()]);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /* package*/ void purgeResourceSyncCache(IResource resource) throws CVSException {
- safeSetSessionProperty(resource, RESOURCE_SYNC_KEY, null);
- EclipseSynchronizer.getInstance().adjustDirtyStateRecursively(resource, RECOMPUTE_INDICATOR);
- }
-
- /**
- * Sets the array of folder ignore patterns for the container, must not be null.
- * Folder must exist and must not be the workspace root.
- *
- * @param container the container
- * @param ignores the array of ignore patterns
- */
- /*package*/ void setCachedFolderIgnores(IContainer container, String[] ignores) throws CVSException {
- safeSetSessionProperty(container, IGNORE_SYNC_KEY, new FileNameMatcher(ignores));
- }
-
-
- /**
- * Sets the folder sync info for the container; if null, deletes it.
- * Folder must exist and must not be the workspace root.
- * The folder sync info for the container need not have previously been cached.
- *
- * @param container the container
- * @param info the new folder sync info
- */
- void setCachedFolderSync(IContainer container, FolderSyncInfo info, boolean canModifyWorkspace) throws CVSException {
- if (!container.exists()) return;
- if (info == null) {
- info = NULL_FOLDER_SYNC_INFO;
- }
- safeSetSessionProperty(container, FOLDER_SYNC_KEY, info);
- // Ensure the synchronizer is clear for exiting resources
- if (canModifyWorkspace && synchronizerCache.getCachedFolderSync(container, true) != null) {
- synchronizerCache.setCachedFolderSync(container, null, true);
- }
- }
-
- /*package*/ void setDirtyIndicator(IResource resource, String indicator) throws CVSException {
- if (resource.getType() == IResource.FILE) {
- internalSetDirtyIndicator((IFile)resource, indicator);
- } else {
- internalSetDirtyIndicator((IContainer)resource, indicator);
- }
- }
- /*package*/ String getDirtyIndicator(IResource resource, boolean threadSafeAccess) throws CVSException {
- if (resource.getType() == IResource.FILE) {
- return internalGetDirtyIndicator((IFile)resource, threadSafeAccess);
- } else {
- return internalGetDirtyIndicator((IContainer)resource, threadSafeAccess);
- }
- }
-
- private void internalSetDirtyIndicator(IFile file, String indicator) throws CVSException {
- safeSetSessionProperty(file, IS_DIRTY, indicator);
- }
-
- private String internalGetDirtyIndicator(IFile file, boolean threadSafeAccess) throws CVSException {
- String di = (String)safeGetSessionProperty(file, IS_DIRTY);
- if(di == null) {
- di = RECOMPUTE_INDICATOR;
- }
- return di;
- }
-
- private void internalSetDirtyIndicator(IContainer container, String indicator) throws CVSException {
- safeSetSessionProperty(container, IS_DIRTY, indicator);
- }
-
- private String internalGetDirtyIndicator(IContainer container, boolean threadSafeAccess) throws CVSException {
- try {
- String di = (String)safeGetSessionProperty(container, IS_DIRTY);
-
- // if the session property is not available then restore from persisted sync info. At this
- // time the sync info is not flushed because we don't want the workspace to generate
- // a delta.
- if(di == null) {
- byte [] diBytes = ResourcesPlugin.getWorkspace().getSynchronizer().getSyncInfo(FOLDER_DIRTY_STATE_KEY, container);
- if(diBytes != null && !CVSProviderPlugin.getPlugin().crashOnLastRun()) {
- di = new String(diBytes);
- if(di.equals(NOT_DIRTY_INDICATOR)) {
- di = NOT_DIRTY_INDICATOR;
- } else if(di.equals(IS_DIRTY_INDICATOR)) {
- di = IS_DIRTY_INDICATOR;
- } else {
- di = RECOMPUTE_INDICATOR;
- }
- } else {
- di = RECOMPUTE_INDICATOR;
- }
- // Only set the session property if we are thread safe
- if (threadSafeAccess) {
- setDirtyIndicator(container, di);
- }
- }
- return di;
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /*
- * Flush dirty cache for the resource
- */
- /*package*/ void flushDirtyCache(IResource resource) throws CVSException {
- if (resource.exists()) {
- if (resource.getType() == IResource.FILE) {
- safeSetSessionProperty(resource, IS_DIRTY, null);
- } else {
- safeSetSessionProperty(resource, IS_DIRTY, null);
- flushDirtyStateFromDisk((IContainer)resource);
- }
- }
- }
-
- /**
- * Method isSyncInfoLoaded returns true if all the sync info for the
- * provided resources is loaded into the internal cache.
- *
- * @param resources
- * @param i
- * @return boolean
- */
- /*package*/ boolean isSyncInfoLoaded(IContainer parent) throws CVSException {
- if (parent.getFolder(new Path(SyncFileWriter.CVS_DIRNAME)).exists()) {
- if (safeGetSessionProperty(parent, RESOURCE_SYNC_CACHED_KEY) == null)
- return false;
- if (safeGetSessionProperty(parent, FOLDER_SYNC_KEY) == null)
- return false;
-// if (parent.getSessionProperty(IGNORE_SYNC_KEY) == null)
-// return false;
- }
- return true;
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#getCachedSyncBytes(org.eclipse.core.resources.IResource, boolean)
- */
- byte[] getCachedSyncBytes(IResource resource, boolean threadSafeAccess) throws CVSException {
- byte[] bytes = (byte[])safeGetSessionProperty(resource, RESOURCE_SYNC_KEY);
- // If we are not thread safe, just return whatever was found in the session property
- if (!threadSafeAccess)
- return bytes;
- if (bytes == null) {
- // Defer to the synchronizer in case the file was recreated
- bytes = synchronizerCache.getCachedSyncBytes(resource, true);
- if (bytes != null) {
- boolean genderChange = false;
- if (resource.getType() == IResource.FILE) {
- if (ResourceSyncInfo.isFolder(bytes)) {
- genderChange = true;
- }
- } else if (!ResourceSyncInfo.isFolder(bytes)) {
- genderChange = true;
- }
- if (genderChange) {
- // Return null if it is a gender change
- bytes = null;
- } else {
- safeSetSessionProperty(resource, RESOURCE_SYNC_KEY, ResourceSyncInfo.convertFromDeletion(bytes));
- }
- }
- }
- return bytes;
- }
-
- Object safeGetSessionProperty(IResource resource, QualifiedName key) throws CVSException {
- try {
- return resource.getSessionProperty(key);
- } catch (CoreException e) {
- IStatus status = e.getStatus();
- if(status != null) {
- int code = e.getStatus().getCode();
- if(code != IResourceStatus.RESOURCE_NOT_LOCAL ||
- code != IResourceStatus.RESOURCE_NOT_FOUND) {
- // ignore error since a phantom would of been created
- // and we can safely ignore these cases
- return null;
- }
- }
- // some other error we did not expect
- throw CVSException.wrapException(e);
- }
- }
-
- void safeSetSessionProperty(IResource resource, QualifiedName key, Object value) throws CVSException {
- try {
- resource.setSessionProperty(key, value);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#setCachedSyncBytes(org.eclipse.core.resources.IResource, byte[])
- */
- void setCachedSyncBytes(IResource resource, byte[] syncBytes, boolean canModifyWorkspace) throws CVSException {
- // Ensure that the sync bytes do not indicate a deletion
- if (syncBytes != null && ResourceSyncInfo.isDeletion(syncBytes)) {
- syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes);
- }
- // Put the sync bytes into the cache
- safeSetSessionProperty(resource, RESOURCE_SYNC_KEY, syncBytes);
- // Ensure the synchronizer is clear
- if (canModifyWorkspace && synchronizerCache.getCachedSyncBytes(resource, true) != null) {
- synchronizerCache.setCachedSyncBytes(resource, null, canModifyWorkspace);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.ISaveParticipant#doneSaving(org.eclipse.core.resources.ISaveContext)
- */
- public void doneSaving(ISaveContext context) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(org.eclipse.core.resources.ISaveContext)
- */
- public void prepareToSave(ISaveContext context) throws CoreException {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.ISaveParticipant#rollback(org.eclipse.core.resources.ISaveContext)
- */
- public void rollback(ISaveContext context) {
- }
-
- /* Called when the workbench is shutdown or projects are closed. The dirty state
- * of folders is persisted, using sync info, so that at startup or project open
- * the folder state can be quickly calculated. This is mainly for improving decorator
- * performance.
- * @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext)
- */
- public void saving(ISaveContext context) throws CoreException {
- boolean fullSave = (context.getKind() == ISaveContext.FULL_SAVE);
- boolean projectSave = (context.getKind() == ISaveContext.PROJECT_SAVE);
-
- if((projectSave || fullSave)) {
- // persist all session properties for folders into sync info.
- final ISynchronizer synchronizer = ResourcesPlugin.getWorkspace().getSynchronizer();
-
- // traverse the workspace looking for CVS managed projects or just the
- // specific projects being closed
- IProject[] projects;
- if(projectSave) {
- projects = new IProject[1];
- projects[0] = context.getProject();
- } else {
- projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- }
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- RepositoryProvider provider = RepositoryProvider.getProvider(
- project,
- CVSProviderPlugin.getTypeId());
-
- // found a project managed by CVS, convert each session property on a
- // folder to a sync object.
- if (provider != null) {
- project.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if(resource.getType() != IResource.FILE) {
- String di = null;
- try {
- di = getDirtyIndicator(resource, true);
- } catch (CVSException e) {
- // continue traversal
- CVSProviderPlugin.log(e);
- }
- if(di != null) {
- synchronizer.setSyncInfo(FOLDER_DIRTY_STATE_KEY, resource, di.getBytes());
- }
- }
- return true;
- }
- });
- }
- }
- }
- }
-
- /*
- * Called to clear the folder dirty state from the resource sync tree and stop persisting
- * these values to disk.
- */
- private void flushDirtyStateFromDisk(IContainer container) {
- final ISynchronizer synchronizer = ResourcesPlugin.getWorkspace().getSynchronizer();
- try {
- synchronizer.flushSyncInfo(FOLDER_DIRTY_STATE_KEY, container, IResource.DEPTH_INFINITE);
- } catch (CoreException e) {
- CVSProviderPlugin.log(e);
- }
- }
-
- /*
- * Flush all the cahced dirty state for the resource and its members.
- */
- /* package*/ void purgeDirtyCache(IResource resource) throws CVSException {
- if (! resource.exists()) return;
- try {
- if (resource.getType() != IResource.ROOT) {
- safeSetSessionProperty(resource, IS_DIRTY, null);
- }
- if (resource.getType() != IResource.FILE) {
- ResourcesPlugin.getWorkspace().getSynchronizer().flushSyncInfo(FOLDER_DIRTY_STATE_KEY, resource, IResource.DEPTH_INFINITE);
- IResource[] members = ((IContainer)resource).members();
- for (int i = 0; i < members.length; i++) {
- purgeDirtyCache(members[i]);
- }
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#cachesDirtyState()
- */
- public boolean cachesDirtyState() {
- return true;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SyncInfoCache.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SyncInfoCache.java
deleted file mode 100644
index 83e395b98..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SyncInfoCache.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-
-/**
- * The low level cache provides the sync info as bytes
- */
-/*package*/ abstract class SyncInfoCache {
-
- // the resources plugin synchronizer is used to cache and possibly persist. These
- // are keys for storing the sync info.
- /*package*/ static final QualifiedName FOLDER_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-sync"); //$NON-NLS-1$
- /*package*/ static final QualifiedName RESOURCE_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "resource-sync"); //$NON-NLS-1$
- /*package*/ static final QualifiedName IGNORE_SYNC_KEY = new QualifiedName(CVSProviderPlugin.ID, "folder-ignore"); //$NON-NLS-1$
-
- /*package*/ static final byte[][] EMPTY_RESOURCE_SYNC_INFOS = new byte[0][0];
-
- /*package*/ static final QualifiedName IS_DIRTY = new QualifiedName(CVSProviderPlugin.ID, "is-dirty"); //$NON-NLS-1$
- /*package*/ static final String IS_DIRTY_INDICATOR = "d"; //$NON-NLS-1$
- /*package*/ static final String NOT_DIRTY_INDICATOR = "c"; //$NON-NLS-1$
- /*package*/ static final String RECOMPUTE_INDICATOR = "r"; //$NON-NLS-1$
-
- /*package*/ static final IStatus STATUS_OK = new Status(IStatus.OK, CVSProviderPlugin.ID, 0, CVSMessages.ok, null);
-
- /**
- * Returns the folder sync info for the container; null if none.
- * Folder must exist and must not be the workspace root.
- * The folder sync info for the container MUST ALREADY BE CACHED.
- * <p>
- * The <code>canModifyWorkspace</code>
- * flag is used to indicate whether it is OK to modify ISycnrhonizer entries for
- * the given resource. A value of <code>true</code> indicates that the client
- * holds a scheduling rule that encompasses the resource and the workspace is
- * open for modification.
- * @param container the container
- * @param threadSafeAccess if false, the return value can only be used if not null
- * @param canModifyWorkspace indicates if it is OK to modify the ISycnrhonizer
- *
- * @return the folder sync info for the folder, or null if none.
- * @see #cacheFolderSync
- */
- /*package*/ abstract FolderSyncInfo getCachedFolderSync(IContainer container, boolean threadSafeAccess) throws CVSException;
-
- /**
- * Sets the folder sync info for the container; if null, deletes it.
- * Folder must exist and must not be the workspace root.
- * The folder sync info for the container need not have previously been
- * cached. The <code>canModifyWorkspace</code>
- * flag is used to indicate whether it is OK to modify ISycnrhonizer entries for
- * the given resource. A value of <code>true</code> indicates that the client
- * holds a scheduling rule that encompasses the resource and the workspace is
- * open for modification.
- *
- * @param container the container
- * @param info the new folder sync info
- * @param canModifyWorkspace indicates if it is OK to modify the ISycnrhonizer
- */
- /*package*/ abstract void setCachedFolderSync(IContainer container, FolderSyncInfo info, boolean canModifyWorkspace) throws CVSException;
-
- /**
- * Returns the resource sync info for the given resource. The resource sync
- * info for the resource MUST ALREADY BE CACHED.
- * @param resource the resource
- * @param threadSafeAccess if false, the return value can only be used if not null
- *
- * @return the bytes containing the resource's sync info
- * @see #cacheResourceSyncForChildren
- */
- /*package*/ abstract byte[] getCachedSyncBytes(IResource resource, boolean threadSafeAccess) throws CVSException;
-
- /**
- * Sets the resource sync info for the resource; if null, deletes it. Parent
- * must exist and must not be the workspace root. The resource sync info for
- * the resource MUST ALREADY BE CACHED. The <code>canModifyWorkspace</code>
- * flag is used to indicate whether it is OK to modify ISycnrhonizer entries for
- * the given resource. A value of <code>true</code> indicates that the client
- * holds a scheduling rule that encompasses the resource and the workspace is
- * open for modification.
- *
- * @param resource the resource
- * @param syncBytes the bytes containing the new resource sync info
- * @param canModifyWorkspace indicates if it is OK to modify the ISycnrhonizer
- * @see #cacheResourceSyncForChildren
- */
- /*package*/ abstract void setCachedSyncBytes(IResource resource, byte[] syncBytes, boolean canModifyWorkspace) throws CVSException;
-
- /*package*/ abstract String getDirtyIndicator(IResource resource, boolean threadSafeAccess) throws CVSException;
-
- /*package*/ abstract void setDirtyIndicator(IResource resource, String indicator) throws CVSException;
-
- /*package*/ abstract void flushDirtyCache(IResource resource) throws CVSException;
-
- /*package*/ abstract boolean isSyncInfoLoaded(IContainer parent) throws CVSException;
-
- /**
- * Query the low level cache to see if the sync info for the provided
- * container is loaded.
- *
- * @param container
- * @return boolean
- * @throws CVSException
- */
- /*package*/ abstract boolean isFolderSyncInfoCached(IContainer container) throws CVSException;
-
- /**
- * Query the low level cache to see if the sync info for the direct children
- * of the provided container is loaded.
- *
- * @param container
- * @return boolean
- */
- /*package*/ abstract boolean isResourceSyncInfoCached(IContainer container) throws CVSException;
-
- /**
- * Indicate to the low level cache that the sync info for all it's direct
- * children have been set so they match what is on disk.
- *
- * @param container
- */
- /*package*/ abstract void setResourceSyncInfoCached(IContainer container) throws CVSException;
-
- /**
- * Return whether the cache also caches dirty state or recomputes it
- * each time it is requested.
- */
- public abstract boolean cachesDirtyState();
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java
deleted file mode 100644
index deee885e2..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import java.util.*;
-
-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.core.resources.IResourceStatus;
-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.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * This cache uses session properties to hold the bytes representing the sync
- * info
- */
-/*package*/ class SynchronizerSyncInfoCache extends SyncInfoCache {
-
- // Map of sync bytes that were set without a scheduling rule
- Map pendingCacheWrites = new HashMap();
- private static final Object BYTES_REMOVED = new byte[0];
-
- public SynchronizerSyncInfoCache() {
- getWorkspaceSynchronizer().add(FOLDER_SYNC_KEY);
- getWorkspaceSynchronizer().add(RESOURCE_SYNC_KEY);
- }
- /**
- * Return the Eclipse Workspace Synchronizer (from org.eclipse.core.resources)
- */
- private ISynchronizer getWorkspaceSynchronizer() {
- return ResourcesPlugin.getWorkspace().getSynchronizer();
- }
-
- /*package*/ void flush(IProject project) throws CVSException {
- purgeCache(project, true);
- }
-
- /**
- * Method flush.
- * @param folder
- */
- /*package*/ void flush(IFolder folder) throws CVSException {
- purgeCache(folder, false);
- }
-
- /**
- * Returns the folder sync info for the container; null if none.
- * Folder must exist and must not be the workspace root.
- * The folder sync info for the container MUST ALREADY BE CACHED.
- * @param container the container
- *
- * @return the folder sync info for the folder, or null if none.
- * @see #cacheFolderSync
- */
- FolderSyncInfo getCachedFolderSync(IContainer container, boolean threadSafeAccess) throws CVSException {
- byte[] bytes = internalGetCachedSyncBytes(container);
- if (bytes == null) return null;
- return FolderSyncInfo.getFolderSyncInfo(bytes);
- }
-
- boolean hasCachedFolderSync(IContainer container) throws CVSException {
- return internalGetCachedSyncBytes(container) != null;
- };
-
- /*
- * Retieve the cached sync bytes from the synchronizer. A null
- * is returned if there are no cached sync bytes.
- */
- private byte[] internalGetCachedSyncBytes(IContainer container) throws CVSException {
- try {
- return getWorkspaceSynchronizer().getSyncInfo(FOLDER_SYNC_KEY, container);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
- /**
- * Sets the folder sync info for the container; if null, deletes it.
- * Folder must exist and must not be the workspace root.
- * The folder sync info for the container need not have previously been
- * cached.
- *
- * @param container the container
- * @param info the new folder sync info
- */
- void setCachedFolderSync(IContainer container, FolderSyncInfo info, boolean canModifyWorkspace) throws CVSException {
- try {
- if (info == null) {
- if (container.exists() || container.isPhantom()) {
- getWorkspaceSynchronizer().flushSyncInfo(FOLDER_SYNC_KEY, container, IResource.DEPTH_ZERO);
- }
- } else {
- getWorkspaceSynchronizer().setSyncInfo(FOLDER_SYNC_KEY, container, info.getBytes());
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#getCachedSyncBytes(org.eclipse.core.resources.IResource, boolean)
- */
- byte[] getCachedSyncBytes(IResource resource, boolean threadSafeAccess) throws CVSException {
- try {
- byte[] bytes = null;
- if (!hasPendingCacheRemoval(resource)) {
- bytes = getPendingCacheWrite(resource);
- if (bytes == null) {
- bytes = getWorkspaceSynchronizer().getSyncInfo(RESOURCE_SYNC_KEY, resource);
- }
- }
- if (bytes != null && resource.getType() == IResource.FILE) {
- if (ResourceSyncInfo.isAddition(bytes)) {
- // The local file has been deleted but was an addition
- // Therefore, ignore the sync bytes
- bytes = null;
- } else if (!ResourceSyncInfo.isDeletion(bytes)) {
- // Ensure the bytes indicate an outgoing deletion
- bytes = ResourceSyncInfo.convertToDeletion(bytes);
- }
- }
- return bytes;
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#setCachedSyncBytes(org.eclipse.core.resources.IResource, byte[])
- */
- void setCachedSyncBytes(IResource resource, byte[] syncBytes, boolean canModifyWorkspace) throws CVSException {
- byte[] oldBytes = getCachedSyncBytes(resource, true);
- try {
- if (syncBytes == null) {
- if (oldBytes != null) {
- if (canModifyWorkspace) {
- if (resource.exists() || resource.isPhantom()) {
- getWorkspaceSynchronizer().flushSyncInfo(RESOURCE_SYNC_KEY, resource, IResource.DEPTH_ZERO);
- }
- removePendingCacheWrite(resource);
- } else {
- if (resource.exists() || resource.isPhantom()) {
- setPendingCacheWriteToDelete(resource);
- }
- }
- }
- } else {
- // ensure that the sync info is not already set to the same thing.
- // We do this to avoid causing a resource delta when the sync info is
- // initially loaded (i.e. the synchronizer has it and so does the Entries file
- // Ignore the
- if (oldBytes == null || !equals(syncBytes, oldBytes)) {
- if (canModifyWorkspace) {
- getWorkspaceSynchronizer().setSyncInfo(RESOURCE_SYNC_KEY, resource, syncBytes);
- removePendingCacheWrite(resource);
- } else {
- setPendingCacheWrite(resource, syncBytes);
- }
- }
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /*
- * Convert file sync bytes to deletions to ensure proper comparison
- */
- private boolean equals(byte[] syncBytes, byte[] oldBytes) throws CVSException {
- if (!ResourceSyncInfo.isFolder(syncBytes)) {
- syncBytes = ResourceSyncInfo.convertToDeletion(syncBytes);
- }
- if (!ResourceSyncInfo.isFolder(oldBytes)) {
- try {
- oldBytes = ResourceSyncInfo.convertToDeletion(oldBytes);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- return false;
- }
- }
- return Util.equals(syncBytes, oldBytes);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#getDirtyIndicator(org.eclipse.core.resources.IResource)
- */
- String getDirtyIndicator(IResource resource, boolean threadSafeAccess) throws CVSException {
- if (resource.getType() == IResource.FILE) {
- // a phantom file is dirty if it was managed before it was deleted
- return getCachedSyncBytes(resource, threadSafeAccess) != null ?
- IS_DIRTY_INDICATOR :
- NOT_DIRTY_INDICATOR;
- } else {
- return calculateDirtyCountForPhantomFolder((IContainer)resource);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#setDirtyIndicator(org.eclipse.core.resources.IResource, java.lang.String)
- */
- void setDirtyIndicator(IResource resource, String indicator) throws CVSException {
- // We don't cache the dirty count for folders because it would cause
- // resource delta's in the decorator thread and possible deadlock.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#cachesDirtyState()
- */
- public boolean cachesDirtyState() {
- // We don't cache the dirty count for folders because it would cause
- // resource delta's in the decorator thread and possible deadlock.
- return false;
- }
-
- /*package*/ void flushDirtyCache(IResource container) throws CVSException {
- // Dirty state is not cached
- }
-
- /*package*/ boolean isSyncInfoLoaded(IContainer parent) throws CVSException {
- return true;
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#isResourceSyncInfoCached(org.eclipse.core.resources.IContainer)
- */
- boolean isResourceSyncInfoCached(IContainer container) throws CVSException {
- // the sync info is always cahced when using the synchronizer
- return true;
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#setResourceSyncInfoCached(org.eclipse.core.resources.IContainer)
- */
- void setResourceSyncInfoCached(IContainer container) throws CVSException {
- // do nothing
- }
- /**
- * @see org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache#isFolderSyncInfoCached(org.eclipse.core.resources.IContainer)
- */
- boolean isFolderSyncInfoCached(IContainer container) throws CVSException {
- return true;
- }
-
- /*
- * Calculate the dirty count for the given phantom folder, performing any
- * necessary calculations on the childen as well
- */
- private String calculateDirtyCountForPhantomFolder(IContainer parent) throws CVSException {
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(parent);
- if(getCachedFolderSync(parent, true) == null) {
- return NOT_DIRTY_INDICATOR;
- }
-
- String indicator = NOT_DIRTY_INDICATOR;
- ICVSResource[] children = cvsFolder.members(ICVSFolder.MANAGED_MEMBERS | ICVSFolder.PHANTOM_MEMBERS);
- for (int i = 0; i < children.length; i++) {
- ICVSResource resource = children[i];
- // keep looking into phantom folders until a managed phantom file
- // is found.
- if (resource.isFolder()) {
- indicator = calculateDirtyCountForPhantomFolder((IContainer)resource.getIResource());
- } else {
- // Any non-existant managed files are dirty (outgoing deletion)
- indicator = IS_DIRTY_INDICATOR;
- break;
- }
- }
- return indicator;
- }
-
- /**
- * @param root
- * @param deep
- */
- public void purgeCache(IContainer root, boolean deep) throws CVSException {
- int depth = deep ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO;
- try {
- if (root.exists() || root.isPhantom()) {
- getWorkspaceSynchronizer().flushSyncInfo(RESOURCE_SYNC_KEY, root, depth);
- }
- if (root.exists() || root.isPhantom()) {
- getWorkspaceSynchronizer().flushSyncInfo(FOLDER_SYNC_KEY, root, depth);
- }
- if (deep) {
- removePendingCacheWritesUnder(root);
- } else {
- removePendingCacheWrite(root);
- }
- } catch (CoreException e) {
- if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND) {
- // Must have been deleted since we checked
- return;
- }
- throw CVSException.wrapException(e);
- }
-
- }
-
- public boolean isPhantom(IResource resource) {
- return resource.isPhantom() || hasPendingCacheWrite(resource);
- }
-
- public IResource[] members(IContainer folder) throws CoreException {
- IResource[] pendingWrites = getPendingCacheWrites();
- if (pendingWrites != null){
- HashSet cachedResources = new HashSet();
- for (int i = 0; i < pendingWrites.length; i++) {
- IResource resource = pendingWrites[i];
- if (resource.getParent().equals(folder))
- cachedResources.add(resource);
- }
-
- if (cachedResources.size() != 0){
- IResource[] resources = folder.members(true);
- IResource[] cachedResourcesArray = (IResource[]) cachedResources.toArray(new IResource[cachedResources.size()]);
- IResource[]finalResources = new IResource[resources.length + cachedResourcesArray.length];
- System.arraycopy(resources, 0, finalResources, 0, resources.length);
- System.arraycopy(cachedResourcesArray, 0, finalResources, resources.length, cachedResourcesArray.length);
- return finalResources;
- }
- }
- try {
- return folder.members(true);
- } catch (CoreException e) {
- if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND)
- return new IResource[0];
- throw e;
- }
- }
-
- /**
- * Return whether the given resource has a pending cache write
- * @param resource the resource
- * @return whether the given resource has a pending cache write
- */
- private boolean hasPendingCacheWrite(IResource resource) {
- synchronized (pendingCacheWrites) {
- return pendingCacheWrites.containsKey(resource);
- }
- }
-
- private byte[] getPendingCacheWrite(IResource resource) {
- synchronized (pendingCacheWrites) {
- Object object = pendingCacheWrites.get(resource);
- if (object instanceof byte[]) {
- return (byte[])object;
- }
- return null;
- }
- }
-
- private boolean hasPendingCacheRemoval(IResource resource) {
- synchronized (pendingCacheWrites) {
- Object object = pendingCacheWrites.get(resource);
- return object == BYTES_REMOVED;
- }
- }
-
- private void setPendingCacheWrite(IResource resource, byte[] syncBytes) {
- synchronized (pendingCacheWrites) {
- pendingCacheWrites.put(resource, syncBytes);
- }
- }
-
- private void setPendingCacheWriteToDelete(IResource resource) {
- synchronized (pendingCacheWrites) {
- pendingCacheWrites.put(resource, BYTES_REMOVED);
- }
- }
-
- private void removePendingCacheWrite(IResource resource) {
- synchronized (pendingCacheWrites) {
- pendingCacheWrites.remove(resource);
- }
- }
-
- private void removePendingCacheWritesUnder(IContainer root) {
- synchronized (pendingCacheWrites) {
- IPath fullPath = root.getFullPath();
- for (Iterator iter = pendingCacheWrites.keySet().iterator(); iter.hasNext();) {
- IResource resource = (IResource) iter.next();
- if (fullPath.isPrefixOf(resource.getFullPath())) {
- iter.remove();
- }
- }
- }
- }
-
- /**
- * Return the resources with pending cache writes or
- * <code>null</code> if there aren't any.
- * @return the resources with pending cache writes or
- * <code>null</code>
- */
- private IResource[] getPendingCacheWrites() {
- synchronized (pendingCacheWrites) {
- if (pendingCacheWrites.isEmpty())
- return null;
- return (IResource[]) pendingCacheWrites.keySet().toArray(new IResource[pendingCacheWrites.size()]);
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/UpdateContentCachingService.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/UpdateContentCachingService.java
deleted file mode 100644
index aedc28300..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/UpdateContentCachingService.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.resources;
-
-import java.util.*;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.client.listeners.*;
-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 can be used to fetch and cache file contents for remote files.
- */
-public class UpdateContentCachingService implements IUpdateMessageListener {
-
- private CVSRepositoryLocation repository;
- private ICVSFolder remoteRoot;
- private final CVSTag tag;
- private final int depth;
- private boolean fetchAbsentDirectories = true;
- private ArrayList removed = new ArrayList();
-
- public class SandboxUpdate extends Update {
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Update#shouldRetrieveAbsentDirectories(org.eclipse.team.internal.ccvs.core.client.Session)
- */
- protected boolean shouldRetrieveAbsentDirectories(Session session) {
- return fetchAbsentDirectories;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Command#commandFinished(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[], org.eclipse.team.internal.ccvs.core.client.Command.LocalOption[], org.eclipse.team.internal.ccvs.core.ICVSResource[], org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IStatus)
- */
- protected IStatus commandFinished(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor, IStatus status) throws CVSException {
- // Don't do anything (i.e. don't prune)
- return status;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.Command#doExecute(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[], org.eclipse.team.internal.ccvs.core.client.Command.LocalOption[], java.lang.String[], org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus doExecute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions, String[] arguments, ICommandOutputListener listener, IProgressMonitor monitor) throws CVSException {
- session.registerResponseHandler(new SandboxUpdatedHandler(UpdatedHandler.HANDLE_CREATED));
- session.registerResponseHandler(new SandboxUpdatedHandler(UpdatedHandler.HANDLE_MERGED));
- session.registerResponseHandler(new SandboxUpdatedHandler(UpdatedHandler.HANDLE_UPDATE_EXISTING));
- session.registerResponseHandler(new SandboxUpdatedHandler(UpdatedHandler.HANDLE_UPDATED));
- return super.doExecute(session, globalOptions, localOptions, arguments, listener, monitor);
- }
- }
-
- /**
- * This class overrides the "Created" handler in order to configure the remote file
- * to receive and cache the contents
- */
- public class SandboxUpdatedHandler extends UpdatedHandler {
- public SandboxUpdatedHandler(int type) {
- super(type);
- }
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.UpdatedHandler#receiveTargetFile(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.ICVSFile, java.lang.String, java.util.Date, boolean, boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void receiveTargetFile(
- Session session,
- ICVSFile mFile,
- String entryLine,
- Date modTime,
- boolean binary,
- boolean readOnly,
- boolean executable,
- IProgressMonitor monitor)
- throws CVSException {
-
- // Set the sync info first so that the contents are cached properly
- ResourceSyncInfo info = new ResourceSyncInfo(entryLine, modTime);
- // We're always excepting new revisions so the file is clean
- mFile.setSyncInfo(info, ICVSFile.CLEAN);
-
- // receive the file contents from the server
- session.receiveFile(mFile, binary, getHandlerType(), monitor);
-
- // Handle execute
- try {
- if (executable) mFile.setExecutable(true);
- } catch (CVSException e) {
- // Just log and keep going
- CVSProviderPlugin.log(e);
- }
- }
- }
-
- public static RemoteFolder buildRemoteTree(final CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag, int depth, IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(null, 100);
- try {
- RemoteFolder tree = buildBaseTree(repository, root, tag, Policy.subMonitorFor(monitor, 50));
- UpdateContentCachingService service = new UpdateContentCachingService(repository, tree, tag, depth);
- service.setFetchAbsentDirectories(getFetchAbsentDirectories(root));
- if (!service.cacheFileContents(Policy.subMonitorFor(monitor, 50)))
- return null;
- return tree;
- } finally {
- monitor.done();
- }
- }
-
- private void setFetchAbsentDirectories(boolean fetchAbsentDirectories) {
- this.fetchAbsentDirectories = fetchAbsentDirectories;
- }
-
- private static boolean getFetchAbsentDirectories(ICVSFolder root) {
- IResource resource = root.getIResource();
- if (resource != null) {
- IProject project = resource.getProject();
- RepositoryProvider provider = RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId());
- if (provider instanceof CVSTeamProvider) {
- CVSTeamProvider cp = (CVSTeamProvider) provider;
- try {
- return cp.getFetchAbsentDirectories();
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- }
- }
- return CVSProviderPlugin.getPlugin().getFetchAbsentDirectories();
- }
-
- private static RemoteFolder buildBaseTree(final CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag, IProgressMonitor progress) throws CVSException {
- try {
- RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, root, tag) {
- protected RemoteFolder createRemoteFolder(ICVSFolder local, RemoteFolder parent, FolderSyncInfo folderSyncInfo) {
- return new RemoteFolderSandbox(parent, local.getName(), repository, folderSyncInfo.getRepository(), folderSyncInfo.getTag(), folderSyncInfo.getIsStatic());
- }
- protected RemoteFile createRemoteFile(RemoteFolder remote, byte[] syncBytes) throws CVSException {
- return new RemoteFile(remote, syncBytes){
- public boolean isModified(IProgressMonitor monitor) throws CVSException {
- return false;
- }
- public void delete() {
- RemoteFolderSandbox parent = (RemoteFolderSandbox)getParent();
- parent.remove(this);
- }
- };
- }
- protected boolean isPruneEmptyDirectories() {
- return true;
- }
- };
- progress.beginTask(null, 100);
- IProgressMonitor subProgress = Policy.infiniteSubMonitorFor(progress, 100);
- subProgress.beginTask(null, 512);
- subProgress.subTask(NLS.bind(CVSMessages.RemoteFolderTreeBuilder_buildingBase, new String[] { root.getName() }));
- RemoteFolder tree = builder.buildBaseTree(null, root, subProgress);
- if (tree == null) {
- // The local tree is empty and was pruned.
- // Return the root folder so that the operation can proceed
- FolderSyncInfo folderSyncInfo = root.getFolderSyncInfo();
- if (folderSyncInfo == null) return null;
- return new RemoteFolderSandbox(null, root.getName(), repository, folderSyncInfo.getRepository(), folderSyncInfo.getTag(), folderSyncInfo.getIsStatic());
- }
- return tree;
- } finally {
- progress.done();
- }
- }
-
- public static RemoteFile buildRemoteTree(CVSRepositoryLocation repository, ICVSFile file, CVSTag tag, IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(null, 100);
- try {
- RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, file.getParent(), tag);
- RemoteFile remote = builder.buildTree(file, Policy.subMonitorFor(monitor, 10));
-
- if (remote == null)
- return null;
-
- byte[] syncBytes = remote.getSyncBytes();
- if (builder.getFileDiffs().length > 0) {
- // Getting the storage of the file will cache the contents
- remote.getStorage(Policy.subMonitorFor(monitor, 90));
- }
- // We need to set the sync bytes back because the content fetch
- // makes the handle sticky
- remote.setSyncBytes(syncBytes, ICVSFile.CLEAN);
- return remote;
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- } finally {
- monitor.done();
- }
- }
-
- public UpdateContentCachingService(CVSRepositoryLocation repository, RemoteFolder tree, CVSTag tag, int depth) {
- this.repository = repository;
- this.remoteRoot = tree;
- this.tag = tag;
- this.depth = depth;
- }
-
- private boolean cacheFileContents(IProgressMonitor monitor) throws CVSException {
- // Fetch the file contents for all out-of-sync files by running an update
- // on the remote tree passing the known changed files as arguments
- monitor.beginTask(null, 100);
- Policy.checkCanceled(monitor);
- Session session = new Session(repository, remoteRoot, false);
- session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */);
- try {
- Policy.checkCanceled(monitor);
- IStatus status = new SandboxUpdate().execute(session,
- Command.NO_GLOBAL_OPTIONS,
- getLocalOptions(),
- new String[] { Session.CURRENT_LOCAL_FOLDER },
- new UpdateListener(this),
- Policy.subMonitorFor(monitor, 90));
- if (!status.isOK()) {
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- CVSServerException e = new CVSServerException(status);
- if ( ! e.isNoTagException() && e.containsErrors())
- throw e;
- return false;
- } else if (status.getSeverity() == IStatus.ERROR && isReportableError(status)) {
- throw new CVSException(status);
- }
- }
- for (Iterator iterator = removed.iterator(); iterator.hasNext();) {
- ICVSResource resource = (ICVSResource) iterator.next();
- if (resource.exists())
- resource.delete();
- }
- } finally {
- session.close();
- monitor.done();
- }
- return true;
- }
-
- private boolean isReportableError(IStatus status) {
- return CVSStatus.isInternalError(status)
- || status.getCode() == TeamException.UNABLE
- || status.getCode() == CVSStatus.INVALID_LOCAL_RESOURCE_PATH
- || status.getCode() == CVSStatus.RESPONSE_HANDLING_FAILURE;
- }
-
- private LocalOption[] getLocalOptions() {
- ArrayList options = new ArrayList();
- if (tag != null)
- options.add(Update.makeTagOption(tag));
-
- if (depth != IResource.DEPTH_INFINITE )
- options.add(Command.DO_NOT_RECURSE);
-
- if (fetchAbsentDirectories)
- options.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
-
- if (!options.isEmpty())
- return (LocalOption[]) options.toArray(new LocalOption[options.size()]);
-
- return Command.NO_LOCAL_OPTIONS;
- }
-
- public void directoryDoesNotExist(ICVSFolder commandRoot, String path) {
- try {
- removed.add(commandRoot.getChild(path));
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- }
-
- public void directoryInformation(ICVSFolder commandRoot, String path,
- boolean newDirectory) {
- // Nothing to do
- }
-
- public void fileDoesNotExist(ICVSFolder parent, String filename) {
- try {
- removed.add(parent.getChild(filename));
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- }
-
- public void fileInformation(int type, ICVSFolder parent, String filename) {
- // Nothing to do
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaserevInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaserevInfo.java
deleted file mode 100644
index 9b6dbb42a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaserevInfo.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * This class represents the information in the CVS/Baserev file
- */
-public class BaserevInfo {
- private static final String BASEREV_PREFIX = "B"; //$NON-NLS-1$
-
- private String name;
- private String revision;
-
- public BaserevInfo(String entryLine) throws CVSException {
- setEntryLine(entryLine);
- }
-
- public BaserevInfo(String name, String revision) {
- this.name = name;
- this.revision = revision;
- }
- /**
- * Return the entry line as it appears in the CVS/Baserev file
- * @return String
- */
- public String getEntryLine() {
- StringBuffer result = new StringBuffer();
- result.append(BASEREV_PREFIX);
- result.append(name);
- result.append(ResourceSyncInfo.SEPARATOR);
- result.append(revision);
- result.append(ResourceSyncInfo.SEPARATOR);
- return result.toString();
- }
- private void setEntryLine(String entryLine) throws CVSException {
- if(entryLine.startsWith(BASEREV_PREFIX)) {
- entryLine = entryLine.substring(1);
- }
- String[] strings = Util.parseIntoSubstrings(entryLine, ResourceSyncInfo.SEPARATOR);
- // Accept either a length of 2 or 3. If the length is 3, we ignore the last
- // string as per the CVS spec.
- if(strings.length != 2 && strings.length != 3) {
- IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.BaseRevInfo_malformedEntryLine, new String[] { entryLine }));
- throw new CVSException(status);
- }
-
- name = strings[0];
-
- if(name.length()==0) {
- IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.BaseRevInfo_malformedEntryLine, new String[] { entryLine }));
- throw new CVSException(status);
- }
-
- revision = strings[1];
-
- if(revision.length()==0) {
- IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.BaseRevInfo_malformedEntryLine, new String[] { entryLine }));
- throw new CVSException(status);
- }
- }
- /**
- * Returns the name.
- * @return String
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns the revision.
- * @return String
- */
- public String getRevision() {
- return revision;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSBaseResourceVariantTree.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSBaseResourceVariantTree.java
deleted file mode 100644
index 23348c7cd..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSBaseResourceVariantTree.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.variants.ResourceVariantByteStore;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-
-
-public class CVSBaseResourceVariantTree extends ResourceVariantByteStore {
- public void dispose() {
- // Do nothing
- }
- public byte[] getBytes(IResource resource) throws TeamException {
- if (resource.getType() == IResource.FILE) {
- // For a file, return the entry line
- byte[] bytes = EclipseSynchronizer.getInstance().getSyncBytes(resource);
- if (bytes != null) {
- // Use the base sync info (i.e. no deletion or addition)
- if (ResourceSyncInfo.isDeletion(bytes)) {
- bytes = ResourceSyncInfo.convertFromDeletion(bytes);
- } else if (ResourceSyncInfo.isAddition(bytes)) {
- bytes = null;
- }
- }
- return bytes;
- } else {
- // For a folder, return the folder sync info bytes
- FolderSyncInfo info = EclipseSynchronizer.getInstance().getFolderSync((IContainer)resource);
- if (info == null) return null;
- return info.getBytes();
- }
- }
- public boolean isVariantKnown(IResource resource) throws TeamException {
- return getBytes(resource) != null;
- }
- public boolean flushBytes(IResource resource, int depth) throws TeamException {
- throw new UnsupportedOperationException();
- }
- public boolean setBytes(IResource resource, byte[] bytes) throws TeamException {
- throw new UnsupportedOperationException();
- }
- public boolean deleteBytes(IResource resource) throws TeamException {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.utils.SynchronizationCache#members(org.eclipse.core.resources.IResource)
- */
- public IResource[] members(IResource resource) throws TeamException {
- if(resource.getType() == IResource.FILE) {
- return new IResource[0];
- }
- return EclipseSynchronizer.getInstance().members((IContainer)resource);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSDescendantResourceVariantByteStore.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSDescendantResourceVariantByteStore.java
deleted file mode 100644
index 36c800396..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSDescendantResourceVariantByteStore.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.variants.PersistantResourceVariantByteStore;
-import org.eclipse.team.core.variants.ResourceVariantByteStore;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.core.subscribers.DescendantResourceVariantByteStore;
-
-/**
- * CVS sycnrhonization cache that ignores stale remote bytes
- */
-public class CVSDescendantResourceVariantByteStore extends DescendantResourceVariantByteStore {
-
- public CVSDescendantResourceVariantByteStore(ResourceVariantByteStore baseCache, PersistantResourceVariantByteStore remoteCache) {
- super(baseCache, remoteCache);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.DescendantSynchronizationCache#isDescendant(org.eclipse.core.resources.IResource, byte[], byte[])
- */
- protected boolean isDescendant(IResource resource, byte[] baseBytes, byte[] remoteBytes) throws TeamException {
- if (resource.getType() != IResource.FILE) return true;
- try {
- return ResourceSyncInfo.isLaterRevisionOnSameBranch(remoteBytes, baseBytes);
- } catch (CVSException e) {
- throw TeamException.asTeamException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.helpers.SynchronizationCache#setSyncBytes(org.eclipse.core.resources.IResource, byte[])
- */
- public boolean setBytes(IResource resource, byte[] bytes) throws TeamException {
- boolean changed = super.setBytes(resource, bytes);
- if (resource.getType() == IResource.FILE && getBytes(resource) != null && !parentHasSyncBytes(resource)) {
- // Log a warning if there is no sync bytes available for the resource's
- // parent but there is valid sync bytes for the child
- CVSProviderPlugin.log(new TeamException(NLS.bind(CVSMessages.ResourceSynchronizer_missingParentBytesOnSet, new String[] { ((PersistantResourceVariantByteStore)getRemoteStore()).getSyncName().toString(), resource.getFullPath().toString() })));
- }
- return changed;
- }
-
- /**
- * Indicates whether the parent of the given local resource has sync bytes for its
- * corresponding remote resource. The parent bytes of a remote resource are required
- * (by CVS) to create a handle to the remote resource.
- */
- protected boolean parentHasSyncBytes(IResource resource) throws TeamException {
- if (resource.getType() == IResource.PROJECT) return true;
- return (getBytes(resource.getParent()) != null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.core.subscribers.caches.ResourceVariantByteStore#isVariantKnown(org.eclipse.core.resources.IResource)
- */
- public boolean isVariantKnown(IResource resource) throws TeamException {
- return ((PersistantResourceVariantByteStore)getRemoteStore()).isVariantKnown(resource);
- }
-
- /*
- * TODO: Could possibly be generalized and moved up
- */
- public IStatus handleResourceChanges(IResource[] changedResources, boolean canModifyWorkspace) {
- // IMPORTANT NOTE: This will throw exceptions if performed during the POST_CHANGE delta phase!!!
- List errors = new ArrayList();
- for (int i = 0; i < changedResources.length; i++) {
- IResource resource = changedResources[i];
- try {
- if (!isInCVSProject(resource)) continue;
- if (resource.getType() == IResource.FILE
- && (resource.exists() || resource.isPhantom())) {
- byte[] remoteBytes = getBytes(resource);
- if (remoteBytes == null) {
- if (isVariantKnown(resource)) {
- // The remote is known not to exist. If the local resource is
- // managed then this information is stale
- if (getBaseStore().getBytes(resource) != null) {
- if (canModifyWorkspace) {
- flushBytes(resource, IResource.DEPTH_ZERO);
- } else {
- // The revision comparison will handle the stale sync bytes
- // TODO: Unless the remote is known not to exist (see bug 52936)
- }
- }
- }
- } else {
- byte[] localBytes = getBaseStore().getBytes(resource);
- if (localBytes == null || !isDescendant(resource, localBytes, remoteBytes)) {
- if (canModifyWorkspace) {
- flushBytes(resource, IResource.DEPTH_ZERO);
- } else {
- // The remote byte store handles the stale sync bytes
- }
- }
- }
- } else if (resource.getType() == IResource.FOLDER) {
- // If the base has sync info for the folder, purge the remote bytes
- if (getBaseStore().getBytes(resource) != null && canModifyWorkspace) {
- flushBytes(resource, IResource.DEPTH_ZERO);
- }
- }
- } catch (TeamException e) {
- errors.add(e);
- }
- }
- for (Iterator iter = errors.iterator(); iter.hasNext();) {
- TeamException e = (TeamException) iter.next();
- CVSProviderPlugin.log(e);
- }
- return Status.OK_STATUS; // TODO
- }
-
- private boolean isInCVSProject(IResource resource) {
- return RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) != null;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSResourceVariantTree.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSResourceVariantTree.java
deleted file mode 100644
index 39ececcfa..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSResourceVariantTree.java
+++ /dev/null
@@ -1,402 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.variants.*;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.*;
-
-/**
- * CVS Specific refresh operation
- */
-public class CVSResourceVariantTree extends ResourceVariantTree {
-
- private CVSTag tag;
- private boolean cacheFileContentsHint;
- private CVSSyncTreeSubscriber subscriber;
-
- public CVSResourceVariantTree(ResourceVariantByteStore cache, CVSTag tag, boolean cacheFileContentsHint) {
- super(cache);
- this.tag = tag;
- this.cacheFileContentsHint = cacheFileContentsHint;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.RefreshOperation#getSynchronizationCache()
- */
- public ResourceVariantByteStore getByteStore() {
- return super.getByteStore();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.RefreshOperation#getRemoteSyncBytes(org.eclipse.core.resources.IResource, org.eclipse.team.core.subscribers.ISubscriberResource)
- */
- protected byte[] getBytes(IResource local, IResourceVariant remote) throws TeamException {
- if (remote != null) {
- return super.getBytes(local, remote);
- } else {
- if (local.getType() == IResource.FOLDER) {
- // If there is no remote, use the local sync for the folder
- return getBaseBytes((IContainer)local, getTag(local));
- }
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.RefreshOperation#getRemoteChildren(org.eclipse.team.core.subscribers.ISubscriberResource, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IResourceVariant[] fetchMembers(IResourceVariant remote, IProgressMonitor progress) throws TeamException {
- ICVSRemoteResource[] children = remote != null ? (ICVSRemoteResource[])((RemoteResource)remote).members(progress) : new ICVSRemoteResource[0];
- IResourceVariant[] result = new IResourceVariant[children.length];
- for (int i = 0; i < children.length; i++) {
- result[i] = (IResourceVariant)children[i];
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.RefreshOperation#buildRemoteTree(org.eclipse.core.resources.IResource, int, boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IResourceVariant fetchVariant(IResource resource, int depth, IProgressMonitor monitor) throws TeamException {
- return (IResourceVariant)CVSWorkspaceRoot.getRemoteTree(resource, getTag(resource), isCacheFileContentsHint(), depth, monitor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.core.subscribers.caches.ResourceVariantTreeRefreshOperation#collectChanges(org.eclipse.core.resources.IResource, org.eclipse.team.core.synchronize.IResourceVariant, int, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IResource[] collectChanges(IResource local,
- IResourceVariant remote, int depth, IProgressMonitor monitor)
- throws TeamException {
- return super.collectChanges(local, remote, depth, monitor);
- }
-
- public IResource[] members(IResource resource) throws TeamException {
- if (resource.getType() == IResource.FILE) {
- return new IResource[0];
- }
- // Must ensure that any shared folders are included
- Set members = new HashSet();
- members.addAll(Arrays.asList(super.members(resource)));
- try {
- IResource[] localMembers = EclipseSynchronizer.getInstance().members((IContainer) resource); //((IContainer)resource).members(true);
- for (int i = 0; i < localMembers.length; i++) {
- IResource local = localMembers[i];
- if (local.getType() != IResource.FILE) {
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)local);
- if (folder.isCVSFolder()) {
- members.add(local);
- }
- }
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- return (IResource[]) members.toArray(new IResource[members.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.core.subscribers.caches.IResourceVariantTree#roots()
- */
- public IResource[] roots() {
- return subscriber.roots();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.core.subscribers.caches.IResourceVariantTree#getResourceVariant(org.eclipse.core.resources.IResource)
- */
- public IResourceVariant getResourceVariant(IResource resource) throws TeamException {
- byte[] remoteBytes = getByteStore().getBytes(resource);
- if (remoteBytes == null) {
- // There is no remote handle for this resource
- return null;
- } else {
- if (resource.getType() == IResource.FILE) {
- byte[] parentBytes = getParentBytes(resource);
- if (parentBytes == null) {
- IProject project = resource.getProject();
- if (project.exists() && RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()) != null) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR,NLS.bind(CVSMessages.ResourceSynchronizer_missingParentBytesOnGet, new String[] { getSyncName(getByteStore()).toString(), resource.getFullPath().toString() }),resource);
- CVSProviderPlugin.log(status);
- // Assume there is no remote and the problem is a programming error
- }
- return null;
- }
- return RemoteFile.fromBytes(resource, remoteBytes, parentBytes);
- } else {
- return RemoteFolder.fromBytes(resource, remoteBytes);
- }
- }
- }
-
- private String getSyncName(ResourceVariantByteStore cache) {
- if (cache instanceof PersistantResourceVariantByteStore) {
- return ((PersistantResourceVariantByteStore)cache).getSyncName().toString();
- }
- return cache.getClass().getName();
- }
-
-
- private byte[] getParentBytes(IResource resource) throws TeamException {
- IContainer parent = resource.getParent();
- byte[] bytes = getByteStore().getBytes(parent);
- if (bytes == null ) {
- bytes = getBaseBytes(parent, getTag(resource));
- }
- return bytes;
- }
-
- private byte[] getBaseBytes(IContainer parent, CVSTag tag) throws CVSException {
- byte[] bytes;
- // Look locally for the folder bytes
- ICVSFolder local = CVSWorkspaceRoot.getCVSFolderFor(parent);
- FolderSyncInfo info = local.getFolderSyncInfo();
- if (info == null) {
- bytes = null;
- } else {
- // Use the folder sync from the workspace and the tag from the store
- MutableFolderSyncInfo newInfo = info.cloneMutable();
- newInfo.setTag(tag);
- newInfo.setStatic(false);
- bytes = newInfo.getBytes();
- }
- return bytes;
- }
-
- private boolean hasLocalSyncInfo(IContainer folder) {
- ICVSFolder local = CVSWorkspaceRoot.getCVSFolderFor(folder);
- try {
- return local.getFolderSyncInfo() != null;
- } catch (CVSException e) {
- // Say that there is sync info and let the failure occur elsewhere
- return true;
- }
- }
-
- public CVSTag getTag(IResource resource) {
- return tag;
- }
-
- /**
- * Dispose of the underlying byte store
- */
- public void dispose() {
- getByteStore().dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.core.subscribers.caches.ResourceVariantTree#setVariant(org.eclipse.core.resources.IResource, org.eclipse.team.core.synchronize.IResourceVariant)
- */
- protected boolean setVariant(IResource local, IResourceVariant remote) throws TeamException {
- if (local.getType() == IResource.FOLDER && remote != null
- && !hasLocalSyncInfo((IFolder)local)
- && hasLocalSyncInfo(local.getParent())) {
- // Manage the folder locally since folders exist in all versions, etc
- // Use the info from the remote except get the tag from the local parent
- CVSTag tag = CVSWorkspaceRoot.getCVSFolderFor(local.getParent()).getFolderSyncInfo().getTag();
- FolderSyncInfo info = null;
- try{
- info = FolderSyncInfo.getFolderSyncInfo(remote.asBytes());
- } catch (CVSException e){
- Status status = new Status(Status.ERROR, CVSProviderPlugin.ID,
- NLS.bind(CVSMessages.CVSResourceVariantTree_GettingSyncInfoError, local.getProjectRelativePath().toString()),
- e);
- throw new CVSException(status);
- }
- MutableFolderSyncInfo newInfo = info.cloneMutable();
- newInfo.setTag(tag);
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IFolder)local);
- cvsFolder.setFolderSyncInfo(newInfo);
- }
- if (remote == null && !isManaged(local)) {
- // Do not record the lack of existence of a remote for unmanaged local files
- // Instead, just flush the remote bytes if there are any
- boolean changed = getByteStore().getBytes(local) != null;
- flushVariants(local, IResource.DEPTH_ZERO);
- return changed;
- } else {
- boolean changed = super.setVariant(local, remote);
- if (local.getType() == IResource.FILE && getByteStore().getBytes(local) != null && !parentHasSyncBytes(local)) {
- // Log a warning if there is no sync bytes available for the resource's
- // parent but there is valid sync bytes for the child
- CVSProviderPlugin.log(new TeamException(NLS.bind(CVSMessages.ResourceSynchronizer_missingParentBytesOnSet, new String[] { getSyncName(getByteStore()), local.getFullPath().toString() })));
- }
- return changed;
- }
- }
-
- private boolean isManaged(IResource local) {
- try {
- return CVSWorkspaceRoot.getCVSResourceFor(local).isManaged();
- } catch (CVSException e) {
- return false;
- }
- }
-
- private boolean parentHasSyncBytes(IResource resource) throws TeamException {
- if (resource.getType() == IResource.PROJECT) return true;
- return getParentBytes(resource) != null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.core.subscribers.caches.AbstractResourceVariantTree#collectedMembers(org.eclipse.core.resources.IResource, org.eclipse.core.resources.IResource[])
- */
- protected IResource[] collectedMembers(IResource local, IResource[] members) throws TeamException {
- // Look for resources that have sync bytes but are not in the resources we care about
- IResource[] resources = getStoredMembers(local);
- List children = new ArrayList();
- List changedResources = new ArrayList();
- children.addAll(Arrays.asList(members));
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if (!children.contains(resource)) {
- // These sync bytes are stale. Purge them
- flushVariants(resource, IResource.DEPTH_INFINITE);
- changedResources.add(resource);
- }
- }
- return (IResource[]) changedResources.toArray(new IResource[changedResources.size()]);
- }
-
- /**
- * Return all the members of that have resource variant information associated with them,
- * such as members that are explicitly flagged as not having a resource variant. This list
- * is used by the collection algorithm to flush variants for which there is no local and
- * no remote.
- * @param local the locla resource
- * @return the local children that have resource variant information cached
- * @throws TeamException
- */
- private IResource[] getStoredMembers(IResource local) throws TeamException {
- try {
- if (local.getType() != IResource.FILE && (local.exists() || local.isPhantom())) {
- IResource[] allChildren = ((IContainer)local).members(true /* include phantoms */);
- List childrenWithSyncBytes = new ArrayList();
- for (int i = 0; i < allChildren.length; i++) {
- IResource resource = allChildren[i];
- if (getByteStore().getBytes(resource) != null) {
- childrenWithSyncBytes.add(resource);
- }
- }
- return (IResource[]) childrenWithSyncBytes.toArray(
- new IResource[childrenWithSyncBytes.size()]);
- }
- } catch (CoreException e) {
- throw TeamException.asTeamException(e);
- }
- return new IResource[0];
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#refresh(org.eclipse.core.resources.IResource, int, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IResource[] refresh(IResource resource, int depth, IProgressMonitor monitor) throws TeamException {
- IResource[] changedResources = null;
- monitor.beginTask(null, 100);
- // Wait while a build is running
- // Initially wait for a short time and then increase the wait
- // if the build is still running
- int count = 0;
- int waitTime = 10;
- while (count < 15
- && (isJobInFamilyRunning(ResourcesPlugin.FAMILY_AUTO_BUILD)
- || isJobInFamilyRunning(ResourcesPlugin.FAMILY_MANUAL_BUILD))) {
- try {
- Thread.sleep(waitTime);
- } catch (InterruptedException e) {
- // Conitinue
- }
- count++;
- if (count >= 10) {
- waitTime = 1000;
- } else if (count >= 5) {
- waitTime = 100;
- }
- Policy.checkCanceled(monitor);
- }
- try {
- changedResources = super.refresh(resource, depth, Policy.subMonitorFor(monitor, 99));
- } catch (TeamException e) {
- // Try to properly handle exceptions that are due to project modifications
- // performed while the refresh was happening
- if (!resource.getProject().isAccessible()) {
- // The project is closed so silently skip it
- return new IResource[0];
- }
- throw e;
- } finally {
- monitor.done();
- }
- if (changedResources == null) return new IResource[0];
- return changedResources;
- }
-
- private boolean isJobInFamilyRunning(Object family) {
- Job[] jobs = Job.getJobManager().find(family);
- if (jobs != null && jobs.length > 0) {
- for (int i = 0; i < jobs.length; i++) {
- Job job = jobs[i];
- if (job.getState() != Job.NONE) {
- return true;
- }
- }
- }
- return false;
- }
-
-
- public ICVSRemoteResource buildTree(RemoteFolderTree parent, IResource resource, boolean immutable, IProgressMonitor monitor) throws TeamException {
-
- Policy.checkCanceled(monitor);
-
- byte[] remoteBytes = getByteStore().getBytes(resource);
- if (remoteBytes == null) {
- // There is no remote handle for this resource
- return null;
- }
-
- if (resource.getType() == IResource.FILE) {
- if (immutable) {
- remoteBytes = ResourceSyncInfo.setTag(remoteBytes, new CVSTag(ResourceSyncInfo.getRevision(remoteBytes), CVSTag.VERSION));
- }
- if (parent == null) {
- return (ICVSRemoteResource)getResourceVariant(resource);
- }
- return new RemoteFile(parent, remoteBytes);
- } else {
- RemoteFolderTree remote = RemoteFolderTree.fromBytes(parent, resource, remoteBytes);
- IResource[] members = members(resource);
- List children = new ArrayList();
- for (int i = 0; i < members.length; i++) {
- IResource member = members[i];
- ICVSRemoteResource child = buildTree(remote, member, immutable, monitor);
- if (child != null)
- children.add(child);
- }
-
- // Add the children to the remote folder tree
- remote.setChildren((ICVSRemoteResource[])children.toArray(new ICVSRemoteResource[children.size()]));
- return remote;
- }
- }
-
- public boolean isCacheFileContentsHint() {
- return cacheFileContentsHint;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java
deleted file mode 100644
index 137b233f0..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.core.BackgroundEventHandler;
-
-/**
- * This class handles resources changes that are reported in deltas
- * in a deferred manner (i.e. in a background job)
- */
-public class DeferredResourceChangeHandler extends BackgroundEventHandler {
-
- public DeferredResourceChangeHandler() {
- super(CVSMessages.DeferredResourceChangeHandler_0, CVSMessages.DeferredResourceChangeHandler_1);
- }
-
- private static final int IGNORE_FILE_CHANGED = 1;
- private static final int RECREATED_CVS_RESOURCE = 2;
- private static final int CONFLICTING_DELETION =3;
-
- private Set changedIgnoreFiles = new HashSet();
- private Set recreatedResources = new HashSet();
- private Set conflictingDeletion = new HashSet();
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.BackgroundEventHandler#processEvent(org.eclipse.team.core.subscribers.BackgroundEventHandler.Event, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void processEvent(Event event, IProgressMonitor monitor) throws TeamException {
- int type = event.getType();
- switch (type) {
- case IGNORE_FILE_CHANGED :
- changedIgnoreFiles.add(event.getResource());
- break;
- case RECREATED_CVS_RESOURCE :
- recreatedResources.add(event.getResource());
- break;
- case CONFLICTING_DELETION :
- conflictingDeletion.add(event.getResource());
- break;
- }
- }
-
- private IContainer[] getParents(Set files) {
- Set parents = new HashSet();
- for (Iterator iter = files.iterator(); iter.hasNext();) {
- IFile file = (IFile) iter.next();
- parents.add(file.getParent());
- }
- return (IContainer[]) parents.toArray(new IContainer[parents.size()]);
- }
-
- public void ignoreFileChanged(IFile file) {
- if (isSharedWithCVS(file))
- queueEvent(new ResourceEvent(file, IGNORE_FILE_CHANGED, IResource.DEPTH_ZERO), false);
- }
-
- /**
- * The resource has been added and has sync info that has not been written to disk.
- * Queue an event to ensure that the CVS directory files
- * are written to disk.
- * @param resource the recently add resource
- */
- public void recreated(IResource resource) {
- if (isSharedWithCVS(resource))
- queueEvent(new ResourceEvent(resource, RECREATED_CVS_RESOURCE, IResource.DEPTH_ZERO), false);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.BackgroundEventHandler#dispatchEvents()
- */
- protected boolean doDispatchEvents(IProgressMonitor monitor) {
- // Handle ignore file changes
- boolean workDone = !changedIgnoreFiles.isEmpty() || !recreatedResources.isEmpty();
- try {
- EclipseSynchronizer.getInstance().ignoreFilesChanged(getParents(changedIgnoreFiles));
- } catch (CVSException e) {
- // Log and continue
- CVSProviderPlugin.log(e);
- }
- changedIgnoreFiles.clear();
- // Handle recreations by project to reduce locking granularity
- Map recreations = getResourcesByProject((IResource[]) recreatedResources.toArray(new IResource[recreatedResources.size()]));
- recreatedResources.clear();
- for (Iterator iter = recreations.values().iterator(); iter.hasNext();) {
- List resources = (List) iter.next();
- try {
- EclipseSynchronizer.getInstance().resourcesRecreated((IResource[]) resources.toArray(new IResource[resources.size()]), monitor);
- } catch (CVSException e) {
- // Log and continue
- CVSProviderPlugin.log(e);
- }
- }
- IResource[] deletions = (IResource[]) conflictingDeletion.toArray(new IResource[conflictingDeletion.size()]);
- conflictingDeletion.clear();
- for (int i = 0; i < deletions.length; i++) {
- IResource resource = deletions[i];
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- try {
- if(!cvsResource.isFolder() && cvsResource.isManaged()) {
- cvsResource.unmanage(monitor);
- }
- } catch (CVSException e) {
- // Log and continue
- CVSProviderPlugin.log(e);
- }
- }
- return workDone;
- }
-
- private Map getResourcesByProject(IResource[] resources) {
- Map result = new HashMap();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- IProject project = resource.getProject();
- List projectResources = (List)result.get(project);
- if (projectResources == null) {
- projectResources = new ArrayList();
- result.put(project, projectResources);
- }
- projectResources.add(resource);
- }
- return result;
- }
-
- public void handleConflictingDeletion(IResource local) {
- if (isSharedWithCVS(local))
- queueEvent(new ResourceEvent(local, CONFLICTING_DELETION, IResource.DEPTH_ZERO), false);
- }
-
- private boolean isSharedWithCVS(IResource resource) {
- return CVSTeamProvider.isSharedWithCVS(resource.getProject());
- }
-
- protected Object getJobFamiliy() {
- return this;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java
deleted file mode 100644
index 8daa85681..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-
-import java.io.*;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * Value (immutable) object that represents workspace state information about the contents of a
- * folder that was retreived from a CVS repository. It is a specialized representation of the files from
- * the CVS sub-directory that contain folder specific connection information (e.g. Root, Repository, Tag).
- *
- * @see ICVSFolder#getFolderSyncInfo()
- */
-public class FolderSyncInfo {
-
- // The Repository value for virtual directories (i.e. local with no corresponding remote)
- public static final String VIRTUAL_DIRECTORY = "CVSROOT/Emptydir"; //$NON-NLS-1$
-
- // relative path of this folder in the repository, project1/folder1/folder2
- protected String repository;
-
- // :pserver:user@host:/home/user/repo
- protected String root;
-
- // sticky tag (e.g. version, date, or branch tag applied to folder)
- private CVSEntryLineTag tag;
-
- // if true then it means only part of the folder was fetched from the repository, and CVS will not create
- // additional files in that folder.
- protected boolean isStatic;
-
- /**
- * Construct a folder sync object.
- *
- * @param repo the relative path of this folder in the repository, cannot be <code>null</code>.
- * @param root the location of the repository, cannot be <code>null</code>.
- * @param tag the tag set for the folder or <code>null</code> if there is no tag applied.
- * @param isStatic to indicate is only part of the folder was fetched from the server.
- */
- public FolderSyncInfo(String repo, String root, CVSTag tag, boolean isStatic) {
- Assert.isNotNull(repo);
- Assert.isNotNull(root);
- this.repository = repo;
- // intern the root so that caching of FolderSyncInfos for folders will use less space
- this.root = root.intern();
- ensureRepositoryRelativeToRoot();
- this.isStatic = isStatic;
- setTag(tag);
- }
-
- /**
- * Method ensureRepositoryRelativeToRoot.
- */
- private void ensureRepositoryRelativeToRoot() {
- String rootDir;
- try {
- rootDir = getRootDirectory();
- } catch (CVSException e) {
- // Ignore the for now. Using the root will show the error to the user.
- return;
- }
- if (repository.startsWith(rootDir)) {
- repository = repository.substring(rootDir.length());
- }
- if (repository.startsWith(ResourceSyncInfo.SEPARATOR)) {
- repository = repository.substring(ResourceSyncInfo.SEPARATOR.length());
- }
- }
-
- public boolean equals(Object other) {
- if(other == this) return true;
- if (!(other instanceof FolderSyncInfo)) return false;
-
- FolderSyncInfo syncInfo = ((FolderSyncInfo)other);
- if (!getRoot().equals(syncInfo.getRoot())) return false;
- if (!getRepository().equals(syncInfo.getRepository())) return false;
- if (getIsStatic() != syncInfo.getIsStatic()) return false;
- if ((getTag() == null) || (syncInfo.getTag() == null)) {
- if ((getTag() == null) && (syncInfo.getTag() != null) && (syncInfo.getTag().getType() != CVSTag.HEAD)) {
- return false;
- } else if ((syncInfo.getTag() == null) && (getTag() != null) && (getTag().getType() != CVSTag.HEAD)) {
- return false;
- }
- } else if (!getTag().equals(syncInfo.getTag())) {
- return false;
- }
- return true;
- }
- /**
- * Gets the root, cannot be <code>null.
- *
- * @return Returns a String
- */
- public String getRoot() {
- return root;
- }
-
- /**
- * Answer the directory portion of the root. For example, if
- * root = :pserver:user@host:/home/user/repo
- * then /home/user/repo is return.
- * <p>
- * The root does not neccesarily contain a user name, in which cas the format is
- * :pserver:host:/home/user/repo.
- *
- *
- * @return String
- */
- private String getRootDirectory() throws CVSException {
- try {
- String root = getRoot();
- int index = root.indexOf(CVSRepositoryLocation.HOST_SEPARATOR);
- if (index == -1) {
- // If the username is missing, we have to find the third ':'.
- index = root.indexOf(CVSRepositoryLocation.COLON);
- if (index == 0) {
- // This indicates that the conection method is present.
- // It is surrounded by two colons so skip them.
- index = root.indexOf(CVSRepositoryLocation.COLON, index + 1);
- index = root.indexOf(CVSRepositoryLocation.COLON, index + 1);
- }
- if (index == -1) {
- // The host colon is missing.
- // Look for a slash to find the path
- index = root.indexOf(ResourceSyncInfo.SEPARATOR);
- // Decrement the index since the slash is part of the path
- if (index != -1) index--;
- }
- } else {
- // If the username was there, we find the first ':' past the '@'
- index = root.indexOf(CVSRepositoryLocation.COLON, index + 1);
- }
- index++;
- // strip off a leading port if there is one
- char c = root.charAt(index);
- while (Character.isDigit(c)) {
- c = root.charAt(++index);
- }
- return root.substring(index);
- } catch (IndexOutOfBoundsException e) {
- IStatus status = new CVSStatus(IStatus.ERROR,CVSMessages.FolderSyncInfo_Maleformed_root_4, e);
- throw new CVSException(status);
- }
- }
-
- /**
- * Gets the tag, may be <code>null</code>.
- *
- * @return Returns a String
- */
- public CVSEntryLineTag getTag() {
- return tag;
- }
-
- /**
- * Gets the repository, may be <code>null</code>.
- *
- * @return Returns a String
- */
- public String getRepository() {
- return repository;
- }
-
- /**
- * Gets the isStatic.
- *
- * @return Returns a boolean
- */
- public boolean getIsStatic() {
- return isStatic;
- }
-
- /**
- * Answers a full path to the folder on the remote server. This by appending the repository to the
- * repository location speficied in the root.
- *
- * Example:
- * root = :pserver:user@host:/home/user/repo
- * repository = folder1/folder2
- *
- * Returns:
- * /home/users/repo/folder1/folder2
- *
- * Note: CVS supports repository root directories that end in a slash (/).
- * For these directories, the remote location must contain two slashes (//)
- * between the root directory and the rest of the path. For example:
- * root = :pserver:user@host:/home/user/repo/
- * repository = folder1/folder2
- * must return:
- * /home/users/repo//folder1/folder2
- *
- * @return the full path of this folder on the server.
- * @throws a CVSException if the root or repository is malformed.
- */
- public String getRemoteLocation() throws CVSException {
- return Util.appendPath(getRootDirectory(), getRepository());
- }
-
- /*
- * Provide a hashCode() method that gaurentees that equal object will have the
- * same hashCode
- */
- public int hashCode() {
- return getRoot().hashCode() | getRepository().hashCode();
- }
-
- /**
- * Sets the tag for the folder.
- *
- * @param tag The tag to set
- */
- protected void setTag(CVSTag tag) {
- if (tag == null || tag.equals(CVSTag.DEFAULT)) {
- this.tag = null;
- } else {
- this.tag = new CVSEntryLineTag(tag);
- }
- }
- /*
- * @see Object#toString()
- */
- public String toString() {
- return getRoot() + "/" + getRepository() + "/" + getTag(); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public MutableFolderSyncInfo cloneMutable() {
- MutableFolderSyncInfo newSync = new MutableFolderSyncInfo(this);
- return newSync;
- }
-
- /**
- * Return true if this FolderSyncInfo is mapped to the same remote directory
- * as the other FolderSyncInfo passed as a parameter.
- *
- * @param remoteInfo
- * @return
- */
- public boolean isSameMapping(FolderSyncInfo other) {
- if (other == null) return false;
- return (this.getRoot().equals(other.getRoot())
- && this.getRepository().equals(other.getRepository())) ;
- }
-
-/**
- * Convert a FolderSyncInfo into a byte array that can be stored
- * in the workspace synchronizer
- */
- public byte[] getBytes() throws CVSException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- DataOutputStream dos = new DataOutputStream(out);
- try {
- dos.writeUTF(getRoot());
- dos.writeUTF(getRepository());
- CVSEntryLineTag t = getTag();
- if (t == null) {
- dos.writeUTF(""); //$NON-NLS-1$
- } else {
- dos.writeUTF(t.toString());
- }
- dos.writeBoolean(getIsStatic());
- dos.close();
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- return out.toByteArray();
- }
-
- /**
- * Convert a byte array that was created using getBytes(FolderSyncInfo)
- * into a FolderSyncInfo
- */
- public static FolderSyncInfo getFolderSyncInfo(byte[] bytes) throws CVSException {
- Assert.isNotNull(bytes, "getFolderSyncInfo cannot be called with null parameter"); //$NON-NLS-1$
- ByteArrayInputStream in = new ByteArrayInputStream(bytes);
- DataInputStream dis = new DataInputStream(in);
- String root;
- String repository;
- CVSEntryLineTag tag;
- boolean isStatic;
- try {
- root = dis.readUTF();
- repository = dis.readUTF();
- String tagName = dis.readUTF();
- if (tagName.length() == 0) {
- tag = null;
- } else {
- tag = new CVSEntryLineTag(tagName);
- }
- isStatic = dis.readBoolean();
- } catch (IOException e) {
- Status status = new Status(Status.ERROR, CVSProviderPlugin.ID, NLS.bind(CVSMessages.FolderSyncInfo_InvalidSyncInfoBytes, new String(bytes)), e);
- CVSException ex = new CVSException(status);
- throw ex;
- }
- return new FolderSyncInfo(repository, root, tag, isStatic);
- }
-
- /**
- * Return whether the local directory is mapped to an existing remote
- * directory or is just a local placeholder for child folders. a return type
- * of <code>true</code> indicates that the local folder is not mapped to a
- * remote folder.
- * @return whether the directory is a local placeholder
- */
- public boolean isVirtualDirectory() {
- return getRepository().equals(VIRTUAL_DIRECTORY);
- }
-
- public FolderSyncInfo asImmutable() {
- return this;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MultiTagResourceVariantTree.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MultiTagResourceVariantTree.java
deleted file mode 100644
index 377d8042d..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MultiTagResourceVariantTree.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.team.core.variants.ResourceVariantByteStore;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-
-/**
- * A CVS resource variant tree that associates a different tag with each root project.
- */
-public class MultiTagResourceVariantTree extends CVSResourceVariantTree {
-
- Map resources = new HashMap();
-
- public MultiTagResourceVariantTree(ResourceVariantByteStore cache, boolean cacheFileContentsHint) {
- super(cache, null, cacheFileContentsHint);
- }
-
- public void addResource(IResource resource, CVSTag tag) {
- Assert.isNotNull(resource);
- Assert.isNotNull(tag);
- resources.put(resource, tag);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.syncinfo.CVSResourceVariantTree#getTag(org.eclipse.core.resources.IResource)
- */
- public CVSTag getTag(IResource resource) {
- return (CVSTag)resources.get(resource);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableFolderSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableFolderSyncInfo.java
deleted file mode 100644
index 84b6e4e7a..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableFolderSyncInfo.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-
-/**
- * Mutable version of FolderSyncInfo. Can be used when either creating a
- * folder sync object from scratch or when modifying an existing
- * <code>FolderSyncInfo</code> instance. Example usage:
- * <pre>
- * FolderSyncInfo info = folder.getFolderSyncInfo();
- * if(info!=null) {
- * MutableFolderSyncInfo newInfo = info.cloneMutable();
- * newInfo.setTag(CVSTag.DEFAULT);
- * folder.setFolderSyncInfo(newInfo);
- * }
- * </pre>
- * @see FolderSyncInfo
- */
-public class MutableFolderSyncInfo extends FolderSyncInfo {
-
- public MutableFolderSyncInfo(FolderSyncInfo info) {
- this(info.getRepository(), info.getRoot(), info.getTag(), info.getIsStatic());
- }
-
- public MutableFolderSyncInfo(String repo, String root, CVSTag tag, boolean isStatic) {
- super(repo, root, tag, isStatic);
- }
-
- public void setTag(CVSTag tag) {
- super.setTag(tag);
- }
-
- public void setRepository(String repository) {
- this.repository = repository;
- }
-
- public void setStatic(boolean isStatic) {
- this.isStatic = isStatic;
- }
-
- public FolderSyncInfo asImmutable() {
- return new FolderSyncInfo(getRepository(), getRoot(), getTag(), getIsStatic());
- }
-
- public void setRoot(String root) {
- this.root = root;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableResourceSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableResourceSyncInfo.java
deleted file mode 100644
index 6e574aef4..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MutableResourceSyncInfo.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-import java.util.Date;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-
-/**
- * Mutable version of ResourceSyncInfo. Can be used when either creating a resource sync
- * object from scratch (e.g. without an entry line) or want to modify an existing
- * <code>ResourceSyncInfo</code> instance. Example usage:
- * <pre>
- * ResourceSyncInfo info = resource.getSyncInfo();
- * if(info!=null) {
- * MutableResourceSyncInfo newInfo = info.cloneMutable();
- * newInfo.setRevision("1.22");
- * resource.setSyncInfo(newInfo);
- * }
- * </pre>
- * @see ResourceSyncInfo
- */
-public class MutableResourceSyncInfo extends ResourceSyncInfo {
-
- protected MutableResourceSyncInfo(ResourceSyncInfo info) {
- this.name = info.getName();
- setRevision(info.getRevision());
- setTag(info.getTag());
- this.timeStamp = info.getTimeStamp();
- this.isDirectory = info.isDirectory();
- this.keywordMode = info.getKeywordMode();
- this.isDeleted = info.isDeleted();
- if(info.isMergedWithConflicts()) {
- setSyncType(TYPE_MERGED_WITH_CONFLICTS);
- } else if(info.isMerged()) {
- setSyncType(TYPE_MERGED);
- } else {
- setSyncType(TYPE_REGULAR);
- }
- }
-
- /**
- * Creates a default sync info, if revision is <code>null</code> then
- * the sync info will be considered in the newly added state.
- */
- public MutableResourceSyncInfo(String name, String revision) {
- Assert.isNotNull(name);
- this.name = name;
- setRevision(revision);
- }
-
- /**
- * Sets the revision.
- * @param revision The revision to set
- */
- public void setRevision(String revision) {
- super.setRevision(revision);
- }
-
- /**
- * Sets the timeStamp.
- * @param timeStamp The timeStamp to set
- */
- public void setTimeStamp(Date timeStamp) {
- this.timeStamp = timeStamp;
- }
-
- /**
- * Sets the timeStamp.
- * @param timeStamp The timeStamp to set
- */
- public void setTimeStamp(Date timeStamp, boolean clearMerged) {
- setTimeStamp(timeStamp);
- if (clearMerged) setSyncType(TYPE_REGULAR);
- }
-
- /**
- * Sets the keywordMode.
- * @param keywordMode The keywordMode to set
- */
- public void setKeywordMode(KSubstOption keywordMode) {
- this.keywordMode = keywordMode;
- }
-
- /**
- * Sets the tag.
- * @param tag The tag to set
- */
- public void setTag(CVSTag tag) {
- super.setTag(tag);
- }
-
- /**
- * Sets the deleted state.
- * @param isDeleted The deleted state of this resource sync
- */
- public void setDeleted(boolean isDeleted) {
- this.isDeleted = isDeleted;;
- }
-
- /**
- * Sets to the added state. The timestamp and other are cleared.
- */
- public void setAdded() {
- setRevision(ADDED_REVISION);
- }
-
- /**
- * Sets that this resource sync is a result of a non-conflicting merge
- */
- public void setMerged() {
- // if already merged state then ignore
- if(syncType==TYPE_REGULAR) {
- this.syncType = TYPE_MERGED;
- }
- }
-
- /**
- * @see org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo#setEntryLine(java.lang.String)
- */
- public void setEntryLine(String entryLine) throws CVSException {
- super.setEntryLine(entryLine);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/NotifyInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/NotifyInfo.java
deleted file mode 100644
index f3e3d27b1..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/NotifyInfo.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.text.ParseException;
-import java.util.Date;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.util.CVSDateFormatter;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * This class contains the information required by the server for edit/unedit.
- */
-public class NotifyInfo {
-
- // constants for the notifiation type and watches
- public static final char EDIT = 'E';
- public static final char UNEDIT = 'U';
- public static final char COMMIT = 'C';
- public static final char[] ALL = new char[] {EDIT, UNEDIT, COMMIT};
-
- protected static final String TAB_SEPARATOR = "\t"; //$NON-NLS-1$
-
- private String filename;
- private char notificationType;
- private Date timeStamp;
- private char[] watches;
-
- /**
- * Constructor for setting all variables
- */
- public NotifyInfo(String filename, char notificationType, Date timeStamp, char[] watches) {
-
- this.filename = filename;
- this.notificationType = notificationType;
- this.timeStamp = timeStamp;
- this.watches = watches;
- }
-
- /**
- * Constructor for a line from the CVS/Notify file
- * @param line
- */
- public NotifyInfo(IContainer parent, String line) throws CVSException {
- String[] strings = Util.parseIntoSubstrings(line, ResourceSyncInfo.SEPARATOR);
- if(strings.length != 4) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR_LINE, NLS.bind(CVSMessages.NotifyInfo_MalformedLine, new String[] { line }), parent);
- throw new CVSException(status);
- }
- this.filename = strings[0];
-
- String type = strings[1];
- if (type.length() != 1) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR_LINE, NLS.bind(CVSMessages.NotifyInfo_MalformedNotificationType, new String[] { line }), parent);
- throw new CVSException(status);
- }
- this.notificationType = type.charAt(0);
-
- String date = strings[2];
- try {
- this.timeStamp = CVSDateFormatter.entryLineToDate(date);
- } catch(ParseException e) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR_LINE, NLS.bind(CVSMessages.NotifyInfo_MalformedNotifyDate, new String[] { line }), parent);
- throw new CVSException(status);
- }
-
- String watchesString = strings[3];
- if (watchesString.length() > 0) {
- this.watches = new char[watchesString.length()];
- for (int i = 0; i < watchesString.length(); i++) {
- watches[i] = watchesString.charAt(i);
- }
- } else {
- this.watches = null;
- }
- }
-
- /**
- * Answer a Sting formatted to be written to the CVS/Notify file.
- *
- * XXX NOTE: This is a guess at the local format. Need to obtain proper format
- *
- * @return String
- */
- public String getNotifyLine() {
- StringBuffer buffer = new StringBuffer();
- buffer.append(getName());
- buffer.append(ResourceSyncInfo.SEPARATOR);
- buffer.append(notificationType);
- buffer.append(ResourceSyncInfo.SEPARATOR);
- buffer.append(CVSDateFormatter.dateToEntryLine(timeStamp));
- buffer.append(ResourceSyncInfo.SEPARATOR);
- if (watches != null) {
- for (int i = 0; i < watches.length; i++) {
- char c = watches[i];
- buffer.append(c);
- }
- }
- return buffer.toString();
- }
-
- /**
- * Answer a Sting formatted to be sent to the server.
- *
- * @return String
- */
- public String getServerLine(ICVSFolder parent) throws CVSException {
- StringBuffer buffer = new StringBuffer();
- buffer.append(notificationType);
- buffer.append(TAB_SEPARATOR);
- buffer.append(getServerTimestamp());
- buffer.append(TAB_SEPARATOR);
- buffer.append(getHost());
- buffer.append(TAB_SEPARATOR);
- buffer.append(getWorkingDirectory(parent));
- buffer.append(TAB_SEPARATOR);
- if (watches != null) {
- for (int i = 0; i < watches.length; i++) {
- char c = watches[i];
- buffer.append(c);
- }
- }
- return buffer.toString();
- }
-
- /**
- * Answer the timestamp in GMT format.
- * @return String
- */
- private String getServerTimestamp() {
- return CVSDateFormatter.dateToNotifyServer(timeStamp);
- }
-
- /**
- * Answer the working directory for the receiver's file. The format
- * is NOT device dependant (i.e. /'s are used as the path separator).
- *
- * @return String
- */
- private String getWorkingDirectory(ICVSFolder parent) throws CVSException {
- return parent.getIResource().getLocation().toString();
- }
-
- /**
- * Answer the host name of the client machine.
- * @return String
- */
- private String getHost() throws CVSException {
- try {
- return InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Answer the name of the file associated with the notification
- * @return String
- */
- public String getName() {
- return filename;
- }
-
- /**
- * Answer the notification type associated with the notification
- * @return char
- */
- public char getNotificationType() {
- return notificationType;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ReentrantLock.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ReentrantLock.java
deleted file mode 100644
index fb9d112ca..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ReentrantLock.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.core.subscribers.BatchingLock;
-
-/**
- * Provides a per-thread nested locking mechanism. A thread can acquire a
- * lock on a specific resource by calling acquire(). Subsequently, acquire() can be called
- * multiple times on the resource or any of its children from within the same thread
- * without blocking. Other threads that try
- * and acquire the lock on those same resources will be blocked until the first
- * thread releases all it's nested locks.
- * <p>
- * The locking is managed by the platform via scheduling rules. This class simply
- * provides the nesting mechnism in order to allow the client to determine when
- * the lock for the thread has been released. Therefore, this lock will block if
- * another thread already locks the same resource.</p>
- */
-public class ReentrantLock extends BatchingLock {
-
- public class CVSThreadInfo extends ThreadInfo{
- private Set changedFolders = new HashSet();
- public CVSThreadInfo(IFlushOperation operation) {
- super(operation);
- }
- public void addChangedFolder(IContainer container) {
- changedFolders.add(container);
- }
- public boolean isEmpty() {
- return changedFolders.isEmpty() && super.isEmpty();
- }
- public IContainer[] getChangedFolders() {
- return (IContainer[]) changedFolders.toArray(new IContainer[changedFolders.size()]);
- }
- public void flush(IProgressMonitor monitor) throws TeamException {
- try {
- super.flush(monitor);
- } finally {
- // We have to clear the resources no matter what since the next attempt
- // to flush may not have an appropriate scheduling rule
- changedFolders.clear();
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.core.subscribers.BatchingLock#createThreadInfo(org.eclipse.team.internal.core.subscribers.BatchingLock.IFlushOperation)
- */
- protected ThreadInfo createThreadInfo(IFlushOperation operation) {
- return new CVSThreadInfo(operation);
- }
-
- public void folderChanged(IContainer folder) {
- CVSThreadInfo info = (CVSThreadInfo)getThreadInfo();
- Assert.isNotNull(info, "Folder changed outside of resource lock"); //$NON-NLS-1$
- info.addChangedFolder(folder);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java
deleted file mode 100644
index fa80490d9..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java
+++ /dev/null
@@ -1,923 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Red Hat Incorporated - is/setExecutable() code
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-
-import java.text.ParseException;
-import java.util.Date;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
-import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
-import org.eclipse.team.internal.ccvs.core.util.CVSDateFormatter;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * Value (immutable) object that represents workspace state information about a resource contained in
- * a CVS repository. It is a specialized representation of a line in the CVS/Entry file with the addition of
- * file permissions.
- * <p>
- * ResourceSyncInfo instances are created from entry lines from the CVS server and from the CVS/Entries
- * file. Although both entry lines have slightly different formats (e.g. timestamps) they can safely be passed
- * to the constructor.</p>
- * <p>
- * A class named <code>MutableResourceSyncInfo</code> can be used to modify an existing resource
- * sync or create sync info without an entry line.</p>
- *
- * Example entry line from the CVS/Entry file:
- *
- * /new.java/1.2/Fri Dec 7 00:17:52 2001/-kb/
- * D/src////
- *
- * @see MutableResourceSyncInfo
- * @see ICVSResource#getSyncInfos()
- */
-public class ResourceSyncInfo {
-
- // [Note: permissions aren't honoured in this current implementation]
- // safe default permissions. Permissions are saved separately so that the correct permissions
- // can be sent back to the server on systems that don't save execute bits (e.g. windows).
- private static final String DEFAULT_PERMISSIONS = "u=rw,g=rw,o=r"; //$NON-NLS-1$
- private static final String DEFAULT_EXECUTABLE_PERMISSIONS = "u=rwx,g=rwx,o=rx"; //$NON-NLS-1$
-
- // file sync information can be associated with a local resource that has been deleted. This is
- // noted by prefixing the revision with this character.
- private static final String DELETED_PREFIX = "-"; //$NON-NLS-1$
- private static final byte DELETED_PREFIX_BYTE = '-';
-
- // revision can be locked in repository using "cvs admin -l<rev>" command
- // entry looks like [M revision 1.2.2.3 locked by: igorf;]
- private static final String LOCKEDBY_SUFFIX = "\tlocked by"; //$NON-NLS-1$
-
- // a sync element with a revision of '0' is considered a new file that has
- // not been comitted to the repo. Is visible so that clients can create sync infos
- // for new files.
- public static final String ADDED_REVISION = "0"; //$NON-NLS-1$
-
- // Timestamp constants used to identify special cases
- protected static final int TYPE_REGULAR = 1;
- protected static final int TYPE_MERGED = 2;
- protected static final int TYPE_MERGED_WITH_CONFLICTS = 3;
-
- protected static final String TIMESTAMP_DUMMY = "dummy timestamp"; //$NON-NLS-1$
- protected static final String TIMESTAMP_MERGED = "Result of merge"; //$NON-NLS-1$
- protected static final String TIMESTAMP_MERGED_WITH_CONFLICT = TIMESTAMP_MERGED + "+"; //$NON-NLS-1$
-
- protected static final String TIMESTAMP_SERVER_MERGED = "+modified"; //$NON-NLS-1$
- protected static final String TIMESTAMP_SERVER_MERGED_WITH_CONFLICT = "+="; //$NON-NLS-1$
-
- // a directory sync info will have nothing more than a name
- protected boolean isDirectory = false;
- protected boolean isDeleted = false;
-
- // utility constants
- protected static final String DIRECTORY_PREFIX = "D"; //$NON-NLS-1$
- protected static final String SEPARATOR = "/"; //$NON-NLS-1$
- protected static final byte SEPARATOR_BYTE = (byte)'/';
-
- // fields describing the synchronization of a resource in CVS parlance
- protected String name;
- protected String revision;
- protected Date timeStamp;
- protected KSubstOption keywordMode;
- protected CVSEntryLineTag tag;
-
- // type of sync
- protected int syncType = TYPE_REGULAR;
- protected ResourceSyncInfo() {
- // Added for use by subclasses
- }
-
- public ResourceSyncInfo(byte[] entryLine) throws CVSException {
- this(new String(entryLine), null);
- }
-
- /**
- * Constructor to create a sync object from entry line formats. The entry lines are parsed by this class.
- * The constructor can handle parsing entry lines from the server or from an entry file.
- *
- * @param entryLine the entry line (e.g. /new.java/1.2/Fri Dec 07 00:17:52 2001/-kb/)
- * @param permissions the file permission (e.g. u=rw,g=rw,o=r). May be <code>null</code>.
- * @param timestamp if not included in the entry line. May be <code>null</code>.
- *
- * @exception CVSException is thrown if the entry cannot be parsed.
- */
- public ResourceSyncInfo(String entryLine, Date timestamp) throws CVSException {
- Assert.isNotNull(entryLine);
- setEntryLine(entryLine);
-
- // override the timestamp that may of been in entryLine. In some cases the timestamp is not in the
- // entry line (e.g. receiving entry lines from the server versus reading them from the Entry file).
- if(timestamp!=null) {
- this.timeStamp = timestamp;
- }
- }
-
- /**
- * Constructor to create a resource sync object for a folder.
- *
- * @param name of the resource for which this sync state is associatied, cannot be <code>null</code>.
- */
- public ResourceSyncInfo(String name) {
- Assert.isNotNull(name);
- this.name = name;
- this.isDirectory = true;
- }
- /**
- * Answers if this sync information is for a folder in which case only a name is
- * available.
- *
- * @return <code>true</code> if the sync information is for a folder and <code>false</code>
- * if it is for a file.
- */
- public boolean isDirectory() {
- return isDirectory;
- }
-
- /**
- * Answers if this sync information is for a resource that has been merged by the cvs server with
- * conflicts and has not been modified yet relative to the given timestamp.
- *
- * @param otherTimestamp is the timestamp of the file associated with this resource sync
- * @return <code>true</code> if the sync information is for a file that has been merged and
- * <code>false</code> for folders and for files that have not been merged.
- */
- public boolean isNeedsMerge(Date otherTimestamp) {
- return syncType == TYPE_MERGED_WITH_CONFLICTS && timeStamp != null && timeStamp.equals(otherTimestamp);
- }
-
- /**
- * Answers if this sync information is for a resource that has been merged with conflicts by the
- * cvs server.
- *
- * @return <code>true</code> if the sync information is for a file that has been merged and
- * <code>false</code> for folders and for files that have not been merged.
- */
- public boolean isMergedWithConflicts() {
- return syncType == TYPE_MERGED_WITH_CONFLICTS;
- }
-
- /**
- * Answers if this sync information is for a resource that has been merged by the cvs server.
- *
- * @return <code>true</code> if the sync information is for a file that has been merged and
- * <code>false</code> for folders and for files that have not been merged.
- */
- public boolean isMerged() {
- return syncType == TYPE_MERGED || isMergedWithConflicts();
- }
-
- /**
- * Answers if this sync information is for a file that has been added but not comitted
- * to the CVS repository yet.
- *
- * @return <code>true</code> if the sync information is new or <code>false</code> if
- * the sync is for an file that exists remotely. For folder sync info this returns
- * <code>false</code>.
- */
- public boolean isAdded() {
- if(!isDirectory) {
- return getRevision().equals(ADDED_REVISION);
- } else {
- return false;
- }
- }
-
- /**
- * Answers if this sync information is for a file that is scheduled to be deleted
- * from the repository but the deletion has not yet been comitted.
- *
- * @return <code>true</code> if the sync information is deleted or <code>false</code> if
- * the sync is for an file that exists remotely.
- */
- public boolean isDeleted() {
- return isDeleted;
- }
-
- /**
- * Returns an entry line that can be saved in the CVS/Entries file. For sending entry lines to the
- * server use <code>getServerEntryLine</code>.
- *
- * @return a file or folder entry line reflecting the state of this sync object.
- */
- public String getEntryLine() {
- return getEntryLine(true /*include timestamps*/, null /*no timestamp override*/);
- }
-
- /**
- * Same as <code>getEntryLine</code> except it considers merged files in entry line timestamp format.
- * This is only valid for sending the file to the server.
- *
- * @param fileTimestamp is timestamp of the resource associated with this sync info.
- * @return a file or folder entry line reflecting the state of this sync object.
- */
- public String getServerEntryLine(Date fileTimestamp) {
- String serverTimestamp;
- if(fileTimestamp != null && (isMerged() || isMergedWithConflicts())) {
- if(isNeedsMerge(fileTimestamp)) {
- serverTimestamp = TIMESTAMP_SERVER_MERGED_WITH_CONFLICT;
- } else {
- serverTimestamp = TIMESTAMP_SERVER_MERGED;
- }
- return getEntryLine(true, serverTimestamp);
- } else {
- return getEntryLine(false, null);
- }
- }
-
- /**
- * Gets the tag or <code>null</code> if a tag is not available.
- *
- * @return Returns a String
- */
- public CVSTag getTag() {
- return tag;
- }
- /**
- * Gets the timeStamp or <code>null</code> if a timestamp is not available.
- *
- * @return a date instance representing the timestamp
- */
- public Date getTimeStamp() {
- return timeStamp;
- }
- /**
- * Gets the version or <code>null</code> if this is a folder sync info. The returned
- * revision will never include the DELETED_PREFIX. To found out if this sync info is
- * for a deleted resource call isDeleted().
- *
- * @return Returns a String
- */
- public String getRevision() {
- return revision;
- }
-
- /**
- * Gets the name.
- *
- * @return Returns a String
- */
- public String getName() {
- return name;
- }
- /**
- * Gets the keyword mode.
- * @return the keyword substitution option
- */
- public KSubstOption getKeywordMode() {
- return keywordMode;
- }
-
- /**
- * Answers the default permissions string.
- */
- public static String getDefaultPermissions() {
- return DEFAULT_PERMISSIONS;
- }
-
- /**
- * Answers the default permissions string that is executable.
- */
- public static String getDefaultExecutablePermissions() {
- return DEFAULT_EXECUTABLE_PERMISSIONS;
- }
-
- /**
- * Name equality between resource sync info objects.
- */
- public boolean equals(Object other) {
- if(other instanceof ResourceSyncInfo) {
- ResourceSyncInfo syncInfo = ((ResourceSyncInfo)other);
- if(other == this) return true;
- if(getName() == syncInfo.getName()) return true;
- return getName().equals(syncInfo.getName());
- } else {
- return false;
- }
- }
-
- public int hashCode() {
- return getName().hashCode();
- }
-
- /*
- * @see Object#toString()
- */
- public String toString() {
- return getEntryLine(true, null /*no timestamp override*/);
- }
- public MutableResourceSyncInfo cloneMutable() {
- MutableResourceSyncInfo newSync = new MutableResourceSyncInfo(this);
- return newSync;
- }
- /**
- * Sets the tag for the resource.
- */
- protected void setTag(CVSTag tag) {
- if(tag!=null) {
- this.tag = new CVSEntryLineTag(tag);
- } else {
- this.tag = null;
- }
- }
-
-
- /*
- * Sets the sync type
- */
- protected void setSyncType(int syncType) {
- this.syncType = syncType;
- }
- /**
- * Sets the version and decides if the revision is for a deleted resource the revision field
- * will not include the deleted prefix '-'.
- *
- * @param version the version to set
- */
- protected void setRevision(String revision) {
- if(revision==null || revision.equals(ADDED_REVISION)) {
- this.revision = ADDED_REVISION;
- timeStamp = null;
- syncType = TYPE_REGULAR;
- isDeleted = false;
- } else if(revision.startsWith(DELETED_PREFIX)) {
- this.revision = revision.substring(DELETED_PREFIX.length());
- isDeleted = true;
- } else {
- this.revision = revision;
- isDeleted = false;
- }
- }
-
- /**
- * Set the entry line
- *
- * @throws CVSException if the entryLine is malformed
- */
- protected void setEntryLine(String entryLine) throws CVSException {
-
- String[] strings = Util.parseIntoSubstrings(entryLine, SEPARATOR);
- if(strings.length < 6) {
- throw new CVSException(CVSMessages.Malformed_entry_line___11 + entryLine);
- }
-
- isDirectory = (strings[0].equals(DIRECTORY_PREFIX));
-
- name = strings[1];
-
- if(name.length()==0) {
- throw new CVSException(CVSMessages.Malformed_entry_line__missing_name___12 + entryLine);
- }
-
- String rev = strings[2];
-
- if(rev.length()==0 && !isDirectory()) {
- throw new CVSException(CVSMessages.Malformed_entry_line__missing_revision___13 + entryLine);
- } else {
- setRevision(rev);
- }
-
- String date = strings[3];
-
- // possible timestamps are:
- // from server: "+=" and "+modified"
- // from entry line: "Result of Merge+Thu May 25 12:33:33 2002"
- // "Result of Merge"
- // "Thu May 25 12:33:33 2002"
- //
- // The server will send a timestamp of "+=" if
- // the file was merged with conflicts. The '+' indicates that there are conflicts and the
- // '=' indicate that the timestamp for the file should be used. If the merge does not
- // have conflicts, simply add a text only timestamp and the file will be regarded as
- // having outgoing changes.
- // The purpose for having the two different timestamp options for merges is to
- // dissallow commit of files that have conflicts until they have been manually edited.
- if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED) != -1) {
- syncType = TYPE_MERGED;
- date = null;
- } else if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED_WITH_CONFLICT) != -1) {
- syncType = TYPE_MERGED_WITH_CONFLICTS;
- date = null;
- } else if(date.indexOf(TIMESTAMP_MERGED_WITH_CONFLICT)!=-1) {
- date = date.substring(date.indexOf("+") + 1); //$NON-NLS-1$
- syncType = TYPE_MERGED_WITH_CONFLICTS;
- } else if(date.indexOf(TIMESTAMP_MERGED)!=-1) {
- syncType = TYPE_MERGED;
- date = null;
- }
-
- if(date==null || "".equals(date)) { //$NON-NLS-1$
- timeStamp = null;
- } else {
- try {
- timeStamp = CVSDateFormatter.entryLineToDate(date);
- } catch(ParseException e) {
- // something we don't understand, just make this sync have no timestamp and
- // never be in sync with the server.
- timeStamp = null;
- }
- }
- keywordMode = KSubstOption.fromMode(strings[4]);
- String tagEntry;
- if (strings.length == 6) {
- tagEntry = strings[5];
- } else {
- // It turns out that CVS supports slashes (/) in the tag even though this breaks the spec
- // See http://dev.eclipse.org/bugs/show_bug.cgi?id=26717
- StringBuffer buffer = new StringBuffer();
- for (int i = 5; i < strings.length; i++) {
- buffer.append(strings[i]);
- if (i < strings.length - 1) {
- buffer.append(SEPARATOR);
- }
- }
- tagEntry = buffer.toString();
- }
-
- if(tagEntry.length()>0) {
- tag = new CVSEntryLineTag(tagEntry);
- } else {
- tag = null;
- }
- }
-
- private String getEntryLine(boolean includeTimeStamp, String timestampOverride) {
- StringBuffer result = new StringBuffer();
-
- if(isDirectory) {
- result.append(DIRECTORY_PREFIX);
- result.append(SEPARATOR);
- result.append(name);
- for (int i = 0; i < 4; i++) {
- result.append(SEPARATOR);
- }
- } else {
- result.append(SEPARATOR);
- result.append(name);
- result.append(SEPARATOR);
-
- if(isDeleted){
- result.append(DELETED_PREFIX);
- }
- result.append(revision);
- result.append(SEPARATOR);
- if(includeTimeStamp) {
- String entryLineTimestamp = ""; //$NON-NLS-1$
- if(timestampOverride!=null) {
- entryLineTimestamp = timestampOverride;
- } else {
- switch(syncType) {
- case TYPE_REGULAR:
- if(timeStamp==null) {
- entryLineTimestamp = TIMESTAMP_DUMMY;
- } else {
- entryLineTimestamp = CVSDateFormatter.dateToEntryLine(timeStamp);
- } break;
- case TYPE_MERGED:
- entryLineTimestamp = TIMESTAMP_MERGED; break;
- case TYPE_MERGED_WITH_CONFLICTS:
- entryLineTimestamp = TIMESTAMP_MERGED_WITH_CONFLICT + CVSDateFormatter.dateToEntryLine(timeStamp); break;
- }
- }
- result.append(entryLineTimestamp);
- }
- result.append(SEPARATOR);
- if (keywordMode != null) result.append(keywordMode.toEntryLineMode());
- result.append(SEPARATOR);
- if (tag != null) {
- result.append(tag.toEntryLineFormat(true));
- }
- }
- return result.toString();
- }
-
- /**
- * Method getBytes.
- * @return byte[]
- */
- public byte[] getBytes() {
- return getEntryLine().getBytes();
- }
-
- /**
- * Method getName.
- * @param syncBytes
- * @return String
- */
- public static String getName(byte[] syncBytes) throws CVSException {
- String name = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 1, false);
- if (name == null) {
- throw new CVSException(NLS.bind(CVSMessages.ResourceSyncInfo_malformedSyncBytes, new String[] { new String(syncBytes) }));
- }
- return name;
- }
-
- /**
- * Method getKeywordMode.
- * @param syncBytes
- * @return String
- */
- public static KSubstOption getKeywordMode(byte[] syncBytes) throws CVSException {
- String mode = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 4, false);
- if (mode == null) {
- throw new CVSException(NLS.bind(CVSMessages.ResourceSyncInfo_malformedSyncBytes, new String[] { new String(syncBytes) }));
- }
- return KSubstOption.fromMode(mode);
- }
-
- /**
- * Method getKeywordMode.
- * @param syncBytes
- * @return String
- */
- public static byte[] setKeywordMode(byte[] syncBytes, KSubstOption mode) throws CVSException {
- return setKeywordMode(syncBytes, mode.toEntryLineMode().getBytes());
- }
-
- /**
- * Method getKeywordMode.
- * @param syncBytes
- * @return String
- */
- public static byte[] setKeywordMode(byte[] syncBytes, byte[] modeBytes) throws CVSException {
- return setSlot(syncBytes, 4, modeBytes);
- }
-
- /**
- * Return whether the provided syncBytes represent a binary file.
- * @param syncBytes
- * @return boolean
- * @throws CVSException
- */
- public static boolean isBinary(byte[] syncBytes) throws CVSException {
- if (syncBytes == null) return false;
- String mode = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 4, false);
- if (mode == null) {
- throw new CVSException(NLS.bind(CVSMessages.ResourceSyncInfo_malformedSyncBytes, new String[] { new String(syncBytes) }));
- }
- return "-kb".equals(mode); //$NON-NLS-1$
- }
-
- /**
- * Method isFolder.
- * @param syncBytes
- * @return boolean
- */
- public static boolean isFolder(byte[] syncBytes) {
- return syncBytes.length > 0 && syncBytes[0] == 'D';
- }
-
- /**
- * Method isAddition.
- * @param syncBytes
- * @return boolean
- */
- public static boolean isAddition(byte[] syncBytes) throws CVSException {
- int start = startOfSlot(syncBytes, 2);
- // There must be a slot and, in the very least, there must be two characters after the slot
- if (start == -1 || start > syncBytes.length - 3) {
- throw new CVSException(NLS.bind(CVSMessages.ResourceSyncInfo_malformedSyncBytes, new String[] { new String(syncBytes) }));
- }
- // If the zero is followed by a dot, then it is a valid revision and not an addition
- return syncBytes[start + 1] == '0' && syncBytes[start + 2] != '.';
- }
-
- /**
- * Method isDeleted.
- * @param syncBytes
- * @return boolean
- */
- public static boolean isDeletion(byte[] syncBytes) throws CVSException {
- int start = startOfSlot(syncBytes, 2);
- if (start == -1 || start >= syncBytes.length) {
- throw new CVSException(NLS.bind(CVSMessages.ResourceSyncInfo_malformedSyncBytes, new String[] { new String(syncBytes) }));
- }
- return syncBytes[start + 1] == DELETED_PREFIX_BYTE;
- }
-
- /**
- * Method convertToDeletion.
- * @param syncBytes
- * @return byte[]
- */
- public static byte[] convertToDeletion(byte[] syncBytes) throws CVSException {
- int index = startOfSlot(syncBytes, 2);
- if (index == -1) {
- throw new CVSException(NLS.bind(CVSMessages.ResourceSyncInfo_malformedSyncBytes, new String[] { new String(syncBytes) }));
- }
- if (syncBytes.length > index && syncBytes[index+1] != DELETED_PREFIX_BYTE) {
- byte[] newSyncBytes = new byte[syncBytes.length + 1];
- System.arraycopy(syncBytes, 0, newSyncBytes, 0, index + 1);
- newSyncBytes[index + 1] = DELETED_PREFIX_BYTE;
- System.arraycopy(syncBytes, index + 1, newSyncBytes, index + 2, syncBytes.length - index - 1);
- return newSyncBytes;
- }
- return syncBytes;
- }
-
- /**
- * Method convertFromDeletion.
- * @param syncBytes
- * @return byte[]
- */
- public static byte[] convertFromDeletion(byte[] syncBytes) throws CVSException {
- int index = startOfSlot(syncBytes, 2);
- if (index == -1) {
- throw new CVSException(NLS.bind(CVSMessages.ResourceSyncInfo_malformedSyncBytes, new String[] { new String(syncBytes) }));
- }
- if (syncBytes.length > index && syncBytes[index+1] == DELETED_PREFIX_BYTE) {
- byte[] newSyncBytes = new byte[syncBytes.length - 1];
- System.arraycopy(syncBytes, 0, newSyncBytes, 0, index + 1);
- System.arraycopy(syncBytes, index + 2, newSyncBytes, index + 1, newSyncBytes.length - index - 1);
- return newSyncBytes;
- }
- return syncBytes;
- }
- /**
- * Method startOfSlot returns the index of the slash that occurs before the
- * given slot index. The provided index should be >= 1 which assumes that
- * slot zero occurs before the first slash.
- *
- * @param syncBytes
- * @param i
- * @return int
- */
- private static int startOfSlot(byte[] syncBytes, int slot) {
- int count = 0;
- for (int j = 0; j < syncBytes.length; j++) {
- if (syncBytes[j] == SEPARATOR_BYTE) {
- count++;
- if (count == slot) return j;
- }
- }
- return -1;
- }
-
- /**
- * Method setSlot.
- * @param syncBytes
- * @param i
- * @param b
- * @return byte[]
- */
- private static byte[] setSlot(byte[] syncBytes, int slot, byte[] newBytes) throws CVSException {
- int start = startOfSlot(syncBytes, slot);
- if (start == -1) {
- throw new CVSException(NLS.bind(CVSMessages.ResourceSyncInfo_malformedSyncBytes, new String[] { new String(syncBytes) }));
- }
- int end = startOfSlot(syncBytes, slot + 1);
- int totalLength = start + 1 + newBytes.length;
- if (end != -1) {
- totalLength += syncBytes.length - end;
- }
- byte[] result = new byte[totalLength];
- System.arraycopy(syncBytes, 0, result, 0, start + 1);
- System.arraycopy(newBytes, 0, result, start + 1, newBytes.length);
- if (end != -1) {
- System.arraycopy(syncBytes, end, result, start + 1 + newBytes.length, syncBytes.length - end);
- }
- return result;
- }
-
- /**
- * Return the timestamp portion of the sync info that is to be sent to the
- * server.
- *
- * @param syncBytes
- * @param fileTimestamp
- * @return String
- */
- public static String getTimestampToServer(byte[] syncBytes, Date fileTimestamp) throws CVSException {
- if(fileTimestamp != null) {
- String syncTimestamp = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 3, false);
- if (syncTimestamp == null) {
- throw new CVSException(NLS.bind(CVSMessages.ResourceSyncInfo_malformedSyncBytes, new String[] { new String(syncBytes) }));
- }
- int syncType = getSyncType(syncTimestamp);
- if (syncType != TYPE_REGULAR) {
- if (syncType == TYPE_MERGED_WITH_CONFLICTS && fileTimestamp.equals(getTimestamp(syncTimestamp))) {
- return TIMESTAMP_SERVER_MERGED_WITH_CONFLICT;
- } else {
- return TIMESTAMP_SERVER_MERGED;
- }
- }
- }
- return null;
- }
- /**
- * Method getTimestamp.
- * @param syncTimestamp
- * @return Object
- */
- private static Date getTimestamp(String syncTimestamp) {
- String dateString= syncTimestamp;
- if(syncTimestamp.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED) != -1) {
- dateString = null;
- } else if(syncTimestamp.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED_WITH_CONFLICT) != -1) {
- dateString = null;
- } else if(syncTimestamp.indexOf(TIMESTAMP_MERGED_WITH_CONFLICT)!=-1) {
- dateString = syncTimestamp.substring(syncTimestamp.indexOf("+") + 1); //$NON-NLS-1$
- } else if(syncTimestamp.indexOf(TIMESTAMP_MERGED)!=-1) {
- dateString = null;
- }
-
- if(dateString==null || "".equals(dateString)) { //$NON-NLS-1$
- return null;
- } else {
- try {
- return CVSDateFormatter.entryLineToDate(dateString);
- } catch(ParseException e) {
- // something we don't understand, just make this sync have no timestamp and
- // never be in sync with the server.
- return null;
- }
- }
- }
-
- /**
- * Method getSyncType.
- * @param syncTimestamp
- * @return int
- */
- private static int getSyncType(String date) {
- if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED) != -1) {
- return TYPE_MERGED;
- } else if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED_WITH_CONFLICT) != -1) {
- return TYPE_MERGED_WITH_CONFLICTS;
- } else if(date.indexOf(TIMESTAMP_MERGED_WITH_CONFLICT)!=-1) {
- return TYPE_MERGED_WITH_CONFLICTS;
- } else if(date.indexOf(TIMESTAMP_MERGED)!=-1) {
- return TYPE_MERGED;
- }
- return TYPE_REGULAR;
- }
-
- /**
- * Method getTag.
- * @param syncBytes
- * @return String
- */
- public static byte[] getTagBytes(byte[] syncBytes) throws CVSException {
- byte[] tag = Util.getBytesForSlot(syncBytes, SEPARATOR_BYTE, 5, true);
- if (tag == null) {
- throw new CVSException(NLS.bind(CVSMessages.ResourceSyncInfo_malformedSyncBytes, new String[] { new String(syncBytes) }));
- }
- return tag;
- }
-
- /**
- * Method setTag.
- * @param syncBytes
- * @param tagString
- * @return byte[]
- */
- public static byte[] setTag(byte[] syncBytes, byte[] tagBytes) throws CVSException {
- return setSlot(syncBytes, 5, tagBytes);
- }
-
- /**
- * Method setTag.
- * @param syncBytes
- * @param tag
- * @return ResourceSyncInfo
- */
- public static byte[] setTag(byte[] syncBytes, CVSTag tag) throws CVSException {
- CVSEntryLineTag entryTag;
- if (tag instanceof CVSEntryLineTag) {
- entryTag = (CVSEntryLineTag)tag;
- } else {
- entryTag = new CVSEntryLineTag(tag);
- }
- return setTag(syncBytes, entryTag.toEntryLineFormat(true).getBytes());
- }
-
- /**
- * Method getRevision.
- * @param syncBytes
- */
- public static String getRevision(byte[] syncBytes) throws CVSException {
- String revision = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 2, false);
- if (revision == null) {
- throw new CVSException(NLS.bind(CVSMessages.ResourceSyncInfo_malformedSyncBytes, new String[] { new String(syncBytes) }));
- }
- if(revision.startsWith(DELETED_PREFIX)) {
- revision = revision.substring(DELETED_PREFIX.length());
- }
- int lockedIdx = revision.indexOf(LOCKEDBY_SUFFIX);
- if (lockedIdx >= 0) {
- revision = revision.substring(0, lockedIdx);
- }
- return revision;
- }
-
- /**
- * Method setRevision.
- * @param syncBytes
- * @param revision
- * @return byte[]
- */
- public static byte[] setRevision(byte[] syncBytes, String revision) throws CVSException {
- return setSlot(syncBytes, 2, revision.getBytes());
- }
-
- /**
- * Method isMerge.
- * @param syncBytes1
- * @return boolean
- */
- public static boolean isMerge(byte[] syncBytes) throws CVSException {
- String timestamp = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 3, false);
- if (timestamp == null) {
- throw new CVSException(NLS.bind(CVSMessages.ResourceSyncInfo_malformedSyncBytes, new String[] { new String(syncBytes) }));
- }
- int syncType = getSyncType(timestamp);
- return syncType == TYPE_MERGED || syncType == TYPE_MERGED_WITH_CONFLICTS;
- }
-
- /**
- * Method isMerge.
- * @param syncBytes1
- * @return boolean
- */
- public static boolean isMergedWithConflicts(byte[] syncBytes) throws CVSException {
- String timestamp = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 3, false);
- if (timestamp == null) {
- throw new CVSException(NLS.bind(CVSMessages.ResourceSyncInfo_malformedSyncBytes, new String[] { new String(syncBytes) }));
- }
- int syncType = getSyncType(timestamp);
- return syncType == TYPE_MERGED_WITH_CONFLICTS;
- }
-
-
- /**
- * Return <code>true</code> if the remoteBytes represents a later revision on the same
- * branch as localBytes. Return <code>false</code> if remoteBytes is the same or an earlier
- * revision or if the bytes are on a separate branch (or tag)
- * @param remoteBytes
- * @param localBytes
- * @return
- */
- public static boolean isLaterRevisionOnSameBranch(byte[] remoteBytes, byte[] localBytes) throws CVSException {
- // If the two byte arrays are the same, then the remote isn't a later revision
- if (remoteBytes == localBytes) return false;
- // If the tags differ, then the remote isn't a later revision
- byte[] remoteTag = ResourceSyncInfo.getTagBytes(remoteBytes);
- byte[] localTag = ResourceSyncInfo.getTagBytes(localBytes);
- if (!Util.equals(remoteTag, localTag)) return false;
- // If the revisions are the same, the remote isn't later
- String remoteRevision = ResourceSyncInfo.getRevision(remoteBytes);
- String localRevision = ResourceSyncInfo.getRevision(localBytes);
- if (remoteRevision.equals(localRevision)) return false;
- return isLaterRevision(remoteRevision, localRevision);
- }
-
- /**
- * Return true if the remoteRevision represents a later revision than the local revision
- * on the same branch.
- * @param remoteRevision
- * @param localRevision
- * @return
- */
- public static boolean isLaterRevision(String remoteRevision, String localRevision) {
- int localDigits[] = Util.convertToDigits(localRevision);
- if (localDigits.length == 0) return false;
- int remoteDigits[] = Util.convertToDigits(remoteRevision);
- if (remoteDigits.length == 0) return false;
-
- if (localRevision.equals(ADDED_REVISION)) {
- return (remoteDigits.length >= 2);
- }
- if (localDigits.length < remoteDigits.length) {
- // If there are more digits in the remote revision then all
- // the leading digits must match
- for (int i = 0; i < localDigits.length; i++) {
- int localDigit = localDigits[i];
- int remoteDigit = remoteDigits[i];
- if (remoteDigit != localDigit) return false;
- }
- return true;
- }
- // They are the same length or the local is longer.
- // The last digit must differ and all others must be the same.
- // If the local is longer, ignore the addition numbers
- // (this can occur as the result on an import)
- for (int i = 0; i < remoteDigits.length - 1; i++) {
- int localDigit = localDigits[i];
- int remoteDigit = remoteDigits[i];
- if (remoteDigit != localDigit) return false;
- }
- // All the leading digits are equals so the remote is later if the last digit is greater
- return localDigits[remoteDigits.length - 1] < remoteDigits[remoteDigits.length - 1] ;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/BuildCleanupListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/BuildCleanupListener.java
deleted file mode 100644
index 3249352de..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/BuildCleanupListener.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.util;
-
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-
-/**
- * Cleanup any CVS folders that were copied by a builder. This will also clean up
- * CVS folders that were copied by the user since the last auto-build.
- */
-public class BuildCleanupListener implements IResourceDeltaVisitor, IResourceChangeListener {
-
- public static IResource getResourceFor(IProject container, IResource destination, IPath originating) {
- switch(destination.getType()) {
- case IResource.FILE : return container.getFile(originating);
- case IResource.FOLDER: return container.getFolder(originating);
- case IResource.PROJECT: return ResourcesPlugin.getWorkspace().getRoot().getProject(originating.toString());
- }
- return destination;
- }
-
- /**
- * @see IResourceDeltaVisitor#visit(IResourceDelta)
- */
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource resource = delta.getResource();
- boolean movedFrom = (delta.getFlags() & IResourceDelta.MOVED_FROM) > 0;
- switch (delta.getKind()) {
- case IResourceDelta.ADDED :
- // make sure the added resource isn't a phantom
- if (resource.exists()) {
- if (EclipseSynchronizer.getInstance().wasPhantom(resource)) {
- EclipseSynchronizer.getInstance().resourcesRecreated(new IResource[] { resource }, null);
- }
- if (resource.getType() == IResource.FOLDER) {
- if (resource.getName().equals(SyncFileWriter.CVS_DIRNAME)) {
- handleOrphanedSubtree(resource.getParent());
- } else {
- handleOrphanedSubtree((IContainer)resource);
- }
- }
- }
- break;
- case IResourceDelta.CHANGED :
- // This state means there is a resource before and after but changes were made by deleting and moving.
- // For files, we shouldn'd do anything.
- // For folders, we should purge the CVS info
- if (movedFrom && resource.getType() == IResource.FOLDER && resource.exists()) {
- // When folders are moved, purge the CVS folders
- return ! handleOrphanedSubtree((IContainer)resource);
- }
- break;
- }
- return true;
- }
-
- /*
- * Determine if the container is an orphaned subtree.
- * If it is, handle it and return true.
- * Otherwise, return false
- */
- private boolean handleOrphanedSubtree(IContainer container) {
- try {
- if (CVSWorkspaceRoot.isOrphanedSubtree(container)) {
- ICVSFolder mFolder = CVSWorkspaceRoot.getCVSFolderFor(container);
- mFolder.unmanage(null);
- return true;
- }
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- return false;
- }
-
- public void resourceChanged(IResourceChangeEvent event) {
- try {
- IResourceDelta root = event.getDelta();
- IResourceDelta[] projectDeltas = root.getAffectedChildren();
- for (int i = 0; i < projectDeltas.length; i++) {
- final IResourceDelta delta = projectDeltas[i];
- IResource resource = delta.getResource();
-
- if (resource.getType() == IResource.PROJECT) {
- // If the project is not accessible, don't process it
- if (!resource.isAccessible()) continue;
- }
-
- RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId());
-
- // Make sure that the project is a CVS folder.
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(resource.getProject());
- if (provider != null) {
- try {
- if (! folder.isCVSFolder()) {
- RepositoryProvider.unmap(resource.getProject());
- provider = null;
- }
- } catch (TeamException e) {
- CVSProviderPlugin.log(e);
- }
- }
-
- // if a project is moved the originating project will not be associated with the CVS provider
- // however listeners will probably still be interested in the move delta.
- if ((delta.getFlags() & IResourceDelta.MOVED_TO) > 0) {
- IResource destination = getResourceFor(resource.getProject(), resource, delta.getMovedToPath());
- provider = RepositoryProvider.getProvider(destination.getProject());
- }
-
- if(provider!=null) {
- // Traverse the delta is a runnable so that files are only written at the end
- folder.run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- try {
- delta.accept(BuildCleanupListener.this);
- } catch (CoreException e) {
- Util.logError(CVSMessages.ResourceDeltaVisitor_visitError, e);
- }
- }
- }, Policy.monitorFor(null));
- }
- }
- } catch (CVSException e) {
- Util.logError(CVSMessages.ResourceDeltaVisitor_visitError, e);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java
deleted file mode 100644
index ba2beba67..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.util;
-
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-/**
- * Utility class for converting timestamps used in Entry file lines. The format
- * required in the Entry file is ISO C asctime() function (Sun Apr 7 01:29:26 1996).
- * <p>
- * To be compatible with asctime(), the day field in the entryline format is
- * padded with a space and not a zero. Most other CVS clients use string comparison
- * for timestamps based on the result of the C function asctime().
- * </p>
- */
-public class CVSDateFormatter {
-
- private static final String ENTRYLINE_FORMAT = "E MMM dd HH:mm:ss yyyy"; //$NON-NLS-1$
- private static final String SERVER_FORMAT = "dd MMM yyyy HH:mm:ss";//$NON-NLS-1$
- private static final int ENTRYLINE_TENS_DAY_OFFSET = 8;
-
- private static final SimpleDateFormat serverFormat = new SimpleDateFormat(SERVER_FORMAT, Locale.US);
- private static SimpleDateFormat entryLineFormat = new SimpleDateFormat(ENTRYLINE_FORMAT, Locale.US);
-
- static {
- entryLineFormat.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$
- }
- static synchronized public Date serverStampToDate(String text) throws ParseException {
- serverFormat.setTimeZone(getTimeZone(text));
- Date date = serverFormat.parse(text);
- return date;
- }
-
- static synchronized public Date entryLineToDate(String text) throws ParseException {
- try {
- if (text.charAt(ENTRYLINE_TENS_DAY_OFFSET) == ' ') {
- StringBuffer buf = new StringBuffer(text);
- buf.setCharAt(ENTRYLINE_TENS_DAY_OFFSET, '0');
- text = buf.toString();
- }
- } catch (StringIndexOutOfBoundsException e) {
- throw new ParseException(e.getMessage(), ENTRYLINE_TENS_DAY_OFFSET);
- }
- return entryLineFormat.parse(text);
- }
-
- static synchronized public String dateToEntryLine(Date date) {
- if (date == null) return ""; //$NON-NLS-1$
- String passOne = entryLineFormat.format(date);
- if (passOne.charAt(ENTRYLINE_TENS_DAY_OFFSET) != '0') return passOne;
- StringBuffer passTwo = new StringBuffer(passOne);
- passTwo.setCharAt(ENTRYLINE_TENS_DAY_OFFSET, ' ');
- return passTwo.toString();
- }
-
- static synchronized public String dateToNotifyServer(Date date) {
- serverFormat.setTimeZone(TimeZone.getTimeZone("GMT"));//$NON-NLS-1$
- return serverFormat.format(date) + " GMT"; //$NON-NLS-1$
- }
-
- /*
- * Converts timezone text from date string from CVS server and
- * returns a timezone representing the received timezone.
- * Timezone string is of the following format: [-|+]MMSS
- */
- static private TimeZone getTimeZone(String dateFromServer) {
- if (dateFromServer.lastIndexOf("0000") != -1) //$NON-NLS-1$
- return TimeZone.getTimeZone("GMT");//$NON-NLS-1$
- String tz = null;
- StringBuffer resultTz = new StringBuffer("GMT");//$NON-NLS-1$
- if (dateFromServer.indexOf("-") != -1) {//$NON-NLS-1$
- resultTz.append("-");//$NON-NLS-1$
- tz = dateFromServer.substring(dateFromServer.indexOf("-"));//$NON-NLS-1$
- } else if (dateFromServer.indexOf("+") != -1) {//$NON-NLS-1$
- resultTz.append('+');
- tz = dateFromServer.substring(dateFromServer.indexOf("+"));//$NON-NLS-1$
- }
- try {
- if(tz!=null) {
- resultTz.append(tz.substring(1, 3) /*hours*/ + ":" + tz.substring(3, 5) /*minutes*/);//$NON-NLS-1$
- return TimeZone.getTimeZone(resultTz.toString());
- }
- } catch(IndexOutOfBoundsException e) {
- return TimeZone.getTimeZone("GMT");//$NON-NLS-1$
- }
- return TimeZone.getTimeZone("GMT");//$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileNameMatcher.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileNameMatcher.java
deleted file mode 100644
index d82c91657..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/FileNameMatcher.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.util;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-
-/**
- * A FileNameMatcher associates a String with a String pattern.
- */
-public class FileNameMatcher {
-
- private List matchers = new ArrayList();
- private List results = new ArrayList();
- private static final String TRUE = "true"; //$NON-NLS-1$
-
- public FileNameMatcher() {
- }
-
- public FileNameMatcher(String[] patterns) {
- register(patterns);
- }
-
- void register(String[] patterns) {
- for (int i = 0; i < patterns.length; i++) {
- register(patterns[i],TRUE);
- }
- }
-
- public void register(String pattern, String result) {
-
- Assert.isTrue(matchers.size() == results.size());
-
- pattern = pattern.trim();
-
- // The empty pattern matches everything, but we want to match
- // nothing with it, so we just do not register anything
- if (pattern.length() == 0) {
- return;
- }
-
- matchers.add(new StringMatcher(pattern,false,false));
- results.add(result);
-
- }
-
- public String getMatch(String name) {
- StringMatcher stringMatcher;
-
- for (int i = 0; i < matchers.size(); i++) {
- stringMatcher = (StringMatcher) matchers.get(i);
- if (stringMatcher.match(name)) {
- return (String)results.get(i);
- }
- }
-
- return null;
- }
-
- public boolean match(String name) {
- return getMatch(name) != null;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java
deleted file mode 100644
index b421303a2..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * This class keeps track of the CVS repository locations that are known to
- * the CVS plugin.
- */
-public class KnownRepositories implements INodeChangeListener, IPreferenceChangeListener {
-
- private List repositoryListeners = new ArrayList();
- private Map repositories;
-
- private static KnownRepositories instance;
-
- public static synchronized KnownRepositories getInstance() {
- if (instance == null) {
- instance = new KnownRepositories();
- }
- return instance;
- }
-
- /*
- * Private class used to safely notify listeners of resouce sync info changes.
- * Subclass override the notify(IResourceStateChangeListener) method to
- * fire specific events inside an ISafeRunnable.
- */
- private abstract class Notification implements ISafeRunnable {
- private ICVSListener listener;
- public void handleException(Throwable exception) {
- // don't log the exception....it is already being logged in Platform#run
- }
- public void run(ICVSListener listener) {
- this.listener = listener;
- Platform.run(this);
- }
- public void run() throws Exception {
- notify(listener);
- }
- /**
- * Subsclasses overide this method to send an event safely to a lsistener
- * @param listener
- */
- protected abstract void notify(ICVSListener listener);
- }
-
- /**
- * Register to receive notification of repository creation and disposal
- */
- public void addRepositoryListener(ICVSListener listener) {
- synchronized(repositoryListeners) {
- repositoryListeners.add(listener);
- }
- }
-
- /**
- * De-register a listener
- */
- public void removeRepositoryListener(ICVSListener listener) {
- synchronized(repositoryListeners) {
- repositoryListeners.remove(listener);
- }
- }
-
- /**
- * Add the repository to the receiver's list of known repositories. Doing this will enable
- * password caching across platform invocations.
- */
- public ICVSRepositoryLocation addRepository(final ICVSRepositoryLocation repository, boolean broadcast) {
- CVSRepositoryLocation existingLocation;
- synchronized (this) {
- // Check the cache for an equivalent instance and if there is one, just update the cache
- existingLocation = internalGetRepository(repository.getLocation(false));
- if (existingLocation == null) {
- // Store the location
- store((CVSRepositoryLocation)repository);
- existingLocation = (CVSRepositoryLocation)repository;
- }
- }
- // Notify no matter what since it may not have been broadcast before
- if (broadcast) {
- final CVSRepositoryLocation location = existingLocation;
- ((CVSRepositoryLocation)repository).updateCache();
- fireNotification(new Notification() {
- public void notify(ICVSListener listener) {
- listener.repositoryAdded(location);
- }
- });
- }
- return existingLocation;
- }
-
- /**
- * Dispose of the repository location
- *
- * Removes any cached information about the repository such as a remembered password.
- */
- public void disposeRepository(final ICVSRepositoryLocation repository) {
- Object removed;
- synchronized (this) {
- ((CVSRepositoryLocation)repository).dispose();
- removed = getRepositoriesMap().remove(repository.getLocation(false));
- }
- if (removed != null) {
- fireNotification(new Notification() {
- public void notify(ICVSListener listener) {
- listener.repositoryRemoved(repository);
- }
- });
- }
- }
-
- /**
- * Answer whether the provided repository location is known by the provider or not.
- * The location string corresponds to the String returned by ICVSRepositoryLocation#getLocation()
- */
- public synchronized boolean isKnownRepository(String location) {
- return internalGetRepository(location) != null;
- }
-
- /**
- * Return a list of the know repository locations
- */
- public synchronized ICVSRepositoryLocation[] getRepositories() {
- return (ICVSRepositoryLocation[])getRepositoriesMap().values().toArray(new ICVSRepositoryLocation[getRepositoriesMap().size()]);
- }
-
- /**
- * Get the repository instance which matches the given String. The format of the String is
- * the same as that returned by ICVSRepositoryLocation#getLocation().
- * The format is:
- *
- * connection:user[:password]@host[#port]:root
- *
- * where [] indicates optional and the identier meanings are:
- *
- * connection The connection method to be used
- * user The username for the connection
- * password The password used for the connection (optional)
- * host The host where the repository resides
- * port The port to connect to (optional)
- * root The server directory where the repository is located
- *
- * If the repository is already registered, the cahced instance is returned.
- * Otherwise, a new uncached instance is returned.
- *
- * WARNING: Providing the password as part of the String will result in the password being part
- * of the location permanently. This means that it cannot be modified by the authenticator.
- */
- public synchronized ICVSRepositoryLocation getRepository(String location) throws CVSException {
- ICVSRepositoryLocation repository = internalGetRepository(location);
- if (repository == null) {
- repository = CVSRepositoryLocation.fromString(location);
- }
- return repository;
- }
-
- private CVSRepositoryLocation internalGetRepository(String location) {
- return (CVSRepositoryLocation)getRepositoriesMap().get(location);
- }
-
- /*
- * Cache the location and store it in the preferences for persistance
- */
- private void store(CVSRepositoryLocation location) {
- // Cache the location instance for later retrieval
- getRepositoriesMap().put(location.getLocation(), location);
- location.storePreferences();
- }
-
- private Map getRepositoriesMap() {
- if (repositories == null) {
- // Load the repositories from the preferences
- repositories = new HashMap();
- IEclipsePreferences prefs = (IEclipsePreferences) CVSRepositoryLocation.getParentPreferences();
- prefs.addNodeChangeListener(this);
- try {
- String[] keys = prefs.childrenNames();
- for (int i = 0; i < keys.length; i++) {
- String key = keys[i];
- try {
- IEclipsePreferences node = (IEclipsePreferences) prefs.node(key);
- node.addPreferenceChangeListener(this);
- String location = node.get(CVSRepositoryLocation.PREF_LOCATION, null);
- if (location != null) {
- repositories.put(location, CVSRepositoryLocation.fromString(location));
- } else {
- node.removeNode();
- prefs.flush();
- }
- } catch (CVSException e) {
- // Log and continue
- CVSProviderPlugin.log(e);
- }
- }
- if (repositories.isEmpty()) {
- getRepositoriesFromProjects();
- }
- } catch (BackingStoreException e) {
- // Log and continue (although all repos will be missing)
- CVSProviderPlugin.log(IStatus.ERROR, CVSMessages.KnownRepositories_0, e);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- }
- return repositories;
- }
-
- private void getRepositoriesFromProjects() throws CVSException {
- // If the file did not exist, then prime the list of repositories with
- // the providers with which the projects in the workspace are shared.
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0; i < projects.length; i++) {
- RepositoryProvider provider = RepositoryProvider.getProvider(projects[i], CVSProviderPlugin.getTypeId());
- if (provider!=null) {
- ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(projects[i]);
- FolderSyncInfo info = folder.getFolderSyncInfo();
- if (info != null) {
- addRepository(getRepository(info.getRoot()), false);
- }
- }
- }
- }
-
- private ICVSListener[] getListeners() {
- synchronized(repositoryListeners) {
- return (ICVSListener[]) repositoryListeners.toArray(new ICVSListener[repositoryListeners.size()]);
- }
- }
-
- private void fireNotification(Notification notification) {
- // Get a snapshot of the listeners so the list doesn't change while we're firing
- ICVSListener[] listeners = getListeners();
- // Notify each listener in a safe manner (i.e. so their exceptions don't kill us)
- for (int i = 0; i < listeners.length; i++) {
- ICVSListener listener = listeners[i];
- notification.run(listener);
- }
- }
-
- public void added(NodeChangeEvent event) {
- ((IEclipsePreferences)event.getChild()).addPreferenceChangeListener(this);
- }
-
- public void removed(NodeChangeEvent event) {
- // Cannot remove the listener once the node is removed
- //((IEclipsePreferences)event.getChild()).removePreferenceChangeListener(this);
- }
-
- public void preferenceChange(PreferenceChangeEvent event) {
- if (CVSRepositoryLocation.PREF_LOCATION.equals(event.getKey())) {
- String location = (String)event.getNewValue();
- if (location == null) {
- ((IEclipsePreferences)event.getNode()).removePreferenceChangeListener(this);
- } else {
- try {
- addRepository(CVSRepositoryLocation.fromString(location), true);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/MoveDeleteHook.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/MoveDeleteHook.java
deleted file mode 100644
index b74078f7e..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/MoveDeleteHook.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.resources.team.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-
-/**
- * This hook exists to ensure that folders deletions will be recorded so that outgoing file
- * deletions can be properly communicated to the server.
- */
-public class MoveDeleteHook implements IMoveDeleteHook {
-
- /**
- * @see IMoveDeleteHook#deleteFile(IResourceTree, IFile, int, IProgressMonitor)
- */
- public boolean deleteFile(
- final IResourceTree tree,
- final IFile file,
- final int updateFlags,
- IProgressMonitor monitor) {
-
- try {
- monitor.beginTask(null, 100);
-
- // No special handling required for team-private members
- if (file.isTeamPrivateMember()) return false;
-
- // If the file is ignored by CVS then we can just delete it.
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file);
- if (cvsFile.isIgnored()) return false;
-
- // If we can't check out the files, return.
- if (!checkOutFiles(tree, new IFile[] {file}, Policy.subMonitorFor(monitor, 30))) {
- // Return that the delete was handled because the checkout
- // will have reported the error to the IResourceTree
- return true;
- }
-
- // Otherwise, we need to prepare properly for the delete
- EclipseSynchronizer.getInstance().performMoveDelete(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- try {
- monitor.beginTask(null, 100);
- EclipseSynchronizer.getInstance().prepareForDeletion(file, Policy.subMonitorFor(monitor, 40));
- tree.standardDeleteFile(file, updateFlags, Policy.subMonitorFor(monitor, 60));
- } finally {
- monitor.done();
- }
- }
- }, Policy.subMonitorFor(monitor, 70));
- } catch (CVSException e) {
- tree.failed(e.getStatus());
- } finally {
- monitor.done();
- }
- return true;
- }
-
- /**
- * @see IMoveDeleteHook#deleteFolder(IResourceTree, IFolder, int, IProgressMonitor)
- */
- public boolean deleteFolder(
- final IResourceTree tree,
- final IFolder folder,
- final int updateFlags,
- IProgressMonitor monitor) {
-
- // No special handling required for team-private members
- if (folder.isTeamPrivateMember()) return false;
- monitor.beginTask(null, 100);
- try {
- final ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder);
- if (cvsFolder.isCVSFolder() && ensureCheckedOut(new IFolder[] {folder}, tree, Policy.subMonitorFor(monitor, 30))) {
- EclipseSynchronizer.getInstance().performMoveDelete(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- try {
- monitor.beginTask(null, 100);
- EclipseSynchronizer.getInstance().prepareForDeletion(folder, Policy.subMonitorFor(monitor, 20));
- tree.standardDeleteFolder(folder, updateFlags, Policy.subMonitorFor(monitor, 50));
- } finally {
- monitor.done();
- }
- }
- }, Policy.subMonitorFor(monitor, 70));
- return true;
- } else if (!cvsFolder.isIgnored()) {
- EclipseSynchronizer.getInstance().prepareForDeletion(cvsFolder.getIResource(), Policy.subMonitorFor(monitor, 70));
- }
- } catch (CVSException e) {
- tree.failed(e.getStatus());
- } finally {
- monitor.done();
- }
- return false;
- }
-
- /**
- * @see IMoveDeleteHook#deleteProject(IResourceTree, IProject, int, IProgressMonitor)
- */
- public boolean deleteProject(
- IResourceTree tree,
- IProject project,
- int updateFlags,
- IProgressMonitor monitor) {
-
- // We need to flush any remembered folder deletions for the deleted project.
- // All other sync info is stored in session and persistant properties, which
- // are deleted when the associated resources are deleted
- try {
- EclipseSynchronizer.getInstance().prepareForDeletion(project, monitor);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- // todo: Perform a "cvs release" if there are any edits on the project
- return false;
- }
-
- /**
- * @see IMoveDeleteHook#moveFile(IResourceTree, IFile, IFile, int, IProgressMonitor)
- */
- public boolean moveFile(
- final IResourceTree tree,
- final IFile source,
- final IFile destination,
- final int updateFlags,
- IProgressMonitor monitor) {
-
- try {
- monitor.beginTask(null, 100);
-
- // ensure we can write to both the source and the destination
- IFile[] filesToCheckOut;
- if (destination.exists()) {
- filesToCheckOut = new IFile[] {source, destination};
- } else {
- filesToCheckOut = new IFile[] {source};
- }
- if (!checkOutFiles(tree, filesToCheckOut, Policy.subMonitorFor(monitor, 30))) {
- // Return that the move was handled because the checkout
- // will have reported the error to the IResourceTree
- return true;
- }
-
- // Perform the move
- EclipseSynchronizer.getInstance().performMoveDelete(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- try {
- monitor.beginTask(null, 100);
- EclipseSynchronizer.getInstance().prepareForDeletion(source, Policy.subMonitorFor(monitor, 40));
- if (destination.exists()) {
- EclipseSynchronizer.getInstance().prepareForDeletion(destination, Policy.subMonitorFor(monitor, 20));
- }
- tree.standardMoveFile(source, destination, updateFlags, Policy.subMonitorFor(monitor, 40));
- EclipseSynchronizer.getInstance().postMove(destination);
- } finally {
- monitor.done();
- }
- }
- }, Policy.subMonitorFor(monitor, 70));
- } catch (CVSException e) {
- tree.failed(e.getStatus());
- } finally {
- monitor.done();
- }
- return true;
- }
-
- /**
- * @see IMoveDeleteHook#moveFolder(IResourceTree, IFolder, IFolder, int, IProgressMonitor)
- */
- public boolean moveFolder(
- final IResourceTree tree,
- final IFolder source,
- final IFolder destination,
- final int updateFlags,
- IProgressMonitor monitor) {
-
- monitor.beginTask(null, 100);
- try {
- final ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(source);
- if (cvsFolder.isManaged()) {
- if (!ensureCheckedOut(new IFolder[] {source, destination}, tree, Policy.subMonitorFor(monitor, 20))) return true;
- EclipseSynchronizer.getInstance().performMoveDelete(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- EclipseSynchronizer.getInstance().prepareForDeletion(source, Policy.subMonitorFor(monitor, 20));
- if (destination.exists()) {
- EclipseSynchronizer.getInstance().prepareForDeletion(destination, Policy.subMonitorFor(monitor, 20));
- }
- tree.standardMoveFolder(source, destination, updateFlags, Policy.subMonitorFor(monitor, 30));
- purgeCVSFolders(destination, Policy.subMonitorFor(monitor, 20));
- EclipseSynchronizer.getInstance().postMove(destination);
- }
- private void purgeCVSFolders(IFolder destination, final IProgressMonitor monitor) throws CVSException {
- // Delete any CVS folders
- try {
- destination.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if (resource.getType() == IResource.FOLDER && resource.getName().equals(SyncFileWriter.CVS_DIRNAME)) {
- tree.standardDeleteFolder((IFolder)resource, updateFlags, monitor);
- return false;
- }
- return true;
- }
- }, IResource.DEPTH_INFINITE, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
- }, Policy.subMonitorFor(monitor, 60));
- return true;
- } else if (!cvsFolder.isIgnored()) {
- EclipseSynchronizer.getInstance().prepareForDeletion(cvsFolder.getIResource(), Policy.subMonitorFor(monitor, 60));
- }
- } catch (CVSException e) {
- tree.failed(e.getStatus());
- return true;
- } finally {
- monitor.done();
- }
-
- return false;
- }
-
- /**
- * @see IMoveDeleteHook#moveProject(IResourceTree, IProject, IProjectDescription, int, IProgressMonitor)
- */
- public boolean moveProject(
- IResourceTree tree,
- IProject source,
- IProjectDescription description,
- int updateFlags,
- IProgressMonitor monitor) {
-
- // We need to move (or flush) any remembered folder deletions for the deleted project
- // XXX We flush for now. This means that deleting a managed folder and then moving the
- // project will mean that the file deletions will be lost. It also means that phantom
- // folders are lost.
- try {
- EclipseSynchronizer.getInstance().prepareForDeletion(source, monitor);
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- return false;
- }
-
- /**
- * Ensure that the given file is checked out (i.e. not read only). Return
- * true if it is OK to procede and false otherwise.
- *
- * @param tree
- * @param file
- * @return boolean
- */
- /* private */ boolean checkOutFiles(IResourceTree tree, IFile[] files, IProgressMonitor monitor) {
- // Ensure that the file is "checked out" (i.e. not read-only
- IFileModificationValidator validator = getFileModificationValidator(files);
- if (validator instanceof ICVSFileModificationValidator) {
- IStatus status = ((ICVSFileModificationValidator)validator).validateMoveDelete(files, monitor);
- if (status.isOK()) {
- return true;
- } else {
- tree.failed(status);
- return false;
- }
- }
- return true;
- }
-
- private boolean ensureCheckedOut(IFolder[] folders, IResourceTree tree, IProgressMonitor monitor) {
- final List readOnlyFiles = new ArrayList();
- try {
- // Find any read-only files
- for (int i = 0; i < folders.length; i++) {
- IFolder folder = folders[i];
- if (folder.exists()) {
- folder.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if (resource.getType() == IResource.FILE) {
- IFile file = (IFile) resource;
- if (file.isReadOnly()) {
- readOnlyFiles.add(file);
- }
- }
- return true;
- }
- });
- }
- }
- if (readOnlyFiles.isEmpty()) return true;
- // Ensure read-only files are checked out
- return checkOutFiles(tree, (IFile[]) readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), monitor);
- } catch (CoreException e) {
- tree.failed(e.getStatus());
- return false;
- }
- }
-
- private FileModificationValidator getFileModificationValidator(IFile[] files) {
- return getProvider(files).getFileModificationValidator2();
- }
-
- private CVSTeamProvider getProvider(IFile[] files) {
- CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(files[0].getProject(), CVSProviderPlugin.getTypeId());
- return provider;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java
deleted file mode 100644
index a1f12c027..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Matt McCutchen <hashproduct+eclipse@gmail.com> - Bug 179174 CVS client sets timestamps back when replacing
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.util;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.ConsoleListeners;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * This class is used to prepare a local CVS workspace for replacement by
- * the corresponding remote resources. More specifically, this class will
- * unmanage added and deleted resources so that, after the operation, the
- * resources in the local workspace will either correspond to the remote
- * counterparts or be unmanaged.
- */
-public class PrepareForReplaceVisitor implements ICVSResourceVisitor {
-
- private IProgressMonitor monitor;
- private int depth;
- private CVSTag tag;
- private Set/*<ICVSFile>*/ deletedFiles;
- private Session session;
-
- public PrepareForReplaceVisitor(Session session, CVSTag tag){
- this.tag = tag;
- this.session = session;
- }
-
- /**
- * @see ICVSResourceVisitor#visitFile(ICVSFile)
- */
- public void visitFile(ICVSFile file) throws CVSException {
- byte[] syncBytes = file.getSyncBytes();
- if (syncBytes == null) {
- // Delete unmanaged files if the user wants them deleted
- if (CVSProviderPlugin.getPlugin().isReplaceUnmanaged()) {
- file.delete();
- deletedFiles.add(file);
- }
- } else if (ResourceSyncInfo.isAddition(syncBytes)) {
- file.delete();
- deletedFiles.add(file);
- file.unmanage(null);
- } else if (ResourceSyncInfo.isDeletion(syncBytes)) {
- // If deleted, null the sync info so the file will be refetched.
- // If we are replacing with the "BASE" tag, the file will not be refetched,
- // it is necessary to restore it from history (see bug 150158).
- if (!shouldDeleteModifications(file)) {
- IFile res = (IFile) file.getIResource();
- try {
- IFileState[] states = res.getHistory(null);
- if(states.length > 0){
- restoreParentDirectory(file);
- // recreate file using the latest state
- res.create(states[0].getContents(), true, null);
- } else {
- IStatus status = new Status(Status.ERROR, CVSProviderPlugin.ID,
- CVSMessages.PrepareForReplaceVisitor_DeletedFileWithoutHistoryCannotBeRestoredWhileRevertToBase);
- CVSProviderPlugin.log(status);
- ConsoleListeners.getInstance().errorLineReceived(session,
- NLS.bind(CVSMessages.PrepareForReplaceVisitor_FileCannotBeReplacedWithBase,
- res.getName()),
- status);
- }
- } catch (CoreException e) {
- CVSProviderPlugin.log(e);
- }
- } else {
- file.unmanage(null);
- }
- } else if (file.isModified(null) && shouldDeleteModifications(file)) {
- // If the file is modified, delete and unmanage it and allow the
- // replace operation to fetch it again. This is required because "update -C"
- // will fail for locally modified resources that have been deleted remotely.
- file.delete();
- deletedFiles.add(file);
- // Only unmanage if the delete was successful (bug 76029)
- file.unmanage(null);
- }
- monitor.worked(1);
- }
-
- private void restoreParentDirectory(ICVSFile file) throws CVSException {
- List parents = new ArrayList();
- ICVSFolder parent = file.getParent();
- while(!parent.getIResource().exists()){
- parents.add(parent);
- parent = parent.getParent();
- }
- for(int i = parents.size() - 1; i > -1; i--){
- ((ICVSFolder)parents.get(i)).mkdir();
- }
- }
-
- /*
- * see bug 150158
- */
- private boolean shouldDeleteModifications(ICVSFile file) {
- return (tag == null && !isStickyRevision(file)) // We don't need to delete sticky files since there can't be conflicting modifications (see bug 199367)
- || (tag != null && !tag.getName().equals("BASE")); //$NON-NLS-1$
- }
-
- private boolean isStickyRevision(ICVSFile file) {
- try {
- ResourceSyncInfo info = file.getSyncInfo();
- if (info != null) {
- CVSTag tag = info.getTag();
- if (tag != null) {
- // The problem with tags on files is that they always have the branch type
- // so we need to check if the tag is the file's revision
- return tag.getName().equals(info.getRevision());
- }
- }
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- return false;
- }
-
- /**
- * @see ICVSResourceVisitor#visitFolder(ICVSFolder)
- */
- public void visitFolder(ICVSFolder folder) throws CVSException {
- // Delete unmanaged folders if the user wants them deleted
- if (!folder.isCVSFolder()) {
- if (CVSProviderPlugin.getPlugin().isReplaceUnmanaged()) {
- // Needed to add files inside to deletedFiles set.
- folder.acceptChildren(this);
- folder.delete();
- }
- } else {
- // Visit the children of the folder as appropriate
- if (depth == IResource.DEPTH_INFINITE) {
- folder.acceptChildren(this);
- } else if (depth == IResource.DEPTH_ONE) {
- ICVSResource[] files = folder.members(ICVSFolder.FILE_MEMBERS);
- for (int i = 0; i < files.length; i++) {
- files[i].accept(this);
- }
- }
- // Also delete ignored child files that start with .#
- ICVSResource[] ignoredFiles = folder.members(ICVSFolder.FILE_MEMBERS | ICVSFolder.IGNORED_MEMBERS);
- for (int i = 0; i < ignoredFiles.length; i++) {
- ICVSResource cvsResource = ignoredFiles[i];
- if (cvsResource.getName().startsWith(".#")) { //$NON-NLS-1$
- cvsResource.delete();
- }
- }
- }
- monitor.worked(1);
- }
-
- public void visitResources(IProject project, final ICVSResource[] resources, final String oneArgMessage, int depth, IProgressMonitor pm) throws CVSException {
- this.depth = depth;
- deletedFiles = new HashSet();
- CVSWorkspaceRoot.getCVSFolderFor(project).run(new ICVSRunnable() {
- public void run(IProgressMonitor pm) throws CVSException {
- monitor = Policy.infiniteSubMonitorFor(pm, 100);
- monitor.beginTask(null, 512);
- for (int i = 0; i < resources.length; i++) {
- if (oneArgMessage != null) {
- monitor.subTask(NLS.bind(oneArgMessage, new String[] { resources[i].getIResource().getFullPath().toString() }));
- }
- resources[i].accept(PrepareForReplaceVisitor.this);
- }
- monitor.done();
- }
- }, pm);
- }
-
- public Set/*<ICVSFile>*/ getDeletedFiles() {
- return Collections.unmodifiableSet(deletedFiles);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceStateChangeListeners.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceStateChangeListeners.java
deleted file mode 100644
index a8efc1e03..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceStateChangeListeners.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener;
-import org.eclipse.team.internal.ccvs.core.Policy;
-
-/**
- * Class that manages the listeners of CVS sync change notification
- */
-public class ResourceStateChangeListeners {
-
- private static List listeners = new ArrayList();
-
- private static ResourceStateChangeListeners instance;
-
- public static synchronized ResourceStateChangeListeners getListener() {
- if (instance == null) {
- instance = new ResourceStateChangeListeners();
- }
- return instance;
- }
-
- /*
- * Private class used to safely notify listeners of resouce sync info changes.
- * Subclass override the notify(IResourceStateChangeListener) method to
- * fire specific events inside an ISafeRunnable.
- */
- private abstract class Notification implements ISafeRunnable {
- private IResourceStateChangeListener listener;
- public void handleException(Throwable exception) {
- // don't log the exception....it is already being logged in Platform#run
- }
- public void run(IResourceStateChangeListener listener) {
- this.listener = listener;
- Platform.run(this);
- }
- public void run() throws Exception {
- notify(listener);
- }
- /**
- * Subsclasses overide this method to send an event safely to a lsistener
- * @param listener
- */
- protected abstract void notify(IResourceStateChangeListener listener);
- }
-
- private IResourceStateChangeListener[] getListeners() {
- synchronized(listeners) {
- return (IResourceStateChangeListener[]) listeners.toArray(new IResourceStateChangeListener[listeners.size()]);
- }
- }
-
- private void fireNotification(Notification notification) {
- // Get a snapshot of the listeners so the list doesn't change while we're firing
- IResourceStateChangeListener[] listeners = getListeners();
- // Notify each listener in a safe manner (i.e. so their exceptions don't kill us)
- for (int i = 0; i < listeners.length; i++) {
- IResourceStateChangeListener listener = listeners[i];
- notification.run(listener);
- }
- }
-
- public void addResourceStateChangeListener(IResourceStateChangeListener listener) {
- synchronized(listeners) {
- listeners.add(listener);
- }
- }
-
- public void removeResourceStateChangeListener(IResourceStateChangeListener listener) {
- synchronized(listeners) {
- listeners.remove(listener);
- }
- }
-
- public void resourceSyncInfoChanged(final IResource[] resources) {
- if (Policy.DEBUG_SYNC_CHANGE_EVENTS) {
- printDebugInfo("Sync info change event ", resources); //$NON-NLS-1$
- }
- fireNotification(new Notification() {
- public void notify(IResourceStateChangeListener listener) {
- listener.resourceSyncInfoChanged(resources);
- }
- });
- }
-
- public void externalSyncInfoChange(final IResource[] resources) {
- if (Policy.DEBUG_SYNC_CHANGE_EVENTS) {
- printDebugInfo("External sync info change event ", resources); //$NON-NLS-1$
- }
- fireNotification(new Notification() {
- public void notify(IResourceStateChangeListener listener) {
- listener.externalSyncInfoChange(resources);
- }
- });
- }
-
- public void resourceModified(final IResource[] resources) {
- if (Policy.DEBUG_SYNC_CHANGE_EVENTS) {
- printDebugInfo("Resource modified change event ", resources); //$NON-NLS-1$
- }
- fireNotification(new Notification() {
- public void notify(IResourceStateChangeListener listener) {
- listener.resourceModified(resources);
- }
- });
- }
- public void projectConfigured(final IProject project) {
- if (Policy.DEBUG_SYNC_CHANGE_EVENTS) {
- printDebugInfo("Project configured change event ", new IResource[] { project }); //$NON-NLS-1$
- }
- fireNotification(new Notification() {
- public void notify(IResourceStateChangeListener listener) {
- listener.projectConfigured(project);
- }
- });
- }
- public void projectDeconfigured(final IProject project) {
- if (Policy.DEBUG_SYNC_CHANGE_EVENTS) {
- printDebugInfo("Project deconfigured change event ", new IResource[] { project }); //$NON-NLS-1$
- }
- fireNotification(new Notification() {
- public void notify(IResourceStateChangeListener listener) {
- listener.projectDeconfigured(project);
- }
- });
- }
-
- private void printDebugInfo(String prefix, IResource[] resources) {
- System.out.print(prefix);
- System.out.print(" from thread " + Thread.currentThread().getName()); //$NON-NLS-1$
- System.out.print(" for the following " + resources.length + " resources"); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println(":"); //$NON-NLS-1$
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- System.out.println(resource.getFullPath().toString());
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResponsiveSocketFactory.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResponsiveSocketFactory.java
deleted file mode 100644
index f598b2bbd..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResponsiveSocketFactory.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.util;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.lang.reflect.*;
-import java.net.*;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-
-/**
- * Class copied from "org.eclipse.jsch.internal.core"
- */
-public class ResponsiveSocketFactory {
- private static final String JAVA_NET_PROXY="java.net.Proxy"; //$NON-NLS-1$
- private static final int DEFAULT_TIMEOUT=60; // Seconds
- private IProgressMonitor monitor;
- private final int timeout;
- private static Class proxyClass;
- private static boolean hasProxyClass = true;
- public ResponsiveSocketFactory(IProgressMonitor monitor, int timeout) {
- if (monitor == null)
- monitor = new NullProgressMonitor();
- this.monitor = monitor;
- this.timeout=timeout;
- }
- public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
- Socket socket = null;
- socket = createSocket(host, port, timeout / 1000, monitor);
- // Null out the monitor so we don't hold onto anything
- // (i.e. the SSH2 session will keep a handle to the socket factory around
- monitor = new NullProgressMonitor();
- // Set the socket timeout
- socket.setSoTimeout(timeout);
- return socket;
- }
-
- /**
- * Helper method that will time out when making a socket connection.
- * This is required because there is no way to provide a timeout value
- * when creating a socket and in some instances, they don't seem to
- * timeout at all.
- */
- private Socket createSocket(final String host, final int port, int timeout, IProgressMonitor monitor) throws UnknownHostException, IOException {
-
- // Start a thread to open a socket
- final Socket[] socket = new Socket[] { null };
- final Exception[] exception = new Exception[] {null };
- final Thread thread = new Thread(new Runnable() {
- public void run() {
- try {
- Socket newSocket = internalCreateSocket(host, port);
- synchronized (socket) {
- if (Thread.interrupted()) {
- // we we're either canceled or timed out so just close the socket
- newSocket.close();
- } else {
- socket[0] = newSocket;
- }
- }
- } catch (UnknownHostException e) {
- exception[0] = e;
- } catch (IOException e) {
- exception[0] = e;
- }
- }
- });
- thread.start();
-
- // Wait the appropriate number of seconds
- if (timeout == 0) timeout = DEFAULT_TIMEOUT;
- for (int i = 0; i < timeout; i++) {
- try {
- // wait for the thread to complete or 1 second, which ever comes first
- thread.join(1000);
- } catch (InterruptedException e) {
- // I think this means the thread was interrupted but not necessarily timed out
- // so we don't need to do anything
- }
- synchronized (socket) {
- // if the user canceled, clean up before preempting the operation
- if (monitor.isCanceled()) {
- if (thread.isAlive()) {
- thread.interrupt();
- }
- if (socket[0] != null) {
- socket[0].close();
- }
- // this method will throw the proper exception
- Policy.checkCanceled(monitor);
- }
- }
- }
- // If the thread is still running (i.e. we timed out) signal that it is too late
- synchronized (socket) {
- if (thread.isAlive()) {
- thread.interrupt();
- }
- }
- if (exception[0] != null) {
- if (exception[0] instanceof UnknownHostException)
- throw (UnknownHostException)exception[0];
- else
- throw (IOException)exception[0];
- }
- if (socket[0] == null) {
- throw new InterruptedIOException(NLS.bind(CVSMessages.Util_timeout, new String[] { host }));
- }
- return socket[0];
- }
-
- /* private */ Socket internalCreateSocket(final String host, final int port)
- throws UnknownHostException, IOException{
- Class proxyClass = getProxyClass();
- if (proxyClass != null) {
- // We need to disable proxy support for the socket
- try{
-
- // Obtain the value of the NO_PROXY static field of the proxy class
- Field field = proxyClass.getField("NO_PROXY"); //$NON-NLS-1$
- Object noProxyObject = field.get(null);
- Constructor constructor = Socket.class.getConstructor(new Class[] { proxyClass });
- Object o = constructor.newInstance(new Object[] { noProxyObject });
- if(o instanceof Socket){
- Socket socket=(Socket)o;
- socket.connect(new InetSocketAddress(host, port), timeout * 1000);
- return socket;
- }
- }
- catch(SecurityException e){
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("An internal error occurred while connecting to {0}", host), e); //$NON-NLS-1$
- }
- catch(NoSuchFieldException e){
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("An internal error occurred while connecting to {0}", host), e); //$NON-NLS-1$
- }
- catch(IllegalArgumentException e){
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("An internal error occurred while connecting to {0}", host), e); //$NON-NLS-1$
- }
- catch(IllegalAccessException e){
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("An internal error occurred while connecting to {0}", host), e); //$NON-NLS-1$
- }
- catch(NoSuchMethodException e){
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("An internal error occurred while connecting to {0}", host), e); //$NON-NLS-1$
- }
- catch(InstantiationException e){
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("An internal error occurred while connecting to {0}", host), e); //$NON-NLS-1$
- }
- catch(InvocationTargetException e){
- CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("An internal error occurred while connecting to {0}", host), e); //$NON-NLS-1$
- }
-
- }
- return new Socket(host, port);
- }
-
- private synchronized Class getProxyClass() {
- if (hasProxyClass && proxyClass == null) {
- try{
- proxyClass = Class.forName(JAVA_NET_PROXY);
- }
- catch(ClassNotFoundException e){
- // We couldn't find the class so we'll assume we are using pre-1.5 JRE
- hasProxyClass = false;
- }
- }
- return proxyClass;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/StringMatcher.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/StringMatcher.java
deleted file mode 100644
index 059746443..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/StringMatcher.java
+++ /dev/null
@@ -1,450 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Matt McCutchen (hashproduct+eclipse@gmail.com) - Bug 132260 Eclipse doesn't understand negated character classes in .cvsignore
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.util;
-
-import java.util.Vector;
-import java.util.HashMap;
-
-/**
- * A StringMatcher contains a glob and matches it against strings.
- * StringMatcher supports * and ? wildcards and character classes, possibly
- * negated by !, that contain single characters and/or ranges.
- * Note: code copied from org.eclipse.jdt.internal.core.util.StringMatcher on April 3, 2001
- * (version 0.1 - 010901H18 [rename jbl]).
- */
-public class StringMatcher {
-
- protected static class CharacterClass {
- final boolean isNegated;
- final String text;
-
- CharacterClass(boolean isNegated, String text) {
- this.isNegated = isNegated;
- this.text = text;
- }
-
- boolean listed(char c) {
- for (int i = 0; i < text.length(); ) {
- if (i + 2 < text.length() && text.charAt(i + 1) == '-') {
- if (c >= text.charAt(i) && c <= text.charAt(i + 2))
- return true;
- i += 3;
- } else {
- if (c == text.charAt(i))
- return true;
- i++;
- }
- }
- return false;
- }
- boolean match(char c) {
- return listed(c) ^ isNegated;
- }
- }
-
- protected String fPattern;
- protected int fLength; // pattern length
- protected boolean fIgnoreWildCards;
- protected boolean fIgnoreCase;
- protected boolean fHasLeadingStar;
- protected boolean fHasTrailingStar;
- protected String fSegments[]; //the given pattern is split into * separated segments
- protected HashMap/*<Integer, CharacterClass>*/ fCharacterClassMaps[];
-
- /* boundary value beyond which we don't need to search in the text */
- protected int fBound = 0;
-
- /** \? in pattern becomes ? in fSegments, while ? in pattern becomes this */
- protected static final char fSingleWildCard = '\u0000';
-
- public static class Position {
- int start; //inclusive
- int end; //exclusive
- public Position(int start, int end) {
- this.start = start;
- this.end = end;
- }
- public int getStart() {
- return start;
- }
- public int getEnd() {
- return end;
- }
- }
-
- /**
- * Find the first occurrence of the pattern between <code>start</code> (inclusive)
- * and <code>end</code> (exclusive).
- * @param text the String object to search in
- * @param start the starting index of the search range, inclusive
- * @param end the ending index of the search range, exclusive
- * @return a <code>StringMatcher.Position</code> object that keeps the starting
- * (inclusive) and ending positions (exclusive) of the first occurrence of the
- * pattern in the specified range of the text; return null if not found or subtext
- * is empty (start==end). A pair of zeros is returned if pattern is empty string
- * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
- * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
- */
- public StringMatcher.Position find(String text, int start, int end) {
- if (fPattern == null|| text == null)
- throw new IllegalArgumentException();
-
- int tlen = text.length();
- if (start < 0)
- start = 0;
- if (end > tlen)
- end = tlen;
- if (end < 0 ||start >= end )
- return null;
- if (fLength == 0)
- return new Position(start, start);
- if (fIgnoreWildCards) {
- int x = posIn(text, start, end);
- if (x < 0)
- return null;
- return new Position(x, x+fLength);
- }
-
- int segCount = fSegments.length;
- if (segCount == 0)//pattern contains only '*'(s)
- return new Position (start, end);
-
- int curPos = start;
- int matchStart = -1;
- int i;
- for (i = 0; i < segCount && curPos < end; ++i) {
- String current = fSegments[i];
- int nextMatch = regExpPosIn(text, curPos, end, current, fCharacterClassMaps[i]);
- if (nextMatch < 0 )
- return null;
- if(i == 0)
- matchStart = nextMatch;
- curPos = nextMatch + current.length();
- }
- if (i < segCount)
- return null;
- return new Position(matchStart, curPos);
- }
-
- /**
- * Constructs a StringMatcher that matches strings against the glob
- * <code>aPattern</code>.
- *
- * <code>aPattern</code> may contain "?"s, which match single characters,
- * "*"s, which match zero or more characters, and character classes in
- * "[...]". All characters other than "*", "?", and "[" match themselves,
- * except for "\", which escapes the following character. For example,
- * "\*" matches "*" and "\a" matches "a", while "\\" matches "\". Remember
- * that Java string literals have an additional level of escaping, so a
- * string literal for a glob matching a single backslash is written "\\\\".
- *
- * "[" begins a character class, which may contain characters and/or ranges;
- * "]" ends the class. A character class matches any single character in
- * it; for example, "[ac-e]" matches an "a", a "c", a "d", or an "e". A
- * negated character class begins with "[!" and matches any single character
- * not listed. Inside a character class, "\" loses its special meaning as
- * an escape character. The fancier POSIX requirements for character
- * classes are not supported: ranges use Unicode character numbers, and
- * (for example) [:alpha:], [.ch.], and [=a=] are not recognized.
- *
- * @param aPattern the glob to match text with
- * @param ignoreCase if true, case is ignored
- * @param ignoreWildCards if true, the pattern is taken literally instead of
- * as a glob
- */
- public StringMatcher(String aPattern, boolean ignoreCase, boolean ignoreWildCards) {
- fIgnoreCase = ignoreCase;
- fIgnoreWildCards = ignoreWildCards;
- fLength = aPattern.length();
-
- /* convert case */
- if (fIgnoreCase) {
- fPattern = aPattern.toUpperCase();
- } else {
- fPattern = aPattern;
- }
-
- if (fIgnoreWildCards) {
- parseNoWildCards();
- } else {
- parseWildCards();
- }
- }
- /**
- * Given the starting (inclusive) and the ending (exclusive) poisitions in the
- * <code>text</code>, determine if the given substring matches with aPattern
- * @return true if the specified portion of the text matches the pattern
- * @param text a String object that contains the substring to match
- * @param start marks the starting position (inclusive) of the substring
- * @param end marks the ending index (exclusive) of the substring
- */
- public boolean match(String text, int start, int end) {
- if (null == text)
- throw new IllegalArgumentException();
-
- if (start > end)
- return false;
-
- if (fIgnoreWildCards)
- return (end - start == fLength) && fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
- int segCount= fSegments.length;
- if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) // pattern contains only '*'(s)
- return true;
- if (start == end)
- return fLength == 0;
- if (fLength == 0)
- return start == end;
-
- int tlen= text.length();
- if (start < 0)
- start= 0;
- if (end > tlen)
- end= tlen;
-
- int tCurPos= start;
- int bound= end - fBound;
- if ( bound < 0)
- return false;
- int i=0;
- String current= fSegments[i];
- HashMap/*<Integer, CharacterClass>*/ curCharClassMap= fCharacterClassMaps[i];
- int segLength= current.length();
-
- /* process first segment */
- if (!fHasLeadingStar){
- if(!regExpRegionMatches(text, start, current, 0, segLength, curCharClassMap)) {
- return false;
- } else {
- ++i;
- tCurPos= tCurPos + segLength;
- }
- }
- if ((fSegments.length == 1) && (!fHasLeadingStar) && (!fHasTrailingStar)) {
- // only one segment to match, no wildcards specified
- return tCurPos == end;
- }
- /* process middle segments */
- while (i < segCount) {
- current= fSegments[i];
- curCharClassMap= fCharacterClassMaps[i];
- int currentMatch;
- int k= current.indexOf(fSingleWildCard);
- if (k < 0) {
- currentMatch= textPosIn(text, tCurPos, end, current);
- if (currentMatch < 0)
- return false;
- } else {
- currentMatch= regExpPosIn(text, tCurPos, end, current, curCharClassMap);
- if (currentMatch < 0)
- return false;
- }
- tCurPos= currentMatch + current.length();
- i++;
- }
-
- /* process final segment */
- if (!fHasTrailingStar && tCurPos != end) {
- int clen= current.length();
- return regExpRegionMatches(text, end - clen, current, 0, clen, curCharClassMap);
- }
- return i == segCount ;
- }
- /**
- * match the given <code>text</code> with the pattern
- * @return true if matched eitherwise false
- * @param text the String object to match against the pattern
- */
- public boolean match(String text) {
- return match(text, 0, text.length());
- }
- /**
- * This method parses the given pattern into segments separated by wildcard '*' characters.
- * Since wildcards are not being used in this case, the pattern consists of a single segment.
- */
- private void parseNoWildCards() {
- fSegments = new String[1];
- fSegments[0] = fPattern;
- fBound = fLength;
- }
- /**
- * This method parses the given pattern into segments separated by wildcard '*' characters.
- * @param p a String object that is a simple regular expression with *  and/or ? 
- */
- private void parseWildCards() {
- if(fPattern.startsWith("*"))//$NON-NLS-1$
- fHasLeadingStar = true;
-
- Vector temp = new Vector();
- HashMap/*<Integer, CharacterClass>*/ segmentCCs = null;
- Vector/*<HashMap<Integer, CharacterClass>>*/ allCCs = new Vector();
-
- int pos = 0;
- StringBuffer buf = new StringBuffer();
- while (pos < fLength) {
- char c = fPattern.charAt(pos++);
- fHasTrailingStar = false;
- switch (c) {
- case '\\':
- if (pos >= fLength) {
- buf.append(c);
- } else {
- c = fPattern.charAt(pos++);
- buf.append(c);
- }
- break;
- case '*':
- fHasTrailingStar = true;
- if (buf.length() > 0) {
- /* new segment */
- temp.addElement(buf.toString());
- allCCs.addElement(segmentCCs);
- fBound += buf.length();
- buf.setLength(0);
- segmentCCs = null;
- }
- break;
- case '[':
- if (segmentCCs == null)
- segmentCCs = new HashMap/*<Integer, CharacterClass>*/();
- if (pos >= fLength) {
- // Unterminated; take [ literally for lack of anything better to do
- buf.append(c);
- break;
- }
- boolean negated = (fPattern.charAt(pos) == '!');
- int beginPos = (negated ? pos + 1 : pos);
- int endPos = fPattern.indexOf(']', beginPos + 1);
- if (endPos == -1) {
- // Unterminated; take [ literally for lack of anything better to do
- buf.append(c);
- break;
- }
- CharacterClass cc = new CharacterClass(negated, fPattern.substring(beginPos, endPos));
- segmentCCs.put(new Integer(buf.length()), cc);
- pos = endPos + 1;
- /* fall through; fSingleWildCard can also represent a character class */
- case '?':
- /* append special character representing single match wildcard */
- buf.append(fSingleWildCard);
- break;
- default:
- buf.append(c);
- }
- }
-
- /* add last buffer to segment list */
- if (buf.length() > 0) {
- temp.addElement(buf.toString());
- allCCs.addElement(segmentCCs);
- fBound += buf.length();
- }
-
- fSegments = new String[temp.size()];
- temp.copyInto(fSegments);
- fCharacterClassMaps = new HashMap[allCCs.size()];
- allCCs.copyInto(fCharacterClassMaps);
- }
- /**
- * @param text a string which contains no wildcard
- * @param start the starting index in the text for search, inclusive
- * @param end the stopping point of search, exclusive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int posIn(String text, int start, int end) {//no wild card in pattern
- return textPosIn(text, start, end, fPattern);
- }
- /**
- * @param text a simple regular expression that may only contain '?'(s)
- * @param start the starting index in the text for search, inclusive
- * @param end the stopping point of search, exclusive
- * @param p a simple regular expression that may contains '?'
- * @param caseIgnored whether the pattern is not casesensitive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int regExpPosIn(String text, int start, int end, String p, HashMap/*<Integer, CharacterClass>*/ ccMap) {
- int plen = p.length();
-
- int max = end - plen;
- for (int i = start; i <= max; ++i) {
- if (regExpRegionMatches(text, i, p, 0, plen, ccMap))
- return i;
- }
- return -1;
- }
- /**
- *
- * @return boolean
- * @param text a String to match
- * @param start int that indicates the starting index of match, inclusive
- * @param end int that indicates the ending index of match, exclusive
- * @param p String, a simple regular expression that may contain '?'
- * @param ignoreCase boolean indicating whether <code>p</code> is case sensitive
- * @param ccMap maps each index of p at which fSingleWildCard occurs (as an
- * Integer) to CharacterClass data, or null for a plain old ?
- */
- protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen, HashMap/*<Integer, CharacterClass>*/ ccMap) {
- for (int ppos = 0; plen-- > 0; ppos++) {
- char tchar = text.charAt(tStart++);
- char pchar = p.charAt(pStart++);
-
- /* process wild cards */
- if (!fIgnoreWildCards) {
- /* skip single wild cards */
- if (pchar == fSingleWildCard) {
- if (ccMap == null)
- continue;
- CharacterClass cc = (CharacterClass) ccMap.get(new Integer(ppos));
- if (cc == null || cc.match(tchar))
- continue;
- else
- return false;
- }
- }
- if (pchar == tchar)
- continue;
- if (fIgnoreCase) {
- char tc = Character.toUpperCase(tchar);
- if (tc == pchar)
- continue;
- }
- return false;
- }
- return true;
- }
- /**
- * @param text the string to match
- * @param start the starting index in the text for search, inclusive
- * @param end the stopping point of search, exclusive
- * @param p a string that has no wildcard
- * @param ignoreCase boolean indicating whether p is case sensitive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int textPosIn(String text, int start, int end, String p) {
-
- int plen = p.length();
- int max = end - plen;
-
- if (!fIgnoreCase) {
- int i = text.indexOf(p, start);
- if (i == -1 || i > max)
- return -1;
- return i;
- }
-
- for (int i = start; i <= max; ++i) {
- if (text.regionMatches(true, i, p, 0, plen))
- return i;
- }
-
- return -1;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java
deleted file mode 100644
index 265c3a30c..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.util;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.ccvs.core.syncinfo.DeferredResourceChangeHandler;
-
-/*
- * Listens to CVS meta-file changes and notifies the EclipseSynchronizer of changes made to sync files
- * by 3rd parties.
- *
- * If CVS meta-directories are created outside of the CVS plugin their team-private state will be set
- * by this listener however this change won't be known to other plugins because it does not generate
- * a delta. As a result views, such as the navigator, may show CVS team-private directories. There
- * are some common scenarios where a user may (depending on the order of delta traversal) see
- * this behavior:
- *
- * 1. A user has an existing CVS project outside of Eclipse. By creating the project in Eclipse to point
- * to the existing location the project's contents will be brought into Eclipse and the CVS folders
- * will be marlked as team-private but other delta listeners that have handled the event already won't receive
- * notification that the resource is now team-private. As a result, the user may have to close views or
- * restart the workbench to have the CVS folders filtered.
- *
- * 2. A user performs CVS command line operations outside of Eclipse that result in new CVS folders.
- * From Eclipse the refresh local will bring in the new folders and they will be marked as team-private.
- * But as in 1, they may not appear in the UI.
- *
- * See: http://dev.eclipse.org/bugs/show_bug.cgi?id=12386
- */
-public class SyncFileChangeListener implements IResourceChangeListener {
-
- // consider the following changes types and ignore the others (e.g. marker and description changes are ignored)
- protected int INTERESTING_CHANGES = IResourceDelta.CONTENT |
- IResourceDelta.MOVED_FROM |
- IResourceDelta.MOVED_TO |
- IResourceDelta.OPEN |
- IResourceDelta.REPLACED |
- IResourceDelta.TYPE;
-
- protected boolean isProjectOpening = false;
-
- protected static DeferredResourceChangeHandler deferredHandler = new DeferredResourceChangeHandler();
-
- /**
- * This accessor is for use by test cases only.
- *
- * @return Returns the deferredHandler.
- */
- public static DeferredResourceChangeHandler getDeferredHandler() {
- return deferredHandler;
- }
-
- /*
- * When a resource changes this method will detect if the changed resources is a meta file that has changed
- * by a 3rd party. For example, if the command line tool was run and then the user refreshed from local. To
- * distinguish changes made by this class and thoses made by others a modification stamp is persisted with each
- * metafile.
- *
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- try {
- final Set changedContainers = new HashSet();
- final Set externalDeletions = new HashSet();
-
- setProjectOpening(false);
-
- event.getDelta().accept(new IResourceDeltaVisitor() {
-
- public boolean visit(IResourceDelta delta) {
- IResource resource = delta.getResource();
-
- if(resource.getType()==IResource.ROOT) {
- // continue with the delta
- return true;
- }
-
- if (resource.getType() == IResource.PROJECT) {
- // If the project is not accessible, don't process it
- if (!resource.isAccessible()) return false;
- setProjectOpening((delta.getFlags() & IResourceDelta.OPEN) != 0);
- }
-
- String name = resource.getName();
- int kind = delta.getKind();
-
- // if the file has changed but not in a way that we care
- // then ignore the change (e.g. marker changes to files).
- if(kind == IResourceDelta.CHANGED &&
- (delta.getFlags() & INTERESTING_CHANGES) == 0) {
- return true;
- }
-
- if(name.equals(SyncFileWriter.CVS_DIRNAME)) {
- handleCVSDir((IContainer)resource, kind);
- // if the project is opening there is no need to notify about chagned CVs/ meta files
- // they will all be read from disk.
- if(isProjectOpening()) return false;
- } else {
- // Inform the synchronizer about folder creations
- if(isProjectOpening()) return true;
- }
-
- if(isMetaFile(resource)) {
- IResource[] toBeNotified = handleChangedMetaFile(resource);
- if(toBeNotified.length>0 && isModifiedBy3rdParty(resource)) {
- for (int i = 0; i < toBeNotified.length; i++) {
- changedContainers.add(toBeNotified[i]);
- }
- if(Policy.DEBUG_METAFILE_CHANGES) {
- System.out.println("[cvs] metafile changed by 3rd party: " + resource.getFullPath()); //$NON-NLS-1$
- }
- return false; /*don't visit any children we have all the information we need*/
- }
- } else if(isIgnoreFile(resource) && isModifiedBy3rdParty(resource)) {
- deferredHandler.ignoreFileChanged((IFile)resource);
- } else if (isExternalDeletion(resource, kind)) {
- externalDeletions.add(resource);
- } else if (kind == IResourceDelta.ADDED && isRecreation(resource)) {
- deferredHandler.recreated(resource);
- }
- return true;
- }
- }, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
-
- if(!changedContainers.isEmpty() || !externalDeletions.isEmpty()) {
- EclipseSynchronizer.getInstance().syncFilesChangedExternally(
- (IContainer[])changedContainers.toArray(new IContainer[changedContainers.size()]),
- (IFile[]) externalDeletions.toArray(new IFile[externalDeletions.size()]));
- }
- } catch(CoreException e) {
- CVSProviderPlugin.log(e);
- }
- }
-
- /**
- * Treat a resource as an external deletion if
- * - it is a file
- * - the delta says the file was removed
- * - the file is not managed but its parent is a CVS folder
- *
- * There will be some false positives but the reaction to this situation
- * is to purge the cahced CVS meta-information so nothing bad will happen
- * for the false positives.
- *
- * @param resource
- * @param kind
- * @return
- */
- protected boolean isExternalDeletion(IResource resource, int kind) {
- if (kind != IResourceDelta.REMOVED) return false;
- if (resource.getType() != IResource.FILE) return false;
- ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)resource);
- try {
- return (!file.isManaged() && file.getParent().isCVSFolder() && file.getParent().exists());
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- return false;
- }
- }
-
- /*
- * Consider non-existing resources as being recently deleted and thus modified, and resources
- * with modification stamps that differ from when the CVS plugin last modified the meta-file.
- */
- protected boolean isModifiedBy3rdParty(IResource resource) {
- if(!resource.exists()) return true;
- long modStamp = resource.getModificationStamp();
- Long whenWeWrote;
- try {
- whenWeWrote = (Long)resource.getSessionProperty(SyncFileWriter.MODSTAMP_KEY);
- } catch(CoreException e) {
- CVSProviderPlugin.log(e);
- whenWeWrote = null;
- }
- return (whenWeWrote==null || whenWeWrote.longValue() != modStamp);
- }
-
- /*
- * If it's a new CVS directory with the canonical child metafiles then mark it as team-private. Otherwise
- * if changed or deleted
- */
- protected void handleCVSDir(IContainer cvsDir, int kind) {
- if((kind & IResourceDelta.ALL_WITH_PHANTOMS)!=0) {
- if(kind==IResourceDelta.ADDED) {
- // should this dir be made team-private? If it contains CVS/Root and CVS/Repository then yes!
- IFile rootFile = cvsDir.getFile(new Path(SyncFileWriter.ROOT));
- IFile repositoryFile = cvsDir.getFile(new Path(SyncFileWriter.REPOSITORY));
- if(rootFile.exists() && repositoryFile.exists() && !cvsDir.isTeamPrivateMember()) {
- try {
- // TODO: Is this considered a tree modification?
- cvsDir.setTeamPrivateMember(true);
- if(Policy.DEBUG_METAFILE_CHANGES) {
- System.out.println("[cvs] found a new CVS meta folder, marking as team-private: " + cvsDir.getFullPath()); //$NON-NLS-1$
- }
- } catch(CoreException e) {
- CVSProviderPlugin.log(CVSException.wrapException(cvsDir, CVSMessages.SyncFileChangeListener_errorSettingTeamPrivateFlag, e));
- }
- }
- }
- }
- }
-
- protected boolean isIgnoreFile(IResource resource) {
- return resource.getType() == IResource.FILE &&
- resource.getName().equals(SyncFileWriter.IGNORE_FILE);
- }
-
- private boolean isRecreation(IResource resource) {
- return EclipseSynchronizer.getInstance().wasPhantom(resource);
- }
-
- /*
- * It's a meta file if it's parent is a team-private CVS folder.
- */
- protected boolean isMetaFile(IResource resource) {
- IContainer parent = resource.getParent();
- return resource.getType() == IResource.FILE &&
- parent!=null &&
- parent.getName().equals(SyncFileWriter.CVS_DIRNAME) &&
- (parent.isTeamPrivateMember() || !parent.exists());
- }
-
- /*
- * This is a meta file (e.g. folder/CVS/Entries), notify that 'folder' and it's immediate children
- * may have their CVS sync state changed. If the 'folder' is deleted than no notification is
- * required.
- */
- protected IContainer[] handleChangedMetaFile(IResource resource) {
- IContainer changedContainer = resource.getParent().getParent();
- if(changedContainer.exists()) {
- return new IContainer[] {changedContainer};
- } else {
- return new IContainer[0];
- }
- }
-
- /**
- * @return boolean
- */
- public boolean isProjectOpening() {
- return isProjectOpening;
- }
-
- /**
- * Sets the isProjectOpening.
- * @param isProjectOpening The isProjectOpening to set
- */
- public void setProjectOpening(boolean isProjectOpening) {
- this.isProjectOpening = isProjectOpening;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java
deleted file mode 100644
index c64b54008..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java
+++ /dev/null
@@ -1,750 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Matt McCutchen (hashproduct+eclipse@gmail.com) - Bug 189304 [Sync Info] cvsignore lines should be split on whitespace
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.util;
-
-import java.io.*;
-import java.net.URI;
-import java.util.*;
-
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
-
-/*
- * This is a helper class that knows the format of the CVS metafiles. It
- * provides a bridge between the CVS metafile formats and location to the
- * Eclipse CVS client ResourceSyncInfo and FolderSyncInfo types.
- */
-public class SyncFileWriter {
-
- // the famous CVS meta directory name
- public static final String CVS_DIRNAME = "CVS"; //$NON-NLS-1$
-
- // CVS meta files located in the CVS subdirectory
- public static final String REPOSITORY = "Repository"; //$NON-NLS-1$
- public static final String ROOT = "Root"; //$NON-NLS-1$
- public static final String STATIC = "Entries.Static"; //$NON-NLS-1$
- public static final String TAG = "Tag"; //$NON-NLS-1$
- public static final String ENTRIES = "Entries"; //$NON-NLS-1$
- //private static final String PERMISSIONS = "Permissions"; //$NON-NLS-1$
- public static final String ENTRIES_LOG="Entries.Log"; //$NON-NLS-1$
- public static final String NOTIFY = "Notify"; //$NON-NLS-1$
- public static final String BASE_DIRNAME = "Base"; //$NON-NLS-1$
- public static final String BASEREV = "Baserev"; //$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$
-
- // key for saving the mod stamp for each writen meta file
- public static final QualifiedName MODSTAMP_KEY = new QualifiedName("org.eclipse.team.cvs.core", "meta-file-modtime"); //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * Reads the CVS/Entries, CVS/Entries.log and CVS/Permissions files from the
- * specified folder and returns ResourceSyncInfo instances for the data stored therein.
- * If the folder does not have a CVS subdirectory then <code>null</code> is returned.
- */
- public static byte[][] readAllResourceSync(IContainer parent) throws CVSException {
- IFolder cvsSubDir = getCVSSubdirectory(parent);
-
- if (!folderExists(cvsSubDir)){
- return null;
- }
-
- if (Policy.DEBUG_METAFILE_CHANGES) {
- System.out.println("Reading Entries file for " + parent.getFullPath()); //$NON-NLS-1$
- }
-
- // process Entries file contents
- String[] entries = readLines(cvsSubDir.getFile(ENTRIES));
- if (entries == null) return null;
- Map infos = new TreeMap();
- for (int i = 0; i < entries.length; i++) {
- String line = entries[i];
- if(!FOLDER_TAG.equals(line) && !"".equals(line)) { //$NON-NLS-1$
- try {
- ResourceSyncInfo info = new ResourceSyncInfo(line, null);
- infos.put(info.getName(), info);
- } catch (CVSException e) {
- // There was a problem parsing the entry line.
- // Log the problem and skip the entry
- CVSProviderPlugin.log(new CVSStatus(IStatus.ERROR, NLS.bind(CVSMessages.SyncFileWriter_0, new String[] { parent.getFullPath().toString() }), e));
- }
- }
- }
-
- // process Entries.log file contents
- String[] entriesLog = readLines(cvsSubDir.getFile(ENTRIES_LOG));
- if (entriesLog != null) {
- for (int i = 0; i < entriesLog.length; i++) {
- String line = entriesLog[i];
- if (line.startsWith(ADD_TAG)) {
- line = line.substring(ADD_TAG.length());
- ResourceSyncInfo info = new ResourceSyncInfo(line, null);
- infos.put(info.getName(), info);
- } else if (line.startsWith(REMOVE_TAG)) {
- line = line.substring(REMOVE_TAG.length());
- ResourceSyncInfo info = new ResourceSyncInfo(line, null);
- infos.remove(info.getName());
- }
- }
- }
-
- //return (ResourceSyncInfo[])infos.values().toArray(new ResourceSyncInfo[infos.size()]);
- byte[][] result = new byte[infos.size()][];
- int i = 0;
- for (Iterator iter = infos.values().iterator(); iter.hasNext();) {
- ResourceSyncInfo info = (ResourceSyncInfo) iter.next();
- result[i++] = info.getBytes();
- }
- return result;
- }
-
- private static boolean folderExists(IFolder cvsSubDir) throws CVSException {
- try {
- URI uri = cvsSubDir.getLocationURI();
- if (uri != null){
- IFileStore store = EFS.getStore(uri);
- if (store != null){
- return store.fetchInfo().exists();
- }
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- return false;
- }
-
- public static void writeAllResourceSync(IContainer parent, byte[][] infos) throws CVSException {
- try {
- if (Policy.DEBUG_METAFILE_CHANGES) {
- System.out.println("Writing Entries file for folder " + parent.getFullPath()); //$NON-NLS-1$
- }
- IFolder cvsSubDir = createCVSSubdirectory(parent);
-
- // format file contents
- String[] entries = new String[infos.length];
- for (int i = 0; i < infos.length; i++) {
- byte[] info = infos[i];
- entries[i] = new String(info);
- }
-
- // write Entries
- writeLines(cvsSubDir.getFile(ENTRIES), entries);
-
- // delete Entries.log
- cvsSubDir.getFile(ENTRIES_LOG).delete(IResource.NONE, null);
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
- /**
- * Reads the CVS/Root, CVS/Repository, CVS/Tag, and CVS/Entries.static files from
- * the specified folder and returns a FolderSyncInfo instance for the data stored therein.
- * If the folder does not have a CVS subdirectory then <code>null</code> is returned.
- */
- public static FolderSyncInfo readFolderSync(IContainer folder) throws CVSException {
- IFolder cvsSubDir = getCVSSubdirectory(folder);
-
- if (!folderExists(cvsSubDir)){
- return null;
- }
-
- if (Policy.DEBUG_METAFILE_CHANGES) {
- System.out.println("Reading Root/Repository files for " + folder.getFullPath()); //$NON-NLS-1$
- }
-
- // check to make sure the the cvs folder is hidden
- if (!cvsSubDir.isTeamPrivateMember() && cvsSubDir.exists()) {
- try {
- cvsSubDir.setTeamPrivateMember(true);
- } catch (CoreException e) {
- CVSProviderPlugin.log(e);
- }
- }
-
- // read CVS/Root
- String root = readFirstLine(cvsSubDir.getFile(ROOT));
- if (root == null) return null;
-
- // read CVS/Repository
- String repository = readFirstLine(cvsSubDir.getFile(REPOSITORY));
- if (repository == null) return null;
-
- // read CVS/Tag
- String tag = readFirstLine(cvsSubDir.getFile(TAG));
- if (Policy.DEBUG_METAFILE_CHANGES && tag != null) {
- System.out.println("Reading Tag file for " + folder.getFullPath()); //$NON-NLS-1$
- }
- CVSTag cvsTag = (tag != null) ? new CVSEntryLineTag(tag) : null;
-
- // read Entries.Static
- String staticDir = readFirstLine(cvsSubDir.getFile(STATIC));
- if (Policy.DEBUG_METAFILE_CHANGES && staticDir != null) {
- System.out.println("Reading Static file for " + folder.getFullPath()); //$NON-NLS-1$
- }
- boolean isStatic = (staticDir != null);
-
- // return folder sync
- return new FolderSyncInfo(repository, root, cvsTag, isStatic);
- }
-
- /**
- * Writes the CVS/Root, CVS/Repository, CVS/Tag, and CVS/Entries.static files to the
- * specified folder using the data contained in the specified FolderSyncInfo instance.
- */
- public static void writeFolderSync(IContainer folder, FolderSyncInfo info) throws CVSException {
- try {
- if (Policy.DEBUG_METAFILE_CHANGES) {
- System.out.println("Writing Root/Respository files for " + folder.getFullPath()); //$NON-NLS-1$
- }
- IFolder cvsSubDir = createCVSSubdirectory(folder);
-
- // write CVS/Root
- writeLines(cvsSubDir.getFile(ROOT), new String[] {info.getRoot()});
-
- // write CVS/Repository
- writeLines(cvsSubDir.getFile(REPOSITORY), new String[] {info.getRepository()});
-
- // write CVS/Tag
- IFile tagFile = cvsSubDir.getFile(TAG);
- if (info.getTag() != null) {
- if (Policy.DEBUG_METAFILE_CHANGES) {
- System.out.println("Writing Tag file for " + folder.getFullPath()); //$NON-NLS-1$
- }
- writeLines(tagFile, new String[] {info.getTag().toEntryLineFormat(false)});
- } else {
- if(tagFile.exists()) {
- if (Policy.DEBUG_METAFILE_CHANGES) {
- System.out.println("Deleting Tag file for " + folder.getFullPath()); //$NON-NLS-1$
- }
- tagFile.delete(IResource.NONE, null);
- }
- }
-
- // write CVS/Entries.Static
- IFile staticFile = cvsSubDir.getFile(STATIC);
- if(info.getIsStatic()) {
- // the existance of the file is all that matters
- if (Policy.DEBUG_METAFILE_CHANGES) {
- System.out.println("Writing Static file for " + folder.getFullPath()); //$NON-NLS-1$
- }
- writeLines(staticFile, new String[] {""}); //$NON-NLS-1$
- } else {
- if(staticFile.exists()) {
- if (Policy.DEBUG_METAFILE_CHANGES) {
- System.out.println("Deleting Static file for " + folder.getFullPath()); //$NON-NLS-1$
- }
- staticFile.delete(IResource.NONE, null);
- }
- }
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Returns all .cvsignore entries for the specified folder.
- */
- public static String[] readCVSIgnoreEntries(IContainer folder) throws CVSException {
- IFile ignoreFile = folder.getFile(new Path(IGNORE_FILE));
- if (ignoreFile != null) {
- String[] lines = readLines(ignoreFile);
- if (lines == null)
- return null;
- // Split each line on spaces and tabs.
- ArrayList/*<String>*/ entries = new ArrayList/*<String>*/();
- for (int ln = 0; ln < lines.length; ln++) {
- String line = lines[ln];
- int pos = 0;
- while (pos < line.length()) {
- if (line.charAt(pos) == ' ' || line.charAt(pos) == '\t')
- pos++;
- else {
- int start = pos;
- while (pos < line.length() && line.charAt(pos) != ' ' && line.charAt(pos) != '\t')
- pos++;
- entries.add(line.substring(start, pos));
- }
- }
- }
- return (String[]) entries.toArray(new String[entries.size()]);
- }
- return null;
- }
-
- /**
- * Writes all entries to the specified folder's .cvsignore file, overwriting any
- * previous edition of the file.
- */
- public static void writeCVSIgnoreEntries(IContainer folder, String[] patterns) throws CVSException {
- IFile ignoreFile = folder.getFile(new Path(IGNORE_FILE));
- writeLines(ignoreFile, patterns);
- }
-
- /**
- * Delete folder sync is equilavent to removing the CVS subdir.
- */
- public static void deleteFolderSync(IContainer folder) throws CVSException {
- try {
- if (Policy.DEBUG_METAFILE_CHANGES) {
- System.out.println("Deleting CVS directory from " + folder.getFullPath()); //$NON-NLS-1$
- }
- getCVSSubdirectory(folder).delete(IResource.NONE, null);
- } catch(CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Reads the CVS/Notify file from the specified folder and returns NotifyInfo instances
- * for the data stored therein. If the folder does not have a CVS subdirectory then <code>null</code> is returned.
- */
- public static NotifyInfo[] readAllNotifyInfo(IContainer parent) throws CVSException {
- IFolder cvsSubDir = getCVSSubdirectory(parent);
-
- if (!folderExists(cvsSubDir)){
- return null;
- }
-
- // process Notify file contents
- String[] entries = readLines(cvsSubDir.getFile(NOTIFY));
- if (entries == null) return null;
- Map infos = new TreeMap();
- for (int i = 0; i < entries.length; i++) {
- String line = entries[i];
- if(!"".equals(line)) { //$NON-NLS-1$
- try {
- NotifyInfo info = new NotifyInfo(parent, line);
- infos.put(info.getName(), info);
- } catch (CVSException e) {
- // We couldn't parse the notify info
- // Log it and ignore
- CVSProviderPlugin.log(e);
- }
- }
- }
-
- return (NotifyInfo[])infos.values().toArray(new NotifyInfo[infos.size()]);
- }
-
- /**
- * Writes the CVS/Notify file to the specified folder using the data contained in the
- * specified NotifyInfo instances. A CVS subdirectory must already exist (an exception
- * is thrown if it doesn't).
- */
- public static void writeAllNotifyInfo(IContainer parent, NotifyInfo[] infos) throws CVSException {
- // get the CVS directory
- IFolder cvsSubDir = getCVSSubdirectory(parent);
- // write lines will throw an exception if the CVS directoru does not exist
-
- if (infos.length == 0) {
- // if there are no notify entries, delete the notify file
- try {
- IFile notifyFile = cvsSubDir.getFile(NOTIFY);
- if(notifyFile.exists()) {
- notifyFile.delete(IResource.NONE, null);
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- } else {
- // format file contents
- String[] entries = new String[infos.length];
- for (int i = 0; i < infos.length; i++) {
- NotifyInfo info = infos[i];
- entries[i] = info.getNotifyLine();
- }
-
- // write Notify entries
- writeLines(cvsSubDir.getFile(NOTIFY), entries);
- }
- }
-
- /**
- * Reads the CVS/Baserev file from the specified folder and returns
- * BaserevInfo instances for the data stored therein. If the folder does not
- * have a CVS subdirectory then <code>null</code> is returned.
- */
- public static BaserevInfo[] readAllBaserevInfo(IContainer parent) throws CVSException {
- IFolder cvsSubDir = getCVSSubdirectory(parent);
-
- if (!folderExists(cvsSubDir)){
- return null;
- }
-
- // process Notify file contents
- String[] entries = readLines(cvsSubDir.getFile(BASEREV));
- if (entries == null) return null;
- Map infos = new TreeMap();
- for (int i = 0; i < entries.length; i++) {
- String line = entries[i];
- if(!"".equals(line)) { //$NON-NLS-1$
- BaserevInfo info = new BaserevInfo(line);
- infos.put(info.getName(), info);
- }
- }
-
- return (BaserevInfo[])infos.values().toArray(new BaserevInfo[infos.size()]);
- }
-
- /**
- * Writes the CVS/Baserev file to the specified folder using the data
- * contained in the specified BaserevInfo instances. A CVS subdirectory must
- * already exist (an exception is thrown if it doesn't).
- */
- public static void writeAllBaserevInfo(IContainer parent, BaserevInfo[] infos) throws CVSException {
- // get the CVS directory
- IFolder cvsSubDir = getCVSSubdirectory(parent);
- // write lines will throw an exception if the CVS directory does not exist
-
- // format file contents
- String[] entries = new String[infos.length];
- for (int i = 0; i < infos.length; i++) {
- BaserevInfo info = infos[i];
- entries[i] = info.getEntryLine();
- }
-
- // write Notify entries
- writeLines(cvsSubDir.getFile(BASEREV), entries);
- }
-
- /**
- * Returns the CVS subdirectory for this folder.
- */
- private static IFolder getCVSSubdirectory(IContainer folder) {
- return folder.getFolder(new Path(CVS_DIRNAME));
- }
-
- /**
- * Creates and makes team-private and returns a CVS subdirectory in this folder.
- */
- private static IFolder createCVSSubdirectory(IContainer folder) throws CVSException {
- try {
- final IFolder cvsSubDir = getCVSSubdirectory(folder);
- if (! cvsSubDir.exists()) {
- // important to have both the folder creation and setting of team-private in the
- // same runnable so that the team-private flag is set before other delta listeners
- // sees the CVS folder creation.
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- // Re-check existence in case this method was called without a resource rule
- if (! cvsSubDir.exists()) {
- if (existsInFileSystem(cvsSubDir)) {
- cvsSubDir.refreshLocal(IResource.DEPTH_INFINITE, null);
- cvsSubDir.setTeamPrivateMember(true);
- } else {
- cvsSubDir.create(IResource.TEAM_PRIVATE, true /*make local*/, null);
- }
- } else {
- if (!cvsSubDir.isTeamPrivateMember()) {
- cvsSubDir.setTeamPrivateMember(true);
- }
- }
- }
- }, folder, 0, null);
- }
- return cvsSubDir;
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- protected static boolean existsInFileSystem(IFolder cvsSubDir) {
- URI uri = cvsSubDir.getLocationURI();
- if (uri != null) {
- try {
- IFileStore store = EFS.getStore(uri);
- if (store != null) {
- return store.fetchInfo().exists();
- }
- } catch (CoreException e) {
- CVSProviderPlugin.log(e);
- }
- }
- return false;
- }
-
- /*
- * Reads the first line of the specified file.
- * Returns null if the file does not exist, or the empty string if it is blank.
- */
- private static String readFirstLine(IFile file) throws CVSException {
- try {
- InputStream in = getInputStream(file);
- if (in != null) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in), 512);
- try {
- String line = reader.readLine();
- if (line == null) return ""; //$NON-NLS-1$
- return line;
- } finally {
- reader.close();
- }
- }
- return null;
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- } catch (CoreException e) {
- // If the IFile doesn't exist or the underlying File doesn't exist,
- // just return null to indicate the absence of the file
- if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND
- || e.getStatus().getCode() == IResourceStatus.FAILED_READ_LOCAL)
- return null;
- throw CVSException.wrapException(e);
- }
- }
-
- private static InputStream getInputStream(IFile file) throws CoreException, FileNotFoundException {
- if (file.exists()) {
- return file.getContents(true);
- }
-
- URI uri = file.getLocationURI();
- if (uri != null) {
- IFileStore store = EFS.getStore(uri);
- if (store != null) {
- return store.openInputStream(EFS.NONE, null);
- }
- }
-
- File ioFile = file.getLocation().toFile();
- if (ioFile != null && ioFile.exists()) {
- return new FileInputStream(ioFile);
- }
-
- return null;
- }
-
- /*
- * Reads all lines of the specified file.
- * Returns null if the file does not exist.
- */
- private static String[] readLines(IFile file) throws CVSException {
- try {
- InputStream in = getInputStream(file);
- if (in != null) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in), 512);
- List fileContentStore = new ArrayList();
- try {
- String line;
- while ((line = reader.readLine()) != null) {
- fileContentStore.add(line);
- }
- return (String[]) fileContentStore.toArray(new String[fileContentStore.size()]);
- } finally {
- reader.close();
- }
- }
- return null;
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- } catch (CoreException e) {
- // If the IFile doesn't exist or the underlying File doesn't exist,
- // just return null to indicate the absence of the file
- if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND
- || e.getStatus().getCode() == IResourceStatus.FAILED_READ_LOCAL)
- return null;
- throw CVSException.wrapException(e);
- }
- }
-
- /*
- * Writes all lines to the specified file, using linefeed terminators for
- * compatibility with other CVS clients.
- */
- private static void writeLines(final IFile file, final String[] contents) throws CVSException {
- try {
- // The creation of sync files has to be in a runnable in order for the resulting delta
- // to include the MODSTAMP value. If not in a runnable then create/setContents
- // will trigger a delta and the SyncFileWriter change listener won't know that the delta
- // was a result of our own creation.
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- try {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- writeLinesToStreamAndClose(os, contents);
- if(!file.exists()) {
- file.create(new ByteArrayInputStream(os.toByteArray()), IResource.FORCE /*don't keep history but do force*/, null);
- } else {
- file.setContents(new ByteArrayInputStream(os.toByteArray()), IResource.FORCE /*don't keep history but do force*/, null);
- }
- file.setSessionProperty(MODSTAMP_KEY, new Long(file.getModificationStamp()));
- } catch(CVSException e) {
- throw new CoreException(e.getStatus());
- }
- }
- }, ResourcesPlugin.getWorkspace().getRuleFactory().createRule(file), 0, null);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- private static void writeLinesToStreamAndClose(OutputStream os, String[] contents) throws CVSException {
- byte[] lineEnd = getLineDelimiter();
- try {
- try {
- for (int i = 0; i < contents.length; i++) {
- os.write(contents[i].getBytes());
- os.write(lineEnd);
- }
- } finally {
- os.close();
- }
- } catch (IOException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /**
- * Method writeFileToBaseDirectory.
- *
- * @param file
- * @param info
- */
- public static void writeFileToBaseDirectory(IFile file, IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- try {
- IFolder baseFolder = getBaseDirectory(file);
- if (!baseFolder.exists()) {
- baseFolder.create(false /* force */, true /* local */, Policy.subMonitorFor(monitor, 10));
- }
- IFile target = baseFolder.getFile(new Path(null, file.getName()));
- if (target.exists()) {
- // XXX Should ensure that we haven't already copied it
- // XXX write the revision to the CVS/Baserev file
- setReadOnly(target, false);
- target.delete(true, Policy.subMonitorFor(monitor, 10));
- }
- // Copy the file so the timestamp is maintained
- file.copy(target.getFullPath(), true /* force */, Policy.subMonitorFor(monitor, 80));
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- monitor.done();
- }
- }
- /**
- * Method restoreFileFromBaseDirectory.
- * @param file
- * @param info
- * @param monitor
- */
- public static void restoreFileFromBaseDirectory(IFile file, IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- try {
- IFolder baseFolder = getBaseDirectory(file);
- IFile source = baseFolder.getFile(new Path(null, file.getName()));
- if (!source.exists()) {
- IStatus status = new CVSStatus(IStatus.ERROR, CVSStatus.ERROR, NLS.bind(CVSMessages.SyncFileWriter_baseNotAvailable, new String[] { file.getFullPath().toString() }), file);
- throw new CVSException(status);
- }
- if (file.exists()) {
- file.delete(false /* force */, true /* keep history */, Policy.subMonitorFor(monitor, 10));
- }
- // Make the source writtable to avoid problems on some file systems (bug 109308)
- setReadOnly(source, false);
- // Copy the file so the timestamp is maintained
- source.move(file.getFullPath(), false /* force */, true /* keep history */,Policy.subMonitorFor(monitor, 100));
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- monitor.done();
- }
- }
-
- private static void setReadOnly(IFile source, boolean readOnly) {
- ResourceAttributes attrs = source.getResourceAttributes();
- if (attrs != null && attrs.isReadOnly() != readOnly) {
- attrs.setReadOnly(readOnly);
- try {
- source.setResourceAttributes(attrs);
- } catch (CoreException e) {
- // Just log the failure since the move may succeed anyway
- CVSProviderPlugin.log(e);
- }
- }
- }
-
- /**
- * Method deleteFileFromBaseDirectory.
- * @param file
- * @param monitor
- */
- public static void deleteFileFromBaseDirectory(IFile file, IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- try {
- IFolder baseFolder = getBaseDirectory(file);
- IFile source = baseFolder.getFile(new Path(null, file.getName()));
- if (source.exists()) {
- setReadOnly(source, false);
- source.delete(false, false, Policy.subMonitorFor(monitor, 100));
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- monitor.done();
- }
- }
-
- private static IFolder getBaseDirectory(IFile file) {
- IContainer cvsFolder = getCVSSubdirectory(file.getParent());
- IFolder baseFolder = cvsFolder.getFolder(new Path(BASE_DIRNAME));
- return baseFolder;
- }
-
- /**
- * Return a handle to the CVS/Template file for the given folder
- * @param folder
- * @return IFile
- * @throws CVSException
- */
- public static IFile getTemplateFile(IContainer folder) throws CVSException {
- IFolder cvsFolder = createCVSSubdirectory(folder);
- return cvsFolder.getFile("Template"); //$NON-NLS-1$
- }
-
- /**
- * Method isEdited.
- * @param resource
- * @return boolean
- */
- public static boolean isEdited(IFile file) {
- IFolder baseFolder = getBaseDirectory(file);
- IFile baseFile = baseFolder.getFile(file.getName());
- return baseFile.exists();
- }
-
- private static byte[] getLineDelimiter() {
- if (CVSProviderPlugin.getPlugin().isUsePlatformLineend()) {
- String property = System.getProperty("line.separator"); //$NON-NLS-1$
- if (property != null) return property.getBytes();
- }
- return new byte[] { 0x0A };
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
deleted file mode 100644
index 910ff3b16..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
+++ /dev/null
@@ -1,532 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.util;
-
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-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;
-
-/**
- * Unsorted static helper-methods
- */
-public class Util {
-
- /**
- * Return the last segment of the given path
- * @param path
- * @return String
- */
- public static String getLastSegment(String path) {
- int index = path.lastIndexOf(Session.SERVER_SEPARATOR);
- if (index == -1) {
- return path;
- }
- if (index == path.length() - 1) {
- return getLastSegment(path.substring(0, index));
- }
- return path.substring(index + 1);
-
- }
-
- /**
- * Return the the given path with the last segment removed
- * @param path
- * @return String
- */
- public static String removeLastSegment(String path) {
- int index = path.lastIndexOf(Session.SERVER_SEPARATOR);
- if (index == -1)
- return ""; //$NON-NLS-1$
- else
- return path.substring(0, index);
-
- }
- /**
- * Return the path without a trailing /
- * @param path
- * @return String
- */
- public static String asPath(String path) {
- if (path.endsWith(Session.SERVER_SEPARATOR)) {
- return path.substring(0, path.length() - Session.SERVER_SEPARATOR.length());
- }
- return path;
- }
- /*
- * *
- * Get the extention of the path of resource
- * relative to the path of root
- *
- * @throws CVSException if root is not a root-folder of resource
- */
- public static String getRelativePath(String rootName, String resourceName)
- throws CVSException {
-
- if (!resourceName.startsWith(rootName) || rootName.length() > resourceName.length()) {
- throw new CVSException(CVSMessages.Util_Internal_error__resource_does_not_start_with_root_3);
- }
-
- // Otherwise we would get an ArrayOutOfBoundException
- // in case of two equal Resources
- if (rootName.length() == resourceName.length()) {
- return ""; //$NON-NLS-1$
- }
-
- // Remove leading slash if there is one
- String result = resourceName.substring(rootName.length());
- if (result.startsWith("/")) { //$NON-NLS-1$
- result = result.substring(1);
- }
- return result;
- }
-
- /**
- * Append the prefix and suffix to form a valid CVS path.
- */
- public static String appendPath(String prefix, String suffix) {
- if (prefix.length() == 0 || prefix.equals(Session.CURRENT_LOCAL_FOLDER)) {
- return suffix;
- } else if (prefix.endsWith(Session.SERVER_SEPARATOR)) {
- if (suffix.startsWith(Session.SERVER_SEPARATOR))
- return prefix + suffix.substring(1);
- else
- return prefix + suffix;
- } else if (suffix.startsWith(Session.SERVER_SEPARATOR))
- return prefix + suffix;
- else
- return prefix + Session.SERVER_SEPARATOR + suffix;
- }
-
- public static void logError(String message, Throwable throwable) {
- CVSProviderPlugin.log(IStatus.ERROR, message, throwable);
- }
-
- /**
- * If the number of segments in the relative path of <code>resource</code> to <code>root</code> is
- * greater than <code>split</code> then the returned path is truncated to <code>split</code> number
- * of segments and '...' is shown as the first segment of the path.
- */
- public static String toTruncatedPath(ICVSResource resource, ICVSFolder root, int split) {
- try {
- String stringPath = resource.getRelativePath(root);
- if (stringPath.equals(Session.CURRENT_LOCAL_FOLDER)) {
- return resource.getName();
- }
- String truncatedPath = toTruncatedPath(stringPath, split);
- return truncatedPath;
- } catch(CVSException e) {
- return resource.getName();
- }
- }
-
- public static String toTruncatedPath(String stringPath, int split) {
- // Search backwards until split separators are found
- int count = 0;
- int index = stringPath.length();
- while (count++ < split && index != -1) {
- index = stringPath.lastIndexOf(Session.SERVER_SEPARATOR, index - 1);
- }
- if (index == -1) {
- return stringPath;
- } else {
- return NLS.bind(CVSMessages.Util_truncatedPath, new String[] { stringPath.substring(index) });
- }
- }
-
- /**
- * Helper method that will time out when making a socket connection.
- * This is required because there is no way to provide a timeout value
- * when creating a socket and in some instances, they don't seem to
- * timeout at all.
- */
- public static Socket createSocket(final String host, final int port, IProgressMonitor monitor) throws UnknownHostException, IOException {
- int timeout = CVSProviderPlugin.getPlugin().getTimeout();
- if (timeout == 0) timeout = CVSProviderPlugin.DEFAULT_TIMEOUT;
- ResponsiveSocketFactory factory = new ResponsiveSocketFactory(monitor, timeout);
- return factory.createSocket(host, port);
- }
-
- /**
- * Helper method that will time out when running an external command.
- * This is required because there is no way to provide a timeout value
- * when executing an external command and in some instances, they don't seem to
- * timeout at all.
- */
- public static Process createProcess(final String[] command, IProgressMonitor monitor) throws IOException {
-
- // Start a thread to execute the command and get a handle to the process
- final Process[] process = new Process[] { null };
- final Exception[] exception = new Exception[] {null };
- final Thread thread = new Thread(new Runnable() {
- public void run() {
- try {
- Process newProcess = Runtime.getRuntime().exec(command);
- synchronized (process) {
- if (Thread.interrupted()) {
- // we we're either cancelled or timed out so just destroy the process
- newProcess.destroy();
- } else {
- process[0] = newProcess;
- }
- }
- } catch (IOException e) {
- exception[0] = e;
- }
- }
- });
- thread.start();
-
- // Wait the appropriate number of seconds
- int timeout = CVSProviderPlugin.getPlugin().getTimeout();
- if (timeout == 0) timeout = CVSProviderPlugin.DEFAULT_TIMEOUT;
- for (int i = 0; i < timeout; i++) {
- try {
- // wait for the thread to complete or 1 second, which ever comes first
- thread.join(1000);
- } catch (InterruptedException e) {
- // I think this means the thread was interupted but not necessarily timed out
- // so we don't need to do anything
- }
- synchronized (process) {
- // if the user cancelled, clean up before preempting the operation
- if (monitor.isCanceled()) {
- if (thread.isAlive()) {
- thread.interrupt();
- }
- if (process[0] != null) {
- process[0].destroy();
- }
- // this method will throw the proper exception
- Policy.checkCanceled(monitor);
- }
- }
- }
- // If the thread is still running (i.e. we timed out) signal that it is too late
- synchronized (process) {
- if (thread.isAlive()) {
- thread.interrupt();
- }
- }
- if (exception[0] != null) {
- throw (IOException)exception[0];
- }
- if (process[0] == null) {
- throw new InterruptedIOException(NLS.bind(CVSMessages.Util_processTimeout, new String[] { command[0] }));
- }
- return process[0];
- }
-
- public static String[] parseIntoSubstrings(String string, String delimiter) {
- List result = new ArrayList();
- int start = 0;
- int index = string.indexOf(delimiter);
- String next;
- while (index != -1) {
- next = string.substring(start, index);
- result.add(next);
- start = index + 1;
- index = string.indexOf(delimiter, start);
- }
- if (start >= string.length()) {
- next = "";//$NON-NLS-1$
- } else {
- next = string.substring(start);
- }
- result.add(next);
- return (String[]) result.toArray(new String[result.size()]);
- }
-
- /**
- * Return the substring at the given index (starting at 0) where each
- * element is delimited by the provided delimiter.
- *
- * @param bytes
- * @param delimiter
- * @param index
- * @param includeRest
- * @return String
- */
- public static String getSubstring(byte[] bytes, byte delimiter, int index, boolean includeRest) {
- byte[] bytesForSlot = getBytesForSlot(bytes, delimiter, index, includeRest);
- if (bytesForSlot == null) {
- return null;
- }
- return new String(bytesForSlot);
- }
-
- /**
- * Return the offset the the Nth delimeter from the given start index.
- * @param bytes
- * @param delimiter
- * @param start
- * @param n
- * @return int
- */
- public static int getOffsetOfDelimeter(byte[] bytes, byte delimiter, int start, int n) {
- int count = 0;
- for (int i = start; i < bytes.length; i++) {
- if (bytes[i] == delimiter) count++;
- if (count == n) return i;
- }
- // the Nth delimeter was not found
- return -1;
- }
-
- /**
- * Method getBytesForSlot.
- * @param syncBytes
- * @param SEPARATOR_BYTE
- * @param i
- * @param b
- * @return byte[]
- */
- public static byte[] getBytesForSlot(byte[] bytes, byte delimiter, int index, boolean includeRest) {
- // Find the starting index
- int start;
- if (index == 0) {
- // make start -1 so that end determination will start at offset 0.
- start = -1;
- } else {
- start = getOffsetOfDelimeter(bytes, delimiter, 0, index);
- if (start == -1) return null;
- }
- // Find the ending index
- int end = getOffsetOfDelimeter(bytes, delimiter, start + 1, 1);
- // Calculate the length
- int length;
- if (end == -1 || includeRest) {
- length = bytes.length - start - 1;
- } else {
- length = end - start - 1;
- }
- byte[] result = new byte[length];
- System.arraycopy(bytes, start + 1, result, 0, length);
- return result;
- }
-
- /**
- * Method equals.
- * @param syncBytes
- * @param oldBytes
- * @return boolean
- */
- public static boolean equals(byte[] syncBytes, byte[] oldBytes) {
- if (syncBytes == null || oldBytes == null) return syncBytes == oldBytes;
- if (syncBytes.length != oldBytes.length) return false;
- for (int i = 0; i < oldBytes.length; i++) {
- if (oldBytes[i] != syncBytes[i]) return false;
- }
- return true;
- }
-
- /**
- * Workaround a CVS bug where a CVS Folder with no immediately contained files has an incorrect
- * Tag type stored in the TAG file. In this case, the tag type is always BRANCH (Tv1)
- *
- * The fix is for folders with no files, use the tag type for the containing project. Since projects almost
- * always have files the TAG file is usually correct.
- *
- * For the case where the folder tag name does not match the project tag name we can not do much so we just
- * return the folder tag which will currently always be a branch.
- *
- * @param resource The IResource being tested. Can not be null.
- * @param tag The CVSTag as reported by CVS for the IResource. May be null.
- * @return CVSTag The corrected tag for the resource. May be null.
- */
-
- public static CVSTag getAccurateFolderTag(IResource resource, CVSTag tag) {
-
- // Determine if the folder contains files as immediate children.
- if (resource.getType() != IResource.FOLDER) {
- return tag;
- }
-
- IResource[] members = null;
- try {
- members = ((IFolder) resource).members();
- } catch (CoreException e1) {
- return tag;
- }
-
- for (int i = 0; i < members.length; i++) {
- if (members[i].getType() == IResource.FILE) {
- return tag;
- }
- }
-
- // Folder contains no files so this may not really be a branch.
- // Make the type the same as the project tag type if both are the same tag name.
- IProject project = resource.getProject();
- if (project == null) {
- return tag;
- }
-
- ICVSFolder projectFolder = CVSWorkspaceRoot.getCVSFolderFor(project);
- FolderSyncInfo projectSyncInfo;
- try {
- projectSyncInfo = projectFolder.getFolderSyncInfo();
- } catch (CVSException e) {
- return tag;
- }
-
- if (projectSyncInfo == null) {
- return tag;
- }
-
- CVSTag projectTag = projectSyncInfo.getTag();
-
- if (projectTag != null && projectTag.getName().equals(tag.getName())) {
- return projectTag;
- } else {
- return tag;
- }
- }
-
- /**
- * Workaround for CVS "bug" where CVS ENTRIES file does not contain correct
- * Branch vs. Version info. Entries files always record a Tv1 so all entries would
- * appear as branches.
- *
- * By comparing the revision number to the tag name
- * you can determine if the tag is a branch or version.
- *
- * @param cvsResource the resource to test. Must nut be null.
- * @return the correct cVSTag. May be null.
- */
-
- public static CVSTag getAccurateFileTag(ICVSResource cvsResource) throws CVSException {
-
- CVSTag tag = null;
- ResourceSyncInfo info = cvsResource.getSyncInfo();
- if(info != null) {
- tag = info.getTag();
- }
-
- FolderSyncInfo parentInfo = cvsResource.getParent().getFolderSyncInfo();
- CVSTag parentTag = null;
- if(parentInfo != null) {
- parentTag = parentInfo.getTag();
- }
-
- if(tag != null) {
- if(tag.getName().equals(info.getRevision())) {
- tag = new CVSTag(tag.getName(), CVSTag.VERSION);
- } else if(parentTag != null){
- tag = new CVSTag(tag.getName(), parentTag.getType());
- }
- }
-
- return tag;
- }
-
- /**
- * Return the fullest path that we can obtain for the given resource
- * @param resource
- * @return
- */
- public static String getFullestPath(ICVSResource resource) {
- IResource local = resource.getIResource();
- if (local != null) {
- return local.getFullPath().toString();
- }
- try {
- String remotePath = resource.getRepositoryRelativePath();
- if (remotePath != null) {
- return remotePath;
- }
- } catch (CVSException e) {
- // Ignore and try the next method;
- }
- return resource.getName();
- }
-
- public static String getVariablePattern(String pattern, String variableName) {
- return "(" + variableName + ":" + pattern + ":" + variableName + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- /**
- * @param localRevision
- * @return
- */
- public static int[] convertToDigits(String localRevision) {
- try {
- String digitStrings[] = localRevision.split("\\."); //$NON-NLS-1$
- int[] digits = new int[digitStrings.length];
- for (int i = 0; i < digitStrings.length; i++) {
- String digitString = digitStrings[i];
- digits[i] = Integer.parseInt(digitString);
- }
- return digits;
- } catch (NumberFormatException e) {
- CVSProviderPlugin.log(CVSException.wrapException(e));
- return new int[0];
- }
- }
-
- public static String toTruncatedPath(ICVSStorage file, ICVSFolder localRoot, int i) {
- if (file instanceof ICVSResource) {
- return toTruncatedPath((ICVSResource)file, localRoot, i);
- }
- return file.getName();
- }
-
- /**
- * If the status/log returns that the file is in the Attic, then remove the
- * Attic segment. This is because files added to a branch that are not in
- * the main trunk (HEAD) are added to the Attic but cvs does magic on
- * update to put them in the correct location.
- * (e.g. /project/Attic/file.txt -> /project/file.txt)
- */
- public static String removeAtticSegment(String path) {
- int lastSeparator = path.lastIndexOf(Session.SERVER_SEPARATOR);
- if (lastSeparator == -1) return path;
- int secondLastSeparator = path.lastIndexOf(Session.SERVER_SEPARATOR, lastSeparator - 1);
- if (secondLastSeparator == -1) return path;
- String secondLastSegment = path.substring(secondLastSeparator + 1, lastSeparator);
- if (secondLastSegment.equals("Attic")) { //$NON-NLS-1$
- return path.substring(0, secondLastSeparator) + path.substring(lastSeparator);
- }
- return path;
- }
-
- /**
- * Flatten the text in the multiline comment
- */
- public static String flattenText(String string) {
- StringBuffer buffer = new StringBuffer(string.length() + 20);
- boolean skipAdjacentLineSeparator = true;
- for (int i = 0; i < string.length(); i++) {
- char c = string.charAt(i);
- if (c == '\r' || c == '\n') {
- if (!skipAdjacentLineSeparator)
- buffer.append(Session.SERVER_SEPARATOR);
- skipAdjacentLineSeparator = true;
- } else {
- buffer.append(c);
- skipAdjacentLineSeparator = false;
- }
- }
- return buffer.toString();
- }
-}

Back to the top