diff options
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java')
-rw-r--r-- | bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java | 148 |
1 files changed, 74 insertions, 74 deletions
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)}; } |