diff options
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations')
26 files changed, 884 insertions, 884 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 index 1893d642e..7919b5806 100644 --- 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 @@ -46,18 +46,18 @@ public class AddOperation extends RepositoryProviderOperation { fModesForFiles= Collections.EMPTY_MAP; } - public void addModesForExtensions(Map modes) { + public void addModesForExtensions(Map modes) { fModesForExtensions= modes; - } - - public void addModesForNames(Map modes) { - fModesForFiles= modes; + } + + public void addModesForNames(Map modes) { + fModesForFiles= modes; } @Override protected void execute(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { - if (resources.length == 0) - return; + if (resources.length == 0) + return; add(provider, resources, recurse ? IResource.DEPTH_INFINITE : IResource.DEPTH_ONE, monitor); } @@ -129,7 +129,7 @@ public class AddOperation extends RepositoryProviderOperation { // added explicitly (is equal currentResource) or is not ignored if (! isManaged(mResource) && (currentResource.equals(resource) || ! mResource.isIgnored())) { if (resource.getType() == IResource.FILE) { - KSubstOption ksubst= getKSubstOption((IFile)resource); + KSubstOption ksubst= getKSubstOption((IFile)resource); Set set = files.get(ksubst); if (set == null) { set = new HashSet(); @@ -148,7 +148,7 @@ public class AddOperation extends RepositoryProviderOperation { } } - }, depth, false); + }, depth, false); if (exception[0] != null) { throw exception[0]; } @@ -208,13 +208,13 @@ public class AddOperation extends RepositoryProviderOperation { } /* - * Return true if the resource is a project that is already a CVS folder - */ - protected boolean isManagedProject(IResource resource, ICVSResource resource2) throws CVSException { - return resource.getType() == IResource.PROJECT && ((ICVSFolder)resource2).isCVSFolder(); - } + * Return true if the resource is a project that is already a CVS folder + */ + protected boolean isManagedProject(IResource resource, ICVSResource resource2) throws CVSException { + return resource.getType() == IResource.PROJECT && ((ICVSFolder)resource2).isCVSFolder(); + } - /* + /* * Consider a folder managed only if it's also a CVS folder */ protected boolean isManaged(ICVSResource cvsResource) throws CVSException { @@ -226,19 +226,19 @@ public class AddOperation extends RepositoryProviderOperation { return CVSUIMessages.AddAction_addFailed; } - protected KSubstOption getKSubstOption(IFile file) { - final String extension= file.getFileExtension(); - final Integer mode; - if (extension == null) { - mode= (Integer)fModesForFiles.get(file.getName()); - } else { - mode= (Integer)fModesForExtensions.get(extension); - } - if (mode != null) { - return mode.intValue() == Team.BINARY ? Command.KSUBST_BINARY : KSubstOption.getDefaultTextMode(); - } else { - return KSubstOption.fromFile(file); - } - } + protected KSubstOption getKSubstOption(IFile file) { + final String extension= file.getFileExtension(); + final Integer mode; + if (extension == null) { + mode= (Integer)fModesForFiles.get(file.getName()); + } else { + mode= (Integer)fModesForExtensions.get(extension); + } + if (mode != null) { + return mode.intValue() == Team.BINARY ? Command.KSUBST_BINARY : KSubstOption.getDefaultTextMode(); + } else { + return KSubstOption.fromFile(file); + } + } } 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 index 071f36568..4e350b773 100644 --- 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 @@ -71,8 +71,8 @@ public class BranchOperation extends RepositoryProviderOperation { } catch (InterruptedException e1) { throw new OperationCanceledException(); } - - IResource[] resources = getTraversalRoots(); + + IResource[] resources = getTraversalRoots(); boolean allSticky = areAllResourcesSticky(resources); String initialVersionName = calculateInitialVersionName(resources,allSticky); final BranchPromptDialog dialog = new BranchPromptDialog(getShell(), @@ -134,7 +134,7 @@ public class BranchOperation extends RepositoryProviderOperation { try { // Build the arguments list ICVSResource[] arguments = getCVSArguments(resources); - LocalOption[] localOptions = getLocalOptions(recurse); + LocalOption[] localOptions = getLocalOptions(recurse); // Tag the remote resources IStatus status = null; @@ -176,7 +176,7 @@ public class BranchOperation extends RepositoryProviderOperation { 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( + status = Command.CUSTOM_TAG.execute( session, Command.NO_GLOBAL_OPTIONS, localOptions, 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 index 705564909..5030bfad1 100644 --- 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 @@ -176,7 +176,7 @@ public abstract class CVSOperation extends TeamOperation implements IShellProvid */ protected final void handleErrors(IStatus[] errors) throws CVSException { // We are only concerned with reportable errors. - // Others will appear in the console + // Others will appear in the console List<IStatus> reportableErrors = new ArrayList<>(); for (int i = 0; i < errors.length; i++) { IStatus status = errors[i]; @@ -194,7 +194,7 @@ public abstract class CVSOperation extends TeamOperation implements IShellProvid } } if (!reportableErrors.isEmpty()) - asException(reportableErrors.toArray(new IStatus[reportableErrors.size()])); + asException(reportableErrors.toArray(new IStatus[reportableErrors.size()])); } /** @@ -203,11 +203,11 @@ public abstract class CVSOperation extends TeamOperation implements IShellProvid * @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 || CVSStatus.isInternalError(status) || status.getCode() == TeamException.UNABLE; - } + protected boolean isReportableError(IStatus status) { + return status.getCode() == CVSStatus.SERVER_ERROR || CVSStatus.isInternalError(status) || status.getCode() == TeamException.UNABLE; + } - protected String getErrorMessage(IStatus[] failures, int totalOperations) { + protected String getErrorMessage(IStatus[] failures, int totalOperations) { return NLS.bind(CVSUIMessages.CVSOperation_0, new String[] { String.valueOf(failures.length), String.valueOf(totalOperations) }); } @@ -298,29 +298,29 @@ public abstract class CVSOperation extends TeamOperation implements IShellProvid return true; } - @Override + @Override 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(CVSUIMessages.CVSOperation_1) { - @Override + // 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(CVSUIMessages.CVSOperation_1) { + @Override public void run() { - CVSOutputConsole console = CVSUIPlugin.getPlugin().getConsole(); - if (console != null) - console.show(true); - } - @Override + CVSOutputConsole console = CVSUIPlugin.getPlugin().getConsole(); + if (console != null) + console.show(true); + } + @Override public String getToolTipText() { - return CVSUIMessages.CVSOperation_2; - } - }; - } + return CVSUIMessages.CVSOperation_2; + } + }; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java index cd0d15bac..1fc91f696 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java @@ -99,7 +99,7 @@ public class CacheBaseContentsOperation extends CacheTreeContentsOperation { private void performCleanTimestamps(IProject project, final IResource[] resources, IProgressMonitor monitor) throws CVSException { ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); - final ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false); + final ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false); folder.run(monitor1 -> { monitor1.beginTask(null, resources.length * 100); for (int i = 0; i < resources.length; i++) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheTreeContentsOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheTreeContentsOperation.java index 9177bbe08..b0955b832 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheTreeContentsOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheTreeContentsOperation.java @@ -129,28 +129,28 @@ public abstract class CacheTreeContentsOperation extends SingleCommandOperation @Override protected ICVSResource[] getCVSArguments(Session session, IResource[] resources) { List<ICVSResource> result = new ArrayList<>(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - try { + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + try { ICVSResource file = session.getLocalRoot().getChild(resource.getProjectRelativePath().toString()); result.add(file); } catch (CVSException e) { // Log and continue CVSUIPlugin.log(e); } - } + } - return result.toArray(new ICVSResource[result.size()]); + return result.toArray(new ICVSResource[result.size()]); } @Override protected IStatus executeCommand(Session session, CVSTeamProvider provider, ICVSResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { return Command.UPDATE.execute( - session, - Command.NO_GLOBAL_OPTIONS, - getLocalOptions(true), - resources, - new UpdateListener(new IUpdateMessageListener() { + session, + Command.NO_GLOBAL_OPTIONS, + getLocalOptions(true), + resources, + new UpdateListener(new IUpdateMessageListener() { @Override public void fileInformation(int type, ICVSFolder parent, String filename) { // Do nothing @@ -169,7 +169,7 @@ public abstract class CacheTreeContentsOperation extends SingleCommandOperation // Do nothing } }), - monitor); + monitor); } @Override 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 index 2337cd727..0eb05d5a5 100644 --- 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 @@ -250,10 +250,10 @@ public class CheckoutIntoOperation extends CheckoutOperation { FolderSyncInfo info = folder.getFolderSyncInfo(); if (info.isSameMapping(remoteInfo)) { throw new CVSException(NLS.bind(CVSUIMessages.CheckoutIntoOperation_mappingAlreadyExists, (new Object[] { - remoteFolder.getName(), - targetFolder.getIResource().getFullPath().toString(), - resource.getFullPath().toString() - }))); + remoteFolder.getName(), + targetFolder.getIResource().getFullPath().toString(), + resource.getFullPath().toString() + }))); } folder.acceptChildren(this); } @@ -418,9 +418,9 @@ public class CheckoutIntoOperation extends CheckoutOperation { //use the modfiy rule for the time being //TODO: Just lock the project not the entire workspace (so can't use modifyRule) //since the project already exists - IProject tempProject = getLocalFolder().getIResource().getProject(); - IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory(); - return ruleFactory.modifyRule(tempProject); + IProject tempProject = getLocalFolder().getIResource().getProject(); + IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory(); + return ruleFactory.modifyRule(tempProject); } } 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 index 03ce62031..863931ea3 100644 --- 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 @@ -69,13 +69,13 @@ public abstract class CheckoutOperation extends RemoteOperation { } @Override - public boolean isKeepOneProgressServiceEntry() { - // Keep the last repository provider operation in the progress service - return true; - } - + public boolean isKeepOneProgressServiceEntry() { + // Keep the last repository provider operation in the progress service + return true; + } + @Override - protected IAction getGotoAction() { - return getShowConsoleAction(); - } + protected IAction getGotoAction() { + return getShowConsoleAction(); + } } 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 index 512d8a3b9..c0b093015 100644 --- 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 @@ -58,7 +58,7 @@ public class CheckoutToRemoteFolderOperation extends CheckoutOperation { throws CVSException { if (mFile instanceof RemoteFile) { - try { + try { ((RemoteFile)mFile).aboutToReceiveContents(entryLine.getBytes()); super.receiveTargetFile( session, @@ -69,9 +69,9 @@ public class CheckoutToRemoteFolderOperation extends CheckoutOperation { readOnly, executable, monitor); - } finally { - ((RemoteFile)mFile).doneReceivingContents(); - } + } finally { + ((RemoteFile)mFile).doneReceivingContents(); + } } else { super.receiveTargetFile( session, diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ClipboardDiffOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ClipboardDiffOperation.java index f7125bee5..a51131f09 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ClipboardDiffOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ClipboardDiffOperation.java @@ -29,7 +29,7 @@ public class ClipboardDiffOperation extends DiffOperation { private static final Object DESTINATION_CLIPBOARD = CVSUIMessages.ClipboardDiffOperation_Clipboard; - final ByteArrayOutputStream os = new ByteArrayOutputStream(); + final ByteArrayOutputStream os = new ByteArrayOutputStream(); public ClipboardDiffOperation(IWorkbenchPart part, ResourceMapping[] mappings, LocalOption[] options, boolean isMultiPatch, boolean includeFullPathInformation, IPath patchRoot) { super(part, mappings, options, isMultiPatch, includeFullPathInformation, patchRoot, DESTINATION_CLIPBOARD); @@ -37,24 +37,24 @@ public class ClipboardDiffOperation extends DiffOperation { @Override public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - super.execute(monitor); - - if (os.size() == 0 || - (!patchHasContents && !patchHasNewFiles)) { - reportEmptyDiff(); - } else { - copyToClipboard(os); - } - } + super.execute(monitor); + + if (os.size() == 0 || + (!patchHasContents && !patchHasNewFiles)) { + reportEmptyDiff(); + } else { + copyToClipboard(os); + } + } - private void copyToClipboard(final ByteArrayOutputStream baos) { + private void copyToClipboard(final ByteArrayOutputStream baos) { getShell().getDisplay().syncExec(() -> { TextTransfer plainTextTransfer = TextTransfer.getInstance(); Clipboard clipboard = new Clipboard(getShell().getDisplay()); clipboard.setContents(new String[] { baos.toString() }, new Transfer[] { plainTextTransfer }); clipboard.dispose(); }); - } + } @Override protected PrintStream openStream() { 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 index 273f7e7a4..9f3bb9757 100644 --- 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 @@ -67,7 +67,7 @@ public class CommitOperation extends SingleCommandOperation { } @Override - protected ResourceMappingContext getResourceMappingContext() { - return SubscriberResourceMappingContext.createContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); - } + protected ResourceMappingContext getResourceMappingContext() { + return SubscriberResourceMappingContext.createContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); + } } 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 index 71041bbd0..930bc60b8 100644 --- 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 @@ -45,7 +45,7 @@ public class DisconnectOperation extends RepositoryProviderOperation { throws CVSException, InterruptedException { // This method will be invoked for each provider being disconnected - monitor.beginTask(null, IProgressMonitor.UNKNOWN); + monitor.beginTask(null, IProgressMonitor.UNKNOWN); IProject project = provider.getProject(); try { RepositoryProvider.unmap(project); @@ -57,7 +57,7 @@ public class DisconnectOperation extends RepositoryProviderOperation { cvsFolder.unmanage(monitor); EclipseSynchronizer.getInstance().deconfigure(project, Policy.subMonitorFor(monitor, IProgressMonitor.UNKNOWN)); } - monitor.done(); + monitor.done(); } @Override diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchAllMembersOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchAllMembersOperation.java index a8fea5535..df4b39a09 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchAllMembersOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchAllMembersOperation.java @@ -33,37 +33,37 @@ import org.eclipse.team.internal.ui.Utils; import org.eclipse.ui.IWorkbenchPart; public class FetchAllMembersOperation extends RemoteOperation { - + class RLogTreeBuilder { - - private ICVSRepositoryLocation location; + + private ICVSRepositoryLocation location; private RemoteFolderTree tree; private CVSTag tag; - public RLogTreeBuilder(ICVSRepositoryLocation location, CVSTag tag) { - this.tag = tag; - this.location = location; - reset(); - } + public RLogTreeBuilder(ICVSRepositoryLocation location, CVSTag tag) { + this.tag = tag; + this.location = location; + reset(); + } + + public RemoteFolderTree getTree() { + return tree; + } + + /** + * Reset the builder to prepare for a new build + */ + public void reset() { + tree = new RemoteFolderTree(null, location, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, tag); + tree.setChildren(new ICVSRemoteResource[0]); + } - public RemoteFolderTree getTree() { - return tree; - } - - /** - * Reset the builder to prepare for a new build - */ - public void reset() { - tree = new RemoteFolderTree(null, location, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, tag); - tree.setChildren(new ICVSRemoteResource[0]); - } - /* * @see * org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener. * IFileDiffListener#newFile(java.lang.String, java.lang.String) */ - public void newFile(IPath remoteFilePath, ICVSRemoteFile remoteFile) { + public void newFile(IPath remoteFilePath, ICVSRemoteFile remoteFile) { try { addFile(tree,tag,remoteFile, remoteFilePath); } catch (CVSException e) { @@ -89,7 +89,7 @@ public class FetchAllMembersOperation extends RemoteOperation { tree.setChildren(newChildren); } - /* + /* * Get the folder at the given path in the given tree, creating any missing folders as needed. */ private ICVSRemoteFolder getFolder(RemoteFolderTree tree, CVSTag tag, IPath remoteFolderPath, IPath parentPath) throws CVSException { @@ -130,7 +130,7 @@ public class FetchAllMembersOperation extends RemoteOperation { try { operation.run(monitor); ICVSRemoteResource[] remoteRes = getRemoteResources(); - final ICVSRemoteFolder project = (ICVSRemoteFolder) remoteRes[0]; + final ICVSRemoteFolder project = (ICVSRemoteFolder) remoteRes[0]; //Get the entry paths String[] entry = cache.getCachedFilePaths(); //Strip repo + project info from entries diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FileDiffOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FileDiffOperation.java index 99a818dac..840ec84d5 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FileDiffOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FileDiffOperation.java @@ -42,8 +42,8 @@ public class FileDiffOperation extends DiffOperation { @Override public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - super.execute(monitor); - + super.execute(monitor); + if (tempFile.length() == 0) { tempFile.delete(); reportEmptyDiff(); @@ -57,7 +57,7 @@ public class FileDiffOperation extends DiffOperation { return; } - copyFile(); + copyFile(); } protected void copyFile() throws CVSException { 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 index 1e3d76ae7..353b927d4 100644 --- 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 @@ -23,11 +23,11 @@ public interface ITagOperation { public abstract void setTag(CVSTag tag); public abstract void run() throws InvocationTargetException, InterruptedException; /** - * Return whether the tag operation contains any resource that would be operated on. - * @return whether the tag operation contains any resource that would be operated on + * Return whether the tag operation contains any resource that would be operated on. + * @return whether the tag operation contains any resource that would be operated on */ public abstract boolean isEmpty(); public abstract void moveTag(); public abstract void doNotRecurse(); - public abstract TagSource getTagSource(); + public abstract TagSource getTagSource(); } 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 index d8b5a6d6b..97d82aeeb 100644 --- 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 @@ -36,91 +36,91 @@ 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 - */ + 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 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 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; + } - 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 { + /** + * 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); + 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) { + } + + /** + * 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(() -> 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) { + /** + * 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()); + addFile(rightTree, right, filePath, remote.getRevision()); getFolder(leftTree, left, filePath.removeLastSegments(1), Path.EMPTY); } catch (TeamException e) { CVSUIPlugin.log(e); } - } - if (predecessor != null) { + } + if (predecessor != null) { try { Path filePath = new Path(null, predecessor.getRepositoryRelativePath()); - addFile(leftTree, left, filePath, predecessor.getRevision()); + 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(); @@ -128,14 +128,14 @@ public class RemoteCompareOperation extends RemoteOperation { addChild(parent, file); } - private CVSTag getTag(String revision, CVSTag tag) { - if (tag == null) { - tag = new CVSTag(revision, CVSTag.VERSION); - } - return tag; - } + 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 { @@ -165,7 +165,7 @@ public class RemoteCompareOperation extends RemoteOperation { } tree.setChildren(newChildren); } - + @Override public void fileDiff(String remoteFilePath, String leftRevision, String rightRevision) { try { @@ -320,7 +320,7 @@ public class RemoteCompareOperation extends RemoteOperation { ICVSRemoteResource resource = getRemoteResource(); IStatus status = buildTrees(resource, Policy.subMonitorFor(monitor, 50)); if (status.isOK() && fetchContents) { - builder.cacheContents(Policy.subMonitorFor(monitor, 100)); + builder.cacheContents(Policy.subMonitorFor(monitor, 100)); } collectStatus(status); openCompareEditor(builder); @@ -330,18 +330,18 @@ public class RemoteCompareOperation extends RemoteOperation { } /** - * This method is here to allow subclasses to override - */ - protected void openCompareEditor(CompareTreeBuilder builder) { - builder.openCompareEditor(getTargetPage(), null, null); - } + * 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(); + builder.reset(); Command.QuietOption oldOption= CVSProviderPlugin.getPlugin().getQuietness(); Session session = new Session(resource.getRepository(), builder.getLeftTree(), false); try { @@ -365,7 +365,7 @@ public class RemoteCompareOperation extends RemoteOperation { } } - private LocalOption[] getLocalOptions() { + private LocalOption[] getLocalOptions() { return new LocalOption[] {RDiff.SUMMARY, RDiff.makeTagOption(left), RDiff.makeTagOption(right)}; } 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 index b9f01201a..8eeb0d664 100644 --- 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 @@ -46,41 +46,41 @@ public class RemoteLogOperation extends RepositoryLocationOperation { * remote log operation. */ public static class LogEntryCache implements ILogEntryListener { - - /* - * Cache of all log entries - */ + + /* + * Cache of all log entries + */ private Map<String, Map<String, ILogEntry>> entries = new HashMap<>(); /* * Map String:remoteFilePath->Map * (String:revision -> ILogEntry) */ private Map<String, ILogEntry> internalGetLogEntries(String path) { - return 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) { + return 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<String, ILogEntry> map = internalGetLogEntries(path); - return 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 entries.keySet().toArray(new String[entries.size()]); - } - + return 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 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 @@ -89,20 +89,20 @@ public class RemoteLogOperation extends RepositoryLocationOperation { * @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; + 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 @@ -110,125 +110,125 @@ public class RemoteLogOperation extends RepositoryLocationOperation { */ public synchronized ILogEntry[] getLogEntries(ICVSRemoteResource resource) { Map<String, ILogEntry> fileEntries = internalGetLogEntries(getFullPath(resource)); - if (fileEntries != null) { - return fileEntries.values().toArray(new ILogEntry[fileEntries.size()]); - } - return new ILogEntry[0]; + if (fileEntries != null) { + return 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(false), resource.getRepositoryRelativePath()); - } + * 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(false), resource.getRepositoryRelativePath()); + } public synchronized void clearEntries() { entries.clear(); } - - public synchronized ICVSRemoteFile getImmediatePredecessor(ICVSRemoteFile file) throws TeamException { - ILogEntry[] allLogs = getLogEntries(file); - String revision = file.getRevision(); - // First decrement the last digit and see if that revision exists - String predecessorRevision = getPredecessorRevision(revision); - ICVSRemoteFile predecessor = findRevison(allLogs, predecessorRevision); - // If nothing was found, try to fond the base of a branch - if (predecessor == null && isBrancheRevision(revision)) { - predecessorRevision = getBaseRevision(revision); - predecessor = findRevison(allLogs, predecessorRevision); - } - // If that fails, it is still possible that there is a revision. - // This can happen if the revision has been manually set. - if (predecessor == null) { - // We don't search in this case since this is costly and would be done - // for any file that is new as well. - } - return predecessor; - } - - /* - * Find the given revision in the list of log entries. - * Return null if the revision wasn't found. - */ - 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); - } + + 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); + } - @Override + @Override public void handleLogEntryReceived(ILogEntry entry) { - ICVSRemoteFile file = entry.getRemoteFile(); - String fullPath = getFullPath(file); - String revision = entry.getRevision(); + ICVSRemoteFile file = entry.getRemoteFile(); + String fullPath = getFullPath(file); + String revision = entry.getRevision(); Map<String, ILogEntry> fileEntries = internalGetLogEntries(fullPath); - if (fileEntries == null) { + if (fileEntries == null) { fileEntries = new HashMap<>(); - entries.put(fullPath, fileEntries); - } - fileEntries.put(revision, entry); - } + entries.put(fullPath, fileEntries); + } + fileEntries.put(revision, entry); + } } public RemoteLogOperation(IWorkbenchPart part, ICVSRemoteResource[] remoteResources, CVSTag tag1, CVSTag tag2, LogEntryCache cache) { 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 index 8fb53734a..0962590cb 100644 --- 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 @@ -44,8 +44,8 @@ public class ReplaceOperation extends UpdateOperation { } public ReplaceOperation(IWorkbenchPart part, ResourceMapping[] mappings, CVSTag tag) { - super(part, mappings, new LocalOption[] { Update.IGNORE_LOCAL_CHANGES }, tag); - } + super(part, mappings, new LocalOption[] { Update.IGNORE_LOCAL_CHANGES }, tag); + } @Override protected String getTaskName() { @@ -60,8 +60,8 @@ public class ReplaceOperation extends UpdateOperation { final boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { - final IStatus[] status = new IStatus[] { Status.OK_STATUS }; - try { + final IStatus[] status = new IStatus[] { Status.OK_STATUS }; + try { ResourcesPlugin.getWorkspace().run((IWorkspaceRunnable) monitor1 -> { try { status[0] = internalExecuteCommand(session, provider, resources, recurse, monitor1); @@ -69,9 +69,9 @@ public class ReplaceOperation extends UpdateOperation { throw new OperationCanceledException(); } }, null, IWorkspace.AVOID_UPDATE, monitor); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } + } catch (CoreException e) { + throw CVSException.wrapException(e); + } return status[0]; } @@ -85,41 +85,41 @@ public class ReplaceOperation extends UpdateOperation { private boolean ignoreResourcesIfTagDoesNotExist; - private IStatus internalExecuteCommand(Session session, CVSTeamProvider provider, ICVSResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { - monitor.beginTask(null, 100); - ICVSResource[] managedResources = getResourcesToUpdate(resources, Policy.subMonitorFor(monitor, 5)); + private IStatus internalExecuteCommand(Session session, CVSTeamProvider provider, ICVSResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { + monitor.beginTask(null, 100); + ICVSResource[] managedResources = getResourcesToUpdate(resources, Policy.subMonitorFor(monitor, 5)); if (ignoreResourcesIfTagDoesNotExist && managedResources.length == 0) return OK; - try { - // Purge any unmanaged or added files - PrepareForReplaceVisitor pfrv = new PrepareForReplaceVisitor(session, getTag()); - pfrv.visitResources( - provider.getProject(), - resources, - CVSUIMessages.ReplaceOperation_1, - recurse ? IResource.DEPTH_INFINITE : IResource.DEPTH_ONE, - Policy.subMonitorFor(monitor, 25)); - prepDeletedFiles = pfrv.getDeletedFiles(); - - // 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, recurse, 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(); - } - } + try { + // Purge any unmanaged or added files + PrepareForReplaceVisitor pfrv = new PrepareForReplaceVisitor(session, getTag()); + pfrv.visitResources( + provider.getProject(), + resources, + CVSUIMessages.ReplaceOperation_1, + recurse ? IResource.DEPTH_INFINITE : IResource.DEPTH_ONE, + Policy.subMonitorFor(monitor, 25)); + prepDeletedFiles = pfrv.getDeletedFiles(); + + // 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, recurse, 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. 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 index 12246e034..594210167 100644 --- 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 @@ -53,255 +53,255 @@ public abstract class RepositoryProviderOperation extends CVSOperation { private ISynchronizationScopeManager manager; private final ResourceMapping[] selectedMappings; - /** - * Interface that is available to subclasses which identifies - * the depth for various resources. The files will be included - * in whichever group (deep or shallow) has resources. - */ - public interface ICVSTraversal { - IResource[] getShallowResources(); - IResource[] getDeepResources(); - IResource[] getNontraversedFolders(); - } - + /** + * Interface that is available to subclasses which identifies + * the depth for various resources. The files will be included + * in whichever group (deep or shallow) has resources. + */ + public interface ICVSTraversal { + IResource[] getShallowResources(); + IResource[] getDeepResources(); + IResource[] getNontraversedFolders(); + } + /* * A map entry for a provider that divides the traversals to be performed by depth. * There are really only */ private static class TraversalMapEntry implements ICVSTraversal { - // The provider for this entry - RepositoryProvider provider; - // Files are always shallow + // The provider for this entry + RepositoryProvider provider; + // Files are always shallow List<IResource> files = new ArrayList<>(); - // Not sure what to do with zero depth folders but we'll record them + // Not sure what to do with zero depth folders but we'll record them List<IResource> zeroFolders = new ArrayList<>(); - // Non-recursive folder (-l) + // Non-recursive folder (-l) List<IResource> shallowFolders = new ArrayList<>(); - // Recursive folders (-R) + // Recursive folders (-R) List<IResource> deepFolders = new ArrayList<>(); - public TraversalMapEntry(RepositoryProvider provider) { - this.provider = provider; - } - /** - * Add the resources from the traversals to the entry - * @param traversals the traversals - */ - public void add(ResourceTraversal[] traversals) { - for (int i = 0; i < traversals.length; i++) { - ResourceTraversal traversal = traversals[i]; - add(traversal); - } - } - /** - * Add the resources from the traversal to the entry - * @param traversal the traversal - */ - public void add(ResourceTraversal traversal) { - IResource[] resources = traversal.getResources(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - if (resource.getProject().equals(provider.getProject())) { - if (resource.getType() == IResource.FILE) { - files.add(resource); - } else { - switch (traversal.getDepth()) { - case IResource.DEPTH_ZERO: - zeroFolders.add(resource); - break; - case IResource.DEPTH_ONE: - shallowFolders.add(resource); - break; - case IResource.DEPTH_INFINITE: - deepFolders.add(resource); - break; - default: - deepFolders.add(resource); - } - } - } - } - } - /** - * Return the resources that can be included in a shallow operation. - * Include files with the shallow resources if there are shallow folders - * or if there are no shallow or deep folders. - * @return the resources that can be included in a shallow operation - */ - @Override + public TraversalMapEntry(RepositoryProvider provider) { + this.provider = provider; + } + /** + * Add the resources from the traversals to the entry + * @param traversals the traversals + */ + public void add(ResourceTraversal[] traversals) { + for (int i = 0; i < traversals.length; i++) { + ResourceTraversal traversal = traversals[i]; + add(traversal); + } + } + /** + * Add the resources from the traversal to the entry + * @param traversal the traversal + */ + public void add(ResourceTraversal traversal) { + IResource[] resources = traversal.getResources(); + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + if (resource.getProject().equals(provider.getProject())) { + if (resource.getType() == IResource.FILE) { + files.add(resource); + } else { + switch (traversal.getDepth()) { + case IResource.DEPTH_ZERO: + zeroFolders.add(resource); + break; + case IResource.DEPTH_ONE: + shallowFolders.add(resource); + break; + case IResource.DEPTH_INFINITE: + deepFolders.add(resource); + break; + default: + deepFolders.add(resource); + } + } + } + } + } + /** + * Return the resources that can be included in a shallow operation. + * Include files with the shallow resources if there are shallow folders + * or if there are no shallow or deep folders. + * @return the resources that can be included in a shallow operation + */ + @Override public IResource[] getShallowResources() { - if (shallowFolders.isEmpty() && deepFolders.isEmpty() && !files.isEmpty()) { - return files.toArray(new IResource[files.size()]); - } - if (!shallowFolders.isEmpty()) { - if (files.isEmpty()) { - return shallowFolders.toArray(new IResource[shallowFolders.size()]); - } + if (shallowFolders.isEmpty() && deepFolders.isEmpty() && !files.isEmpty()) { + return files.toArray(new IResource[files.size()]); + } + if (!shallowFolders.isEmpty()) { + if (files.isEmpty()) { + return shallowFolders.toArray(new IResource[shallowFolders.size()]); + } List<IResource> result = new ArrayList<>(); - result.addAll(shallowFolders); - result.addAll(files); - return result.toArray(new IResource[result.size()]); - } - return new IResource[0]; - } - /** - * Return the resources to be included in a deep operation. - * If there are no shallow folders, this will include any files. - * @return - */ - @Override + result.addAll(shallowFolders); + result.addAll(files); + return result.toArray(new IResource[result.size()]); + } + return new IResource[0]; + } + /** + * Return the resources to be included in a deep operation. + * If there are no shallow folders, this will include any files. + * @return + */ + @Override public IResource[] getDeepResources() { - if (deepFolders.isEmpty()) - return new IResource[0]; - if (!shallowFolders.isEmpty()) - return deepFolders.toArray(new IResource[deepFolders.size()]); + if (deepFolders.isEmpty()) + return new IResource[0]; + if (!shallowFolders.isEmpty()) + return deepFolders.toArray(new IResource[deepFolders.size()]); List<IResource> result = new ArrayList<>(); - result.addAll(deepFolders); - result.addAll(files); - return result.toArray(new IResource[result.size()]); - } - /** - * Return the folders that are depth zero - */ - @Override + result.addAll(deepFolders); + result.addAll(files); + return result.toArray(new IResource[result.size()]); + } + /** + * Return the folders that are depth zero + */ + @Override public IResource[] getNontraversedFolders() { - return zeroFolders.toArray(new IResource[zeroFolders.size()]); - } + return zeroFolders.toArray(new IResource[zeroFolders.size()]); + } } - - /** - * Convert the provided resources to one or more resource mappers - * that traverse the elements deeply. The model element of the resource - * mappers will be an IStructuredSelection. - * @param resources the resources - * @return a resource mappers that traverses the resources - */ - public static ResourceMapping[] asResourceMappers(final IResource[] resources) { - return asResourceMappers(resources, IResource.DEPTH_INFINITE); - } - - /** - * Convert the provided resources to one or more resource mappers - * that traverse the elements deeply. The model element of the resource - * mappers will be an IStructuredSelection. - * @param resources the resources - * @return a resource mappers that traverses the resources - */ - public static ResourceMapping[] asResourceMappers(final IResource[] resources, int depth) { - return WorkspaceResourceMapper.asResourceMappers(resources, depth); - } - + + /** + * Convert the provided resources to one or more resource mappers + * that traverse the elements deeply. The model element of the resource + * mappers will be an IStructuredSelection. + * @param resources the resources + * @return a resource mappers that traverses the resources + */ + public static ResourceMapping[] asResourceMappers(final IResource[] resources) { + return asResourceMappers(resources, IResource.DEPTH_INFINITE); + } + + /** + * Convert the provided resources to one or more resource mappers + * that traverse the elements deeply. The model element of the resource + * mappers will be an IStructuredSelection. + * @param resources the resources + * @return a resource mappers that traverses the resources + */ + public static ResourceMapping[] asResourceMappers(final IResource[] resources, int depth) { + return WorkspaceResourceMapper.asResourceMappers(resources, depth); + } + public RepositoryProviderOperation(IWorkbenchPart part, final IResource[] resources) { this(part, asResourceMappers(resources)); } - public RepositoryProviderOperation(IWorkbenchPart part, ResourceMapping[] selectedMappings) { - super(part); + public RepositoryProviderOperation(IWorkbenchPart part, ResourceMapping[] selectedMappings) { + super(part); this.selectedMappings = selectedMappings; - } + } @Override public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { try { - monitor.beginTask(null, 100); - buildScope(monitor); - Map table = getProviderTraversalMapping(Policy.subMonitorFor(monitor, 30)); - execute(table, Policy.subMonitorFor(monitor, 30)); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } finally { - monitor.done(); - } + monitor.beginTask(null, 100); + buildScope(monitor); + Map table = getProviderTraversalMapping(Policy.subMonitorFor(monitor, 30)); + execute(table, Policy.subMonitorFor(monitor, 30)); + } catch (CoreException e) { + throw CVSException.wrapException(e); + } finally { + monitor.done(); + } } @Override protected void endOperation() throws CVSException { - if (manager != null) { - manager.dispose(); - manager = null; - } + if (manager != null) { + manager.dispose(); + manager = null; + } super.endOperation(); } - public ISynchronizationScope buildScope(IProgressMonitor monitor) throws InterruptedException, CVSException { - if (manager == null) { - manager = createScopeManager(consultModelsWhenBuildingScope && consultModelsForMappings()); - BuildScopeOperation op = new BuildScopeOperation(getPart(), manager); + public ISynchronizationScope buildScope(IProgressMonitor monitor) throws InterruptedException, CVSException { + if (manager == null) { + manager = createScopeManager(consultModelsWhenBuildingScope && consultModelsForMappings()); + BuildScopeOperation op = new BuildScopeOperation(getPart(), manager); try { op.run(monitor); } catch (InvocationTargetException e) { throw CVSException.wrapException(e); } - } - return manager.getScope(); + } + return manager.getScope(); } - /** - * Create the scope manager to be used by this operation. - * @param consultModels whether models should be consulted to include additional mappings - * @return a scope manager - */ + /** + * Create the scope manager to be used by this operation. + * @param consultModels whether models should be consulted to include additional mappings + * @return a scope manager + */ protected SynchronizationScopeManager createScopeManager(boolean consultModels) { return new SynchronizationScopeManager(getJobName(), getSelectedMappings(), getResourceMappingContext(), consultModels); } private void execute(Map providerTraversal, IProgressMonitor monitor) throws CVSException, InterruptedException { - Set keySet = providerTraversal.keySet(); - monitor.beginTask(null, keySet.size() * 1000); - Iterator iterator = keySet.iterator(); - while (iterator.hasNext()) { - CVSTeamProvider provider = (CVSTeamProvider)iterator.next(); - monitor.setTaskName(getTaskName(provider)); - TraversalMapEntry entry = (TraversalMapEntry)providerTraversal.get(provider); - execute(provider, entry, Policy.subMonitorFor(monitor, 1000)); - } - } + Set keySet = providerTraversal.keySet(); + monitor.beginTask(null, keySet.size() * 1000); + Iterator iterator = keySet.iterator(); + while (iterator.hasNext()) { + CVSTeamProvider provider = (CVSTeamProvider)iterator.next(); + monitor.setTaskName(getTaskName(provider)); + TraversalMapEntry entry = (TraversalMapEntry)providerTraversal.get(provider); + execute(provider, entry, Policy.subMonitorFor(monitor, 1000)); + } + } - /** - * Execute the operation on the given set of traversals - * @param provider - * @param entry - * @param subMonitor - * @throws CVSException - * @throws InterruptedException - */ - protected void execute(CVSTeamProvider provider, ICVSTraversal entry, IProgressMonitor monitor) throws CVSException, InterruptedException { - IResource[] deepResources = entry.getDeepResources(); - IResource[] shallowResources = entry.getShallowResources(); - IResource[] nontraversedFolders = entry.getNontraversedFolders(); - try { - monitor.beginTask(getTaskName(provider), (deepResources.length > 0 ? 100 : 0) + (shallowResources.length > 0 ? 100 : 0) + (nontraversedFolders.length > 0 ? 10 : 0)); - if (deepResources.length == 0 && shallowResources.length == 0 && nontraversedFolders.length == 0) - return; - final ISchedulingRule rule = getSchedulingRule(provider); - try { - Job.getJobManager().beginRule(rule, monitor); - if (deepResources.length > 0) - execute(provider, deepResources, true /* recurse */, Policy.subMonitorFor(monitor, 100)); - if (shallowResources.length > 0) - execute(provider, shallowResources, false /* recurse */, Policy.subMonitorFor(monitor, 100)); - if (nontraversedFolders.length > 0) { - handleNontraversedFolders(provider, nontraversedFolders, Policy.subMonitorFor(monitor, 10)); - } - } finally { - Job.getJobManager().endRule(rule); - } - } finally { - monitor.done(); - } - } + /** + * Execute the operation on the given set of traversals + * @param provider + * @param entry + * @param subMonitor + * @throws CVSException + * @throws InterruptedException + */ + protected void execute(CVSTeamProvider provider, ICVSTraversal entry, IProgressMonitor monitor) throws CVSException, InterruptedException { + IResource[] deepResources = entry.getDeepResources(); + IResource[] shallowResources = entry.getShallowResources(); + IResource[] nontraversedFolders = entry.getNontraversedFolders(); + try { + monitor.beginTask(getTaskName(provider), (deepResources.length > 0 ? 100 : 0) + (shallowResources.length > 0 ? 100 : 0) + (nontraversedFolders.length > 0 ? 10 : 0)); + if (deepResources.length == 0 && shallowResources.length == 0 && nontraversedFolders.length == 0) + return; + final ISchedulingRule rule = getSchedulingRule(provider); + try { + Job.getJobManager().beginRule(rule, monitor); + if (deepResources.length > 0) + execute(provider, deepResources, true /* recurse */, Policy.subMonitorFor(monitor, 100)); + if (shallowResources.length > 0) + execute(provider, shallowResources, false /* recurse */, Policy.subMonitorFor(monitor, 100)); + if (nontraversedFolders.length > 0) { + handleNontraversedFolders(provider, nontraversedFolders, Policy.subMonitorFor(monitor, 10)); + } + } finally { + Job.getJobManager().endRule(rule); + } + } finally { + monitor.done(); + } + } /** - * Handle any non-traversed (depth-zero) folders that were in the logical modle that primed this operation. - * @param provider the repository provider associated with the project containing the folders - * @param nontraversedFolders the folders - * @param monitor a progress monitor - */ - protected void handleNontraversedFolders(CVSTeamProvider provider, IResource[] nontraversedFolders, IProgressMonitor monitor) throws CVSException { - // Default is do nothing - } + * Handle any non-traversed (depth-zero) folders that were in the logical modle that primed this operation. + * @param provider the repository provider associated with the project containing the folders + * @param nontraversedFolders the folders + * @param monitor a progress monitor + */ + protected void handleNontraversedFolders(CVSTeamProvider provider, IResource[] nontraversedFolders, IProgressMonitor monitor) throws CVSException { + // Default is do nothing + } - /** + /** * Return the taskname to be shown in the progress monitor while operating * on the given provider. * @param provider the provider being processed @@ -327,37 +327,37 @@ public abstract class RepositoryProviderOperation extends CVSOperation { Map getProviderTraversalMapping(IProgressMonitor monitor) throws CoreException { Map<RepositoryProvider, TraversalMapEntry> result = new HashMap<>(); ResourceMapping[] mappings = getScope().getMappings(); - for (int j = 0; j < mappings.length; j++) { - ResourceMapping mapping = mappings[j]; - IProject[] projects = mapping.getProjects(); - ResourceTraversal[] traversals = getScope().getTraversals(mapping); - for (int k = 0; k < projects.length; k++) { - IProject project = projects[k]; - RepositoryProvider provider = RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()); - if (provider != null) { - TraversalMapEntry entry = result.get(provider); - if (entry == null) { - entry = new TraversalMapEntry(provider); - result.put(provider, entry); - } - entry.add(traversals); - } - } - } + for (int j = 0; j < mappings.length; j++) { + ResourceMapping mapping = mappings[j]; + IProject[] projects = mapping.getProjects(); + ResourceTraversal[] traversals = getScope().getTraversals(mapping); + for (int k = 0; k < projects.length; k++) { + IProject project = projects[k]; + RepositoryProvider provider = RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()); + if (provider != null) { + TraversalMapEntry entry = result.get(provider); + if (entry == null) { + entry = new TraversalMapEntry(provider); + result.put(provider, entry); + } + entry.add(traversals); + } + } + } return result; } - /** - * Return the resource mapping context that is to be used by this operation. - * By default, <code>null</code> is returned but subclasses may override - * to provide a specific context. - * @return the resource mapping context for this operation - */ + /** + * Return the resource mapping context that is to be used by this operation. + * By default, <code>null</code> is returned but subclasses may override + * to provide a specific context. + * @return the resource mapping context for this operation + */ protected ResourceMappingContext getResourceMappingContext() { - return ResourceMappingContext.LOCAL_CONTEXT; - } + return ResourceMappingContext.LOCAL_CONTEXT; + } - /** + /** * Execute the operation on the resources for the given provider. * @param provider the provider for the project that contains the resources * @param resources the resources to be operated on @@ -368,19 +368,19 @@ public abstract class RepositoryProviderOperation extends CVSOperation { */ protected abstract void execute(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException; - /** - * Return the local options for this operation including the - * option to provide the requested traversal. - * @param recurse deep or shallow - * @return the local options for the operation - */ - protected LocalOption[] getLocalOptions(boolean recurse) { - if (!recurse) { - return new LocalOption[] { Command.DO_NOT_RECURSE }; - } - return Command.NO_LOCAL_OPTIONS; - } - + /** + * Return the local options for this operation including the + * option to provide the requested traversal. + * @param recurse deep or shallow + * @return the local options for the operation + */ + protected LocalOption[] getLocalOptions(boolean recurse) { + if (!recurse) { + return new LocalOption[] { Command.DO_NOT_RECURSE }; + } + return Command.NO_LOCAL_OPTIONS; + } + protected ICVSResource[] getCVSArguments(IResource[] resources) { ICVSResource[] cvsResources = new ICVSResource[resources.length]; for (int i = 0; i < cvsResources.length; i++) { @@ -444,46 +444,46 @@ public abstract class RepositoryProviderOperation extends CVSOperation { } } - @Override + @Override public boolean isKeepOneProgressServiceEntry() { - // Keep the last repository provider operation in the progress service - return true; - } - - @Override + // Keep the last repository provider operation in the progress service + return true; + } + + @Override protected IAction getGotoAction() { - return getShowConsoleAction(); - } - - /** - * Return the root resources for all the traversals of this operation. - * This method may only be invoked after {@link #buildScope(IProgressMonitor) }. - * @return the root resources for all the traversals of this operation - * @throws CoreException - */ - protected IResource[] getTraversalRoots() { + return getShowConsoleAction(); + } + + /** + * Return the root resources for all the traversals of this operation. + * This method may only be invoked after {@link #buildScope(IProgressMonitor) }. + * @return the root resources for all the traversals of this operation + * @throws CoreException + */ + protected IResource[] getTraversalRoots() { List<IResource> result = new ArrayList<>(); - ResourceTraversal[] traversals = getTraversals(); - for (int i = 0; i < traversals.length; i++) { - ResourceTraversal traversal = traversals[i]; - result.addAll(Arrays.asList(traversal.getResources())); - } - return result.toArray(new IResource[result.size()]); - } - - /** - * Return the traversals that will be used by this operation. - * This method can only be called after {@link #buildScope(IProgressMonitor) }. - * @return the traversals that will be used by this operation - * @throws CoreException - */ - public ResourceTraversal[] getTraversals() { - return getScope().getTraversals(); - } - - public boolean consultModelsForMappings() { - return true; - } + ResourceTraversal[] traversals = getTraversals(); + for (int i = 0; i < traversals.length; i++) { + ResourceTraversal traversal = traversals[i]; + result.addAll(Arrays.asList(traversal.getResources())); + } + return result.toArray(new IResource[result.size()]); + } + + /** + * Return the traversals that will be used by this operation. + * This method can only be called after {@link #buildScope(IProgressMonitor) }. + * @return the traversals that will be used by this operation + * @throws CoreException + */ + public ResourceTraversal[] getTraversals() { + return getScope().getTraversals(); + } + + public boolean consultModelsForMappings() { + return true; + } public ResourceMapping[] getSelectedMappings() { return selectedMappings; 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 index eebe6925d..af8b6e747 100644 --- 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 @@ -110,7 +110,7 @@ public class ShareProjectOperation extends CVSOperation { monitor.beginTask(null, IProgressMonitor.UNKNOWN); purgeAnyCVSFolders(Policy.subMonitorFor(monitor, IProgressMonitor.UNKNOWN)); // Link the project to the newly created module - monitor.subTask(NLS.bind(CVSUIMessages.ShareProjectOperation_3, new String[] { project.getName(), remote.getRepositoryRelativePath() })); + monitor.subTask(NLS.bind(CVSUIMessages.ShareProjectOperation_3, new String[] { project.getName(), remote.getRepositoryRelativePath() })); ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project); folder.setFolderSyncInfo(remote.getFolderSyncInfo()); //Register it with Team. If it already is, no harm done. @@ -187,7 +187,7 @@ public class ShareProjectOperation extends CVSOperation { */ private void purgeAnyCVSFolders(final IProgressMonitor monitor) { try { - monitor.beginTask(null, IProgressMonitor.UNKNOWN); + monitor.beginTask(null, IProgressMonitor.UNKNOWN); ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); folder.accept(new ICVSResourceVisitor() { @Override @@ -196,7 +196,7 @@ public class ShareProjectOperation extends CVSOperation { } @Override public void visitFolder(ICVSFolder folder) throws CVSException { - monitor.subTask(NLS.bind(CVSUIMessages.ShareProjectOperation_2, new String[] { folder.getIResource().getFullPath().toString() } )); + monitor.subTask(NLS.bind(CVSUIMessages.ShareProjectOperation_2, new String[] { folder.getIResource().getFullPath().toString() } )); if (folder.isCVSFolder()) { // for now, just unmanage folder.unmanage(null); @@ -207,7 +207,7 @@ public class ShareProjectOperation extends CVSOperation { // log the exception and return null CVSUIPlugin.log(e); } finally { - monitor.done(); - } + monitor.done(); + } } } 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 index 40403b4df..7e043bbe0 100644 --- 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 @@ -57,21 +57,21 @@ import com.ibm.icu.text.DateFormat; * display them in the annotations view. */ public class ShowAnnotationOperation extends CVSOperation { - - private final ICVSResource fCVSResource; - private final String fRevision; - private final boolean fBinary; + + private final ICVSResource fCVSResource; + private final String fRevision; + private final boolean fBinary; - public ShowAnnotationOperation(IWorkbenchPart part, ICVSResource cvsResource, String revision, boolean binary) { - super(part); - fCVSResource= cvsResource; - fRevision= revision; - fBinary = binary; - } + public ShowAnnotationOperation(IWorkbenchPart part, ICVSResource cvsResource, String revision, boolean binary) { + super(part); + fCVSResource= cvsResource; + fRevision= revision; + fBinary = binary; + } - @Override + @Override protected void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - + monitor.beginTask(null, 100); // Get the annotations from the repository. @@ -100,35 +100,35 @@ public class ShowAnnotationOperation extends CVSOperation { monitor.done(); } - - /** - * Shows the history view, creating it if necessary, but does not give it focus. - * - * @param page the workbench page to operate in - * @param editor the editor that is showing the file - * @return the history view - * @throws PartInitException - */ - private IHistoryView showHistoryView(IWorkbenchPage page, AbstractDecoratedTextEditor editor) throws PartInitException { - Object object = fCVSResource.getIResource(); - if (object == null) - object = editor.getEditorInput(); + + /** + * Shows the history view, creating it if necessary, but does not give it focus. + * + * @param page the workbench page to operate in + * @param editor the editor that is showing the file + * @return the history view + * @throws PartInitException + */ + private IHistoryView showHistoryView(IWorkbenchPage page, AbstractDecoratedTextEditor editor) throws PartInitException { + Object object = fCVSResource.getIResource(); + if (object == null) + object = editor.getEditorInput(); IHistoryView historyView= TeamUI.showHistoryFor(page, object, null); - IHistoryPage historyPage = historyView.getHistoryPage(); - if (historyPage instanceof CVSHistoryPage){ - CVSHistoryPage cvsHistoryPage = (CVSHistoryPage) historyPage; - cvsHistoryPage.setMode(CVSHistoryPage.REMOTE_MODE); - // We need to call link to ensure that the history page gets linked + IHistoryPage historyPage = historyView.getHistoryPage(); + if (historyPage instanceof CVSHistoryPage){ + CVSHistoryPage cvsHistoryPage = (CVSHistoryPage) historyPage; + cvsHistoryPage.setMode(CVSHistoryPage.REMOTE_MODE); + // We need to call link to ensure that the history page gets linked // even if the page input did not change - cvsHistoryPage.linkWithEditor(); - } - return historyView; - } + cvsHistoryPage.linkWithEditor(); + } + return historyView; + } - @Override + @Override protected String getTaskName() { - return CVSUIMessages.ShowAnnotationOperation_taskName; - } + return CVSUIMessages.ShowAnnotationOperation_taskName; + } protected boolean hasCharset(ICVSResource cvsResource, InputStream contents) { try { @@ -147,45 +147,45 @@ public class ShowAnnotationOperation extends CVSOperation { if (fCVSResource instanceof ICVSRemoteResource) { return RevisionAnnotationController.openEditor(getPart().getSite().getPage(), fCVSResource, new RemoteAnnotationStorage((ICVSRemoteFile)fCVSResource, listener.getContents())); } - return null; + return null; } 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); + + 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<Object> localOptions = new ArrayList<>(); - if (revision != null) { - localOptions.add(Annotate.makeRevisionOption(revision)); - } - if (fBinary) { - localOptions.add(Annotate.FORCE_BINARY_ANNOTATE); - } - final IStatus status = Command.ANNOTATE.execute(session, Command.NO_GLOBAL_OPTIONS, 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(); - } - } + if (revision != null) { + localOptions.add(Annotate.makeRevisionOption(revision)); + } + if (fBinary) { + localOptions.add(Annotate.FORCE_BINARY_ANNOTATE); + } + final IStatus status = Command.ANNOTATE.execute(session, Command.NO_GLOBAL_OPTIONS, 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 RevisionInformation createRevisionInformation(final AnnotateListener listener, IProgressMonitor monitor) throws CVSException { + private RevisionInformation createRevisionInformation(final AnnotateListener listener, IProgressMonitor monitor) throws CVSException { Map<String, ILogEntry> logEntriesByRevision = new HashMap<>(); if (fCVSResource instanceof ICVSFile) { try { 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 index a2424a47c..31793ce78 100644 --- 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 @@ -42,8 +42,8 @@ public abstract class SingleCommandOperation extends RepositoryProviderOperation try { IStatus status = executeCommand(session, provider, getCVSArguments(session, resources), recurse, Policy.subMonitorFor(monitor, 90)); if (isReportableError(status)) { - throw new CVSException(status); - } + throw new CVSException(status); + } } finally { session.close(); } @@ -54,21 +54,21 @@ public abstract class SingleCommandOperation extends RepositoryProviderOperation return super.getCVSArguments(resources); } - protected ICVSResource[] getCVSArguments(Session session, IResource[] resources) { + protected ICVSResource[] getCVSArguments(Session session, IResource[] resources) { return getCVSArguments(resources); } @Override - protected void execute(CVSTeamProvider provider, ICVSTraversal entry, IProgressMonitor monitor) throws CVSException, InterruptedException { - try { - // TODO: This does not properly count the number of operations - // Changing it causes an error in the test cases - super.execute(provider, entry, monitor); - collectStatus(Status.OK_STATUS); - } catch (CVSException e) { - collectStatus(e.getStatus()); - } - } + protected void execute(CVSTeamProvider provider, ICVSTraversal entry, IProgressMonitor monitor) throws CVSException, InterruptedException { + try { + // TODO: This does not properly count the number of operations + // Changing it causes an error in the test cases + super.execute(provider, entry, monitor); + collectStatus(Status.OK_STATUS); + } catch (CVSException e) { + collectStatus(e.getStatus()); + } + } /** * 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). @@ -80,24 +80,24 @@ public abstract class SingleCommandOperation extends RepositoryProviderOperation /** * Method overridden by subclasses to issue the command to the CVS repository using the given session. - * @param session an open session which will be closed by the caller - * @param provider the provider for the project that contains the resources - * @param resources the resources to be operated on - * @param recurse whether the operation is deep or shallow - * @param monitor a progress monitor + * @param session an open session which will be closed by the caller + * @param provider the provider for the project that contains the resources + * @param resources the resources to be operated on + * @param recurse whether the operation is deep or shallow + * @param monitor a progress monitor */ protected abstract IStatus executeCommand(Session session, CVSTeamProvider provider, ICVSResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException; @Override protected LocalOption[] getLocalOptions(boolean recurse) { - LocalOption[] result = options; - if (recurse) { - // For deep operations, we just need to make sure that the -l option isn't present - result = Command.DO_NOT_RECURSE.removeFrom(options); - } else { - result = Command.RECURSE.removeFrom(options); - result = Command.DO_NOT_RECURSE.addTo(options); - } + LocalOption[] result = options; + if (recurse) { + // For deep operations, we just need to make sure that the -l option isn't present + result = Command.DO_NOT_RECURSE.removeFrom(options); + } else { + result = Command.RECURSE.removeFrom(options); + result = Command.DO_NOT_RECURSE.addTo(options); + } return result; } 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 index 8ac845dbd..3efb9d265 100644 --- 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 @@ -104,18 +104,18 @@ public class TagInRepositoryOperation extends RemoteOperation implements ITagOpe } @Override - public TagSource getTagSource() { - return TagSource.create(getCVSResources()); - } - - @Override + public TagSource getTagSource() { + return TagSource.create(getCVSResources()); + } + + @Override protected boolean isReportableError(IStatus status) { - return super.isReportableError(status) - || status.getCode() == CVSStatus.TAG_ALREADY_EXISTS; - } + return super.isReportableError(status) + || status.getCode() == CVSStatus.TAG_ALREADY_EXISTS; + } @Override - public boolean isEmpty() { - return getCVSResources().length == 0; - } + public boolean isEmpty() { + return getCVSResources().length == 0; + } } 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 index b9ae57e79..a525ba91e 100644 --- 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 @@ -84,12 +84,12 @@ public class TagOperation extends RepositoryProviderOperation implements ITagOpe public IStatus tag(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor progress) throws CVSException { LocalOption[] commandOptions = localOptions.toArray(new LocalOption[localOptions.size()]); - if (recurse) { - commandOptions = Command.DO_NOT_RECURSE.removeFrom(commandOptions); - } else { - commandOptions = Command.RECURSE.removeFrom(commandOptions); - commandOptions = Command.DO_NOT_RECURSE.addTo(commandOptions); - } + if (recurse) { + commandOptions = Command.DO_NOT_RECURSE.removeFrom(commandOptions); + } else { + commandOptions = Command.RECURSE.removeFrom(commandOptions); + commandOptions = Command.DO_NOT_RECURSE.addTo(commandOptions); + } // Build the arguments list String[] arguments = getStringArguments(resources); @@ -150,21 +150,21 @@ public class TagOperation extends RepositoryProviderOperation implements ITagOpe } } - private ICVSResource[] getCVSResources() { - IResource[] resources = getTraversalRoots(); - ICVSResource[] cvsResources = new ICVSResource[resources.length]; - for (int i = 0; i < resources.length; i++) { - cvsResources[i] = CVSWorkspaceRoot.getCVSResourceFor(resources[i]); - } - return cvsResources; - } + private ICVSResource[] getCVSResources() { + IResource[] resources = getTraversalRoots(); + ICVSResource[] cvsResources = new ICVSResource[resources.length]; + for (int i = 0; i < resources.length; i++) { + cvsResources[i] = CVSWorkspaceRoot.getCVSResourceFor(resources[i]); + } + return cvsResources; + } - @Override + @Override public TagSource getTagSource() { - return TagSource.create(getProjects()); - } + return TagSource.create(getProjects()); + } - private IProject[] getProjects() { + private IProject[] getProjects() { ResourceMapping[] mappings = getSelectedMappings(); Set<IProject> projects = new HashSet<>(); for (int i = 0; i < mappings.length; i++) { @@ -176,12 +176,12 @@ public class TagOperation extends RepositoryProviderOperation implements ITagOpe @Override protected boolean isReportableError(IStatus status) { - return super.isReportableError(status) - || status.getCode() == CVSStatus.TAG_ALREADY_EXISTS; - } + return super.isReportableError(status) + || status.getCode() == CVSStatus.TAG_ALREADY_EXISTS; + } - @Override + @Override public boolean isEmpty() { - return getSelectedMappings().length == 0; - } + return getSelectedMappings().length == 0; + } } 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 index d84d546f2..ef808f6c5 100644 --- 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 @@ -48,17 +48,17 @@ public class UpdateOperation extends SingleCommandOperation { this(part, asResourceMappers(resources), options, 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. - */ - public UpdateOperation(IWorkbenchPart part, ResourceMapping[] mappings, LocalOption[] options, CVSTag tag) { - super(part, mappings, options); - this.tag = 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. + */ + public UpdateOperation(IWorkbenchPart part, ResourceMapping[] mappings, LocalOption[] options, CVSTag tag) { + super(part, mappings, options); + this.tag = tag; + } @Override protected IStatus executeCommand( @@ -84,19 +84,19 @@ public class UpdateOperation extends SingleCommandOperation { return execute; } - @Override + @Override protected LocalOption[] getLocalOptions(boolean recurse) { - // Build the local options + // Build the local options List<LocalOption> localOptions = new ArrayList<>(); - // Use the appropriate tag options - if (tag != null) { - localOptions.add(Update.makeTagOption(tag)); - } - // Build the arguments list - localOptions.addAll(Arrays.asList(super.getLocalOptions(recurse))); - LocalOption[] commandOptions = localOptions.toArray(new LocalOption[localOptions.size()]); - return commandOptions; - } + // Use the appropriate tag options + if (tag != null) { + localOptions.add(Update.makeTagOption(tag)); + } + // Build the arguments list + localOptions.addAll(Arrays.asList(super.getLocalOptions(recurse))); + LocalOption[] commandOptions = localOptions.toArray(new LocalOption[localOptions.size()]); + return commandOptions; + } protected Update getUpdateCommand() { return Command.UPDATE; @@ -121,23 +121,23 @@ public class UpdateOperation extends SingleCommandOperation { return null; } - @Override + @Override 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; - } + return super.isReportableError(status) + || status.getCode() == CVSStatus.UNMEGERED_BINARY_CONFLICT + || status.getCode() == CVSStatus.INVALID_LOCAL_RESOURCE_PATH + || status.getCode() == CVSStatus.RESPONSE_HANDLING_FAILURE; + } @Override protected String getErrorMessage(IStatus[] failures, int totalOperations) { return CVSUIMessages.UpdateAction_update; } - - @Override + + @Override protected ResourceMappingContext getResourceMappingContext() { - return SubscriberResourceMappingContext.createContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); - } + return SubscriberResourceMappingContext.createContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); + } public CVSTag getTag() { return tag; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceFileDiffOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceFileDiffOperation.java index e57e8454d..e96513200 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceFileDiffOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceFileDiffOperation.java @@ -70,7 +70,7 @@ public class WorkspaceFileDiffOperation extends FileDiffOperation { tempFile.delete(); } } - } + } } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceResourceMapper.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceResourceMapper.java index 4cacf52ec..2ba9ce323 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceResourceMapper.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceResourceMapper.java @@ -33,49 +33,49 @@ import org.eclipse.core.runtime.IProgressMonitor; * @since 3.1 */ public final class WorkspaceResourceMapper extends ResourceMapping { - - private final IResource resource; - private final int depth; - - /** - * Convert the provided resources to one or more resource mappers - * that traverse the elements deeply. The model element of the resource - * mappers will be the workspace root. - * @param resources the resources - * @return a resource mappers that traverses the resources - */ - public static ResourceMapping[] asResourceMappers(final IResource[] resources, int depth) { + + private final IResource resource; + private final int depth; + + /** + * Convert the provided resources to one or more resource mappers + * that traverse the elements deeply. The model element of the resource + * mappers will be the workspace root. + * @param resources the resources + * @return a resource mappers that traverses the resources + */ + public static ResourceMapping[] asResourceMappers(final IResource[] resources, int depth) { List<WorkspaceResourceMapper> result = new ArrayList<>(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - result.add(new WorkspaceResourceMapper(resource, depth)); - } - return result.toArray(new ResourceMapping[result.size()]); - } - - public WorkspaceResourceMapper(IResource resource, int depth) { - this.resource = resource; - this.depth = depth; - } - @Override + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + result.add(new WorkspaceResourceMapper(resource, depth)); + } + return result.toArray(new ResourceMapping[result.size()]); + } + + public WorkspaceResourceMapper(IResource resource, int depth) { + this.resource = resource; + this.depth = depth; + } + @Override public Object getModelObject() { - return resource; - } - @Override + return resource; + } + @Override public IProject[] getProjects() { - return new IProject[] { resource.getProject() }; - } - @Override + return new IProject[] { resource.getProject() }; + } + @Override public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { - return asTraversal(resource, depth, context); - } - private ResourceTraversal[] asTraversal(IResource resource, final int depth, ResourceMappingContext context) { - return new ResourceTraversal[] { new ResourceTraversal(new IResource[] { resource }, depth, IResource.NONE)} ; - } - @Override + return asTraversal(resource, depth, context); + } + private ResourceTraversal[] asTraversal(IResource resource, final int depth, ResourceMappingContext context) { + return new ResourceTraversal[] { new ResourceTraversal(new IResource[] { resource }, depth, IResource.NONE)} ; + } + @Override public boolean contains(ResourceMapping mapping) { - return false; - } + return false; + } @Override public String getModelProviderId() { |