Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-08-18 14:27:22 +0000
committerMichael Valenta2003-08-18 14:27:22 +0000
commit933efe278dcdb88399398129aa736d4e26050e0a (patch)
tree5cb28e8f92c4e62467f32e002740772aeed1017e
parent708a8fc5ff6b2a231825826b69b97637a5ee8643 (diff)
downloadeclipse.platform.team-933efe278dcdb88399398129aa736d4e26050e0a.tar.gz
eclipse.platform.team-933efe278dcdb88399398129aa736d4e26050e0a.tar.xz
eclipse.platform.team-933efe278dcdb88399398129aa736d4e26050e0a.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java74
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java43
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java31
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java33
4 files changed, 74 insertions, 107 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
index 01cd6c7f3..b3b4dc34a 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
@@ -46,7 +46,6 @@ import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
import org.eclipse.team.internal.ccvs.core.ILogEntry;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.client.Command;
@@ -158,50 +157,54 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
* @see ICVSRemoteFile#getContents()
*/
public InputStream getContents(IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(Policy.bind("RemoteFile.getContents"), 100);//$NON-NLS-1$
- try {
+ if (contents == null) {
+ // First, check to see if there's a cached contents for the file
+ InputStream cached = getCachedContents();
+ if (cached != null) {
+ return cached;
+ }
+
+ // No contents cached so fetch contents from the server.
+ fetchContents(monitor);
+
+ // If the update succeeded but no contents were retreived from the server
+ // than we can assume that the remote file has no contents.
if (contents == null) {
- // First, check to see if there's a cached contents for the file
- InputStream cached = getCachedContents();
+ // The above is true unless there is a cache file
+ cached = getCachedContents();
if (cached != null) {
return cached;
+ } else {
+ contents = new byte[0];
}
+ }
+ }
+ return new ByteArrayInputStream(contents);
+ }
- // We need to fetch the contents from the server
- Session.run(getRepository(), parent, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- IStatus status = Command.UPDATE.execute(
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] {
- Update.makeTagOption(new CVSTag(getRevision(), CVSTag.VERSION)),
- Update.IGNORE_LOCAL_CHANGES },
- new ICVSResource[] { RemoteFile.this },
- null,
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- }
- }, Policy.subMonitorFor(monitor, 100));
-
- // If the update succeeded but no contents were retreived from the server
- // than we can assume that the remote file has no contents.
- if (contents == null) {
- // The above is true unless there is a cache file
- cached = getCachedContents();
- if (cached != null) {
- return cached;
- } else {
- contents = new byte[0];
- }
- }
+ private void fetchContents(IProgressMonitor monitor) throws CVSException {
+ monitor.beginTask(Policy.bind("RemoteFile.getContents"), 100);//$NON-NLS-1$
+ Session session = new Session(getRepository(), parent, false /* create backups */);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ IStatus status = Command.UPDATE.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ new LocalOption[] {
+ Update.makeTagOption(new CVSTag(getRevision(), CVSTag.VERSION)),
+ Update.IGNORE_LOCAL_CHANGES },
+ new ICVSResource[] { this },
+ null,
+ Policy.subMonitorFor(monitor, 90));
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ throw new CVSServerException(status);
}
- return new ByteArrayInputStream(contents);
} finally {
+ session.close();
monitor.done();
}
}
-
+
/*
* @see ICVSRemoteFile#getLogEntry(IProgressMonitor)
*/
@@ -539,6 +542,7 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
}
private InputStream getCachedContents() throws CVSException {
+ // TODO: Update to use Team caching facility
try {
try {
File ioFile = getCacheFile();
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java
index 27027dccb..df6114f0f 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java
@@ -20,7 +20,6 @@ import org.eclipse.team.internal.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.Session;
@@ -34,6 +33,7 @@ public class ReplaceWithBaseVisitor implements ICVSResourceVisitor {
private IProgressMonitor monitor;
private int depth;
+ private Session session;
/**
* @see ICVSResourceVisitor#visitFile(ICVSFile)
@@ -61,13 +61,10 @@ public class ReplaceWithBaseVisitor implements ICVSResourceVisitor {
if (isModified) {
ICVSFolder parent = file.getParent();
FolderSyncInfo folderInfo = parent.getFolderSyncInfo();
- Session.run(CVSProviderPlugin.getPlugin().getRepository(folderInfo.getRoot()), parent, true, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- Command.UPDATE.execute(Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] {Update.makeTagOption(CVSTag.BASE), Update.IGNORE_LOCAL_CHANGES},
- new ICVSResource[] { file }, null, monitor);
- }
- }, Policy.subMonitorFor(monitor, 1));
+ // Use the session opened in tghe replaceWithBase method to make the connection.
+ Command.UPDATE.execute(this.session, Command.NO_GLOBAL_OPTIONS,
+ new LocalOption[] {Update.makeTagOption(CVSTag.BASE), Update.IGNORE_LOCAL_CHANGES},
+ new ICVSResource[] { file }, null, Policy.subMonitorFor(monitor, 1));
// Set the tag to be the original tag
syncBytes = file.getSyncBytes();
@@ -108,26 +105,26 @@ public class ReplaceWithBaseVisitor implements ICVSResourceVisitor {
* results in the workspace are "sticky". This operation does not leave the local workspace "sticky".
*
* NOTE: This operation issues multiple commands over a single connection. It may fail
- * with some servers that are configured to run scripts during an update.
+ * with some servers that are configured to run scripts during an update (see bug 40145).
*/
public void replaceWithBase(IProject project, final IResource[] resources, int depth, IProgressMonitor pm) throws CVSException {
this.depth = depth;
final ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(project);
FolderSyncInfo folderInfo = root.getFolderSyncInfo();
- Session.run(CVSProviderPlugin.getPlugin().getRepository(folderInfo.getRoot()), root, true, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- root.run(new ICVSRunnable() {
- public void run(IProgressMonitor pm) throws CVSException {
- ReplaceWithBaseVisitor.this.monitor = Policy.infiniteSubMonitorFor(pm, 100);
- ReplaceWithBaseVisitor.this.monitor.beginTask(null, 512);
- for (int i = 0; i < resources.length; i++) {
- ReplaceWithBaseVisitor.this.monitor.subTask(Policy.bind("ReplaceWithBaseVisitor.replacing", resources[i].getFullPath().toString())); //$NON-NLS-1$
- CVSWorkspaceRoot.getCVSResourceFor(resources[i]).accept(ReplaceWithBaseVisitor.this);
- }
- ReplaceWithBaseVisitor.this.monitor.done();
- }
- }, monitor);
+ IProgressMonitor monitor = Policy.monitorFor(pm);
+ monitor.beginTask(null, 100);
+ this.session = new Session(CVSProviderPlugin.getPlugin().getRepository(folderInfo.getRoot()), root, true /* creat e backups */);
+ this.session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ this.monitor = Policy.infiniteSubMonitorFor(monitor, 90);
+ this.monitor.beginTask(null, 512);
+ for (int i = 0; i < resources.length; i++) {
+ this.monitor.subTask(Policy.bind("ReplaceWithBaseVisitor.replacing", resources[i].getFullPath().toString())); //$NON-NLS-1$
+ CVSWorkspaceRoot.getCVSResourceFor(resources[i]).accept(this);
}
- }, pm);
+ } finally {
+ this.session.close();
+ monitor.done();
+ }
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
index 85d759e70..d855470e9 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
@@ -34,14 +34,11 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.client.Session;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
/**
@@ -73,6 +70,7 @@ public class CVSCompareEditorInput extends CompareEditorInput {
*/
public CVSCompareEditorInput(ResourceEditionNode left, ResourceEditionNode right, ResourceEditionNode ancestor) {
super(new CompareConfiguration());
+ // TODO: Invokers of this method should ensure that trees and contents are prefetched
this.left = left;
this.right = right;
this.ancestor = ancestor;
@@ -291,28 +289,21 @@ public class CVSCompareEditorInput extends CompareEditorInput {
try {
// do the diff
- final Object[] result = new Object[] { null };
- Session.run(null, null, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- monitor.beginTask(Policy.bind("CVSCompareEditorInput.comparing"), 30); //$NON-NLS-1$
- IProgressMonitor sub = new SubProgressMonitor(monitor, 30);
- sub.beginTask(Policy.bind("CVSCompareEditorInput.comparing"), 100); //$NON-NLS-1$
- try {
- result[0] = d.findDifferences(threeWay, sub, null, ancestor, left, right);
- } finally {
- sub.done();
- }
- }
- }, monitor);
- return result[0];
+ Object result = null;
+ monitor.beginTask(Policy.bind("CVSCompareEditorInput.comparing"), 30); //$NON-NLS-1$
+ IProgressMonitor sub = new SubProgressMonitor(monitor, 30);
+ sub.beginTask(Policy.bind("CVSCompareEditorInput.comparing"), 100); //$NON-NLS-1$
+ try {
+ result = d.findDifferences(threeWay, sub, null, ancestor, left, right);
+ } finally {
+ sub.done();
+ }
+ return result;
} catch (OperationCanceledException e) {
throw new InterruptedException(e.getMessage());
} catch (RuntimeException e) {
handle(e);
return null;
- } catch (CVSException e) {
- handle(e);
- return null;
} finally {
monitor.done();
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java
index 754815e1f..3a4cfe016 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java
@@ -42,8 +42,6 @@ import org.eclipse.team.core.sync.ILocalSyncElement;
import org.eclipse.team.core.sync.IRemoteSyncElement;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
-import org.eclipse.team.internal.ccvs.core.client.Session;
import org.eclipse.team.internal.ccvs.core.resources.CVSRemoteSyncElement;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.AvoidableMessageDialog;
@@ -320,34 +318,11 @@ public class CVSSyncCompareInput extends SyncCompareInput {
*/
public Object prepareInput(IProgressMonitor pm) throws InterruptedException, InvocationTargetException {
final Object[] result = new Object[] { null };
- final Exception[] exception = new Exception[] {null};
- try {
- Session.run(null, null, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- try {
- CVSUIPlugin.runWithRefresh(getShell(), resources, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- result[0] = CVSSyncCompareInput.super.prepareInput(monitor);
- }
- }, monitor);
- } catch (InterruptedException e) {
- exception[0] = e;
- } catch (InvocationTargetException e) {
- exception[0] = e;
- }
- }
- }, pm);
- } catch (CVSException e) {
- throw new InvocationTargetException(e);
- }
-
- if (exception[0] != null) {
- if (exception[0] instanceof InvocationTargetException) {
- throw (InvocationTargetException)exception[0];
- } else {
- throw (InterruptedException)exception[0];
+ CVSUIPlugin.runWithRefresh(getShell(), resources, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ result[0] = CVSSyncCompareInput.super.prepareInput(monitor);
}
- }
+ }, pm);
if (hasDifferences(result[0])) {
return result[0];

Back to the top