Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations')
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java205
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java320
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java366
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java442
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutMultipleProjectsOperation.java53
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java86
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java481
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutSingleProjectOperation.java63
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java213
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java179
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/DisconnectOperation.java81
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchMembersOperation.java147
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java96
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ITagOperation.java27
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/OverrideAndUpdateOperation.java52
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java175
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java381
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteLogOperation.java282
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteOperation.java42
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java135
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryLocationOperation.java72
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.java211
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java208
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java232
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java81
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagInRepositoryOperation.java125
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagOperation.java167
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOnlyMergableOperation.java77
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java132
29 files changed, 0 insertions, 5131 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java
deleted file mode 100644
index 6164e3cd5..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-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.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-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.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Performs a "cvs add"
- */
-public class AddOperation extends RepositoryProviderOperation {
-
- public AddOperation(IWorkbenchPart part, IResource[] resources) {
- super(part, resources);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException {
- add(provider, resources, IResource.DEPTH_INFINITE, monitor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("AddAction.adding"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
- */
- protected String getTaskName(CVSTeamProvider provider) {
- return Policy.bind("AddOperation.0", provider.getProject().getName()); //$NON-NLS-1$
- }
-
- /*
- * Add the given resources to the project.
- * <p>
- * The sematics follow that of CVS in the sense that any folders
- * being added are created remotely as a result of this operation
- * while files are created remotely on the next commit.
- * </p>
- * <p>
- * This method uses the team file type registry to determine the type
- * of added files. If the extension of the file is not in the registry,
- * the file is assumed to be binary.
- * </p>
- * <p>
- * NOTE: for now we do three operations: one each for folders, text files and binary files.
- * We should optimize this when time permits to either use one operations or defer server
- * contact until the next commit.
- * </p>
- *
- * <p>
- * There are special semantics for adding the project itself to the repo. In this case, the project
- * must be included in the resources array.
- * </p>
- */
- private void add(CVSTeamProvider provider, IResource[] resources, int depth, IProgressMonitor progress) throws CVSException {
-
- // Visit the children of the resources using the depth in order to
- // determine which folders, text files and binary files need to be added
- // A TreeSet is needed for the folders so they are in the right order (i.e. parents created before children)
- final SortedSet folders = new TreeSet();
- // Sets are required for the files to ensure that files will not appear twice if there parent was added as well
- // and the depth isn't zero
- final Map /* from KSubstOption to Set */ files = new HashMap();
- final CVSException[] eHolder = new CVSException[1];
- for (int i=0; i<resources.length; i++) {
-
- final IResource currentResource = resources[i];
-
- try {
- // Auto-add parents if they are not already managed
- IContainer parent = currentResource.getParent();
- ICVSResource cvsParentResource = CVSWorkspaceRoot.getCVSResourceFor(parent);
- while (parent.getType() != IResource.ROOT && parent.getType() != IResource.PROJECT && ! isManaged(cvsParentResource)) {
- folders.add(cvsParentResource);
- parent = parent.getParent();
- cvsParentResource = cvsParentResource.getParent();
- }
-
- // Auto-add children
- final TeamException[] exception = new TeamException[] { null };
- currentResource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) {
- try {
- ICVSResource mResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- // Add the resource is its not already managed and it was either
- // added explicitly (is equal currentResource) or is not ignored
- if (! isManaged(mResource) && (currentResource.equals(resource) || ! mResource.isIgnored())) {
- if (resource.getType() == IResource.FILE) {
- KSubstOption ksubst = KSubstOption.fromFile((IFile) resource);
- Set set = (Set) files.get(ksubst);
- if (set == null) {
- set = new HashSet();
- files.put(ksubst, set);
- }
- set.add(mResource);
- } else {
- folders.add(mResource);
- }
- }
- // Always return true and let the depth determine if children are visited
- return true;
- } catch (CVSException e) {
- exception[0] = e;
- return false;
- }
- }
- }, depth, false);
- if (exception[0] != null) {
- throw exception[0];
- }
- } catch (CoreException e) {
- throw new CVSException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, TeamException.UNABLE, Policy.bind("CVSTeamProvider.visitError", new Object[] {resources[i].getFullPath()}), e)); //$NON-NLS-1$
- }
- }
- // If an exception occured during the visit, throw it here
- if (eHolder[0] != null)
- throw eHolder[0];
-
- // Add the folders, followed by files!
- progress.beginTask(null, files.size() * 10 + (folders.isEmpty() ? 0 : 10));
- try {
- if (!folders.isEmpty()) {
- Session session = new Session(getRemoteLocation(provider), getLocalRoot(provider), true /* output to console */);
- session.open(Policy.subMonitorFor(progress, 2), true /* open for modification */);
- try {
- IStatus status = Command.ADD.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- (ICVSResource[])folders.toArray(new ICVSResource[folders.size()]),
- null,
- Policy.subMonitorFor(progress, 8));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- session.close();
- }
- }
- for (Iterator it = files.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- final KSubstOption ksubst = (KSubstOption) entry.getKey();
- final Set set = (Set) entry.getValue();
- Session session = new Session(getRemoteLocation(provider), getLocalRoot(provider), true /* output to console */);
- session.open(Policy.subMonitorFor(progress, 2), true /* open for modification */);
- try {
- IStatus status = Command.ADD.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] { ksubst },
- (ICVSResource[])set.toArray(new ICVSResource[set.size()]),
- null,
- Policy.subMonitorFor(progress, 8));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- session.close();
- }
- }
- } finally {
- progress.done();
- }
- }
-
- /*
- * Consider a folder managed only if it's also a CVS folder
- */
- private boolean isManaged(ICVSResource cvsResource) throws CVSException {
- return cvsResource.isManaged() && (!cvsResource.isFolder() || ((ICVSFolder)cvsResource).isCVSFolder());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getErrorMessage(org.eclipse.core.runtime.IStatus[], int)
- */
- protected String getErrorMessage(IStatus[] failures, int totalOperations) {
- return Policy.bind("AddAction.addFailed"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java
deleted file mode 100644
index a64454789..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.actions.CVSAction;
-import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager;
-import org.eclipse.team.internal.ccvs.ui.tags.BranchPromptDialog;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Perform a CVS branch operaiton
- */
-public class BranchOperation extends RepositoryProviderOperation {
-
- private boolean update;
- private CVSTag rootVersionTag;
- private CVSTag branchTag;
-
- public BranchOperation(IWorkbenchPart part, IResource[] resources) {
- super(part, resources);
- }
-
- public void setTags(CVSTag rootVersionTag, CVSTag branchTag, boolean updateToBranch) {
- this.rootVersionTag = rootVersionTag;
- this.branchTag = branchTag;
- this.update = updateToBranch;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.TeamOperation#shouldRun()
- */
- protected boolean shouldRun() {
- IResource[] resources = getResources();
- boolean allSticky = areAllResourcesSticky(resources);
- final BranchPromptDialog dialog = new BranchPromptDialog(getShell(),
- Policy.bind("BranchWizard.title"), //$NON-NLS-1$
- getResources(),
- allSticky,
- calculateInitialVersionName(resources,allSticky));
- if (dialog.open() != InputDialog.OK) return false;
-
- // Capture the dialog info in local variables
- final String tagString = dialog.getBranchTagName();
- update = dialog.getUpdate();
- final String versionString = dialog.getVersionTagName();
- rootVersionTag = (versionString == null) ? null : new CVSTag(versionString, CVSTag.VERSION);
- branchTag = new CVSTag(tagString, CVSTag.BRANCH);
-
- // For non-projects determine if the tag being loaded is the same as the resource's parent
- // If it's not, warn the user that they will be mixing tags
- if (update) {
- try {
- if(!CVSAction.checkForMixingTags(getShell(), resources, branchTag)) {
- return false;
- }
- } catch (CVSException e) {
- CVSUIPlugin.log(e);
- }
- }
- return super.shouldRun();
- }
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(CVSTeamProvider provider, IResource[] providerResources, IProgressMonitor monitor) throws CVSException, InterruptedException {
- try {
- monitor.beginTask(null, 100);
- makeBranch(provider, providerResources, rootVersionTag, branchTag, update, Policy.subMonitorFor(monitor, 90));
- updateRememberedTags(providerResources);
- if (update) {
- updateWorkspaceSubscriber(provider, getCVSArguments(providerResources), Policy.subMonitorFor(monitor, 10));
- }
- collectStatus(Status.OK_STATUS);
- } catch (TeamException e) {
- // Accumulate the status which will be displayed by CVSAction#endOperation(IAction)
- collectStatus(e.getStatus());
- } finally {
- monitor.done();
- }
- }
-
- private void makeBranch(CVSTeamProvider provider, IResource[] resources, final CVSTag versionTag, final CVSTag branchTag, boolean moveToBranch, IProgressMonitor monitor) throws TeamException {
-
- // Determine the total amount of work
- int totalWork = (versionTag!= null ? 60 : 40) + (moveToBranch ? 20 : 0);
- monitor.beginTask(Policy.bind("CVSTeamProvider.makeBranch"), totalWork); //$NON-NLS-1$
- try {
- // Build the arguments list
- final ICVSResource[] arguments = getCVSArguments(resources);
-
- // Tag the remote resources
- IStatus status = null;
- if (versionTag != null) {
- // Version using a custom tag command that skips added but not commited reesources
- Session session = new Session(getRemoteLocation(provider), getLocalRoot(provider), true /* output to console */);
- session.open(Policy.subMonitorFor(monitor, 5), true /* open for modification */);
- try {
- status = Command.CUSTOM_TAG.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- versionTag,
- arguments,
- null,
- Policy.subMonitorFor(monitor, 35));
- } finally {
- session.close();
- }
- if (status.isOK()) {
- // Branch using the tag
- session = new Session(getRemoteLocation(provider), getLocalRoot(provider), true /* output to console */);
- session.open(Policy.subMonitorFor(monitor, 5), true /* open for modification */);
- try {
- status = Command.CUSTOM_TAG.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- branchTag,
- arguments,
- null,
- Policy.subMonitorFor(monitor, 15));
- } finally {
- session.close();
- }
- }
- } else {
- // Just branch using tag
- Session session = new Session(getRemoteLocation(provider), getLocalRoot(provider), true /* output to console */);
- session.open(Policy.subMonitorFor(monitor, 5), true /* open for modification */);
- try {
- status = Command.CUSTOM_TAG.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- branchTag,
- arguments,
- null,
- Policy.subMonitorFor(monitor, 35));
- } finally {
- session.close();
- }
-
- }
- if ( ! status.isOK()) {
- throw new CVSServerException(status);
- }
-
- // Set the tag of the local resources to the branch tag (The update command will not
- // properly update "cvs added" and "cvs removed" resources so a custom visitor is used
- if (moveToBranch) {
- setTag(provider, resources, branchTag, Policy.subMonitorFor(monitor, 20));
- }
- } finally {
- monitor.done();
- }
- }
-
- /*
- * This method sets the tag for a project.
- * It expects to be passed an InfiniteSubProgressMonitor
- */
- private void setTag(final CVSTeamProvider provider, final IResource[] resources, final CVSTag tag, IProgressMonitor monitor) throws TeamException {
-
- getLocalRoot(provider).run(new ICVSRunnable() {
- public void run(IProgressMonitor progress) throws CVSException {
- try {
- // 512 ticks gives us a maximum of 2048 which seems reasonable for folders and files in a project
- progress.beginTask(null, 100);
- final IProgressMonitor monitor = Policy.infiniteSubMonitorFor(progress, 100);
- monitor.beginTask(Policy.bind("CVSTeamProvider.folderInfo", provider.getProject().getName()), 512); //$NON-NLS-1$
-
- // Visit all the children folders in order to set the root in the folder sync info
- for (int i = 0; i < resources.length; i++) {
- CVSWorkspaceRoot.getCVSResourceFor(resources[i]).accept(new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {
- monitor.worked(1);
- //ResourceSyncInfo info = file.getSyncInfo();
- byte[] syncBytes = file.getSyncBytes();
- if (syncBytes != null) {
- monitor.subTask(Policy.bind("CVSTeamProvider.updatingFile", file.getName())); //$NON-NLS-1$
- file.setSyncBytes(ResourceSyncInfo.setTag(syncBytes, tag), ICVSFile.UNKNOWN);
- }
- }
- public void visitFolder(ICVSFolder folder) throws CVSException {
- monitor.worked(1);
- FolderSyncInfo info = folder.getFolderSyncInfo();
- if (info != null) {
- monitor.subTask(Policy.bind("CVSTeamProvider.updatingFolder", info.getRepository())); //$NON-NLS-1$
- folder.setFolderSyncInfo(new FolderSyncInfo(info.getRepository(), info.getRoot(), tag, info.getIsStatic()));
- folder.acceptChildren(this);
- }
- }
- });
- }
- } finally {
- progress.done();
- }
- }
- }, monitor);
- }
-
- private void updateRememberedTags(IResource[] providerResources) throws CVSException {
- if (rootVersionTag != null || update) {
- for (int i = 0; i < providerResources.length; i++) {
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(providerResources[i]);
- RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
-
- if (rootVersionTag != null) {
- manager.addTags(cvsResource, new CVSTag[] { rootVersionTag });
- }
- if (update) {
- manager.addTags(cvsResource, new CVSTag[] { branchTag });
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("BranchOperation.0"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
- */
- protected String getTaskName(CVSTeamProvider provider) {
- return Policy.bind("BranchOperation.1", provider.getProject().getName()); //$NON-NLS-1$
- }
-
- /**
- * Answers <code>true</code> if all resources in the array have a sticky tag
- */
- private boolean areAllResourcesSticky(IResource[] resources) {
- for (int i = 0; i < resources.length; i++) {
- if(!hasStickyTag(resources[i])) return false;
- }
- return true;
- }
-
- /**
- * Answers <code>true</code> if the resource has a sticky tag
- */
- private boolean hasStickyTag(IResource resource) {
- try {
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- CVSTag tag;
- if(cvsResource.isFolder()) {
- FolderSyncInfo folderInfo = ((ICVSFolder)cvsResource).getFolderSyncInfo();
- tag = folderInfo.getTag();
- } else {
- ResourceSyncInfo info = cvsResource.getSyncInfo();
- tag = info.getTag();
- }
- if(tag!=null) {
- int tagType = tag.getType();
- if(tagType==CVSTag.VERSION) {
- return true;
- }
- }
- } catch(CVSException e) {
- CVSUIPlugin.log(e);
- return false;
- }
- return false;
- }
-
- private String calculateInitialVersionName(IResource[] resources, boolean allSticky) {
- String versionName = ""; //$NON-NLS-1$
- try {
- if(allSticky) {
- IResource stickyResource = resources[0];
- if(stickyResource.getType()==IResource.FILE) {
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)stickyResource);
- versionName = cvsFile.getSyncInfo().getTag().getName();
- } else {
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)stickyResource);
- versionName = cvsFolder.getFolderSyncInfo().getTag().getName();
- }
- }
- } catch(CVSException e) {
- CVSUIPlugin.log(e);
- versionName = ""; //$NON-NLS-1$
- }
- return versionName;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java
deleted file mode 100644
index 3d33624ef..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java
+++ /dev/null
@@ -1,366 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-import org.eclipse.team.internal.ccvs.ui.*;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.console.CVSOutputConsole;
-import org.eclipse.team.ui.TeamOperation;
-import org.eclipse.ui.IWorkbenchPart;
-
-
-/**
- * This class is the abstract superclass for CVS operations. It provides
- * error handling, prompting and other UI.
- */
-public abstract class CVSOperation extends TeamOperation {
-
- private int statusCount;
-
- private boolean involvesMultipleResources = false;
-
- private List errors = new ArrayList(); // of IStatus
-
- protected static final IStatus OK = Status.OK_STATUS; //$NON-NLS-1$
-
- private Shell shell;
-
- // instance variable used to indicate behavior while prompting for overwrite
- private boolean confirmOverwrite = true;
-
- protected CVSOperation(IWorkbenchPart part) {
- super(part);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.actions.TeamOperation#getJobName()
- */
- protected String getJobName() {
- return getTaskName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.TeamOperation#getOperationIcon()
- */
- protected URL getOperationIcon() {
- URL url = null;
- try {
- URL baseURL = CVSUIPlugin.getPlugin().getBundle().getEntry("/"); //$NON-NLS-1$
- return new URL(baseURL, ICVSUIConstants.ICON_PATH + ICVSUIConstants.IMG_CVS_PERSPECTIVE);
- } catch (MalformedURLException e) {
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- public final void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- startOperation();
- try {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- monitor.setTaskName(getTaskName());
- execute(Policy.subMonitorFor(monitor, 100));
- endOperation();
- } catch (CVSException e) {
- // TODO: errors may not be empty (i.e. endOperation has not been executed)
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
-
- protected void startOperation() {
- statusCount = 0;
- resetErrors();
- confirmOverwrite = true;
- }
-
- protected void endOperation() throws CVSException {
- handleErrors((IStatus[]) errors.toArray(new IStatus[errors.size()]));
- }
-
- /**
- * Subclasses must override this method to perform the operation.
- * Clients should never call this method directly.
- *
- * @param monitor
- * @throws CVSException
- * @throws InterruptedException
- */
- protected abstract void execute(IProgressMonitor monitor) throws CVSException, InterruptedException;
-
- protected void addError(IStatus status) {
- if (status.isOK()) return;
- if (isLastError(status)) return;
- errors.add(status);
- }
-
- protected void collectStatus(IStatus status) {
- if (isLastError(status)) return;
- statusCount++;
- if (!status.isOK()) addError(status);
- }
-
- protected void resetErrors() {
- errors.clear();
- statusCount = 0;
- }
-
- /**
- * Get the last error taht occured. This can be useful when a method
- * has a return type but wants to signal an error. The method in question
- * can add the error using <code>addError(IStatus)</code> and return null.
- * The caller can then query the error using this method. Also, <code>addError(IStatus)</code>
- * will not add the error if it is already on the end of the list (using identity comparison)
- * which allows the caller to still perform a <code>collectStatus(IStatus)</code>
- * to get a valid operation count.
- * @return
- */
- protected IStatus getLastError() {
- Assert.isTrue(errors.size() > 0);
- IStatus status = (IStatus)errors.get(errors.size() - 1);
- return status;
- }
-
- private boolean isLastError(IStatus status) {
- return (errors.size() > 0 && getLastError() == status);
- }
-
- /**
- * Throw an exception that contains the given error status
- * @param errors the errors that occurred during the operation
- * @throws CVSException an exception that wraps the errors
- */
- protected void asException(IStatus[] errors) throws CVSException {
- if (errors.length == 0) return;
- if (errors.length == 1 && statusCount == 1) {
- throw new CVSException(errors[0]);
- }
- MultiStatus result = new MultiStatus(CVSUIPlugin.ID, 0, getErrorMessage(errors, statusCount), null);
- for (int i = 0; i < errors.length; i++) {
- IStatus s = errors[i];
- if (s.isMultiStatus()) {
- result.add(new CVSStatus(s.getSeverity(), s.getMessage(), s.getException()));
- result.addAll(s);
- } else {
- result.add(s);
- }
- }
- throw new CVSException(result);
- }
-
- /**
- * Handle the errors that occured during an operation.
- * The default is to throw an exception containing an status
- * that are reportable (determined using <code>isReportableError</code>).
- * @param errors the errors that occurred during the operation.
- * Subclasses may override.
- * @throws CVSException an exception if appropriate
- */
- protected void handleErrors(IStatus[] errors) throws CVSException {
- // We are only concerned with reportable errors.
- // Others will appear in the console
- List serverErrors = new ArrayList();
- for (int i = 0; i < errors.length; i++) {
- IStatus status = errors[i];
- if (isReportableError(status)) {
- serverErrors.add(status);
- } else if (status.isMultiStatus()) {
- IStatus[] children = status.getChildren();
- for (int j = 0; j < children.length; j++) {
- IStatus child = children[j];
- if (isReportableError(child)) {
- serverErrors.add(status);
- break;
- }
- }
- }
- }
- if (!serverErrors.isEmpty())
- asException((IStatus[]) serverErrors.toArray(new IStatus[serverErrors.size()]));
- }
-
- /**
- * Return whether the given status is reportable. By default,
- * only server errors are reportable. Subclasses may override.
- * @param status an error status
- * @return whether the status is reportable or should be ignored
- */
- protected boolean isReportableError(IStatus status) {
- return status.getCode() == CVSStatus.SERVER_ERROR;
- }
-
- protected String getErrorMessage(IStatus[] failures, int totalOperations) {
- return Policy.bind("CVSOperation.0", String.valueOf(failures.length), String.valueOf(totalOperations)); //$NON-NLS-1$
- }
-
- /**
- * This method prompts the user to overwrite an existing resource. It uses the
- * <code>involvesMultipleResources</code> to determine what buttons to show.
- * @param project
- * @return
- */
- protected boolean promptToOverwrite(final String title, final String msg) {
- if (!confirmOverwrite) {
- return true;
- }
- final String buttons[];
- if (involvesMultipleResources()) {
- buttons = new String[] {
- IDialogConstants.YES_LABEL,
- IDialogConstants.YES_TO_ALL_LABEL,
- IDialogConstants.NO_LABEL,
- IDialogConstants.CANCEL_LABEL};
- } else {
- buttons = new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL};
- }
- final Shell displayShell = getShell();
- if (displayShell == null) {
- // We couldn't get a shell (perhaps due to shutdown)
- return false;
- }
-
- // run in syncExec because callback is from an operation,
- // which is probably not running in the UI thread.
- final int[] code = new int[] {0};
- displayShell.getDisplay().syncExec(
- new Runnable() {
- public void run() {
- MessageDialog dialog =
- new MessageDialog(displayShell, title, null, msg, MessageDialog.QUESTION, buttons, 0);
- dialog.open();
- code[0] = dialog.getReturnCode();
- }
- });
- if (involvesMultipleResources()) {
- switch (code[0]) {
- case 0://Yes
- return true;
- case 1://Yes to all
- confirmOverwrite = false;
- return true;
- case 2://No
- return false;
- case 3://Cancel
- default:
- throw new OperationCanceledException();
- }
- } else {
- return code[0] == 0;
- }
- }
-
- /**
- * This method is used by <code>promptToOverwrite</code> to determine which
- * buttons to show in the prompter.
- *
- * @return
- */
- protected boolean involvesMultipleResources() {
- return involvesMultipleResources;
- }
-
- public void setInvolvesMultipleResources(boolean b) {
- involvesMultipleResources = b;
- }
-
- /**
- * Return the string that is to be used as the task name for the operation
- *
- * @param remoteFolders
- * @return
- */
- protected abstract String getTaskName();
-
- /**
- * Return true if any of the accumulated status have a severity of ERROR
- * @return
- */
- protected boolean errorsOccurred() {
- for (Iterator iter = errors.iterator(); iter.hasNext();) {
- IStatus status = (IStatus) iter.next();
- if (status.getSeverity() == IStatus.ERROR) return true;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.actions.TeamOperation#getShell()
- */
- protected Shell getShell() {
- // Use the shell assigned to the operation if possible
- if (shell != null && !shell.isDisposed()) {
- return shell;
- }
- return super.getShell();
- }
-
- /**
- * Set the shell to be used by the operation. This only needs
- * to be done if the operation does not have a workbench part.
- * For example, if the operation is being run in a wizard.
- * @param shell The shell to set.
- */
- public void setShell(Shell shell) {
- this.shell = shell;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.TeamOperation#canRunAsJob()
- */
- protected boolean canRunAsJob() {
- // Put CVS jobs in the background by default.
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.TeamOperation#isSameFamilyAs(org.eclipse.team.ui.TeamOperation)
- */
- protected boolean isSameFamilyAs(TeamOperation operation) {
- // Trat all CVS operations as a single family
- return operation instanceof CVSOperation;
- }
-
- /*
- * Action to show the console that can be used by subclasses
- * that wish to link the progress service to the console
- */
- protected IAction getShowConsoleAction() {
- // Show the console as the goto action
- return new Action(Policy.bind("CVSOperation.1")) { //$NON-NLS-1$
- public void run() {
- CVSOutputConsole console = CVSUIPlugin.getPlugin().getConsole();
- if (console != null)
- console.show(true);
- }
- public String getToolTipText() {
- return Policy.bind("CVSOperation.2"); //$NON-NLS-1$
- }
- };
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java
deleted file mode 100644
index 6a3433720..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java
+++ /dev/null
@@ -1,442 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-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.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * This method checks out one or more remote folders from the same repository
- * into an existing project or folder in the workspace. The target project
- * must either be shared with the same repository or it must not be shared
- * with any repository
- */
-public class CheckoutIntoOperation extends CheckoutOperation {
-
- private boolean recursive;
- private ICVSFolder localFolder;
- private String localFolderName;
-
- /**
- * Constructor which takes a set of remote folders and the local folder into which the folders should be
- * loaded.
- */
- public CheckoutIntoOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders, IContainer localFolder, boolean recursive) {
- super(part, remoteFolders);
- this.recursive = recursive;
- this.localFolder = CVSWorkspaceRoot.getCVSFolderFor(localFolder);
- }
-
- /**
- * Constructor which takes a single remote folder and the target local folder.
- */
- public CheckoutIntoOperation(IWorkbenchPart part, ICVSRemoteFolder remoteFolder, IContainer localFolder, boolean recursive) {
- this(part, new ICVSRemoteFolder[] { remoteFolder }, localFolder.getParent(), recursive);
- this.localFolderName = localFolder.getName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#getTaskName()
- */
- protected String getTaskName() {
- ICVSRemoteFolder[] remoteFolders = getRemoteFolders();
- String localFolderName = ""; //$NON-NLS-1$
- try {
- localFolderName = getLocalFolder().getIResource().getFullPath().toString();
- } catch (CVSException e) {
- CVSUIPlugin.log(e);
- }
- return Policy.bind("CheckoutIntoOperation.taskname", new Integer(remoteFolders.length).toString(), localFolderName); //$NON-NLS-1$
- }
-
- /**
- * @return
- */
- public ICVSFolder getLocalFolder() {
- return localFolder;
- }
-
- /**
- * @return
- */
- public boolean isRecursive() {
- return recursive;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#checkout(org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus checkout(final ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException {
- final IStatus[] result = new IStatus[] { null };
- try {
- // Wrap in a workspace runnable to avoid auto-build.
- // This is necessary because CVS has a POST_BUILD
- // listener that will clear the sync info from
- // orphaned (i.e. unmanaged) subtrees and we will
- // purposely create some which we subsequently manage
- // from their parent (see manageFolders())
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- result[0] = checkout(folder, getLocalFolder(), isRecursive(), monitor);
- }
- }, getSchedulingRule(), 0, monitor);
- } catch (CoreException e) {
- result[0] = CVSException.wrapException(e).getStatus();
- }
- return result[0];
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#checkout(org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder[], org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void checkout(final ICVSRemoteFolder[] folders, IProgressMonitor monitor) throws CVSException {
- // Batch sync info changes with the CVS synchronizer to optimize cache writing
- EclipseSynchronizer.getInstance().run(getSchedulingRule(), new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(null, 100);
- try {
- // Obtain a scheduling rule on the projects were about to overwrite
- CheckoutIntoOperation.super.checkout(folders, Policy.subMonitorFor(monitor, 90));
- refreshRoot(getLocalRoot(getLocalFolder()), Policy.subMonitorFor(monitor, 10));
- } finally {
- monitor.done();
- }
- }
- }, Policy.monitorFor(monitor));
- }
-
- /*
- * Prepare the local folders to receive the remote folders. If localFolderName is not null, then
- * if will be the only target folder of the checkout. Otherwise, the remote folder
- * could expand to multiple local folders witinb the given parent folder.
- */
- private ICVSFolder[] prepareLocalFolders(Session session, ICVSRemoteFolder remoteFolder, ICVSFolder parentFolder, String localFolderName, IProgressMonitor monitor) throws CVSException {
- Set targetFolderSet = new HashSet();
- monitor.beginTask(null, 30);
- if (localFolderName == null) {
-
- // Determine which local folders will be afected
- IStatus status = Request.EXPAND_MODULES.execute(session, new String[] { remoteFolder.getRepositoryRelativePath()}, Policy.subMonitorFor(monitor, 10));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- addError(status);
- return null;
- }
-
- // Convert the module expansions to target folders
- String[] expansions = session.getModuleExpansions();
- for (int j = 0; j < expansions.length; j++) {
- String childPath = new Path(null, expansions[j]).segment(0);
- ICVSResource resource = parentFolder.getChild(childPath);
- if (resource != null && !resource.isFolder()) {
- // The target folder conflicts with an existing file
- addError(new CVSStatus(IStatus.ERROR, Policy.bind("CheckoutIntoOperation.targetIsFile", remoteFolder.getName(), resource.getIResource().getFullPath().toString()))); //$NON-NLS-1$
- return null;
- }
- targetFolderSet.add(parentFolder.getFolder(childPath));
- }
-
- } else {
- targetFolderSet.add(parentFolder.getFolder(localFolderName));
- }
-
- final ICVSFolder[] targetFolders = (ICVSFolder[]) targetFolderSet.toArray(new ICVSFolder[targetFolderSet.size()]);
-
- // Ensure that the checkout will not conflict with existing resources
- IStatus status = validateTargetFolders(remoteFolder, targetFolders, Policy.subMonitorFor(monitor, 10));
- if (!status.isOK()) {
- addError(status);
- return null;
- }
-
- // Prepare the target projects to receive resources
- status = scrubFolders(remoteFolder, targetFolders, Policy.subMonitorFor(monitor, 10));
- // return the target projects if the scrub succeeded
- if (status.isOK()) {
- return targetFolders;
- } else {
- addError(status);
- return null;
- }
- }
-
- /*
- * Ensure that the new folders will not conflict with existing folders (even those that are pruned).
- */
- private IStatus validateTargetFolders(ICVSRemoteFolder remoteFolder, ICVSFolder[] targetFolders, IProgressMonitor monitor) throws CVSException {
- for (int i = 0; i < targetFolders.length; i++) {
- ICVSFolder targetFolder = targetFolders[i];
- FolderSyncInfo localInfo = targetFolder.getFolderSyncInfo();
- FolderSyncInfo remoteInfo = remoteFolder.getFolderSyncInfo();
-
- if (!remoteInfo.isSameMapping(localInfo)) {
- if (localInfo != null ) {
- if (isRemoteChildOfParent(targetFolder)) {
- // if the local folder is child of it's parent remotely (i.e. path of child is parent/child)
- // then the remote cannot be loaded.
- String message;
- if (targetFolder.exists()) {
- message = Policy.bind("CheckoutIntoOperation.targetIsFolder", remoteFolder.getName(), targetFolder.getIResource().getFullPath().toString()); //$NON-NLS-1$
- } else {
- message = Policy.bind("CheckoutIntoOperation.targetIsPrunedFolder", remoteFolder.getName(), targetFolder.getFolderSyncInfo().getRepository()); //$NON-NLS-1$
- }
- return new CVSStatus(IStatus.ERROR, message);
- }
- }
- // Verify that no other folders in the local workspace are mapped to the remote folder
- IStatus status = validateUniqueMapping(remoteFolder, targetFolder, Policy.subMonitorFor(monitor, 10));
- if (!status.isOK()) return status;
- }
- }
- return OK;
- }
-
- /*
- * Return true if the given local folder is a direct descendant of it's local parent in
- * the repository as well
- */
- private boolean isRemoteChildOfParent(ICVSFolder targetFolder) throws CVSException {
- FolderSyncInfo localInfo = targetFolder.getFolderSyncInfo();
- if (localInfo == null) return false;
- FolderSyncInfo parentInfo = targetFolder.getParent().getFolderSyncInfo();
- if (parentInfo == null) return false;
- IPath childPath = new Path(null, localInfo.getRepository());
- IPath parentPath = new Path(null, parentInfo.getRepository());
- return parentPath.isPrefixOf(childPath);
- }
-
- /**
- * @param targetFolder
- * @return
- */
- private IContainer getLocalRoot(ICVSFolder targetFolder) throws CVSException {
- return targetFolder.getIResource().getProject();
- }
-
- /*
- * Ensure that there is no equivalent mapping alreay in the local workspace
- */
- private IStatus validateUniqueMapping(final ICVSRemoteFolder remoteFolder, final ICVSFolder targetFolder, IProgressMonitor iProgressMonitor) throws CVSException {
-
- final IContainer root = getLocalRoot(targetFolder);
- final FolderSyncInfo remoteInfo = remoteFolder.getFolderSyncInfo();
- if (remoteInfo.equals(FolderSyncInfo.VIRTUAL_DIRECTORY)) {
- // We can't really check the mapping ahead of time
- // so we'll let the operation continue
- return OK;
- }
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(root);
- try {
- cvsFolder.accept(new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {
- // do nothing
- }
- public void visitFolder(ICVSFolder folder) throws CVSException {
- if (!folder.isCVSFolder()) return;
- IResource resource = folder.getIResource();
- if (resource == null) return;
- FolderSyncInfo info = folder.getFolderSyncInfo();
- if (info.isSameMapping(remoteInfo)) {
- throw new CVSException(Policy.bind("CheckoutIntoOperation.mappingAlreadyExists", //$NON-NLS-1$
- new Object[] {
- remoteFolder.getName(),
- targetFolder.getIResource().getFullPath().toString(),
- resource.getFullPath().toString()
- }));
- }
- folder.acceptChildren(this);
- }
- });
- } catch (CVSException e) {
- return e.getStatus();
- }
- return OK;
- }
-
- /*
- * Purge the local contents of the given folders
- */
- private IStatus scrubFolders(ICVSRemoteFolder remoteFolder, ICVSFolder[] targetFolders, IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(null, 100 * targetFolders.length);
-
- // Prompt first before any work is done
- if (targetFolders.length > 1) {
- setInvolvesMultipleResources(true);
- }
- for (int i=0;i<targetFolders.length;i++) {
- ICVSFolder targetFolder = targetFolders[i];
- if (needsPromptForOverwrite(targetFolder, Policy.subMonitorFor(monitor, 50)) && !promptToOverwrite(targetFolder)) {
- return new CVSStatus(IStatus.INFO, Policy.bind("CheckoutIntoOperation.cancelled", remoteFolder.getName())); //$NON-NLS-1$
- }
- }
-
- for (int i = 0; i < targetFolders.length; i++) {
- IStatus status = scrubFolder(targetFolders[i], Policy.subMonitorFor(monitor, 50));
- if (!status.isOK()) return status;
- }
- monitor.done();
- return OK;
- }
-
- private boolean needsPromptForOverwrite(ICVSFolder targetFolder, IProgressMonitor monitor) throws CVSException {
- return targetFolder.isModified(monitor);
- }
-
- private boolean promptToOverwrite(ICVSFolder folder) {
- return promptToOverwrite(
- Policy.bind("CheckoutOperation.confirmOverwrite"), //$NON-NLS-1$
- Policy.bind("CheckoutIntoOperation.overwriteMessage", folder.getName())); //$NON-NLS-1$
- }
-
- private IStatus scrubFolder(ICVSFolder folder, IProgressMonitor monitor) throws CVSException {
- if (folder.exists() || folder.isCVSFolder()) {
- // Unmanage first so we don't get outgoing deletions
- folder.unmanage(Policy.subMonitorFor(monitor, 50));
- if (folder.exists()) folder.delete();
- }
- return OK;
- }
-
- /* private */ IStatus checkout(final ICVSRemoteFolder remoteFolder, ICVSFolder parentFolder, boolean recurse, IProgressMonitor monitor) throws CVSException {
- // Open a connection session to the repository
- monitor.beginTask(null, 100);
- ICVSRepositoryLocation repository = remoteFolder.getRepository();
- Session session = new Session(repository, parentFolder);
- try {
- session.open(Policy.subMonitorFor(monitor, 5), false /* read-only */);
-
- // Determine which local folders will be affected
- String localName = localFolderName;
- if (localName == null) {
- IPath path = new Path(null, remoteFolder.getRepositoryRelativePath());
- if (path.segmentCount() > 1) {
- localName = path.lastSegment();
- }
- }
- ICVSFolder[] targetFolders = prepareLocalFolders(session, remoteFolder, parentFolder, localName, Policy.subMonitorFor(monitor, 5));
- if (targetFolders == null) {
- // an error occured and has been added to the operation's error list
- return getLastError();
- }
-
- // Add recurse option
- List localOptions = new ArrayList();
- if (!recurse)
- localOptions.add(Update.DO_NOT_RECURSE);
- if (localName != null) {
- localOptions.add(Checkout.makeDirectoryNameOption(localName));
- }
-
- // Prune empty directories if pruning enabled
- if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories())
- localOptions.add(Checkout.PRUNE_EMPTY_DIRECTORIES);
- // Add the options related to the CVSTag
- CVSTag tag = remoteFolder.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[] { remoteFolder.getRepositoryRelativePath() },
- null,
- Policy.subMonitorFor(monitor, 80));
- if (!status.isOK()) {
- return status;
- }
-
- manageFolders(targetFolders, repository.getLocation());
-
- return OK;
-
- } finally {
- session.close();
- }
- }
-
- private void manageFolders(ICVSFolder[] targetFolders, String root) throws CVSException {
- for (int i = 0; i < targetFolders.length; i++) {
- manageFolder(targetFolders[i], root);
- }
- }
-
- private static void manageFolder(ICVSFolder folder, String root) throws CVSException {
- // Ensure that the parent is a CVS folder
- ICVSFolder parent = folder.getParent();
- if (!parent.isCVSFolder()) {
- parent.setFolderSyncInfo(new FolderSyncInfo(FolderSyncInfo.VIRTUAL_DIRECTORY, root, CVSTag.DEFAULT, true));
- IResource resource = parent.getIResource();
- if (resource.getType() != IResource.PROJECT) {
- manageFolder(parent, root);
- }
- }
- // reset the folder sync info so it will be managed by it's parent
- folder.setFolderSyncInfo(folder.getFolderSyncInfo());
- }
-
- /*
- * Bring the provided projects into the workspace
- */
- private static void refreshRoot(IContainer root, IProgressMonitor monitor) throws CVSException {
- try {
- IProject project = root.getProject();
- CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId());
- if (provider == null) {
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project);
- if (folder.isCVSFolder()) {
- // Register the project with Team
- RepositoryProvider.map(project, CVSProviderPlugin.getTypeId());
-
- // TODO: This should be somewhere else
- provider = (CVSTeamProvider)RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId());
- provider.setWatchEditEnabled(CVSProviderPlugin.getPlugin().isWatchEditEnabled());
- }
- }
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- public String getName() {
- return getTaskName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getSchedulingRule()
- */
- protected ISchedulingRule getSchedulingRule() {
- try {
- // Use the project of the target folder as the scheduling rule
- return getLocalFolder().getIResource().getProject();
- } catch (CVSException e) {
- CVSUIPlugin.log(e);
- return null;
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutMultipleProjectsOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutMultipleProjectsOperation.java
deleted file mode 100644
index 54abf5a03..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutMultipleProjectsOperation.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * This operation checks out a multiple remote folders into the workspace.
- * Each one will become a new project (overwritting any exsiting projects
- * with the same name).
- */
-public class CheckoutMultipleProjectsOperation extends CheckoutProjectOperation {
-
- boolean hasTargetLocation;
-
- public CheckoutMultipleProjectsOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders, String targetLocation) {
- super(part, remoteFolders, targetLocation);
- hasTargetLocation = targetLocation != null;
- setInvolvesMultipleResources(remoteFolders.length > 1);
- }
-
- /**
- * Return the target location where the given project should be located or
- * null if the default location should be used.
- *
- * @param project
- */
- protected IPath getTargetLocationFor(IProject project) {
- IPath targetLocation = super.getTargetLocationFor(project);
- if (targetLocation == null) return null;
- return targetLocation.append(project.getName());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#checkout(org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus checkout(ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException {
- return checkout(folder, null, monitor);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java
deleted file mode 100644
index 761169a42..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-
-public abstract class CheckoutOperation extends RemoteOperation {
-
- public CheckoutOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders) {
- super(part, remoteFolders);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
- ICVSRemoteFolder[] folders = getRemoteFolders();
- checkout(folders, monitor);
- }
-
- /**
- * This method invokes <code>checkout(ICVSRemoteFolder, IProgressMonitor)</code>
- * for each remote folder of the operation.
- * @param folders the remote folders for the operation
- * @param monitor the progress monitor
- * @throws CVSException if an error occured that should prevent the remaining
- * folders from being checked out
- */
- protected void checkout(ICVSRemoteFolder[] folders, IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(null, folders.length * 100);
- for (int i = 0; i < folders.length; i++) {
- ICVSRemoteFolder folder = folders[i];
- IStatus result = checkout(folder, Policy.subMonitorFor(monitor, 100));
- collectStatus(result);
- Policy.checkCanceled(monitor);
- }
- monitor.done();
- }
-
- protected ICVSRemoteFolder[] getRemoteFolders() {
- return (ICVSRemoteFolder[])getRemoteResources();
- }
-
- /**
- * Checkout the selected remote folders in a form appropriate for the operation subclass.
- * @param folders
- * @param monitor
- */
- protected abstract IStatus checkout(ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException;
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#canRunAsJob()
- */
- public boolean canRunAsJob() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.TeamOperation#isKeepOneProgressServiceEntry()
- */
- public boolean isKeepOneProgressServiceEntry() {
- // Keep the last repository provider operation in the progress service
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.TeamOperation#getGotoAction()
- */
- protected IAction getGotoAction() {
- return getShowConsoleAction();
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java
deleted file mode 100644
index 3fc09d18d..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java
+++ /dev/null
@@ -1,481 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.io.File;
-import java.io.IOException;
-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.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.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-/**
- * This class acts as an abstract class for checkout operations.
- * It provides a few common methods.
- */
-public abstract class CheckoutProjectOperation extends CheckoutOperation {
-
- private String targetLocation;
-
- public CheckoutProjectOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders, String targetLocation) {
- super(part, remoteFolders);
- this.targetLocation = targetLocation;
- }
-
- /**
- * Create and open the project, using a custom location if there is one.
- *
- * @param project
- * @param monitor
- * @throws CVSException
- */
- protected void createAndOpenProject(IProject project, IProgressMonitor monitor) throws CVSException {
- try {
- monitor.beginTask(null, 5);
- IProjectDescription desc = getDescriptionFor(project);
- if (project.exists()) {
- if (desc != null) {
- project.move(desc, true, Policy.subMonitorFor(monitor, 3));
- }
- } else {
- if (desc == null) {
- // create in default location
- project.create(Policy.subMonitorFor(monitor, 3));
- } else {
- // create in some other location
- project.create(desc, Policy.subMonitorFor(monitor, 3));
- }
- }
- if (!project.isOpen()) {
- project.open(Policy.subMonitorFor(monitor, 2));
- }
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- monitor.done();
- }
- }
-
- protected IProjectDescription getDescriptionFor(IProject project) {
- if (targetLocation == null) return null;
- String projectName = project.getName();
- IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(projectName);
- description.setLocation(getTargetLocationFor(project));
- return description;
- }
-
- /**
- * Return the target location where the given project should be located or
- * null if the default location should be used.
- *
- * @param project
- */
- protected IPath getTargetLocationFor(IProject project) {
- if (targetLocation == null) return null;
- return new Path(targetLocation);
- }
-
- protected String getRemoteModuleName(ICVSRemoteFolder resource) {
- String moduleName;
- if (resource.isDefinedModule()) {
- moduleName = resource.getName();
- } else {
- moduleName = resource.getRepositoryRelativePath();
- }
- return moduleName;
- }
-
- protected IStatus checkout(final ICVSRemoteFolder resource, IProject project, IProgressMonitor pm) throws CVSException {
- // Get the location and the workspace root
- ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot());
- ICVSRepositoryLocation repository = resource.getRepository();
- // Open a connection session to the repository
- final Session session = new Session(repository, root);
- pm.beginTask(null, 100);
- Policy.checkCanceled(pm);
- session.open(Policy.subMonitorFor(pm, 5), false /* read-only */);
- try {
-
- // Check to see if the entire repo is being checked out.
- if (project == null && resource.getName().equals(".")) { //$NON-NLS-1$
- // No project was specified but we need on for this to work
- String name = new Path(null, resource.getRepository().getRootDirectory()).lastSegment();
- project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
- }
-
- // Determine the local target projects (either the project provider or the module expansions)
- // Note: Module expansions can be run over the same connection as a checkout
- final IProject[] targetProjects = determineProjects(session, resource, project, Policy.subMonitorFor(pm, 5));
- if (targetProjects == null) {
- // An error occurred and was recorded so return it
- return getLastError();
- } else if (targetProjects.length == 0) {
- return OK;
- }
-
- final boolean sendModuleName = project != null;
- final IStatus[] result = new IStatus[] { null };
- ISchedulingRule schedulingRule = getSchedulingRule(targetProjects);
- if (schedulingRule instanceof IResource && ((IResource)schedulingRule).getType() == IResource.ROOT) {
- // One of the projects is mapped to a provider that locks the workspace.
- // Just return the workspace root rule
- try {
- Platform.getJobManager().beginRule(schedulingRule, pm);
- result[0] = performCheckout(session, resource, targetProjects, sendModuleName, Policy.subMonitorFor(pm, 90));
- } finally {
- Platform.getJobManager().endRule(schedulingRule);
- }
- } else {
- EclipseSynchronizer.getInstance().run(schedulingRule, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- result[0] = performCheckout(session, resource, targetProjects, sendModuleName, monitor);
- }
- }, Policy.subMonitorFor(pm, 90));
- }
- return result[0];
- } catch (CVSException e) {
- // An exception occurred either during the module-expansion or checkout
- // Since we were able to make a connection, return the status so the
- // checkout of any other modules can proceed
- return e.getStatus();
- } finally {
- session.close();
- pm.done();
- }
- }
-
- private ISchedulingRule getSchedulingRule(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()]));
- }
- }
-
- /* private */ IStatus performCheckout(Session session, ICVSRemoteFolder resource, IProject[] targetProjects, boolean sendModuleName, IProgressMonitor pm) throws CVSException {
- // Set the task name of the progress monitor to let the user know
- // which project we're on. Don't use subTask since that will be
- // changed when the checkout command is run.
- String taskName;
- if (targetProjects.length == 1) {
- taskName = Policy.bind("CheckoutProjectOperation.8", resource.getName(), targetProjects[0].getName()); //$NON-NLS-1$
- } else {
- taskName = Policy.bind("CheckoutProjectOperation.9", resource.getName(), String.valueOf(targetProjects.length)); //$NON-NLS-1$
- }
- pm.beginTask(taskName, 100);
- pm.setTaskName(taskName);
- Policy.checkCanceled(pm);
- try {
- // Scrub the local contents if requested
- if (performScrubProjects()) {
- IStatus result = scrubProjects(resource, targetProjects, Policy.subMonitorFor(pm, 9));
- if (!result.isOK()) {
- return result;
- }
- }
-
- // Determine if t
- // in which case we'll use -d to flatten the directory structure.
- // Only flatten the directory structure if the folder is not a root folder
- IProject project = null;
- if (targetProjects.length == 1) {
- if (sendModuleName) {
- project = targetProjects[0];
- } else if (targetProjects[0].getName().equals(resource.getName())) {
- // The target project has the same name as the remote folder.
- // If the repository relative path has multiple segments
- // we will want to flatten the directory structure
- String path = resource.getRepositoryRelativePath();
- if (!path.equals(FolderSyncInfo.VIRTUAL_DIRECTORY)
- && new Path(null, path).segmentCount() > 1) {
- project = targetProjects[0];
- }
- }
- }
-
- try {
- // Build the local options
- List localOptions = new ArrayList();
- // Add the option to load into the target project if one was supplied
- if (project != null) {
- localOptions.add(Checkout.makeDirectoryNameOption(project.getName()));
- }
- // Prune empty directories if pruning enabled
- if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories())
- localOptions.add(Checkout.PRUNE_EMPTY_DIRECTORIES);
- // Add the options related to the CVSTag
- CVSTag tag = resource.getTag();
- if (tag == null) {
- // A null tag in a remote resource indicates HEAD
- tag = CVSTag.DEFAULT;
- }
- localOptions.add(Update.makeTagOption(tag));
-
- // Perform the checkout
- IStatus status = Command.CHECKOUT.execute(session,
- Command.NO_GLOBAL_OPTIONS,
- (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]),
- new String[]{getRemoteModuleName(resource)},
- null,
- Policy.subMonitorFor(pm, 90));
- return status;
- } finally {
- // Map the projects if they have CVS meta infomation even if a failure occurred
- refreshProjects(targetProjects, Policy.subMonitorFor(pm, 1));
- }
- } finally {
- pm.done();
- }
- }
-
- /*
- * Determine the workspace project(s) that will be affected by the checkout.
- * If project is not null, then it will be the only target project of the checkout.
- * Otherwise, the remote folder could expand to multiple projects.
- *
- * If the remote resource is a folder which is not a root folder (i.e. a/b/c),
- * then the target project will be the last segment (i.e. c).
- */
- private IProject[] determineProjects(Session session, final ICVSRemoteFolder remoteFolder, IProject project, IProgressMonitor pm) throws CVSException {
-
- Set targetProjectSet = new HashSet();
- String moduleName = getRemoteModuleName(remoteFolder);
- if (project == null) {
-
- // Fetch the module expansions
- Policy.checkCanceled(pm);
- IStatus status = Request.EXPAND_MODULES.execute(session, new String[] {moduleName}, pm);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- collectStatus(status);
- return null;
- }
-
- // Convert the module expansions to local projects
- String[] expansions = session.getModuleExpansions();
- if (expansions.length == 1 && expansions[0].equals(moduleName)) {
- // For a remote folder, use the last segment as the project to be created
- String lastSegment = new Path(null, expansions[0]).lastSegment();
- targetProjectSet.add(ResourcesPlugin.getWorkspace().getRoot().getProject(lastSegment));
- } else {
- for (int j = 0; j < expansions.length; j++) {
- targetProjectSet.add(ResourcesPlugin.getWorkspace().getRoot().getProject(new Path(null, expansions[j]).segment(0)));
- }
- }
-
- } else {
- targetProjectSet.add(project);
- }
-
- // Return the local projects affected by the checkout
- IProject[] targetProjects = (IProject[]) targetProjectSet.toArray(new IProject[targetProjectSet.size()]);
- return targetProjects;
- }
-
- /**
- * Return true if the target projects should be scrubbed before the checkout occurs.
- * Default is to scrub the projects. Can be overridden by subclasses.
- */
- protected boolean performScrubProjects() {
- return true;
- }
-
- /*
- * This method is invoked to scrub the local projects that are the check out target of
- * a single remote module.
- */
- private IStatus scrubProjects(ICVSRemoteFolder remoteFolder, IProject[] projects, IProgressMonitor monitor) throws CVSException {
- if (projects == null) {
- monitor.done();
- return OK;
- }
- // Prompt first before any work is done
- if (projects.length > 1) {
- setInvolvesMultipleResources(true);
- }
- for (int i=0;i<projects.length;i++) {
- IProject project = projects[i];
- Policy.checkCanceled(monitor);
- if (needsPromptForOverwrite(project) && !promptToOverwrite(remoteFolder, project)) {
- // User said no to this project but not no to all
- return new CVSStatus(IStatus.INFO, CVSStatus.CANCEL, Policy.bind("CheckoutProjectOperation.0", remoteFolder.getRepositoryRelativePath())); //$NON-NLS-1$
- }
- }
- // Create the projects and remove any previous content
- monitor.beginTask(null, projects.length * 100); //$NON-NLS-1$
- for (int i=0;i<projects.length;i++) {
- IProject project = projects[i];
- createAndOpenProject(project, Policy.subMonitorFor(monitor, 10));
- scrubProject(project, Policy.subMonitorFor(monitor, 90));
- }
- monitor.done();
- return OK;
- }
-
- private void scrubProject(IProject project, IProgressMonitor monitor) throws CVSException {
- try {
- // unmap the project from any previous repository provider
- if (RepositoryProvider.getProvider(project) != null)
- RepositoryProvider.unmap(project);
- // 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
- IResource[] children = project.members(IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
- Policy.checkCanceled(monitor);
- monitor.beginTask(null, 100 + children.length * 100);
- monitor.subTask(Policy.bind("CheckoutOperation.scrubbingProject", project.getName())); //$NON-NLS-1$
- 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(monitor, 100));
- }
- }
- // Make sure there is no sync info cached for the project since
- // a reader thread may have caused it to be loaded since the unmap.
- EclipseSynchronizer.getInstance().flush(project, true, Policy.subMonitorFor(monitor, 100));
- } finally {
- monitor.done();
- }
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- protected boolean needsPromptForOverwrite(IProject project) {
-
- // First, check the description location
- IProjectDescription desc = getDescriptionFor(project);
- if (desc != null) {
- File localLocation = desc.getLocation().toFile();
- if (localLocation.exists()) return true;
- }
-
- // Next, check if the resource itself exists
- if (project.exists()) return true;
-
- // Finally, check if the location in the workspace exists;
- File localLocation = getFileLocation(project);
- if (localLocation.exists()) return true;
-
- // The target doesn't exist
- return false;
- }
-
- protected File getFileLocation(IProject project) {
- return new File(project.getParent().getLocation().toFile(), project.getName());
- }
-
- private boolean promptToOverwrite(ICVSRemoteFolder remoteFolder, IProject project) {
- // First, if the project exists in the workspace, prompt
- if (project.exists()) {
- if (!promptToOverwrite(
- Policy.bind("CheckoutOperation.confirmOverwrite"), //$NON-NLS-1$
- Policy.bind("CheckoutOperation.thisResourceExists", project.getName(), getRemoteModuleName(remoteFolder)))) { //$NON-NLS-1$
- return false;
- }
- }
- // Even if the project exists, check the target location
- IPath path = getTargetLocationFor(project);
- File localLocation = null;
- if (path == null) {
- try {
- // There is no custom location. However, still prompt
- // if the project directory in the workspace directory
- // would be overwritten.
- if (!project.exists() || !project.isOpen() || project.getDescription().getLocation() != null) {
- localLocation = getFileLocation(project);
- }
- } catch (CoreException e) {
- CVSUIPlugin.log(e);
- }
- } else {
- localLocation = path.toFile();
- }
- if (localLocation != null && localLocation.exists()) {
- try {
- return (promptToOverwrite(
- Policy.bind("CheckoutOperation.confirmOverwrite"), //$NON-NLS-1$
- Policy.bind("CheckoutOperation.thisExternalFileExists", localLocation.getCanonicalPath(), getRemoteModuleName(remoteFolder)))); //$NON-NLS-1$
- } catch (IOException e) {
- CVSUIPlugin.log(CVSException.wrapException(e));
- }
- }
- return true;
- }
-
- protected String getOverwritePromptMessage(ICVSRemoteFolder remoteFolder, IProject project) {
- if(project.exists()) {
- return Policy.bind("CheckoutOperation.thisResourceExists", project.getName(), getRemoteModuleName(remoteFolder));//$NON-NLS-1$
- } else {
- return Policy.bind("CheckoutOperation.thisExternalFileExists", project.getName(), getRemoteModuleName(remoteFolder));//$NON-NLS-1$
- }
- }
-
- /*
- * Bring the provied projects into the workspace
- */
- private void refreshProjects(IProject[] projects, IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(null, projects.length * 100);
- try {
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- // Register the project with Team
- try {
- monitor.subTask(Policy.bind("CheckoutOperation.refreshingProject", project.getName())); //$NON-NLS-1$
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project);
- if (folder.isCVSFolder()) {
- RepositoryProvider.map(project, CVSProviderPlugin.getTypeId());
- }
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- }
- CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId());
- if (provider != null) {
- provider.setWatchEditEnabled(CVSProviderPlugin.getPlugin().isWatchEditEnabled());
- }
- }
- } finally {
- monitor.done();
- }
- }
-
- protected String getTaskName() {
- ICVSRemoteFolder[] remoteFolders = getRemoteFolders();
- if (remoteFolders.length == 1) {
- return Policy.bind("CheckoutSingleProjectOperation.taskname", remoteFolders[0].getName()); //$NON-NLS-1$
- } else {
- return Policy.bind("CheckoutMultipleProjectsOperation.taskName", new Integer(remoteFolders.length).toString()); //$NON-NLS-1$
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutSingleProjectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutSingleProjectOperation.java
deleted file mode 100644
index d9db4191b..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutSingleProjectOperation.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import org.eclipse.core.resources.IProject;
-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.ICVSRemoteFolder;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * This operation checks out a single remote folder into the workspace as
- * a project.
- */
-public class CheckoutSingleProjectOperation extends CheckoutProjectOperation {
-
- private boolean preconfigured;
- private IProject targetProject;
-
- public CheckoutSingleProjectOperation(IWorkbenchPart part, ICVSRemoteFolder remoteFolder, IProject targetProject, String targetLocation, boolean preconfigured) {
- super(part, new ICVSRemoteFolder[] { remoteFolder }, targetLocation);
- this.targetProject = targetProject;
- this.preconfigured = preconfigured;
- }
-
- private boolean isPreconfigured() {
- return preconfigured;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#needsPromptForOverwrite(org.eclipse.core.resources.IProject)
- */
- public boolean needsPromptForOverwrite(IProject project) {
- // No need to prompt if the project was preconfigured
- if (isPreconfigured()) return false;
- return super.needsPromptForOverwrite(project);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutProjectOperation#performScrubProjects()
- */
- protected boolean performScrubProjects() {
- // Do not scrub the projects if they were preconfigured.
- return !isPreconfigured();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#checkout(org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus checkout(ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException {
- return checkout(folder, targetProject, monitor);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java
deleted file mode 100644
index 9d3690a48..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-import org.eclipse.core.runtime.*;
-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.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderSandbox;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Checkout a remote folder into a sandbox that is contained within remote folder handles and
- * the file contents cache.
- */
-public class CheckoutToRemoteFolderOperation extends CheckoutOperation {
-
- RemoteFolderSandbox sandbox;
-
- /**
- * This class overrides the "Created" handler in order to configure the remote file
- * to recieve and cache the contents
- */
- public class CreatedResponseHandler extends UpdatedHandler {
- public CreatedResponseHandler() {
- super(UpdatedHandler.HANDLE_CREATED);
- }
- /* (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 (mFile instanceof RemoteFile) {
- try {
- ((RemoteFile)mFile).aboutToReceiveContents(entryLine.getBytes());
- super.receiveTargetFile(
- session,
- mFile,
- entryLine,
- modTime,
- binary,
- readOnly,
- executable,
- monitor);
- } finally {
- ((RemoteFile)mFile).doneReceivingContents();
- }
- } else {
- super.receiveTargetFile(
- session,
- mFile,
- entryLine,
- modTime,
- binary,
- readOnly,
- executable,
- monitor);
- }
- }
- }
-
- public class SandboxCheckout extends Checkout {
-
- /* (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 {
-
- 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);
- }
- }
-
-}
- public static ICVSRemoteFolder checkoutRemoteFolder(IWorkbenchPart part, ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException, InvocationTargetException, InterruptedException {
- CheckoutToRemoteFolderOperation op = new CheckoutToRemoteFolderOperation(part, folder);
- op.run(monitor);
- return op.getResultingFolder();
- }
- public CheckoutToRemoteFolderOperation(IWorkbenchPart part, ICVSRemoteFolder remoteFolder) {
- super(part, new ICVSRemoteFolder[] { remoteFolder });
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CheckoutOperation#checkout(org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus checkout(
- ICVSRemoteFolder folder,
- IProgressMonitor monitor)
- throws CVSException {
-
- IPath sandboxPath = new Path(null, folder.getRepositoryRelativePath()).removeLastSegments(1);
- String pathString;
- if (sandboxPath.isEmpty()) {
- pathString = ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME;
- } else {
- pathString = sandboxPath.toString();
- }
- sandbox = new RemoteFolderSandbox(null, folder.getRepository(), pathString, folder.getTag());
- return checkout(folder, sandbox, monitor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("CheckoutToRemoteFolderOperation.0", getRemoteFolders()[0].getName()); //$NON-NLS-1$
- }
-
- protected IStatus checkout(final ICVSRemoteFolder resource, final ICVSFolder sandbox, IProgressMonitor pm) throws CVSException {
- // Get the location and the workspace root
- ICVSRepositoryLocation repository = resource.getRepository();
- // Open a connection session to the repository
- final Session session = new Session(repository, sandbox);
- pm.beginTask(null, 100);
- Policy.checkCanceled(pm);
- session.open(Policy.subMonitorFor(pm, 5), false /* read-only */);
- try {
- // Build the local options
- List localOptions = new ArrayList();
- // 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));
- localOptions.add(Checkout.makeDirectoryNameOption(resource.getName()));
-
- // Perform the checkout
- IStatus status = new SandboxCheckout().execute(session,
- Command.NO_GLOBAL_OPTIONS,
- (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]),
- new String[]{resource.getRepositoryRelativePath()},
- null,
- Policy.subMonitorFor(pm, 90));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- // Any created projects will exist but will not be mapped to CVS
- return status;
- }
- return OK;
- } catch (CVSException e) {
- // An exception occurred either during the module-expansion or checkout
- // Since we were able to make a connection, return the status so the
- // checkout of any other modules can proceed
- return e.getStatus();
- } finally {
- session.close();
- pm.done();
- }
- }
-
- public ICVSRemoteFolder getResultingFolder() throws CVSException {
- return (ICVSRemoteFolder)sandbox.getFolder(getRemoteFolders()[0].getName());
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java
deleted file mode 100644
index 6a641b5f2..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.*;
-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.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Perform a "cvs commit"
- */
-public class CommitOperation extends SingleCommandOperation {
-
- public CommitOperation(IWorkbenchPart part, IResource[] resources, LocalOption[] options) {
- super(part, resources, options);
- }
-
- /**
- * Perform prompting for unadded resources and comment
- * @param monitor a progess monitor
- * @return <code>true</code> if execution should continue
- */
- public boolean performPrompting(IProgressMonitor monitor) throws CVSException, InvocationTargetException, InterruptedException {
- monitor.beginTask(null, 20);
- IResource[] resourcesToBeAdded = promptForResourcesToBeAdded(Policy.subMonitorFor(monitor, 10));
- if (resourcesToBeAdded == null) return false;
- String comment = promptForComment(getResources());
- if (comment == null) return false;
- addLocalOption(Commit.makeArgumentOption(Command.MESSAGE_OPTION, comment));
- if (resourcesToBeAdded.length > 0) {
- new AddOperation(getPart(), resourcesToBeAdded)
- .run(Policy.subMonitorFor(monitor, 10));
- }
- setResources(getSharedResources(getResources()));
- monitor.done();
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
- // Ensure that a comment has been provided
- if (!Command.MESSAGE_OPTION.isElementOf(getLocalOptions())) {
- String comment = promptForComment(getResources());
- if (comment == null) return;
- addLocalOption(Commit.makeArgumentOption(Command.MESSAGE_OPTION, comment));
- }
- super.execute(monitor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.team.internal.ccvs.core.ICVSResource[], org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus executeCommand(Session session, CVSTeamProvider provider, ICVSResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException {
- return Command.COMMIT.execute(session,
- Command.NO_GLOBAL_OPTIONS,
- getLocalOptions(),
- resources,
- null,
- monitor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("RepositoryManager.committing"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
- */
- protected String getTaskName(CVSTeamProvider provider) {
- return Policy.bind("CommitOperation.0", provider.getProject().getName()); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getErrorMessage(org.eclipse.core.runtime.IStatus[], int)
- */
- protected String getErrorMessage(IStatus[] failures, int totalOperations) {
- return Policy.bind("CommitAction.commitFailed"); //$NON-NLS-1$
- }
-
- private IResource[] getUnaddedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws CVSException {
- final List unadded = new ArrayList();
- final CVSException[] exception = new CVSException[] { null };
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- // visit each resource deeply
- try {
- resource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- // skip ignored resources and their children
- try {
- if (cvsResource.isIgnored())
- return false;
- // visit the children of shared resources
- if (cvsResource.isManaged())
- return true;
- if (cvsResource.isFolder() && ((ICVSFolder)cvsResource).isCVSFolder())
- return true;
- } catch (CVSException e) {
- exception[0] = e;
- }
- // don't add folders to avoid comitting empty folders
- if (resource.getType() == IResource.FOLDER)
- return true;
- // file is unshared so record it
- unadded.add(resource);
- // no need to go into children because add is deep
- return false;
- }
- });
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- if (exception[0] != null) throw exception[0];
- }
- return (IResource[]) unadded.toArray(new IResource[unadded.size()]);
- }
-
- protected IResource[] promptForResourcesToBeAdded(IProgressMonitor monitor) throws CVSException {
- IResource[] unadded = getUnaddedResources(getResources(), monitor);
- RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
- return manager.promptForResourcesToBeAdded(getShell(), unadded);
- }
-
- protected String promptForComment(IResource[] resourcesToCommit) {
- RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
- return manager.promptForComment(getShell(), resourcesToCommit, null);
- }
-
- /*
- * Return all resources in the provided collection that are shared with a repo
- * @param resources
- * @return IResource[]
- */
- private IResource[] getSharedResources(IResource[] resources) throws CVSException {
- List shared = new ArrayList();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- if (cvsResource.isManaged()
- || (cvsResource.isFolder() && ((ICVSFolder)cvsResource).isCVSFolder())) {
- shared.add(resource);
- }
- }
- return (IResource[]) shared.toArray(new IResource[shared.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#isServerModificationOperation()
- */
- protected boolean isServerModificationOperation() {
- return true;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/DisconnectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/DisconnectOperation.java
deleted file mode 100644
index c32e8abaa..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/DisconnectOperation.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-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.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Disconnect the given projects from CVS control
- */
-public class DisconnectOperation extends RepositoryProviderOperation {
-
- private boolean unmanage;
-
- public DisconnectOperation(IWorkbenchPart part, IProject[] projects, boolean unmanage) {
- super(part, projects);
- this.unmanage = unmanage;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(
- CVSTeamProvider provider,
- IResource[] resources,
- IProgressMonitor monitor)
- throws CVSException, InterruptedException {
-
- // This method will be invoked for each provider being disconnected
- IProject project = provider.getProject();
- try {
- RepositoryProvider.unmap(project);
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- }
- if (unmanage) {
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(project);
- cvsFolder.unmanage(monitor);
- EclipseSynchronizer.getInstance().deconfigure(project, monitor);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("DisconnectOperation.0"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
- */
- protected String getTaskName(CVSTeamProvider provider) {
- return Policy.bind("DisconnectOperation.1", provider.getProject().getName()); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#canRunAsJob()
- */
- public boolean canRunAsJob() {
- // Do not run in the background
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchMembersOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchMembersOperation.java
deleted file mode 100644
index d7a4cd68a..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchMembersOperation.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-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.*;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderMemberFetcher;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.progress.IElementCollector;
-
-/**
- * Fetch the members of a remote folder in the background, passing incremental
- * results through an IElementCollector.
- */
-public class FetchMembersOperation extends RemoteOperation {
-
- /* internal uzse only */ IElementCollector collector;
- /* internal uzse only */ RemoteFolderFilter filter = new RemoteFolderFilter();
-
- public static class RemoteFolderFilter {
- public ICVSRemoteResource[] filter(ICVSRemoteResource[] resource) {
- return resource;
- }
- }
-
- public class InternalRemoteFolderMemberFetcher extends RemoteFolderMemberFetcher {
- long sendIncrement = 100;
- List unsent = new ArrayList();
- long intervalStart;
- protected InternalRemoteFolderMemberFetcher(RemoteFolder parentFolder, CVSTag tag) {
- super(parentFolder, tag);
- }
- protected void parentDoesNotExist() {
- super.parentDoesNotExist();
- // Indicate that there are no children
- collector.add(new Object[0], getProgressMonitor());
- }
- protected RemoteFolder recordFolder(String name) {
- RemoteFolder folder = super.recordFolder(name);
- unsent.add(folder);
- if (isTimeToSend()) {
- sendFolders();
- }
- return folder;
- }
- private boolean isTimeToSend() {
- long currentTime = System.currentTimeMillis();
- return ((currentTime - intervalStart) > sendIncrement) || unsent.size() > sendIncrement;
- }
- protected IStatus performUpdate(IProgressMonitor progress, CVSTag tag) throws CVSException {
- intervalStart = System.currentTimeMillis();
- IStatus status = super.performUpdate(progress, tag);
- sendFolders();
- return status;
- }
- protected void updateFileRevisions(ICVSFile[] files, IProgressMonitor monitor) throws CVSException {
- super.updateFileRevisions(files, monitor);
- sendFiles();
- }
- private void sendFolders() {
- updateParentFolderChildren();
- collector.add(filter.filter((ICVSRemoteFolder[]) unsent.toArray(new ICVSRemoteFolder[unsent.size()])), getProgressMonitor());
- unsent.clear();
- intervalStart = System.currentTimeMillis();
- }
- private void sendFiles() {
- collector.add(getFiles(), getProgressMonitor());
- unsent.clear();
- }
- private IProgressMonitor getProgressMonitor() {
- return null;
- }
- }
-
- public FetchMembersOperation(IWorkbenchPart part, ICVSRemoteFolder folder, IElementCollector collector) {
- super(part, new ICVSRemoteResource[] { folder });
- this.collector = collector;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
- ICVSRemoteFolder remote = getRemoteFolder();
- if (remote.getClass().equals(RemoteFolder.class)) {
- monitor = Policy.monitorFor(monitor);
- boolean isRoot = remote.getName().equals(ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME);
- monitor.beginTask(null, 100 + (isRoot ? 30 : 0));
- RemoteFolderMemberFetcher fetcher = new InternalRemoteFolderMemberFetcher((RemoteFolder)remote, remote.getTag());
- fetcher.fetchMembers(Policy.subMonitorFor(monitor, 100));
- if (isRoot) {
- ICVSRemoteResource[] modules = CVSUIPlugin.getPlugin()
- .getRepositoryManager()
- .getRepositoryRootFor(remote.getRepository())
- .getDefinedModules(remote.getTag(), Policy.subMonitorFor(monitor, 25));
- collector.add(filter.filter(modules), Policy.subMonitorFor(monitor, 5));
- }
- } else {
- monitor = Policy.monitorFor(monitor);
- try {
- monitor.beginTask(null, 100);
- ICVSRemoteResource[] children = remote.members(Policy.subMonitorFor(monitor, 95));
- collector.add(children, Policy.subMonitorFor(monitor, 5));
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- } finally {
- monitor.done();
- }
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("FetchMembersOperation.0", getRemoteFolder().getName()); //$NON-NLS-1$
- }
-
- private ICVSRemoteFolder getRemoteFolder() {
- return (ICVSRemoteFolder)getRemoteResources()[0];
- }
-
- public RemoteFolderFilter getFilter() {
- return filter;
- }
-
- public void setFilter(RemoteFolderFilter filter) {
- this.filter = filter;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java
deleted file mode 100644
index 00a0cf363..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/HasProjectMetaFileOperation.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Operation which checks for the existance of the .project file
- * in a remote folder. The operation can be run using the <code>hasMetaFile</code>
- * static method of by executing the operation and then checking <code>metaFileExists</code>
- */
-public class HasProjectMetaFileOperation extends CVSOperation {
-
- private ICVSRemoteFolder remoteFolder;
- private boolean metaFileExists;
-
- public static boolean hasMetaFile(IWorkbenchPart part, ICVSRemoteFolder remoteFolder) throws InvocationTargetException, InterruptedException {
- HasProjectMetaFileOperation op = new HasProjectMetaFileOperation(part, remoteFolder);
- op.run();
- return op.metaFileExists();
- }
-
- public HasProjectMetaFileOperation(IWorkbenchPart part, ICVSRemoteFolder remoteFolder) {
- super(part);
- this.remoteFolder = remoteFolder;
- }
-
- /*
- * Return true if the provided remote folder contains a valid meta-file
- * (i.e. .project file).
- */
- private boolean hasMetaFile(ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException {
-
- // make a copy of the folder so that we will not effect the original folder when we refetch the members
- // TODO: this is a strange thing to need to do. We shold fix this.
- folder = (ICVSRemoteFolder)folder.forTag(remoteFolder.getTag());
-
- try {
- folder.members(monitor);
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- }
- // Check for the existance of the .project file
- try {
- folder.getFile(".project"); //$NON-NLS-1$
- return true;
- } catch (TeamException e) {
- // We couldn't retrieve the meta file so assume it doesn't exist
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
- metaFileExists = hasMetaFile(remoteFolder, monitor);
- }
-
- /**
- * Return true if the meta file exists remotely. This method should only be invoked
- * after the operation has been executed;
- * @return
- */
- public boolean metaFileExists() {
- return metaFileExists;
- }
-
- protected String getTaskName() {
- return Policy.bind("HasProjectMetaFile.taskName"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#canRunAsJob()
- */
- public boolean canRunAsJob() {
- // This operation should never be run in the background.
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ITagOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ITagOperation.java
deleted file mode 100644
index 493126987..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ITagOperation.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.ui.tags.TagSource;
-
-public interface ITagOperation {
- public abstract CVSTag getTag();
- public abstract void setTag(CVSTag tag);
- public abstract void run() throws InvocationTargetException, InterruptedException;
- public abstract ICVSResource[] getCVSResources();
- public abstract void moveTag();
- public abstract void recurse();
- public abstract TagSource getTagSource();
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/OverrideAndUpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/OverrideAndUpdateOperation.java
deleted file mode 100644
index c5bb066f3..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/OverrideAndUpdateOperation.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.util.*;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * A specialized Replace operation that will update managed resources and
- * unmanaged resources that are conflicting additions (so that the remote is fetched)
- */
-public class OverrideAndUpdateOperation extends ReplaceOperation {
-
- private IResource[] conflictingAdditions;
-
- public OverrideAndUpdateOperation(IWorkbenchPart part, IResource[] allResources, IResource[] conflictingAdditions, CVSTag tag, boolean recurse) {
- super(part, allResources, tag, recurse);
- this.conflictingAdditions = conflictingAdditions;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation#getResourcesToUpdate(org.eclipse.team.internal.ccvs.core.ICVSResource[])
- */
- protected ICVSResource[] getResourcesToUpdate(ICVSResource[] resources) throws CVSException {
- // Add the conflicting additions to the list of resources to update
- Set update = new HashSet();
- ICVSResource[] conflicts = getCVSArguments(conflictingAdditions);
- update.addAll(Arrays.asList(conflicts));
- update.addAll(Arrays.asList(super.getResourcesToUpdate(resources)));
- return (ICVSResource[]) update.toArray(new ICVSResource[update.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#updateWorkspaceSubscriber(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.team.internal.ccvs.core.ICVSResource[], org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void updateWorkspaceSubscriber(CVSTeamProvider provider, ICVSResource[] resources, IProgressMonitor monitor) {
- // No need to update the workspace subscriber since we know this operation will do it properly by itself
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java
deleted file mode 100644
index 875b30376..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReconcileProjectOperation.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Date;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.synchronize.SyncInfoFilter.ContentComparisonSyncInfoFilter;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-
-/**
- * Reconcile an existing unshared local project with an existing remote folder.
- */
-public class ReconcileProjectOperation extends ShareProjectOperation {
-
- private ICVSRemoteFolder folder;
- private ContentComparisonSyncInfoFilter contentCompare = new ContentComparisonSyncInfoFilter(false);
- private CVSWorkspaceSubscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber();
-
- public ReconcileProjectOperation(Shell shell, IProject project, ICVSRemoteFolder folder) {
- super(shell, folder.getRepository(), project, folder.getRepositoryRelativePath());
- this.folder = folder;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("ReconcileProjectOperation.0", getProject().getName(), folder.getRepositoryRelativePath()); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.ShareProjectOperation#createRemoteFolder(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected ICVSRemoteFolder createRemoteFolder(IProgressMonitor monitor) throws CVSException {
- // The folder already exists so just return the handle
- return folder;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.ShareProjectOperation#mapProjectToRemoteFolder(org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void mapProjectToRemoteFolder(ICVSRemoteFolder remote, IProgressMonitor monitor) throws TeamException {
- // Map the project
- monitor.beginTask(null, 100);
- super.mapProjectToRemoteFolder(remote, Policy.subMonitorFor(monitor, 10));
- // Reconcile the sync info
- reconcileSyncInfo(Policy.subMonitorFor(monitor, 90));
- monitor.done();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void reconcileSyncInfo(IProgressMonitor monitor) throws CVSException {
- try {
- monitor.beginTask(null, 100);
- // Fetch the entire remote tree
- ICVSRemoteFolder remote = CheckoutToRemoteFolderOperation.checkoutRemoteFolder(getPart(), folder, Policy.subMonitorFor(monitor, 80));
- // Traverse the tree and populate the workspace base or remote
- // with the sync info depending on file contents
- populateWorkspace(remote, Policy.subMonitorFor(monitor, 20));
- } catch (InvocationTargetException e) {
- throw CVSException.wrapException(e);
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- } catch (InterruptedException e) {
- throw new OperationCanceledException();
- } finally {
- monitor.done();
- }
-
- }
-
- private void populateWorkspace(final ICVSRemoteFolder remote, IProgressMonitor monitor) throws CVSException {
- CVSWorkspaceRoot.getCVSFolderFor(getProject()).run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- populateWorkspace(getProject(), remote, monitor);
- }
- }, monitor);
-
- }
-
- /* private */ void populateWorkspace(IResource resource, ICVSRemoteResource remote, IProgressMonitor monitor) throws CVSException {
- try {
- if (resource.getType() == IResource.FILE) {
- if (remote.isContainer()) {
- CVSUIPlugin.log(IStatus.ERROR, Policy.bind("ReconcileProjectOperation.1", resource.getFullPath().toString(), remote.getRepositoryRelativePath()), null); //$NON-NLS-1$
- } else {
- IFile file = (IFile)resource;
- IResourceVariant variant = (IResourceVariant)remote;
- if (file.exists()
- && variant != null
- && contentCompare.compareContents(file, variant, monitor)) {
- // The contents are the same so populate the local workspace
- // with the remote sync info and make the file in-sync
- makeInSync(file, remote, monitor);
- } else {
- // Would like to put the bytes in the remote but this
- // is complicated due to subscriber events.
- // We'll refresh the subcriber at the end.
- }
- }
- } else {
- if (!remote.isContainer()) {
- CVSUIPlugin.log(IStatus.ERROR, Policy.bind("ReconcileProjectOperation.2", resource.getFullPath().toString(), remote.getRepositoryRelativePath()), null); //$NON-NLS-1$
- } else {
- // Map the local folder to the remote folder.
- // (Note that this will make phantoms for non-exisiting local folders)
- ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(resource);
- folder.setFolderSyncInfo(((ICVSFolder)remote).getFolderSyncInfo());
- // Traverse the children of the remote
- // (The members were prefetched).
- ICVSRemoteResource[] members = remote.members(monitor);
- for (int i = 0; i < members.length; i++) {
- ICVSRemoteResource member = members[i];
- populateWorkspace(getLocalChild((IContainer)resource, member), member, monitor);
- }
- }
- }
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- /*
- * Get the local resource handle for corresponding to the remote resource
- */
- private IResource getLocalChild(IContainer parent, ICVSRemoteResource member) {
- IResource resource = parent.findMember(member.getName());
- if (resource == null) {
- if (member.isContainer()) {
- resource = parent.getFolder(new Path(null, member.getName()));
- } else {
- resource = parent.getFile(new Path(null, member.getName()));
- }
- }
- return resource;
- }
-
- /*
- * Make the file in-sync with its corresponding remote.
- */
- private void makeInSync(IFile file, ICVSRemoteResource remote, IProgressMonitor monitor) throws CVSException {
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file);
- ResourceSyncInfo info = remote.getSyncInfo();
- Date modTime = info.getTimeStamp();
- if (modTime != null) {
- cvsFile.setTimeStamp(modTime);
- }
- modTime = cvsFile.getTimeStamp();
- MutableResourceSyncInfo newInfoWithTimestamp = info.cloneMutable();
- newInfoWithTimestamp.setTimeStamp(modTime);
- cvsFile.setSyncInfo(newInfoWithTimestamp, ICVSFile.CLEAN);
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java
deleted file mode 100644
index 3c5fb84ff..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.util.*;
-
-import org.eclipse.compare.CompareUI;
-import org.eclipse.core.runtime.*;
-import org.eclipse.swt.widgets.Display;
-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.RDiffSummaryListener;
-import org.eclipse.team.internal.ccvs.core.resources.*;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-import org.eclipse.team.internal.ccvs.ui.*;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Compare the two versions of given remote folders obtained from the two tags specified.
- */
-public class RemoteCompareOperation extends RemoteOperation {
-
- private CompareTreeBuilder builder;
- private CVSTag left, right;
-
- /**
- * Helper class for builder and comparing the resource trees
- */
- public static class CompareTreeBuilder implements RDiffSummaryListener.IFileDiffListener {
- private ICVSRepositoryLocation location;
- private RemoteFolderTree leftTree, rightTree;
- private CVSTag left, right;
-
- public CompareTreeBuilder(ICVSRepositoryLocation location, CVSTag left, CVSTag right) {
- this.left = left;
- this.right = right;
- this.location = location;
- reset();
- }
-
- public RemoteFolderTree getLeftTree() {
- return leftTree;
- }
- public RemoteFolderTree getRightTree() {
- return rightTree;
- }
-
- /**
- * Reset the builder to prepare for a new build
- */
- public void reset() {
- leftTree = new RemoteFolderTree(null, location, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, left);
- leftTree.setChildren(new ICVSRemoteResource[0]);
- rightTree = new RemoteFolderTree(null, location, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, right);
- rightTree.setChildren(new ICVSRemoteResource[0]);
- }
-
- /**
- * Cache the contents for the files that are about to be compares
- * @throws CVSException
- */
- public void cacheContents(IProgressMonitor monitor) throws CVSException {
- String[] overlappingFilePaths = getOverlappingFilePaths();
- if (overlappingFilePaths.length > 0) {
- monitor.beginTask(null, 100);
- fetchFileContents(leftTree, overlappingFilePaths, Policy.subMonitorFor(monitor, 50));
- fetchFileContents(rightTree, overlappingFilePaths, Policy.subMonitorFor(monitor, 50));
- monitor.done();
- }
- }
-
- /**
- * Open the comparison in a compare editor
- */
- public void openCompareEditor(final IWorkbenchPage page, final String title, final String toolTip) {
- if (leftTree == null || rightTree == null) return;
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- CompareUI.openCompareEditorOnPage(
- new CVSCompareEditorInput(title, toolTip, new ResourceEditionNode(leftTree), new ResourceEditionNode(rightTree)), page);
- }
- });
- }
-
- /**
- * Add the predecessor to the left tree and the remote to the right tree.
- * @param predecessor
- * @param remote
- */
- public void addToTrees(ICVSRemoteFile predecessor, ICVSRemoteFile remote) {
- if (remote != null) {
- try {
- Path filePath = new Path(null, remote.getRepositoryRelativePath());
- addFile(rightTree, right, filePath, remote.getRevision());
- getFolder(leftTree, left, filePath.removeLastSegments(1), Path.EMPTY);
- } catch (TeamException e) {
- CVSUIPlugin.log(e);
- }
- }
- if (predecessor != null) {
- try {
- Path filePath = new Path(null, predecessor.getRepositoryRelativePath());
- addFile(leftTree, left, filePath, predecessor.getRevision());
- getFolder(rightTree, right, filePath.removeLastSegments(1), Path.EMPTY);
- } catch (TeamException e) {
- CVSUIPlugin.log(e);
- }
- }
- }
-
- private void addFile(RemoteFolderTree tree, CVSTag tag, Path filePath, String revision) throws CVSException {
- RemoteFolderTree parent = (RemoteFolderTree)getFolder(tree, tag, filePath.removeLastSegments(1), Path.EMPTY);
- String name = filePath.lastSegment();
- ICVSRemoteFile file = new RemoteFile(parent, 0, name, revision, null, getTag(revision, tag));
- addChild(parent, file);
- }
-
- private CVSTag getTag(String revision, CVSTag tag) {
- if (tag == null) {
- tag = new CVSTag(revision, CVSTag.VERSION);
- }
- return tag;
- }
-
- /*
- * 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);
- ((RemoteFolderTree)child).setChildren(new ICVSRemoteResource[0]);
- addChild(tree, (ICVSRemoteResource)child);
- }
- return getFolder((RemoteFolderTree)child, tag, remoteFolderPath.removeFirstSegments(1), childPath);
- }
-
- private void addChild(RemoteFolderTree tree, ICVSRemoteResource 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);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener.IFileDiffListener#fileDiff(java.lang.String, java.lang.String, java.lang.String)
- */
- public void fileDiff(String remoteFilePath, String leftRevision, String rightRevision) {
- try {
- addFile(rightTree, right, new Path(null, remoteFilePath), rightRevision);
- } catch (CVSException e) {
- CVSUIPlugin.log(e);
- }
- try {
- addFile(leftTree, left, new Path(null, remoteFilePath), leftRevision);
- } catch (CVSException e) {
- CVSUIPlugin.log(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener.IFileDiffListener#newFile(java.lang.String, java.lang.String)
- */
- public void newFile(String remoteFilePath, String rightRevision) {
- try {
- addFile(rightTree, right, new Path(null, remoteFilePath), rightRevision);
- } catch (CVSException e) {
- CVSUIPlugin.log(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener.IFileDiffListener#deletedFile(java.lang.String)
- */
- public void deletedFile(String remoteFilePath, String leftRevision) {
- // The leftRevision may be null in which case the tag is used
- try {
- addFile(leftTree, left, new Path(null, remoteFilePath), leftRevision);
- } catch (CVSException e) {
- CVSUIPlugin.log(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener.IFileDiffListener#directory(java.lang.String)
- */
- public void directory(String remoteFolderPath) {
- try {
- getFolder(leftTree, left, new Path(null, remoteFolderPath), Path.EMPTY);
- } catch (CVSException e) {
- CVSUIPlugin.log(e);
- }
- try {
- getFolder(rightTree, right, new Path(null, remoteFolderPath), Path.EMPTY);
- } catch (CVSException e) {
- CVSUIPlugin.log(e);
- }
- }
-
- private String[] getOverlappingFilePaths() {
- String[] leftFiles = getFilePaths(leftTree);
- String[] rightFiles = getFilePaths(rightTree);
- Set set = new HashSet();
- for (int i = 0; i < rightFiles.length; i++) {
- String rightFile = rightFiles[i];
- for (int j = 0; j < leftFiles.length; j++) {
- String leftFile = leftFiles[j];
- if (leftFile.equals(rightFile)) {
- set.add(leftFile);
- }
- }
- }
- return (String[]) set.toArray(new String[set.size()]);
- }
-
- private void fetchFileContents(RemoteFolderTree tree, String[] overlappingFilePaths, IProgressMonitor monitor) throws CVSException {
- FileContentCachingService.fetchFileContents(tree, overlappingFilePaths, monitor);
- }
-
- private String[] getFilePaths(RemoteFolderTree tree) {
- ICVSRemoteResource[] children = tree.getChildren();
- List result = new ArrayList();
- for (int i = 0; i < children.length; i++) {
- ICVSRemoteResource resource = children[i];
- if (resource.isContainer()) {
- result.addAll(Arrays.asList(getFilePaths((RemoteFolderTree)resource)));
- } else {
- result.add(resource.getRepositoryRelativePath());
- }
- }
- return (String[]) result.toArray(new String[result.size()]);
- }
- }
-
- public static CVSTag getTag(ICVSRemoteResource resource) throws CVSException {
- CVSTag tag = null;
- try {
- if (resource.isContainer()) {
- tag = ((ICVSRemoteFolder)resource).getTag();
- } else {
- ICVSRemoteFile file = (ICVSRemoteFile)resource;
- String revision = file.getRevision();
- if (revision.equals(ResourceSyncInfo.ADDED_REVISION)) {
- ResourceSyncInfo info =file.getSyncInfo();
- if (info != null) tag = info.getTag();
- } else {
- tag = new CVSTag(revision, CVSTag.VERSION);
- }
- }
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- }
- if (tag == null) tag = CVSTag.DEFAULT;
- return tag;
- }
-
- /**
- * Compare two versions of the given remote resource.
- * @param shell
- * @param remoteResource the resource whose tags are being compared
- * @param left the earlier tag (not null)
- * @param right the later tag (not null)
- */
- public RemoteCompareOperation(IWorkbenchPart part, ICVSRemoteResource remoteResource, CVSTag tag) {
- super(part, new ICVSRemoteResource[] {remoteResource});
- Assert.isNotNull(tag);
- this.right = tag;
- try {
- this.left = getTag(remoteResource);
- } catch (CVSException e) {
- // This shouldn't happen but log it just in case
- CVSProviderPlugin.log(e);
- }
- if (this.left == null) {
- this.left = CVSTag.DEFAULT;
- }
- builder = new CompareTreeBuilder(remoteResource.getRepository(), left, right);
- }
-
- /*
- * This command only supports the use of a single resource
- */
- private ICVSRemoteResource getRemoteResource() {
- return getRemoteResources()[0];
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(IProgressMonitor monitor) throws CVSException {
- boolean fetchContents = CVSUIPlugin.getPlugin().getPluginPreferences().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS);
- monitor.beginTask(getTaskName(), 50 + (fetchContents ? 100 : 0));
- try {
- ICVSRemoteResource resource = getRemoteResource();
- IStatus status = buildTrees(resource, Policy.subMonitorFor(monitor, 50));
- if (status.isOK() && fetchContents) {
- builder.cacheContents(Policy.subMonitorFor(monitor, 100));
- }
- collectStatus(status);
- openCompareEditor(builder);
- } finally {
- monitor.done();
- }
- }
-
- /**
- * This method is here to allow subclasses to override
- */
- protected void openCompareEditor(CompareTreeBuilder builder) {
- builder.openCompareEditor(getTargetPage(), null, null);
- }
-
- /*
- * Build the two trees uses the reponses from "cvs rdiff -s ...".
- */
- private IStatus buildTrees(ICVSRemoteResource resource, IProgressMonitor monitor) throws CVSException {
- // Initialize the resulting trees
- builder.reset();
- Command.QuietOption oldOption= CVSProviderPlugin.getPlugin().getQuietness();
- Session session = new Session(resource.getRepository(), builder.getLeftTree(), false);
- try {
- monitor.beginTask(getTaskName(), 100);
- CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
- session.open(Policy.subMonitorFor(monitor, 10));
- IStatus status = Command.RDIFF.execute(session,
- Command.NO_GLOBAL_OPTIONS,
- getLocalOptions(),
- new ICVSResource[] { resource },
- new RDiffSummaryListener(builder),
- Policy.subMonitorFor(monitor, 90));
- return status;
- } finally {
- try {
- session.close();
- } finally {
- CVSProviderPlugin.getPlugin().setQuietness(oldOption);
- }
- monitor.done();
- }
- }
-
- private LocalOption[] getLocalOptions() {
- return new LocalOption[] {RDiff.SUMMARY, RDiff.makeTagOption(left), RDiff.makeTagOption(right)};
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("RemoteCompareOperation.0", new Object[] {left.getName(), right.getName(), getRemoteResource().getRepositoryRelativePath()}); //$NON-NLS-1$
- }
-
- protected IWorkbenchPage getTargetPage() {
- return TeamUIPlugin.getActivePage();
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteLogOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteLogOperation.java
deleted file mode 100644
index b2ad792ce..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteLogOperation.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.util.*;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-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.*;
-import org.eclipse.team.internal.ccvs.core.client.*;
-import org.eclipse.team.internal.ccvs.core.client.listeners.*;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Performs an rlog on the resources and caches the results.
- */
-public class RemoteLogOperation extends RepositoryLocationOperation {
-
- private RLog rlog = new RLog();
- private CVSTag tag1;
- private CVSTag tag2;
- private LogEntryCache entryCache;
-
- /**
- * A log entry cache that can be shared by multiple instances of the
- * remote log operation.
- */
- public static class LogEntryCache implements ILogEntryListener {
-
- /*
- * Cache of all log entries
- */
- private Map entries = new HashMap(); /* Map String:remoteFilePath->Map (String:revision -> ILogEntry) */
-
- private 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()]);
- }
-
- private 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
- CVSUIPlugin.log(e);
- }
- }
- 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.
- */
- private String getFullPath(ICVSRemoteResource resource) {
- return Util.appendPath(resource.getRepository().getLocation(), 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.
- */
- private 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.
- */
- private 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)
- */
- private 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
- */
- private 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);
- }
- }
-
- public RemoteLogOperation(IWorkbenchPart part, ICVSRemoteResource[] remoteResources, CVSTag tag1, CVSTag tag2, LogEntryCache cache) {
- super(part, remoteResources);
- this.tag1 = tag1;
- this.tag2 = tag2;
- this.entryCache = cache;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryLocationOperation#execute(org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSRemoteResource[], org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(ICVSRepositoryLocation location, ICVSRemoteResource[] remoteResources, IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(Policy.bind("RemoteLogOperation.0", location.getHost()), 100); //$NON-NLS-1$
- Session s = new Session(location, CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot()), false /* do not output to console */);
- // Create a log listener that will update the cache as entries are received
- LogListener listener = new LogListener(entryCache);
-
- ICVSRemoteResource[] remotes = remoteResources;
- Command.LocalOption[] localOptions = getLocalOptions(tag1, tag2);
- if(tag1 == null || tag2 == null) {
- // Optimize the cases were we are only fetching the history for a single revision. If it is
- // already cached, don't fetch it again.
- ArrayList unCachedRemotes = new ArrayList();
- for (int i = 0; i < remoteResources.length; i++) {
- ICVSRemoteResource r = remoteResources[i];
- if(entryCache.getLogEntry(r) == null) {
- unCachedRemotes.add(r);
- }
- }
- remotes = (ICVSRemoteResource[]) unCachedRemotes.toArray(new ICVSRemoteResource[unCachedRemotes.size()]);
- }
- if (remotes.length > 0) {
- try {
- s.open(Policy.subMonitorFor(monitor, 10));
- IStatus status = rlog.execute(s, Command.NO_GLOBAL_OPTIONS, localOptions, remotes, listener, Policy.subMonitorFor(monitor, 90));
- collectStatus(status);
- } finally {
- s.close();
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("RemoteLogOperation.1"); //$NON-NLS-1$
- }
-
- 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 {
- return new Command.LocalOption[] {RLog.NO_TAGS, RLog.ONLY_INCLUDE_CHANGES};
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteOperation.java
deleted file mode 100644
index 8e778e947..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteOperation.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.ui.IWorkbenchPart;
-
-public abstract class RemoteOperation extends CVSOperation {
-
- private ICVSRemoteResource[] remoteResources;
-
- protected RemoteOperation(IWorkbenchPart part, ICVSRemoteResource[] remoteResources) {
- super(part);
- this.remoteResources =remoteResources;
- }
-
- protected ICVSRemoteResource[] getRemoteResources() {
- return remoteResources;
- }
-
- public void setRemoteResources(ICVSRemoteResource[] remoteResources) {
- this.remoteResources = remoteResources;
- }
-
- public ICVSResource[] getCVSResources() {
- ICVSResource[] cvsResources = new ICVSResource[remoteResources.length];
- for (int i = 0; i < remoteResources.length; i++) {
- cvsResources[i] = remoteResources[i];
- }
- return cvsResources;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java
deleted file mode 100644
index c12f535b3..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.util.ArrayList;
-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.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.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.PrepareForReplaceVisitor;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Thsi operation replaces the local resources with their remote contents
- */
-public class ReplaceOperation extends UpdateOperation {
-
- boolean recurse = true;
-
- public ReplaceOperation(IWorkbenchPart part, IResource[] resources, CVSTag tag, boolean recurse) {
- super(part, resources, getReplaceOptions(recurse), tag);
- this.recurse = recurse;
- }
-
- /*
- * Create the local options required to do a replace
- */
- private static LocalOption[] getReplaceOptions(boolean recurse) {
- List options = new ArrayList();
- options.add(Update.IGNORE_LOCAL_CHANGES);
- if(!recurse) {
- options.add(Command.DO_NOT_RECURSE);
- }
- return (LocalOption[]) options.toArray(new LocalOption[options.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("ReplaceOperation.taskName"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus executeCommand(
- Session session,
- CVSTeamProvider provider,
- ICVSResource[] resources,
- IProgressMonitor monitor)
- throws CVSException, InterruptedException {
-
- monitor.beginTask(null, 100);
- ICVSResource[] managedResources = getResourcesToUpdate(resources);
- try {
- // Purge any unmanaged or added files
- new PrepareForReplaceVisitor().visitResources(
- provider.getProject(),
- resources,
- "CVSTeamProvider.scrubbingResource", // TODO: This is a key in CVS core! //$NON-NLS-1$
- recurse ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO,
- Policy.subMonitorFor(monitor, 30)); //$NON-NLS-1$
-
- // Only perform the remote command if some of the resources being replaced were managed
- IStatus status = OK;
- if (managedResources.length > 0) {
- // Perform an update, ignoring any local file modifications
- status = super.executeCommand(session, provider, managedResources, Policy.subMonitorFor(monitor, 70));
- }
-
- // Prune any empty folders left after the resources were purged.
- // This is done to prune any empty folders that contained only unmanaged resources
- if (status.isOK() && CVSProviderPlugin.getPlugin().getPruneEmptyDirectories()) {
- new PruneFolderVisitor().visit(session, resources);
- }
-
- return status;
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Return the resources that need to be updated from the server.
- * By default, this is all resources that are managed.
- * @param resources all resources being replaced
- * @return resources that ae to be updated from the server
- * @throws CVSException
- */
- protected ICVSResource[] getResourcesToUpdate(ICVSResource[] resources) throws CVSException {
- // Accumulate the managed resources from the list of provided resources
- List managedResources = new ArrayList();
- for (int i = 0; i < resources.length; i++) {
- ICVSResource resource = resources[i];
- if ((resource.isFolder() && ((ICVSFolder)resource).isCVSFolder())) {
- managedResources.add(resource);
- } else if (!resource.isFolder()){
- byte[] syncBytes = ((ICVSFile)resource).getSyncBytes();
- if (syncBytes != null && !ResourceSyncInfo.isAddition(syncBytes)) {
- managedResources.add(resource);
- }
- }
- }
- return (ICVSResource[]) managedResources.toArray(new ICVSResource[managedResources.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation#getUpdateCommand()
- */
- protected Update getUpdateCommand() {
- return Command.REPLACE;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
- */
- protected String getTaskName(CVSTeamProvider provider) {
- return Policy.bind("ReplaceOperation.0", provider.getProject().getName()); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryLocationOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryLocationOperation.java
deleted file mode 100644
index 0da7eaaec..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryLocationOperation.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.util.*;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Operation that divides the resources by location
- */
-public abstract class RepositoryLocationOperation extends RemoteOperation {
-
- protected RepositoryLocationOperation(IWorkbenchPart part, ICVSRemoteResource[] remoteResources) {
- super(part, remoteResources);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
- Map table = getLocationMapping(getRemoteResources());
- Set keySet = table.keySet();
- monitor.beginTask(null, keySet.size() * 100);
- Iterator iterator = keySet.iterator();
- while (iterator.hasNext()) {
- ICVSRepositoryLocation location = (ICVSRepositoryLocation)iterator.next();
- List list = (List)table.get(location);
- ICVSRemoteResource[] remoteResources = (ICVSRemoteResource[])list.toArray(new ICVSRemoteResource[list.size()]);
- execute(location, remoteResources, Policy.subMonitorFor(monitor, 100));
- }
- }
-
- /**
- * Perform the operation for the given resources found on the
- * given repository.
- * @param location the repository location
- * @param resources the resources of this operation found in the repository
- * @param monitor a progres monitor
- */
- protected abstract void execute(ICVSRepositoryLocation location, ICVSRemoteResource[] resources, IProgressMonitor monitor) throws CVSException;
-
- /*
- * Return a map that maps a location to all the resources
- * from the given list that are located in that repository.
- */
- private Map getLocationMapping(ICVSRemoteResource[] remoteResources) {
- Map locationsMap = new HashMap();
- for (int i = 0; i < remoteResources.length; i++) {
- ICVSRemoteResource resource = remoteResources[i];
- ICVSRepositoryLocation location = resource.getRepository();
- List resources = (List)locationsMap.get(location);
- if (resources == null) {
- resources = new ArrayList();
- locationsMap.put(location, resources);
- }
- resources.add(resource);
- }
- return locationsMap;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.java
deleted file mode 100644
index cc2e0bf5a..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.util.*;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jface.action.IAction;
-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.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Performs a cvs operation on multiple repository providers
- */
-public abstract class RepositoryProviderOperation extends CVSOperation {
-
- private IResource[] resources;
-
- public RepositoryProviderOperation(IWorkbenchPart part, IResource[] resources) {
- super(part);
- this.resources = resources;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
- Map table = getProviderMapping(getResources());
- Set keySet = table.keySet();
- monitor.beginTask(null, keySet.size() * 1000);
- Iterator iterator = keySet.iterator();
- while (iterator.hasNext()) {
- IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
- CVSTeamProvider provider = (CVSTeamProvider)iterator.next();
- List list = (List)table.get(provider);
- IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
- ISchedulingRule rule = getSchedulingRule(provider);
- try {
- Platform.getJobManager().beginRule(rule, monitor);
- monitor.setTaskName(getTaskName(provider));
- execute(provider, providerResources, subMonitor);
- } finally {
- Platform.getJobManager().endRule(rule);
- }
- }
- }
-
- /**
- * Return the taskname to be shown in the progress monitor while operating
- * on the given provider.
- * @param provider the provider being processed
- * @return the taskname to be shown in the progress monitor
- */
- protected abstract String getTaskName(CVSTeamProvider provider);
-
- /**
- * Retgurn the scheduling rule to be obtained before work
- * begins on the given provider. By default, it is the provider's project.
- * This can be changed by subclasses.
- * @param provider
- * @return
- */
- protected ISchedulingRule getSchedulingRule(CVSTeamProvider provider) {
- return provider.getProject();
- }
-
- /*
- * Helper method. Return a Map mapping provider to a list of resources
- * shared with that provider.
- */
- private Map getProviderMapping(IResource[] resources) {
- Map result = new HashMap();
- for (int i = 0; i < resources.length; i++) {
- RepositoryProvider provider = RepositoryProvider.getProvider(resources[i].getProject(), CVSProviderPlugin.getTypeId());
- List list = (List)result.get(provider);
- if (list == null) {
- list = new ArrayList();
- result.put(provider, list);
- }
- list.add(resources[i]);
- }
- return result;
- }
-
- /**
- * Return the resources that the operation is being performed on
- * @return
- */
- protected IResource[] getResources() {
- return resources;
- }
-
- /**
- * Set the resources that the operation is to be performed on
- * @param resources
- */
- protected void setResources(IResource[] resources) {
- this.resources = resources;
- }
-
- /**
- * Execute the operation on the resources for the given provider.
- * @param provider
- * @param providerResources
- * @param subMonitor
- * @throws CVSException
- * @throws InterruptedException
- */
- protected abstract void execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException;
-
- protected 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;
- }
-
- /*
- * Get the arguments to be passed to a commit or update
- */
- protected String[] getStringArguments(IResource[] resources) throws CVSException {
- List arguments = new ArrayList(resources.length);
- for (int i=0;i<resources.length;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()]);
- }
-
- public ICVSResource[] getCVSResources() {
- ICVSResource[] cvsResources = new ICVSResource[resources.length];
- for (int i = 0; i < resources.length; i++) {
- cvsResources[i] = CVSWorkspaceRoot.getCVSResourceFor(resources[i]);
- }
- return cvsResources;
- }
-
- protected ICVSRepositoryLocation getRemoteLocation(CVSTeamProvider provider) throws CVSException {
- CVSWorkspaceRoot workspaceRoot = provider.getCVSWorkspaceRoot();
- return workspaceRoot.getRemoteLocation();
- }
-
- protected ICVSFolder getLocalRoot(CVSTeamProvider provider) throws CVSException {
- CVSWorkspaceRoot workspaceRoot = provider.getCVSWorkspaceRoot();
- return workspaceRoot.getLocalRoot();
- }
-
- /**
- * Update the workspace subscriber for an update operation performed on the
- * given resources. After an update, the remote tree is flushed in order
- * to ensure that stale incoming additions are removed. This need only
- * be done for folders. At the time of writting, all update operations
- * are deep so the flush is deep as well.
- * @param provider the provider (projedct) for all the given resources
- * @param resources the resources that were updated
- * @param monitor a progress monitor
- */
- protected void updateWorkspaceSubscriber(CVSTeamProvider provider, ICVSResource[] resources, IProgressMonitor monitor) {
- CVSWorkspaceSubscriber s = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber();
- monitor.beginTask(null, 100 * resources.length);
- for (int i = 0; i < resources.length; i++) {
- ICVSResource resource = resources[i];
- if (resource.isFolder()) {
- try {
- s.updateRemote(provider, (ICVSFolder)resource, Policy.subMonitorFor(monitor, 100));
- } catch (TeamException e) {
- // Just log the error and continue
- CVSUIPlugin.log(e);
- }
- } else {
- monitor.worked(100);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.TeamOperation#isKeepOneProgressServiceEntry()
- */
- public boolean isKeepOneProgressServiceEntry() {
- // Keep the last repository provider operation in the progress service
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.TeamOperation#getGotoAction()
- */
- protected IAction getGotoAction() {
- return getShowConsoleAction();
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java
deleted file mode 100644
index dae747075..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.swt.widgets.Shell;
-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.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTree;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-
-/**
- * Create a folder and any missing parents in the repository
- */
-public class ShareProjectOperation extends CVSOperation {
-
- private ICVSRepositoryLocation location;
- private IProject project;
- private String moduleName;
- private Shell shell;
-
- public ShareProjectOperation(Shell shell, ICVSRepositoryLocation location, IProject project, String moduleName) {
- super(null);
- this.shell = shell;
- this.moduleName = moduleName;
- this.project = project;
- this.location = location;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
- try {
- monitor.beginTask(getTaskName(), 100);
- // Create the remote module
- final ICVSRemoteFolder remote = createRemoteFolder(Policy.subMonitorFor(monitor, 50));
- // Map the project to the module in a workspace runnable
- final TeamException[] exception = new TeamException[] {null};
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- try {
- mapProjectToRemoteFolder(remote, monitor);
- } catch (TeamException e) {
- exception[0] = e;
- }
- }
- }, ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(project), 0, Policy.subMonitorFor(monitor, 100));
- if (exception[0] != null)
- throw exception[0];
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Create the remote folder to which the project is being mapped
- * (as well as any ancestors) and return it. If the remote folder does not
- * exist remotely, this method will create it.
- * @param monitor a progress monitor
- * @return the existing remote folder to which the project is being mapped
- * @throws CVSException
- */
- protected ICVSRemoteFolder createRemoteFolder(IProgressMonitor monitor) throws CVSException {
- String projectName = project.getName();
- if (moduleName == null)
- moduleName = projectName;
-
- RemoteFolderTree root = new RemoteFolderTree(null, location, Path.EMPTY.toString(), null);
- Path path = new Path(null, moduleName);
-
- try {
- monitor.beginTask(getTaskName(), 100 * path.segmentCount());
- return ensureTreeExists(root, path, monitor);
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- } finally {
- monitor.done();
- }
- }
-
- /**
- * Map the project to the remote folder by associating the CVS
- * Repository Provider with the project and, at the very least,
- * assigning the folder sync info for the remote folder as the
- * folder sync info for the project.
- * @param remote the remote folder to which the projetc is being mapped
- * @param monitor a progress monitor
- * @throws CVSException
- */
- protected void mapProjectToRemoteFolder(final ICVSRemoteFolder remote, IProgressMonitor monitor) throws TeamException {
- monitor.beginTask(null, 100);
- purgeAnyCVSFolders();
- // Link the project to the newly created module
- ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project);
- folder.setFolderSyncInfo(remote.getFolderSyncInfo());
- //Register it with Team. If it already is, no harm done.
- RepositoryProvider.map(project, CVSProviderPlugin.getTypeId());
- monitor.done();
- }
-
- /*
- * Create handles for all the children in the moduleName path
- */
- private RemoteFolderTree createChild(RemoteFolderTree parent, String name, IProgressMonitor monitor) throws CVSException, TeamException {
- RemoteFolderTree child = new RemoteFolderTree(parent, name, location, new Path(null, parent.getRepositoryRelativePath()).append(name).toString(), null);
- parent.setChildren(new ICVSRemoteResource[] { child });
- if (child.exists(Policy.subMonitorFor(monitor, 50))) {
- // The child exists so get the handle that was received from the server
- return (RemoteFolderTree)parent.getFolder(name);
- } else {
- // Create the folder remotely
- createFolder(child, Policy.subMonitorFor(monitor, 50));
- return child;
- }
- }
-
- /*
- * Ensure that all the folders in the tree exist
- */
- private ICVSRemoteFolder ensureTreeExists(RemoteFolderTree folder, IPath path, IProgressMonitor monitor) throws TeamException {
- if (path.isEmpty()) return folder;
- String name = path.segment(0);
- RemoteFolderTree child = createChild(folder, name, monitor);
- return ensureTreeExists(child, path.removeFirstSegments(1), monitor);
- }
-
- private void createFolder(RemoteFolderTree folder, IProgressMonitor monitor) throws TeamException {
- Session s = new Session(location, folder.getParent());
- s.open(monitor, true /* open for modification */);
- try {
- IStatus status = Command.ADD.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- new String[] { folder.getName() },
- null,
- monitor);
- // If we get a warning, the operation most likely failed so check that the status is OK
- if (status.getCode() == CVSStatus.SERVER_ERROR || ! status.isOK()) {
- throw new CVSServerException(status);
- }
- } finally {
- s.close();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("ShareProjectOperation.0", project.getName(), moduleName); //$NON-NLS-1$
- }
-
- /**
- * @return Returns the project.
- */
- public IProject getProject() {
- return project;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getShell()
- */
- protected Shell getShell() {
- return shell;
- }
-
- /**
- * Method findCommonRootInSubfolders.
- * @return String
- */
- private void purgeAnyCVSFolders() {
- try {
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project);
- folder.accept(new ICVSResourceVisitor() {
- public void visitFile(ICVSFile file) throws CVSException {
- // nothing to do for files
- }
- public void visitFolder(ICVSFolder folder) throws CVSException {
- if (folder.isCVSFolder()) {
- // for now, just unmanage
- folder.unmanage(null);
- }
- }
- }, true /* recurse */);
- } catch (CVSException e) {
- // log the exception and return null
- CVSUIPlugin.log(e);
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java
deleted file mode 100644
index cf33ca6e5..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.team.core.variants.IResourceVariant;
-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.AnnotateListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.KnownRepositories;
-import org.eclipse.team.internal.ccvs.ui.*;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.core.TeamPlugin;
-import org.eclipse.team.internal.ui.Utils;
-import org.eclipse.ui.*;
-
-/**
- * An operation to fetch the annotations for a file from the repository and
- * display them in the annotations view.
- */
-public class ShowAnnotationOperation extends CVSOperation {
-
- final private ICVSResource fCVSResource;
- final private String fRevision;
- private final boolean binary;
-
- public ShowAnnotationOperation(IWorkbenchPart part, ICVSResource cvsResource, String revision, boolean binary) {
- super(part);
- fCVSResource= cvsResource;
- fRevision= revision;
- this.binary = binary;
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
-
- monitor.beginTask(null, 100);
-
- // Get the annotations from the repository.
- final AnnotateListener listener= new AnnotateListener();
- fetchAnnotation(listener, fCVSResource, fRevision, Policy.subMonitorFor(monitor, 80));
- try {
- if (hasCharset(fCVSResource, listener.getContents())) {
- listener.setContents(getRemoteContents(fCVSResource, Policy.subMonitorFor(monitor, 20)));
- }
- } catch (CoreException e) {
- // Log and continue, using the original fetched contents
- CVSUIPlugin.log(e);
- }
-
- // Open the view and display it from the UI thread.
- final Display display= getPart().getSite().getShell().getDisplay();
- display.asyncExec(new Runnable() {
- public void run() { showView(listener); }
- });
- monitor.done();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("ShowAnnotationOperation.taskName"); //$NON-NLS-1$
- }
-
- protected boolean hasCharset(ICVSResource cvsResource, InputStream contents) {
- try {
- return TeamPlugin.getCharset(cvsResource.getName(), contents) != null;
- } catch (IOException e) {
- // Assume that the contents do have a charset
- return true;
- }
- }
-
- /**
- * Shows the view once the background operation is finished. This must be called
- * from the UI thread.
- *
- * @param listener The listener with the results.
- */
- protected void showView(final AnnotateListener listener) {
- final IWorkbench workbench= PlatformUI.getWorkbench();
- final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
-
- final String defaultPerspectiveID= promptForPerspectiveSwitch();
-
- if (defaultPerspectiveID != null) {
- try {
- workbench.showPerspective(defaultPerspectiveID, window);
- } catch (WorkbenchException e) {
- Utils.handleError(window.getShell(), e, Policy.bind("ShowAnnotationOperation.0"), e.getMessage()); //$NON-NLS-1$
- }
- }
-
- try {
- final AnnotateView view = AnnotateView.openInActivePerspective();
- view.showAnnotations(fCVSResource, listener.getCvsAnnotateBlocks(), listener.getContents());
- } catch (PartInitException e) {
- CVSUIPlugin.log(e);
- } catch (CVSException e) {
- CVSUIPlugin.log(e);
- }
- }
-
-
- private void fetchAnnotation(AnnotateListener listener, ICVSResource cvsResource, String revision, IProgressMonitor monitor) throws CVSException {
-
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
-
- final ICVSFolder folder = cvsResource.getParent();
- final FolderSyncInfo info = folder.getFolderSyncInfo();
- final ICVSRepositoryLocation location = KnownRepositories.getInstance().getRepository(info.getRoot());
-
- final Session session = new Session(location, folder, true /*output to console*/);
- session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */);
- try {
- final Command.QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
- try {
- CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
- List localOptions = new ArrayList();
- if (revision != null) {
- localOptions.add(Annotate.makeRevisionOption(revision));
- }
- if (binary) {
- localOptions.add(Annotate.FORCE_BINARY_ANNOTATE);
- }
- final IStatus status = Command.ANNOTATE.execute(session, Command.NO_GLOBAL_OPTIONS, (LocalOption[]) localOptions.toArray(new LocalOption[localOptions.size()]), new ICVSResource[]{cvsResource}, listener, Policy.subMonitorFor(monitor, 90));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- CVSProviderPlugin.getPlugin().setQuietness(quietness);
- monitor.done();
- }
- } finally {
- session.close();
- }
- }
-
- private InputStream getRemoteContents(ICVSResource resource, IProgressMonitor monitor) throws CoreException {
-
- final ICVSRemoteResource remote = CVSWorkspaceRoot.getRemoteResourceFor(resource);
- if (remote == null) {
- return new ByteArrayInputStream(new byte[0]);
- }
- final IStorage storage = ((IResourceVariant)remote).getStorage(monitor);
- if (storage == null) {
- return new ByteArrayInputStream(new byte[0]);
- }
- return storage.getContents();
- }
-
- /**
- * @return The ID of the perspective if the perspective needs to be changed,
- * null otherwise.
- */
- private String promptForPerspectiveSwitch() {
- // check whether we should ask the user.
- final IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
- final String option = store.getString(ICVSUIConstants.PREF_CHANGE_PERSPECTIVE_ON_SHOW_ANNOTATIONS);
- final String desiredID = store.getString(ICVSUIConstants.PREF_DEFAULT_PERSPECTIVE_FOR_SHOW_ANNOTATIONS);
-
- if (option.equals(MessageDialogWithToggle.ALWAYS))
- return desiredID; // no, always switch
-
- if (option.equals(MessageDialogWithToggle.NEVER))
- return null; // no, never switch
-
- // Check whether the desired perspective is already active.
- final IPerspectiveRegistry registry= PlatformUI.getWorkbench().getPerspectiveRegistry();
- final IPerspectiveDescriptor desired = registry.findPerspectiveWithId(desiredID);
- final IWorkbenchPage page = CVSUIPlugin.getActivePage();
-
- if (page != null) {
- final IPerspectiveDescriptor current = page.getPerspective();
- if (current != null && current.getId().equals(desiredID)) {
- return null; // it is active, so no prompt and no switch
- }
- }
-
- if (desired != null) {
-
- // Ask the user whether to switch
- final MessageDialogWithToggle m = MessageDialogWithToggle.openYesNoQuestion(
- Utils.getShell(null),
- Policy.bind("ShowAnnotationOperation.1"), //$NON-NLS-1$
- Policy.bind("ShowAnnotationOperation.2", desired.getLabel()), //$NON-NLS-1$
- Policy.bind("ShowAnnotationOperation.4"), //$NON-NLS-1$
- false /* toggle state */,
- store,
- ICVSUIConstants.PREF_CHANGE_PERSPECTIVE_ON_SHOW_ANNOTATIONS);
-
- final int result = m.getReturnCode();
- switch (result) {
- // yes
- case IDialogConstants.YES_ID:
- case IDialogConstants.OK_ID :
- return desiredID;
- // no
- case IDialogConstants.NO_ID :
- return null;
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java
deleted file mode 100644
index 41b846253..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import org.eclipse.core.resources.IResource;
-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.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-
-public abstract class SingleCommandOperation extends RepositoryProviderOperation {
-
- private LocalOption[] options = Command.NO_LOCAL_OPTIONS;
-
- public SingleCommandOperation(IWorkbenchPart part, IResource[] resources, LocalOption[] options) {
- super(part, resources);
- if (options != null) {
- this.options = options;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException {
- monitor.beginTask(null, 100);
- Session session = new Session(getRemoteLocation(provider), getLocalRoot(provider), true /* output to console */);
- session.open(Policy.subMonitorFor(monitor, 10), isServerModificationOperation());
- try {
- // TODO: This does not properly count the number of operations
- // Changing it causes an error in the test cases
- IStatus status = executeCommand(session, provider, getCVSArguments(resources), Policy.subMonitorFor(monitor, 90));
- collectStatus(status);
- } finally {
- session.close();
- }
- }
-
- /**
- * Indicate whether the operation requires write access to the server (i.e.
- * the operation changes state on the server whether it be to commit, tag, admin, etc).
- * @return
- */
- protected boolean isServerModificationOperation() {
- return false;
- }
-
- /**
- * Method overridden by subclasses to issue the command to the CVS repository using the given session.
- */
- protected abstract IStatus executeCommand(Session session, CVSTeamProvider provider, ICVSResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException;
-
- protected LocalOption[] getLocalOptions() {
- return options;
- }
-
- protected void setLocalOptions(LocalOption[] options) {
- this.options = options;
- }
-
- protected void addLocalOption(LocalOption option) {
- LocalOption[] newOptions = new LocalOption[options.length + 1];
- System.arraycopy(options, 0, newOptions, 0, options.length);
- newOptions[options.length] = option;
- options = newOptions;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagInRepositoryOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagInRepositoryOperation.java
deleted file mode 100644
index 083f1db42..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagInRepositoryOperation.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.RTag;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.actions.TagAction;
-import org.eclipse.team.internal.ccvs.ui.tags.TagSource;
-import org.eclipse.ui.IWorkbenchPart;
-
-public class TagInRepositoryOperation extends RemoteOperation implements ITagOperation {
-
- private Set localOptions = new HashSet();
- private CVSTag tag;
-
- public TagInRepositoryOperation(IWorkbenchPart part, ICVSRemoteResource[] remoteResource) {
- super(part, remoteResource);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
- ICVSRemoteResource[] resources = getRemoteResources();
- monitor.beginTask(null, 1000 * resources.length);
- for (int i = 0; i < resources.length; i++) {
- IStatus status = resources[i].tag(getTag(), getLocalOptions(), new SubProgressMonitor(monitor, 1000));
- collectStatus(status);
- }
- if (!errorsOccurred()) {
- try {
- TagAction.broadcastTagChange(getCVSResources(), getTag());
- } catch (InvocationTargetException e) {
- throw CVSException.wrapException(e);
- }
- }
- }
-
- /**
- * Override to dislay the number of tag operations that succeeded
- */
- protected String getErrorMessage(IStatus[] problems, int operationCount) {
- if(operationCount == 1) {
- return Policy.bind("TagInRepositoryAction.tagProblemsMessage"); //$NON-NLS-1$
- } else {
- return Policy.bind("TagInRepositoryAction.tagProblemsMessageMultiple", //$NON-NLS-1$
- Integer.toString(operationCount - problems.length), Integer.toString(problems.length));
- }
- }
-
- private LocalOption[] getLocalOptions() {
- return (LocalOption[]) localOptions.toArray(new LocalOption[localOptions.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#getTag()
- */
- public CVSTag getTag() {
- return tag;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#setTag(org.eclipse.team.internal.ccvs.core.CVSTag)
- */
- public void setTag(CVSTag tag) {
- this.tag = tag;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#addLocalOption(org.eclipse.team.internal.ccvs.core.client.Command.LocalOption)
- */
- public void addLocalOption(LocalOption option) {
- localOptions.add(option);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#moveTag()
- */
- public void moveTag() {
- addLocalOption(RTag.FORCE_REASSIGNMENT);
- addLocalOption(RTag.CLEAR_FROM_REMOVED);
- if (tag != null && tag.getType() == CVSTag.BRANCH) {
- addLocalOption(RTag.FORCE_BRANCH_REASSIGNMENT);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#recurse()
- */
- public void recurse() {
- addLocalOption(Command.DO_NOT_RECURSE);
- }
-
- protected String getTaskName() {
- return Policy.bind("TagFromRepository.taskName"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#getTagSource()
- */
- public TagSource getTagSource() {
- return TagSource.create(getCVSResources());
- }
-
- protected boolean isReportableError(IStatus status) {
- return super.isReportableError(status)
- || status.getCode() == CVSStatus.TAG_ALREADY_EXISTS;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagOperation.java
deleted file mode 100644
index 7d413df58..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagOperation.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.swt.widgets.Shell;
-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.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.actions.TagAction;
-import org.eclipse.team.internal.ccvs.ui.tags.TagSource;
-import org.eclipse.ui.IWorkbenchPart;
-
-public class TagOperation extends RepositoryProviderOperation implements ITagOperation {
-
- private Set localOptions = new HashSet();
- private CVSTag tag;
-
- public TagOperation(IWorkbenchPart part, IResource[] resources) {
- super(part, resources);
- }
-
- /**
- * TODO: needed to prevent re-release of releng tool.
- * Shoudl eb able to remove eventually
- */
- public TagOperation(Shell shell, IResource[] resources) {
- super(null, resources);
- }
-
- public CVSTag getTag() {
- return tag;
- }
-
- public void setTag(CVSTag tag) {
- this.tag = tag;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException {
- IStatus status = tag(provider, resources, monitor);
- collectStatus(status);
- }
-
- /**
- * Override to dislay the number of tag operations that succeeded
- */
- protected String getErrorMessage(IStatus[] problems, int operationCount) {
- // We accumulated 1 status per resource above.
- if(operationCount == 1) {
- return Policy.bind("TagAction.tagProblemsMessage"); //$NON-NLS-1$
- } else {
- return Policy.bind("TagAction.tagProblemsMessageMultiple", //$NON-NLS-1$
- Integer.toString(operationCount - problems.length), Integer.toString(problems.length));
- }
- }
-
- /**
- * Tag the resources in the CVS repository with the given tag.
- *
- * The returned IStatus will be a status containing any errors or warnings.
- * If the returned IStatus is a multi-status, the code indicates the severity.
- * Possible codes are:
- * CVSStatus.OK - Nothing to report
- * CVSStatus.SERVER_ERROR - The server reported an error
- * any other code - warning messages received from the server
- */
- public IStatus tag(CVSTeamProvider provider, IResource[] resources, IProgressMonitor progress) throws CVSException {
-
- LocalOption[] commandOptions = (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]);
-
- // Build the arguments list
- String[] arguments = getStringArguments(resources);
-
- // Execute the command
- CVSWorkspaceRoot root = provider.getCVSWorkspaceRoot();
- Session s = new Session(root.getRemoteLocation(), root.getLocalRoot());
- progress.beginTask(null, 100);
- try {
- // Opening the session takes 20% of the time
- s.open(Policy.subMonitorFor(progress, 20), true /* open for modification */);
- return Command.TAG.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- commandOptions,
- tag,
- arguments,
- null,
- Policy.subMonitorFor(progress, 80));
- } finally {
- s.close();
- progress.done();
- }
- }
-
- public void addLocalOption(LocalOption option) {
- localOptions.add(option);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#moveTag()
- */
- public void moveTag() {
- addLocalOption(Tag.FORCE_REASSIGNMENT);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#recurse()
- */
- public void recurse() {
- addLocalOption(Command.DO_NOT_RECURSE);
- }
-
- protected String getTaskName() {
- return Policy.bind("TagFromWorkspace.taskName"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
- */
- protected String getTaskName(CVSTeamProvider provider) {
- return Policy.bind("TagOperation.0", provider.getProject().getName()); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
- super.execute(monitor);
- if (!errorsOccurred()) {
- try {
- TagAction.broadcastTagChange(getCVSResources(), getTag());
- } catch (InvocationTargetException e) {
- throw CVSException.wrapException(e);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#getTagSource()
- */
- public TagSource getTagSource() {
- return TagSource.create(getResources());
- }
-
- protected boolean isReportableError(IStatus status) {
- return super.isReportableError(status)
- || status.getCode() == CVSStatus.TAG_ALREADY_EXISTS;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOnlyMergableOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOnlyMergableOperation.java
deleted file mode 100644
index d0fbb2c9b..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOnlyMergableOperation.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-import java.util.*;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-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.*;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * This operation performs an update that will only effect files
- * that have no conflicts or automergable conflicts.
- */
-public class UpdateOnlyMergableOperation extends SingleCommandOperation {
-
- List skippedFiles = new ArrayList();
-
- public UpdateOnlyMergableOperation(IWorkbenchPart part, IResource[] resources, LocalOption[] localOptions) {
- super(part, resources, localOptions);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus executeCommand(Session session, CVSTeamProvider provider, ICVSResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException {
- UpdateMergableOnly update = new UpdateMergableOnly();
- IStatus status = update.execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- getLocalOptions(),
- resources,
- null,
- monitor);
- if (status.getSeverity() != IStatus.ERROR) {
- addSkippedFiles(update.getSkippedFiles());
- return OK;
- }
- return status;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("UpdateOnlyMergeable.taskName"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
- */
- protected String getTaskName(CVSTeamProvider provider) {
- return Policy.bind("UpdateOperation.0", provider.getProject().getName()); //$NON-NLS-1$
- }
-
- protected void addSkippedFiles(IFile[] files) {
- skippedFiles.addAll(Arrays.asList(files));
- }
-
- public IFile[] getSkippedFiles() {
- return (IFile[]) skippedFiles.toArray(new IFile[skippedFiles.size()]);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java
deleted file mode 100644
index 5e66fd6c8..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.operations;
-
-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.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.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Operation which performs a CVS update
- */
-public class UpdateOperation extends SingleCommandOperation {
-
- CVSTag tag;
-
- /**
- * Create an UpdateOperation that will perform on update on the given resources
- * using the given local option. If a tag is provided, it will be added to the
- * local options using the appropriate argument (-r or -D). If the tag is <code>null</code>
- * then the tag will be omitted from the local options and the tags on the local resources
- * will be used.
- * @param shell
- * @param resources
- * @param options
- * @param tag
- */
- public UpdateOperation(IWorkbenchPart part, IResource[] resources, LocalOption[] options, CVSTag tag) {
- super(part, resources, options);
- this.tag = tag;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus executeCommand(
- Session session,
- CVSTeamProvider provider,
- ICVSResource[] resources,
- IProgressMonitor monitor)
- throws CVSException, InterruptedException {
-
- // Build the local options
- List localOptions = new ArrayList();
-
- // Use the appropriate tag options
- if (tag != null) {
- localOptions.add(Update.makeTagOption(tag));
- }
-
- // Build the arguments list
- localOptions.addAll(Arrays.asList(getLocalOptions()));
- LocalOption[] commandOptions = (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]);
-
- monitor.beginTask(null, 100);
- IStatus execute = getUpdateCommand().execute(
- session,
- Command.NO_GLOBAL_OPTIONS,
- commandOptions,
- resources,
- getCommandOutputListener(),
- Policy.subMonitorFor(monitor, 95));
-
- updateWorkspaceSubscriber(provider, resources, Policy.subMonitorFor(monitor, 5));
- monitor.done();
- return execute;
- }
-
- protected Update getUpdateCommand() {
- return Command.UPDATE;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
- */
- protected String getTaskName() {
- return Policy.bind("UpdateOperation.taskName"); //$NON-NLS-1$;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
- */
- protected String getTaskName(CVSTeamProvider provider) {
- return Policy.bind("UpdateOperation.0", provider.getProject().getName()); //$NON-NLS-1$
- }
-
- /**
- * Return the listener that is used to process E and M messages.
- * The default is <code>null</code>.
- * @return
- */
- protected ICommandOutputListener getCommandOutputListener() {
- return null;
- }
-
- protected boolean isReportableError(IStatus status) {
- return super.isReportableError(status)
- || status.getCode() == CVSStatus.UNMEGERED_BINARY_CONFLICT
- || status.getCode() == CVSStatus.INVALID_LOCAL_RESOURCE_PATH
- || status.getCode() == CVSStatus.RESPONSE_HANDLING_FAILURE;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getErrorMessage(org.eclipse.core.runtime.IStatus[], int)
- */
- protected String getErrorMessage(IStatus[] failures, int totalOperations) {
- return Policy.bind("UpdateAction.update"); //$NON-NLS-1$
- }
-}

Back to the top