Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java103
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java7
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java8
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java348
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java19
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java40
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java9
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java7
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java50
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java8
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java190
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java17
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java8
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java41
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties1
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java103
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java10
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileContentCachingService.java116
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java368
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java429
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java172
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaseSynchronizer.java15
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteTagSynchronizer.java8
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSynchronizer.java8
-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/CVSLocalCompareEditorInput.java6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java45
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java53
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java117
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java22
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java131
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.java13
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java66
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOnlyMergableOperation.java53
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java86
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java33
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java21
44 files changed, 1361 insertions, 1463 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java
index 3d8551e5f..d6f3aceb7 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java
@@ -18,10 +18,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Date;
-import java.util.Enumeration;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -48,6 +45,7 @@ import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.Team;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.TeamProvider;
+import org.eclipse.team.core.sync.RemoteContentsCache;
import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption;
@@ -93,16 +91,6 @@ public class CVSProviderPlugin extends Plugin {
public static final String PT_CONNECTIONMETHODS = "connectionmethods"; //$NON-NLS-1$
public static final String PT_FILE_MODIFICATION_VALIDATOR = "filemodificationvalidator"; //$NON-NLS-1$
- // Directory to cache file contents
- private static final String CACHE_DIRECTORY = ".cache"; //$NON-NLS-1$
- // Maximum lifespan of local cache file, in milliseconds
- private static final long CACHE_FILE_LIFESPAN = 60*60*1000; // 1hr
-
- private Hashtable cacheFileNames;
- private Hashtable cacheFileTimes;
- private long lastCacheCleanup;
- private int cacheDirSize;
-
private QuietOption quietness;
private int compressionLevel = DEFAULT_COMPRESSION_LEVEL;
private KSubstOption defaultTextKSubstOption = DEFAULT_TEXT_KSUBST_OPTION;
@@ -339,7 +327,7 @@ public class CVSProviderPlugin extends Plugin {
workspace.addResourceChangeListener(fileModificationManager, IResourceChangeEvent.POST_CHANGE);
fileModificationManager.registerSaveParticipant();
- createCacheDirectory();
+ RemoteContentsCache.enableCaching(ID);
cvsWorkspaceSubscriber = new CVSWorkspaceSubscriber(
CVS_WORKSPACE_SUBSCRIBER_ID,
@@ -368,7 +356,7 @@ public class CVSProviderPlugin extends Plugin {
// each class that added itself as a participant to have to listen to shutdown.
workspace.removeSaveParticipant(this);
- deleteCacheDirectory();
+ RemoteContentsCache.disableCache(ID);
}
/**
@@ -571,91 +559,6 @@ public class CVSProviderPlugin extends Plugin {
public void setReplaceUnmanaged(boolean replaceUnmanaged) {
this.replaceUnmanaged = replaceUnmanaged;
}
-
- private void createCacheDirectory() {
- try {
- IPath cacheLocation = getStateLocation().append(CACHE_DIRECTORY);
- File file = cacheLocation.toFile();
- if (file.exists()) {
- deleteFile(file);
- }
- file.mkdir();
- cacheFileNames = new Hashtable();
- cacheFileTimes = new Hashtable();
- lastCacheCleanup = -1;
- cacheDirSize = 0;
- } catch (IOException e) {
- log(new Status(IStatus.ERROR, ID, 0, Policy.bind("CVSProviderPlugin.errorCreatingCache", e.getMessage()), e)); //$NON-NLS-1$
- }
- }
-
- private void deleteCacheDirectory() {
- try {
- IPath cacheLocation = getStateLocation().append(CACHE_DIRECTORY);
- File file = cacheLocation.toFile();
- if (file.exists()) {
- deleteFile(file);
- }
- cacheFileNames = cacheFileTimes = null;
- lastCacheCleanup = -1;
- cacheDirSize = 0;
- } catch (IOException e) {
- log(new Status(IStatus.ERROR, ID, 0, Policy.bind("CVSProviderPlugin.errorDeletingCache", e.getMessage()), e)); //$NON-NLS-1$
- }
- }
-
- private void deleteFile(File file) throws IOException {
- if (file.isDirectory()) {
- File[] children = file.listFiles();
- for (int i = 0; i < children.length; i++) {
- deleteFile(children[i]);
- }
- }
- file.delete();
- }
-
- public synchronized File getCacheFileFor(String path) throws IOException {
- String physicalPath;
- if (cacheFileNames.containsKey(path)) {
- /*
- * cache hit
- */
- physicalPath = (String)cacheFileNames.get(path);
- registerHit(path);
- } else {
- /*
- * cache miss
- */
- physicalPath = String.valueOf(cacheDirSize++);
- cacheFileNames.put(path, physicalPath);
- registerHit(path);
- clearOldCacheEntries();
- }
- return getCacheFileForPhysicalPath(physicalPath);
- }
- private File getCacheFileForPhysicalPath(String physicalPath) throws IOException {
- return new File(getStateLocation().append(CACHE_DIRECTORY).toFile(), physicalPath);
- }
- private void registerHit(String path) {
- cacheFileTimes.put(path, Long.toString(new Date().getTime()));
- }
- private void clearOldCacheEntries() throws IOException {
- long current = new Date().getTime();
- if ((lastCacheCleanup!=-1) && (current - lastCacheCleanup < CACHE_FILE_LIFESPAN)) return;
- Enumeration e = cacheFileTimes.keys();
- while (e.hasMoreElements()) {
- String f = (String)e.nextElement();
- long lastHit = Long.valueOf((String)cacheFileTimes.get(f)).longValue();
- if ((current - lastHit) > CACHE_FILE_LIFESPAN) purgeCacheFile(f);
- }
-
- }
- private void purgeCacheFile(String path) throws IOException {
- File f = getCacheFileForPhysicalPath((String)cacheFileNames.get(path));
- f.delete();
- cacheFileTimes.remove(path);
- cacheFileNames.remove(path);
- }
/*
* Add the repository location to the cahced locations
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java
index 63fbfb6e8..68bf3e2d4 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSRevisionNumberCompareCriteria.java
@@ -89,4 +89,11 @@ import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
return false;
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.subscribers.ComparisonCriteria#usesFileContents()
+ */
+ public boolean usesFileContents() {
+ return false;
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java
index ab00088f1..1ffee9ae5 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java
@@ -212,7 +212,7 @@ public abstract class CVSSyncTreeSubscriber extends TeamSubscriber {
try {
monitor.beginTask(null, 100);
IResource[] remoteChanges = refreshRemote(resources, depth, Policy.subMonitorFor(monitor, 60));
- IResource[] baseChanges = getBaseSynchronizer().refresh(resources, depth, Policy.subMonitorFor(monitor, 40));
+ IResource[] baseChanges = getBaseSynchronizer().refresh(resources, depth, getCacheFileContentsHint(), Policy.subMonitorFor(monitor, 40));
Set allChanges = new HashSet();
allChanges.addAll(Arrays.asList(remoteChanges));
@@ -225,7 +225,7 @@ public abstract class CVSSyncTreeSubscriber extends TeamSubscriber {
}
protected IResource[] refreshRemote(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
- return getRemoteSynchronizer().refresh(resources, depth, monitor);
+ return getRemoteSynchronizer().refresh(resources, depth, getCacheFileContentsHint(), monitor);
}
/* (non-Javadoc)
@@ -235,6 +235,10 @@ public abstract class CVSSyncTreeSubscriber extends TeamSubscriber {
return (ComparisonCriteria)comparisonCriterias.get(defaultCriteria);
}
+ private boolean getCacheFileContentsHint() {
+ return getCurrentComparisonCriteria().usesFileContents();
+ }
+
/* (non-Javadoc)
* @see org.eclipse.team.core.sync.ISyncTreeSubscriber#setCurrentComparisonCriteria(java.lang.String)
*/
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java
index 58f14e924..ed4715ff3 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java
@@ -297,37 +297,43 @@ public class CVSTeamProvider extends RepositoryProvider {
progress.beginTask(null, files.size() * 10 + (folders.isEmpty() ? 0 : 10));
try {
if (!folders.isEmpty()) {
- Session.run(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- IStatus status = Command.ADD.execute(
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- (ICVSResource[])folders.toArray(new ICVSResource[folders.size()]),
- null,
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
+ Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */);
+ session.open(Policy.subMonitorFor(progress, 2));
+ try {
+ IStatus status = Command.ADD.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ Command.NO_LOCAL_OPTIONS,
+ (ICVSResource[])folders.toArray(new ICVSResource[folders.size()]),
+ null,
+ Policy.subMonitorFor(progress, 8));
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ throw new CVSServerException(status);
}
- }, Policy.subMonitorFor(progress, 10));
+ } finally {
+ session.close();
+ }
}
for (Iterator it = files.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
final KSubstOption ksubst = (KSubstOption) entry.getKey();
final Set set = (Set) entry.getValue();
- Session.run(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- IStatus status = Command.ADD.execute(
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] { ksubst },
- (ICVSResource[])set.toArray(new ICVSResource[set.size()]),
- null,
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
+ Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */);
+ session.open(Policy.subMonitorFor(progress, 2));
+ try {
+ IStatus status = Command.ADD.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ new LocalOption[] { ksubst },
+ (ICVSResource[])set.toArray(new ICVSResource[set.size()]),
+ null,
+ Policy.subMonitorFor(progress, 8));
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ throw new CVSServerException(status);
}
- }, Policy.subMonitorFor(progress, 10));
+ } finally {
+ session.close();
+ }
}
} finally {
progress.done();
@@ -439,14 +445,14 @@ public class CVSTeamProvider extends RepositoryProvider {
// Remove the files remotely
IStatus status;
Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
- s.open(progress);
+ s.open(Policy.subMonitorFor(progress, 10));
try {
status = Command.REMOVE.execute(s,
Command.NO_GLOBAL_OPTIONS,
Command.NO_LOCAL_OPTIONS,
(String[])files.toArray(new String[files.size()]),
null,
- Policy.subMonitorFor(progress, 70));
+ Policy.subMonitorFor(progress, 60));
} finally {
s.close();
}
@@ -526,9 +532,7 @@ public class CVSTeamProvider extends RepositoryProvider {
* @param format
* @throws CVSException
*/
-
private void newFileDiff(final ICVSResource resource, final PrintStream stream, final boolean doNotRecurse, final int format) throws CVSException {
-
resource.accept(new ICVSResourceVisitor() {
public void visitFile(ICVSFile file) throws CVSException {
if (!(file.isIgnored() || file.isManaged())) {
@@ -549,10 +553,10 @@ public class CVSTeamProvider extends RepositoryProvider {
private void addFileToDiff(ICVSFile file, PrintStream stream, int format) throws CVSException {
- String nullFilePrefix = "";
- String newFilePrefix = "";
- String positionInfo = "";
- String linePrefix = "";
+ String nullFilePrefix = ""; //$NON-NLS-1$
+ String newFilePrefix = ""; //$NON-NLS-1$
+ String positionInfo = ""; //$NON-NLS-1$
+ String linePrefix = ""; //$NON-NLS-1$
String pathString = file.getIResource().getProjectRelativePath().toString();
@@ -568,14 +572,14 @@ public class CVSTeamProvider extends RepositoryProvider {
case UNIFIED_FORMAT :
nullFilePrefix = "--- "; //$NON-NLS-1$
newFilePrefix = "+++ "; //$NON-NLS-1$
- positionInfo = "@@ -0,0 +1," + lines + " @@" ; //$NON-NLS-1$
+ positionInfo = "@@ -0,0 +1," + lines + " @@" ; //$NON-NLS-1$ //$NON-NLS-2$
linePrefix = "+"; //$NON-NLS-1$
break;
case CONTEXT_FORMAT :
nullFilePrefix = "*** "; //$NON-NLS-1$
newFilePrefix = "--- "; //$NON-NLS-1$
- positionInfo = "--- 1," + lines + " ----"; //$NON-NLS-1$
+ positionInfo = "--- 1," + lines + " ----"; //$NON-NLS-1$ //$NON-NLS-2$
linePrefix = "+ "; //$NON-NLS-1$
break;
@@ -613,7 +617,7 @@ public class CVSTeamProvider extends RepositoryProvider {
}
}
} catch (IOException e) {
- throw new CVSException(Policy.bind("java.io.IOException", pathString));
+ throw CVSException.wrapException(file.getIResource(), Policy.bind("CVSTeamProvider.errorAddingFileToDiff", pathString), e); //$NON-NLS-1$
} finally {
try {
fileReader.close();
@@ -639,32 +643,25 @@ public class CVSTeamProvider extends RepositoryProvider {
return;
}
- // Make a connection before preparing for the replace to avoid deletion of resources before a failed connection
- Session.run(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */,
- new ICVSRunnable() {
- public void run(IProgressMonitor progress) throws CVSException {
- // Prepare for the replace (special handling for "cvs added" and "cvs removed" resources
- progress.beginTask(null, 100);
- try {
- new PrepareForReplaceVisitor().visitResources(getProject(), resources, "CVSTeamProvider.scrubbingResource", depth, Policy.subMonitorFor(progress, 30)); //$NON-NLS-1$
-
- // Perform an update, ignoring any local file modifications
- List options = new ArrayList();
- options.add(Update.IGNORE_LOCAL_CHANGES);
- if(depth != IResource.DEPTH_INFINITE) {
- options.add(Command.DO_NOT_RECURSE);
- }
- LocalOption[] commandOptions = (LocalOption[]) options.toArray(new LocalOption[options.size()]);
- try {
- update(resources, commandOptions, tag, true /*createBackups*/, Policy.subMonitorFor(progress, 70));
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- }
- } finally {
- progress.done();
- }
- }
- }, progress);
+ // Make a connection before preparing for the replace to avoid deletion of resources before a failed connection
+ progress.beginTask(null, 100);
+ Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */);
+ session.open(Policy.subMonitorFor(progress,10));
+ try {
+ new PrepareForReplaceVisitor().visitResources(getProject(), resources, "CVSTeamProvider.scrubbingResource", depth, Policy.subMonitorFor(progress, 20)); //$NON-NLS-1$
+
+ List options = new ArrayList();
+ options.add(Update.IGNORE_LOCAL_CHANGES);
+ if(depth != IResource.DEPTH_INFINITE) {
+ options.add(Command.DO_NOT_RECURSE);
+ }
+ LocalOption[] commandOptions = (LocalOption[]) options.toArray(new LocalOption[options.size()]);
+
+ update(session, resources, commandOptions, tag, true /*createBackups*/, Policy.subMonitorFor(progress, 70));
+ } finally {
+ session.close();
+ progress.done();
+ }
}
/**
@@ -699,59 +696,60 @@ public class CVSTeamProvider extends RepositoryProvider {
final ICVSResource[] arguments = getCVSArguments(resources);
// Tag the remote resources
- Session s = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot());
- try {
- final IStatus status[] = new IStatus[] { null };
- if (versionTag != null) {
- // Version using a custom tag command that skips added but not commited reesources
- Session.run(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */,
- new ICVSRunnable( ) {
- public void run(IProgressMonitor monitor) throws CVSException {
- status[0] = Command.CUSTOM_TAG.execute(
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- versionTag,
- arguments,
- null,
- monitor);
- }
- }, Policy.subMonitorFor(monitor, 40));
- if (status[0].isOK()) {
- // Branch using the tag
- Session.run(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */,
- new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- status[0] = Command.CUSTOM_TAG.execute(
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- branchTag,
- arguments,
- null,
- monitor);
- }
- }, Policy.subMonitorFor(monitor, 20));
+ IStatus status = null;
+ if (versionTag != null) {
+ // Version using a custom tag command that skips added but not commited reesources
+ Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 5));
+ try {
+ status = Command.CUSTOM_TAG.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ Command.NO_LOCAL_OPTIONS,
+ versionTag,
+ arguments,
+ null,
+ Policy.subMonitorFor(monitor, 35));
+ } finally {
+ session.close();
+ }
+ if (status.isOK()) {
+ // Branch using the tag
+ session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 5));
+ try {
+ status = Command.CUSTOM_TAG.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ Command.NO_LOCAL_OPTIONS,
+ branchTag,
+ arguments,
+ null,
+ Policy.subMonitorFor(monitor, 15));
+ } finally {
+ session.close();
}
- } else {
- // Just branch using tag
- Session.run(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */,
- new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- status[0] = Command.CUSTOM_TAG.execute(
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- branchTag,
- arguments,
- null,
- monitor);
- }
- }, Policy.subMonitorFor(monitor, 40));
-
}
- if ( ! status[0].isOK()) {
- throw new CVSServerException(status[0]);
+ } else {
+ // Just branch using tag
+ Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 5));
+ try {
+ status = Command.CUSTOM_TAG.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ Command.NO_LOCAL_OPTIONS,
+ branchTag,
+ arguments,
+ null,
+ Policy.subMonitorFor(monitor, 35));
+ } finally {
+ session.close();
}
- } finally {
- s.close();
+
+ }
+ if ( ! status.isOK()) {
+ throw new CVSServerException(status);
}
// Set the tag of the local resources to the branch tag (The update command will not
@@ -886,7 +884,18 @@ public class CVSTeamProvider extends RepositoryProvider {
*
* @param createBackups if true, creates .# files for updated files
*/
- public void update(IResource[] resources, LocalOption[] options, CVSTag tag, final boolean createBackups, IProgressMonitor progress) throws TeamException {
+ public void update(IResource[] resources, LocalOption[] options, CVSTag tag, boolean createBackups, IProgressMonitor progress) throws TeamException {
+ progress.beginTask(null, 100);
+ Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */);
+ session.open(Policy.subMonitorFor(progress,10));
+ try {
+ update(session, resources, options, tag, createBackups, Policy.subMonitorFor(progress, 90));
+ } finally {
+ session.close();
+ }
+ }
+
+ private void update(Session session, IResource[] resources, LocalOption[] options, CVSTag tag, boolean createBackups, IProgressMonitor progress) throws TeamException {
// Build the local options
List localOptions = new ArrayList();
@@ -900,16 +909,16 @@ public class CVSTeamProvider extends RepositoryProvider {
final LocalOption[] commandOptions = (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]);
final ICVSResource[] arguments = getCVSArguments(resources);
- Session.run(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */,
- new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- IStatus status = Command.UPDATE.execute(Command.NO_GLOBAL_OPTIONS, commandOptions, arguments,
- null, monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- }
- }, progress);
+ IStatus status = Command.UPDATE.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ commandOptions,
+ arguments,
+ null,
+ progress);
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ throw new CVSServerException(status);
+ }
}
/*
@@ -1103,10 +1112,11 @@ public class CVSTeamProvider extends RepositoryProvider {
/*** commit then admin the resources ***/
// compute the total work to be performed
- int totalWork = filesToCommit.size();
+ int totalWork = filesToCommit.size() + 1;
for (Iterator it = filesToAdmin.values().iterator(); it.hasNext();) {
List list = (List) it.next();
totalWork += list.size();
+ totalWork += 1; // Add 1 for each connection that needs to be made
}
if (totalWork != 0) {
monitor.beginTask(Policy.bind("CVSTeamProvider.settingKSubst"), totalWork); //$NON-NLS-1$
@@ -1115,21 +1125,25 @@ public class CVSTeamProvider extends RepositoryProvider {
// NOTE: The files are committed as text with conversions even if the
// resource sync info still says "binary".
if (filesToCommit.size() != 0) {
- Session.run(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */,
- new ICVSRunnable( ) {
- public void run(IProgressMonitor monitor) throws CVSException {
- String keywordChangeComment = comment;
- if (keywordChangeComment == null || keywordChangeComment.length() == 0)
- keywordChangeComment = Policy.bind("CVSTeamProvider.changingKeywordComment"); //$NON-NLS-1$
- result[0] = Command.COMMIT.execute(
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] { Commit.DO_NOT_RECURSE, Commit.FORCE,
- Commit.makeArgumentOption(Command.MESSAGE_OPTION, keywordChangeComment) },
- (ICVSResource[]) filesToCommit.toArray(new ICVSResource[filesToCommit.size()]),
- filesToCommitAsText,
- null, Policy.subMonitorFor(monitor, filesToCommit.size()));
- }
- }, Policy.subMonitorFor(monitor, filesToCommit.size()));
+ Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 1));
+ try {
+ String keywordChangeComment = comment;
+ if (keywordChangeComment == null || keywordChangeComment.length() == 0)
+ keywordChangeComment = Policy.bind("CVSTeamProvider.changingKeywordComment"); //$NON-NLS-1$
+ result[0] = Command.COMMIT.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ new LocalOption[] { Commit.DO_NOT_RECURSE, Commit.FORCE,
+ Commit.makeArgumentOption(Command.MESSAGE_OPTION, keywordChangeComment) },
+ (ICVSResource[]) filesToCommit.toArray(new ICVSResource[filesToCommit.size()]),
+ filesToCommitAsText,
+ null,
+ Policy.subMonitorFor(monitor, filesToCommit.size()));
+ } finally {
+ session.close();
+ }
+
// if errors were encountered, abort
if (! result[0].isOK()) return;
}
@@ -1145,16 +1159,19 @@ public class CVSTeamProvider extends RepositoryProvider {
final KSubstOption toKSubst = (KSubstOption) entry.getKey();
final List list = (List) entry.getValue();
// do it
- Session.run(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */,
- new ICVSRunnable( ) {
- public void run(IProgressMonitor monitor) throws CVSException {
- result[0] = Command.ADMIN.execute(Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] { toKSubst },
- (ICVSResource[]) list.toArray(new ICVSResource[list.size()]),
- new AdminKSubstListener(toKSubst),
- Policy.subMonitorFor(monitor, list.size()));
- }
- }, Policy.subMonitorFor(monitor, list.size()));
+ Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 1));
+ try {
+ result[0] = Command.ADMIN.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ new LocalOption[] { toKSubst },
+ (ICVSResource[]) list.toArray(new ICVSResource[list.size()]),
+ new AdminKSubstListener(toKSubst),
+ Policy.subMonitorFor(monitor, list.size()));
+ } finally {
+ session.close();
+ }
// if errors were encountered, abort
if (! result[0].isOK()) return;
}
@@ -1318,10 +1335,9 @@ public class CVSTeamProvider extends RepositoryProvider {
* This method captures the common behavior between the edit and unedit methods.
*/
private void notifyEditUnedit(final IResource[] resources, final boolean recurse, final boolean notifyServer, final ICVSResourceVisitor editUneditVisitor, IProgressMonitor monitor) throws CVSException {
- final IProgressMonitor progress = Policy.monitorFor(monitor);
final CVSException[] exception = new CVSException[] { null };
IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor pm) throws CoreException {
+ public void run(IProgressMonitor monitor) throws CoreException {
final ICVSResource[] cvsResources = getCVSArguments(resources);
// mark the files locally as being checked out
@@ -1336,27 +1352,33 @@ public class CVSTeamProvider extends RepositoryProvider {
// send the noop command to the server in order to deliver the notifications
if (notifyServer) {
- final boolean[] connected = new boolean[] { false };
+ monitor.beginTask(null, 100);
+ Session session = new Session(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true);
try {
- Session.run(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- connected[0] = true;
- Command.NOOP.execute(Command.NO_GLOBAL_OPTIONS, Command.NO_LOCAL_OPTIONS,
- cvsResources, null, monitor);
- }
- }, progress);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ } catch (CVSException e1) {
+ // If the connection cannot be opened, just exit normally.
+ // The notifications will be sent when a connection can be made
+ return;
+ }
+ try {
+ Command.NOOP.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ Command.NO_LOCAL_OPTIONS,
+ cvsResources,
+ null,
+ Policy.subMonitorFor(monitor, 90));
} catch (CVSException e) {
- // Only report the exception if we were able to connect.
- // If we couldn't connect, the notification will be sent the next time we do.
- if (connected[0]) exception[0] = e;
+ exception[0] = e;
} finally {
- progress.done();
+ monitor.done();
}
}
}
};
try {
- ResourcesPlugin.getWorkspace().run(workspaceRunnable, monitor);
+ ResourcesPlugin.getWorkspace().run(workspaceRunnable, Policy.monitorFor(monitor));
} catch (CoreException e) {
if (exception[0] == null) {
throw CVSException.wrapException(e);
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java
index e05339701..5f99078cc 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Add.java
@@ -72,25 +72,6 @@ public class Add extends Command {
}
}
return status;
- }
-
- /**
- * Since the arguments of the add are probably not managed, find a parent of at least
- * one argument that is a CVS folder.
- *
- * @see Command#getOpenSession(ICVSResource[])
- */
- protected Session getOpenSession(ICVSResource[] arguments) throws CVSException {
- for (int i = 0; i < arguments.length; i++) {
- ICVSResource cvsResource = arguments[i];
- if (cvsResource.isManaged()) {
- return super.getOpenSession(new ICVSResource[] { cvsResource });
- } else if (cvsResource.getParent().isCVSFolder()) {
- return super.getOpenSession(new ICVSResource[] { cvsResource.getParent() });
- }
- }
- // If no approrpiate resource was found, invoke the overriden method and let it fail.
- return super.getOpenSession(arguments);
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java
index 0b7541c74..9779eb93d 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java
@@ -17,7 +17,6 @@ import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -33,7 +32,6 @@ import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
import org.eclipse.team.internal.ccvs.core.client.listeners.IConsoleListener;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
/**
* Abstract base class for command requests.
@@ -630,7 +628,7 @@ public abstract class Command extends Request {
*/
public static LocalOption makeArgumentOption(LocalOption option, String argument) {
if(argument == null) {
- argument = "";
+ argument = ""; //$NON-NLS-1$
}
return new LocalOption(option.getOption(), argument); //$NON-NLS-1$
}
@@ -710,42 +708,26 @@ public abstract class Command extends Request {
}
/**
- * Execute a CVS command inside an ICVSRunnable passed to Session.run()
- * <p>
- * Dispatches the commands, retrieves the results, and determines whether or
- * not an error occurred. A listener may be supplied to capture message text
- * that would normally be written to the standard error and standard output
- * streams of a command line CVS client.
+ * Execute a CVS command on an array of ICVSResource. This method simply converts
+ * the ICVSResource to String paths relative to the local root of the session and
+ * invokes <code>execute(Session, GlobalOption[], LocalOption[], String[], ICommandOutputListener, IProgressMonitor)</code>.
* </p>
+ * @param session the open CVS session
* @param globalOptions the array of global options, or NO_GLOBAL_OPTIONS
* @param localOptions the array of local options, or NO_LOCAL_OPTIONS
- * @param arguments the array of arguments (usually filenames relative to localRoot), or NO_ARGUMENTS
+ * @param arguments the array of ICVSResource to be operated on
* @param listener the command output listener, or null to discard all messages
* @param monitor the progress monitor
* @return a status code indicating success or failure of the operation
* @throws CVSException if a fatal error occurs (e.g. connection timeout)
+ *
+ * @see Command#execute(Session, GlobalOption[], LocalOption[], String[], ICommandOutputListener, IProgressMonitor)
*/
- public final IStatus execute(GlobalOption[] globalOptions, LocalOption[] localOptions, ICVSResource[] arguments,
+ public final IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions, ICVSResource[] arguments,
ICommandOutputListener listener, IProgressMonitor pm) throws CVSException {
- Session openSession = getOpenSession(arguments);
- String[] stringArguments = convertArgumentsForOpenSession(arguments, openSession);
- return execute(openSession, globalOptions, localOptions, stringArguments, listener, pm);
- }
-
- protected Session getOpenSession(ICVSResource[] arguments) throws CVSException {
- // We assume that all the passed resources have the same root
- Session openSession;
- if (arguments == null || arguments.length == 0) {
- // If there are no arguments to the command, assume that the command is rooted at the workspace root
- openSession = Session.getOpenSession(CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot()));
- } else {
- openSession = Session.getOpenSession(arguments[0]);
- }
- if (openSession == null) {
- throw new CVSException(Policy.bind("Command.noOpenSession")); //$NON-NLS-1$
- }
- return openSession;
+ String[] stringArguments = convertArgumentsForOpenSession(arguments, session);
+ return execute(session, globalOptions, localOptions, stringArguments, listener, pm);
}
protected String[] convertArgumentsForOpenSession(ICVSResource[] arguments, Session openSession) throws CVSException {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java
index 463a91e7e..9bff4204f 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java
@@ -109,16 +109,15 @@ public class Commit extends Command {
protected void sendArguments(Session session, String[] arguments) throws CVSException {
}
- public final IStatus execute(GlobalOption[] globalOptions, LocalOption[] localOptions,
+ public final IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions,
ICVSResource[] arguments, Collection filesToCommitAsText,
ICommandOutputListener listener, IProgressMonitor pm) throws CVSException {
- Session openSession = getOpenSession(arguments);
- openSession.setTextTransferOverride(filesToCommitAsText);
+ session.setTextTransferOverride(filesToCommitAsText);
try {
- return super.execute(globalOptions, localOptions, arguments, listener, pm);
+ return super.execute(session, globalOptions, localOptions, arguments, listener, pm);
} finally {
- openSession.setTextTransferOverride(null);
+ session.setTextTransferOverride(null);
}
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java
index ea956d82d..6e7f20fc3 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/MTHandler.java
@@ -18,6 +18,13 @@ public class MTHandler extends ResponseHandler {
private String nextLine;
private boolean isLineAvailable;
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.core.client.ResponseHandler#getInstance()
+ */
+ ResponseHandler getInstance() {
+ return new MTHandler();
+ }
+
/**
* @see ResponseHandler#getResponseID()
*/
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java
index 288d8e22f..a83cca00b 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java
@@ -94,12 +94,11 @@ public class RTag extends RemoteCommand {
newArguments, null, monitor);
}
- public IStatus execute(GlobalOption[] globalOptions, LocalOption[] localOptions,
+ public IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions,
CVSTag sourceTag, CVSTag tag, ICVSRemoteResource[] arguments, IProgressMonitor monitor)
throws CVSException {
ICVSResource[] resources = (ICVSResource[])Arrays.asList(arguments).toArray(new ICVSResource[arguments.length]);
- Session session = getOpenSession(resources);
String[] stringArguments = convertArgumentsForOpenSession(arguments);
return execute(session, globalOptions, localOptions, sourceTag, tag, stringArguments, monitor);
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java
index b261f6dc1..5066ce408 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Request.java
@@ -36,7 +36,8 @@ public abstract class Request {
/*** Response handler map ***/
private static final Map responseHandlers = new HashMap();
- static {
+
+ private static void initializeHandlerCache() {
synchronized(responseHandlers) {
registerResponseHandler(new CheckedInHandler());
registerResponseHandler(new CopyHandler());
@@ -59,22 +60,32 @@ public abstract class Request {
registerResponseHandler(new TemplateHandler());
}
}
- protected static void registerResponseHandler(ResponseHandler handler) {
+ private static void registerResponseHandler(ResponseHandler handler) {
synchronized(responseHandlers) {
responseHandlers.put(handler.getResponseID(), handler);
}
}
- protected static void removeResponseHandler(String responseID) {
- synchronized(responseHandlers) {
- responseHandlers.remove(responseID);
- }
- }
- protected static ResponseHandler getResponseHandler(String responseID) {
+
+ /**
+ * This method is invoked by Session to get a mutable copy of the
+ * global list of acceptable response handlers.
+ *
+ * @return a map of reponse handlers
+ */
+ protected static Map getReponseHandlerMap() {
synchronized(responseHandlers) {
- return (ResponseHandler)responseHandlers.get(responseID);
+ if (responseHandlers.isEmpty()) {
+ initializeHandlerCache();
+ }
+ Map copy = new HashMap();
+ for (Iterator iter = responseHandlers.values().iterator(); iter.hasNext();) {
+ ResponseHandler handler = (ResponseHandler) iter.next();
+ copy.put(handler.getResponseID(), handler.getInstance());
+
+ }
+ return copy;
}
}
-
/**
* Prevents client code from instantiating us.
*/
@@ -181,7 +192,7 @@ public abstract class Request {
// handle message responses
} else if (response.equals("MT")) { //$NON-NLS-1$
// Handle the MT response
- MTHandler handler = (MTHandler) responseHandlers.get(response);
+ MTHandler handler = (MTHandler) session.getResponseHandler(response);
if (handler != null) {
handler.handle(session, argument, monitor);
} else {
@@ -216,7 +227,7 @@ public abstract class Request {
}
// handle other responses
} else {
- ResponseHandler handler = (ResponseHandler) responseHandlers.get(response);
+ ResponseHandler handler = (ResponseHandler) session.getResponseHandler(response);
if (handler != null) {
handler.handle(session, argument, monitor);
} else {
@@ -242,19 +253,4 @@ public abstract class Request {
protected String getServerErrorMessage() {
return Policy.bind("Command.serverError", Policy.bind("Command." + getRequestId())); //$NON-NLS-1$ //$NON-NLS-2$
}
-
- /**
- * Makes a list of all valid responses; for initializing a session.
- * @return a space-delimited list of all valid response strings
- */
- static String makeResponseList() {
- StringBuffer result = new StringBuffer("ok error M E"); //$NON-NLS-1$
- Iterator elements = responseHandlers.keySet().iterator();
- while (elements.hasNext()) {
- result.append(' ');
- result.append((String) elements.next());
- }
-
- return result.toString();
- }
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java
index 7e50eca0b..e3a00037e 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ResponseHandler.java
@@ -175,5 +175,13 @@ public abstract class ResponseHandler {
}
folder.mkdir();
}
+
+ /**
+ * Return as instance that can be used by an open session. Subclasses that contain
+ * session related state must override this message to return a copy of themselves.
+ */
+ /* package */ ResponseHandler getInstance() {
+ return this;
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
index a5d3bb2c8..1c6844236 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
@@ -45,7 +45,6 @@ import org.eclipse.team.internal.ccvs.core.ICVSFolder;
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.Policy;
import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption;
@@ -93,9 +92,6 @@ public class Session {
private static final boolean IS_CRLF_PLATFORM = Arrays.equals(
System.getProperty("line.separator").getBytes(), new byte[] { '\r', '\n' }); //$NON-NLS-1$
-
- private static Map currentOpenSessions = null;
- private static final int MAX_SESSIONS_OPEN = 10;
private CVSRepositoryLocation location;
private ICVSFolder localRoot;
@@ -115,6 +111,7 @@ public class Session {
// The resource bundle key that provides the file sending message
private String sendFileTitleKey;
+ private Map responseHandlers;
/**
* Creates a new CVS session, initially in the CLOSED state.
@@ -140,129 +137,6 @@ public class Session {
this.outputToConsole = outputToConsole;
}
- /**
- * Execute the given runnable in a context that has access to an open session
- *
- * A session will be opened for the provided root. If the root is null, no session is opened.
- * However, sessions will be open for nested calls to run and these sessions will not be closed
- * until the outer most run finishes.
- */
- public static void run(final ICVSRepositoryLocation location, final ICVSFolder root, final boolean outputToConsole,
- final ICVSRunnable runnable, final IProgressMonitor monitor) throws CVSException {
-
- // Serialize runnables to allow only one thread to run at a time.
- // TODO: The following removed due to bug 40129
-// CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot()).run(new ICVSRunnable() {
-// public void run(IProgressMonitor monitor) throws CVSException {
- internalRun(location, root, outputToConsole, runnable, monitor);
-// }
-// }, monitor);
- }
-
- private static void internalRun(ICVSRepositoryLocation location, ICVSFolder root, boolean outputToConsole,
- ICVSRunnable runnable, IProgressMonitor monitor) throws CVSException {
-
- // Determine if we are nested or not
- boolean isOuterRun = false;
- if (currentOpenSessions == null) {
- // Initialize the variable to be a map
- currentOpenSessions = new HashMap();
- isOuterRun = true;
- }
-
- try {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- if (root == null) {
- // We don't have a root, so just run the runnable
- // (assuming that nested runs will create sessions)
- runnable.run(Policy.subMonitorFor(monitor, 90));
- } else {
- // Open a session on the root as far up the chain as possible
- ICVSFolder actualRoot = root;
- while (actualRoot.isManaged()) {
- actualRoot = actualRoot.getParent();
- }
- // Look for the root in the current open sessions
- Session session = (Session)currentOpenSessions.get(actualRoot);
- if (session == null) {
- // Make sure we don't exceed our maximum
- if (currentOpenSessions.size() == MAX_SESSIONS_OPEN) {
- // Pick one at random and close it
- Object key = currentOpenSessions.keySet().iterator().next();
- try {
- ((Session)currentOpenSessions.get(key)).close();
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- } finally {
- currentOpenSessions.remove(key);
- }
- }
- // If it's not there, open a session for the given root and remember it
- session = new Session(location, actualRoot, outputToConsole);
- session.open(Policy.subMonitorFor(monitor, 10));
- currentOpenSessions.put(actualRoot, session);
- }
-
- try {
- root.run(runnable, Policy.subMonitorFor(monitor, 100));
- } catch (CVSException e) {
- // The run didn't succeed so close the session and forget it ever existed
- try {
- // The session may have been close by a nested run
- if (currentOpenSessions.get(actualRoot) != null) session.close();
- } finally {
- currentOpenSessions.remove(actualRoot);
- throw e;
- }
- }
- }
- } finally {
- monitor.done();
- if (isOuterRun) {
- // Close all open sessions
- try {
- Iterator iter = currentOpenSessions.keySet().iterator();
- while (iter.hasNext()) {
- Session session = (Session)currentOpenSessions.get(iter.next());
- try {
- session.close();
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- }
- } finally {
- currentOpenSessions = null;
- }
- }
- }
- }
-
- /**
- * Answer the currently open session
- */
- protected static Session getOpenSession(ICVSResource resource) throws CVSException {
- ICVSFolder root;
- if (resource.isFolder()) {
- root = (ICVSFolder)resource;
- } else {
- root = resource.getParent();
- }
- // go to the top of the management chain
- while (root.isManaged()) {
- root = root.getParent();
- }
- // Look for the root in the current open sessions
- Session session;
- do {
- session = (Session)currentOpenSessions.get(root);
- if (session != null) return session;
- // we should have found it the first time but continue up the chain
- root = root.getParent();
- } while (root != null);
- return null;
- }
-
/**
* Register a case collision with the session.
*
@@ -319,26 +193,15 @@ public class Session {
try {
connection = location.openConnection(Policy.subMonitorFor(monitor, 50));
- ResponseHandler mtHandler = Request.getResponseHandler("MT"); //$NON-NLS-1$
- // accept MT messages for all non-standard server
+ // If we're connected to a CVSNT server or we don't know the platform,
+ // accept MT. Otherwise don't.
boolean useMT = ! (location.getServerPlatform() == CVSRepositoryLocation.CVS_SERVER);
- try {
- // If we're connected to a CVSNT server or we don't know the platform,
- // accept MT. Otherwise don't.
- // We only want to disable MT messages for this particular session
- // since there may be multiple sessions open.
- if ( ! useMT) {
- Request.removeResponseHandler("MT"); //$NON-NLS-1$
- }
-
- // tell the server the names of the responses we can handle
- connection.writeLine("Valid-responses " + Request.makeResponseList()); //$NON-NLS-1$
- } finally {
- // Re-register the MT handler since there may be more than one session open
- if ( ! useMT) {
- Request.registerResponseHandler(mtHandler);
- }
+ if ( ! useMT) {
+ removeResponseHandler("MT"); //$NON-NLS-1$
}
+
+ // tell the server the names of the responses we can handle
+ connection.writeLine("Valid-responses " + makeResponseList()); //$NON-NLS-1$
// ask for the set of valid requests
IStatus status = Request.VALID_REQUESTS.execute(this, Policy.subMonitorFor(monitor, 40));
@@ -1238,4 +1101,41 @@ public class Session {
return oldPath.toString();
}
+ /*
+ * Get the response handler map to be used for this session. The map is created by making a copy of the global
+ * reponse handler map.
+ */
+ protected Map getReponseHandlers() {
+ if (responseHandlers == null) {
+ responseHandlers = Request.getReponseHandlerMap();
+ }
+ return responseHandlers;
+ }
+
+ /*
+ * Makes a list of all valid responses; for initializing a session.
+ * @return a space-delimited list of all valid response strings
+ */
+ private String makeResponseList() {
+ StringBuffer result = new StringBuffer("ok error M E"); //$NON-NLS-1$
+ Iterator elements = getReponseHandlers().keySet().iterator();
+ while (elements.hasNext()) {
+ result.append(' ');
+ result.append((String) elements.next());
+ }
+
+ return result.toString();
+ }
+ protected void registerResponseHandler(ResponseHandler handler) {
+ getReponseHandlers().put(handler.getResponseID(), handler);
+ }
+
+ protected void removeResponseHandler(String responseID) {
+ getReponseHandlers().remove(responseID);
+ }
+
+ protected ResponseHandler getResponseHandler(String responseID) {
+ return (ResponseHandler)getReponseHandlers().get(responseID);
+ }
+
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java
index 7248a2f20..e7dba043e 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java
@@ -79,11 +79,10 @@ public class Tag extends Command {
return execute(session, globalOptions, localOptions, newArguments, listener, monitor);
}
- public IStatus execute(GlobalOption[] globalOptions, LocalOption[] localOptions,
+ public IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions,
CVSTag tag, ICVSResource[] arguments, ICommandOutputListener listener, IProgressMonitor monitor)
throws CVSException {
- Session session = getOpenSession(arguments);
String[] stringArguments = convertArgumentsForOpenSession(arguments, session);
return execute(session, globalOptions, localOptions, tag, stringArguments, listener, monitor);
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java
index 5e0840ae7..d685e99ce 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java
@@ -100,23 +100,6 @@ public class Update extends Command {
}
/**
- * Convenience method that allows the creation of .# files to be disabled.
- * @param createBackups if true, creates .# files
- * @see Command.execute
- */
- public final IStatus execute(GlobalOption[] globalOptions,
- LocalOption[] localOptions, ICVSResource[] arguments, ICommandOutputListener listener,
- IProgressMonitor pm, boolean createBackups) throws CVSException {
-
- Session s = getOpenSession(arguments);
- s.setCreateBackups(createBackups);
- try {
- return super.execute(globalOptions, localOptions, arguments, listener, pm);
- } finally {
- s.setCreateBackups(true);
- }
- }
- /**
* On successful finish, prune empty directories if the -P or -D option was specified.
*/
protected IStatus commandFinished(Session session, GlobalOption[] globalOptions,
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java
index 407cfd392..84b28180d 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java
@@ -48,7 +48,7 @@ public class UpdateMergableOnly extends Update {
String adjustedFileName = fileName;
if (ResourceSyncInfo.isMergedWithConflicts(entryBytes)) {
// for merged-with-conflict, return a temp file
- adjustedFileName = ".##" + adjustedFileName;
+ adjustedFileName = ".##" + adjustedFileName; //$NON-NLS-1$
skippedFiles.add(((IContainer)mParent.getIResource()).getFile(new Path(fileName)));
}
return super.getTargetFile(mParent, adjustedFileName, entryBytes);
@@ -90,10 +90,10 @@ public class UpdateMergableOnly extends Update {
throws CVSException {
MergableOnlyUpdatedHandler newHandler = new MergableOnlyUpdatedHandler();
- ResponseHandler oldHandler = getResponseHandler(newHandler.getResponseID());
+ ResponseHandler oldHandler = session.getResponseHandler(newHandler.getResponseID());
skippedFiles.clear();
try {
- registerResponseHandler(newHandler);
+ session.registerResponseHandler(newHandler);
return super.doExecute(
session,
globalOptions,
@@ -102,7 +102,7 @@ public class UpdateMergableOnly extends Update {
listener,
monitor);
} finally {
- registerResponseHandler(oldHandler);
+ session.registerResponseHandler(oldHandler);
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java
index 140a32e23..abb426e3f 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java
@@ -43,9 +43,6 @@ public class Version extends RemoteCommand {
public IStatus execute(Session session, final ICVSRepositoryLocation location, IProgressMonitor monitor) throws CVSException {
// The server may not support the version request
- if (session == null) {
- session = getOpenSession(null);
- }
if ( ! session.isValidRequest(getRequestId())) {
IStatus status = new CVSStatus(IStatus.WARNING, CVSStatus.SERVER_IS_UNKNOWN, Policy.bind("Version.versionNotValidRequest", location.getHost()));//$NON-NLS-1$
((CVSRepositoryLocation)location).setServerPlaform(status);
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java
index cfcfc08d9..bdb1d76c5 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java
@@ -39,12 +39,10 @@ import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSStatus;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
import org.eclipse.team.internal.ccvs.core.IConnectionMethod;
import org.eclipse.team.internal.ccvs.core.IUserAuthenticator;
import org.eclipse.team.internal.ccvs.core.IUserInfo;
@@ -481,25 +479,30 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit
*/
public void validateConnection(IProgressMonitor monitor) throws CVSException {
try {
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(null, 100);
ICVSFolder root = CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot());
- Session.run(this, root, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- IStatus status = Command.VERSION.execute(null, CVSRepositoryLocation.this, monitor);
- // Log any non-ok status
- if (! status.isOK()) {
- CVSProviderPlugin.log(status);
- }
- if (getServerPlatform() == CVSNT_SERVER) {
- // check for the use of a repository prefix
- if (getRootDirectory().startsWith(Session.SERVER_SEPARATOR)) {
- // A prefix is in use. Log a warning
- CVSProviderPlugin.log(IStatus.WARNING, Policy.bind("CVSRepositoryLocation.cvsntPrefix", getLocation()), null); //$NON-NLS-1$
- throw new CVSAuthenticationException(new Status(IStatus.WARNING, CVSProviderPlugin.ID, 0,
- Policy.bind("CVSRepositoryLocation.cvsntPrefix", getLocation()), null)); //$NON-NLS-1$
- }
- }
+ Session session = new Session(this, root, false /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 50));
+ try {
+ IStatus status = Command.VERSION.execute(session, this, Policy.subMonitorFor(monitor, 50));
+ // Log any non-ok status
+ if (! status.isOK()) {
+ CVSProviderPlugin.log(status);
+ }
+ } finally {
+ session.close();
+ monitor.done();
+ }
+ if (getServerPlatform() == CVSNT_SERVER) {
+ // check for the use of a repository prefix
+ if (getRootDirectory().startsWith(Session.SERVER_SEPARATOR)) {
+ // A prefix is in use. Log a warning
+ CVSProviderPlugin.log(IStatus.WARNING, Policy.bind("CVSRepositoryLocation.cvsntPrefix", getLocation()), null); //$NON-NLS-1$
+ throw new CVSAuthenticationException(new Status(IStatus.WARNING, CVSProviderPlugin.ID, 0,
+ Policy.bind("CVSRepositoryLocation.cvsntPrefix", getLocation()), null)); //$NON-NLS-1$
}
- }, monitor);
+ }
} catch (CVSException e) {
// If the validation failed, dispose of any cached info
dispose();
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
index ec9d9cc4d..d14eae708 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
@@ -104,6 +104,7 @@ CVSTeamProvider.overlappingRemoteFolder=Cannot create linked resource ''{0}'' be
CVSTeamProvider.overlappingFileDeletion=Cannot create linked resource ''{0}'' because a deletion for the file of that name has not been committed.
CVSTeamProvider.errorGettingWatchEdit=Could not get "watch/edit" property for project ''{0}''.
CVSTeamProvider.errorSettingWatchEdit=Could not set "watch/edit" property for project ''{0}''.
+CVSTeamProvider.errorAddingFileToDiff=An I/O error occurred adding file ''{0}'' to the patch output.
ProjectDescriptionManager.unableToSetDescription=An error occurred setting the project description
ProjectDescriptionManager.unableToReadDescription=An error occurred reading the project description
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java
index 69ba9d922..757aa8e77 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java
@@ -224,81 +224,6 @@ public class CVSWorkspaceRoot {
}
}
- /**
- * Checkout the remote resources into the provided local folder.
- */
- public static void checkout(final ICVSRemoteFolder resource, final IContainer target, final boolean configure, final boolean recurse, final IProgressMonitor monitor) throws TeamException {
- final TeamException[] eHolder = new TeamException[1];
- try {
- IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor pm) throws CoreException {
- try {
- pm.beginTask(null, 1000);
-
- final ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(target);
-
- // Delete the target folder if it exists.
- String folderName = cvsFolder.getName();
- if (cvsFolder.exists()) {
- // Unmanage first so we don't get outgoing deletions
- cvsFolder.unmanage(Policy.subMonitorFor(pm, 50));
- cvsFolder.delete();
- }
-
- // Prepare the target to receive the contents of the directory
- cvsFolder.mkdir();
- cvsFolder.setFolderSyncInfo(resource.getFolderSyncInfo());
-
- // Open a connection session to the repository
- ICVSRepositoryLocation repository = resource.getRepository();
- Session.run(repository, cvsFolder, true, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- List localOptions = new ArrayList();
- // Add recurse option
- if (!recurse)
- localOptions.add(Update.DO_NOT_RECURSE);
- // Perform the checkout using the update command
- // We use update to avoid communicating info about the parent
- // directory which may or may not be shared with CVS
- IStatus status = Command.UPDATE.execute(
- Command.NO_GLOBAL_OPTIONS,
- (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]),
- new ICVSResource[]{ cvsFolder },
- null,
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- }
- }, Policy.subMonitorFor(pm, 800));
- if (configure) {
- manageFolder(cvsFolder, repository.getLocation());
- refreshProjects(new IProject[] { target.getProject() }, Policy.subMonitorFor(pm, 50));
- } else {
- cvsFolder.unmanage(Policy.subMonitorFor(pm, 50));
- }
- }
- catch (TeamException e) {
- // Pass it outside the workspace runnable
- eHolder[0] = e;
- } finally {
- pm.done();
- }
- // CoreException and OperationCanceledException are propagated
- }
- };
- ResourcesPlugin.getWorkspace().run(workspaceRunnable, monitor);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- } finally {
- monitor.done();
- }
- // Re-throw the TeamException, if one occurred
- if (eHolder[0] != null) {
- throw eHolder[0];
- }
- }
-
private static void manageFolder(ICVSFolder folder, String root) throws CVSException {
// Ensure that the parent is a CVS folder
ICVSFolder parent = folder.getParent();
@@ -674,20 +599,40 @@ public class CVSWorkspaceRoot {
}
public static ICVSRemoteResource getRemoteTree(IResource resource, CVSTag tag, IProgressMonitor progress) throws TeamException {
+ return getRemoteTree(resource, tag, false /* cache file contents hint */, progress);
+ }
+
+ public static ICVSRemoteResource getRemoteTree(IResource resource, CVSTag tag, boolean cacheFileContentsHint, IProgressMonitor progress) throws TeamException {
ICVSResource managed = CVSWorkspaceRoot.getCVSResourceFor(resource);
ICVSRemoteResource remote = CVSWorkspaceRoot.getRemoteResourceFor(resource);
if (remote == null) {
- remote = getRemoteTreeFromParent(resource, managed, tag, progress);
+ progress.beginTask(null, 100);
+ remote = getRemoteTreeFromParent(resource, managed, tag, Policy.subMonitorFor(progress, 50));
+ if (cacheFileContentsHint && remote != null && remote instanceof RemoteFile) {
+ RemoteFile file = (RemoteFile)remote;
+ if (!file.isContentsCached()) {
+ file.fetchContents(Policy.subMonitorFor(progress, 50));
+ }
+ }
+ progress.done();
} else if(resource.getType() == IResource.FILE) {
ICVSRepositoryLocation location = remote.getRepository();
- remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFile)managed, tag, progress);
+ if (cacheFileContentsHint) {
+ remote = FileContentCachingService.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFile)managed, tag, progress);
+ } else {
+ remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFile)managed, tag, progress);
+ }
} else {
ICVSRepositoryLocation location = remote.getRepository();
- remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress);
+ if (cacheFileContentsHint) {
+ remote = FileContentCachingService.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress);
+ } else {
+ remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress);
+ }
}
return remote;
}
-
+
public static boolean hasRemote(IResource resource) {
try {
ICVSResource cvsResource = getCVSResourceFor(resource);
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java
index 0a1d7bc88..96c58f66a 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java
@@ -37,6 +37,7 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.ILock;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSStatus;
@@ -411,7 +412,14 @@ public class EclipseSynchronizer {
*/
public void beginOperation(IResource resource, IProgressMonitor monitor) throws CVSException {
// ensure locks are acquired in the same order: workspace then cvs
- Platform.getJobManager().beginRule(resource);
+ // The scheduling rule is either the project or the resource's parent
+ ISchedulingRule rule;
+ if (resource.getType() == IResource.PROJECT || resource.getType() == IResource.ROOT) {
+ rule = resource;
+ } else {
+ rule = resource.getParent();
+ }
+ Platform.getJobManager().beginRule(rule);
lock.acquire();
if (lock.getDepth() == 1) {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileContentCachingService.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileContentCachingService.java
new file mode 100644
index 000000000..a1c0d02df
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/FileContentCachingService.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.core.resources;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.CVSTag;
+import org.eclipse.team.internal.ccvs.core.ICVSFile;
+import org.eclipse.team.internal.ccvs.core.ICVSFolder;
+import org.eclipse.team.internal.ccvs.core.ICVSResource;
+import org.eclipse.team.internal.ccvs.core.Policy;
+import org.eclipse.team.internal.ccvs.core.client.Command;
+import org.eclipse.team.internal.ccvs.core.client.Session;
+import org.eclipse.team.internal.ccvs.core.client.Update;
+import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
+import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
+
+/**
+ * This class can be used to fetch and cache file contents for remote files.
+ */
+public class FileContentCachingService {
+
+ String[] fileDiffs;
+ private CVSRepositoryLocation repository;
+ private ICVSFolder remoteRoot;
+
+ public static RemoteFolderTree buildRemoteTree(CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag, IProgressMonitor monitor) throws CVSException {
+ monitor.beginTask(null, 100);
+ try {
+ RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, root, tag);
+ RemoteFolderTree tree = builder.buildTree(new ICVSResource[] { root }, Policy.subMonitorFor(monitor, 50));
+ FileContentCachingService service = new FileContentCachingService(repository, tree, builder.getFileDiffs());
+ service.cacheFileContents(Policy.subMonitorFor(monitor, 50));
+ return tree;
+ } finally {
+ monitor.done();
+ }
+ }
+
+ public static RemoteFile buildRemoteTree(CVSRepositoryLocation repository, ICVSFile file, CVSTag tag, IProgressMonitor monitor) throws CVSException {
+ monitor.beginTask(null, 100);
+ try {
+ RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, file.getParent(), tag);
+ RemoteFile remote = builder.buildTree(file, monitor);
+ if (builder.getFileDiffs().length > 0 && !remote.isContentsCached()) {
+ remote.fetchContents(Policy.subMonitorFor(monitor, 50));
+ }
+ return remote;
+ } finally {
+ monitor.done();
+ }
+ }
+
+ public FileContentCachingService(CVSRepositoryLocation repository, RemoteFolderTree tree, String[] fileDiffs) {
+ this.repository = repository;
+ this.remoteRoot = tree;
+ this.fileDiffs = fileDiffs;
+ }
+
+ private void cacheFileContents(IProgressMonitor monitor) throws CVSException {
+ String[] files = getUncachedFiles();
+ if (files.length == 0) return;
+ // Fetch the file contents for all out-of-sync files by running an update
+ // on the remote tree passing the known changed files as arguments
+ monitor.beginTask(null, 10 + files.length * 100);
+ Policy.checkCanceled(monitor);
+ Session session = new Session(repository, remoteRoot, false);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ Policy.checkCanceled(monitor);
+ IStatus status = Command.UPDATE.execute(session,
+ Command.NO_GLOBAL_OPTIONS,
+ new LocalOption[] { Update.IGNORE_LOCAL_CHANGES },
+ files,
+ null,
+ Policy.subMonitorFor(monitor, files.length * 100));
+ } finally {
+ session.close();
+ monitor.done();
+ }
+ }
+
+ /*
+ * Only return those file in the diff list that exist remotely and whose contents are not already cached
+ */
+ private String[] getUncachedFiles() {
+ if (fileDiffs.length == 0) return fileDiffs;
+ List existing = new ArrayList();
+ for (int i = 0; i < fileDiffs.length; i++) {
+ String filePath = fileDiffs[i];
+ try {
+ ICVSFile file = remoteRoot.getFile(filePath);
+ if (file instanceof RemoteFile) {
+ if (!((RemoteFile)file).isContentsCached()) {
+ existing.add(filePath);
+ }
+ }
+ } catch (CVSException e) {
+ // The child does not exists so exclude it
+ }
+ }
+ return (String[]) existing.toArray(new String[existing.size()]);
+ }
+}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
index ba1ab2071..46f671413 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
@@ -10,17 +10,9 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.core.resources;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -30,10 +22,10 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteResource;
+import org.eclipse.team.core.sync.RemoteContentsCache;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSStatus;
@@ -46,7 +38,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,79 +149,86 @@ 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];
- }
- }
+ /* package*/ 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)
*/
public ILogEntry getLogEntry(IProgressMonitor monitor) throws CVSException {
if (entry == null) {
- Session.run(getRepository(), parent, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100); //$NON-NLS-1$
- try {
- final List entries = new ArrayList();
- IStatus status = Command.LOG.execute(
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] {
- Log.makeRevisionOption(getRevision())},
- new ICVSResource[] { RemoteFile.this },
- new LogListener(RemoteFile.this, entries),
- Policy.subMonitorFor(monitor, 100));
- if (entries.size() == 1) {
- entry = (ILogEntry)entries.get(0);
- }
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- monitor.done();
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100); //$NON-NLS-1$
+ Session session = new Session(getRepository(), parent, false /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ try {
+ final List entries = new ArrayList();
+ IStatus status = Command.LOG.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ new LocalOption[] {
+ Log.makeRevisionOption(getRevision())},
+ new ICVSResource[] { RemoteFile.this },
+ new LogListener(RemoteFile.this, entries),
+ Policy.subMonitorFor(monitor, 90));
+ if (entries.size() == 1) {
+ entry = (ILogEntry)entries.get(0);
}
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ throw new CVSServerException(status);
+ }
+ } finally {
+ monitor.done();
}
- }, monitor);
+ } finally {
+ session.close();
+ }
}
return entry;
}
@@ -239,26 +237,30 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
* @see ICVSRemoteFile#getLogEntries()
*/
public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws CVSException {
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100); //$NON-NLS-1$
final List entries = new ArrayList();
- Session.run(getRepository(), parent, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100); //$NON-NLS-1$
- QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
- try {
- CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
- IStatus status = Command.LOG.execute(Command.NO_GLOBAL_OPTIONS, Command.NO_LOCAL_OPTIONS,
- new ICVSResource[] { RemoteFile.this }, new LogListener(RemoteFile.this, entries),
- Policy.subMonitorFor(monitor, 100));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- CVSProviderPlugin.getPlugin().setQuietness(quietness);
- monitor.done();
+ Session session = new Session(getRepository(), parent, false /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
+ try {
+ CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
+ IStatus status = Command.LOG.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS, Command.NO_LOCAL_OPTIONS,
+ new ICVSResource[] { RemoteFile.this }, new LogListener(RemoteFile.this, entries),
+ Policy.subMonitorFor(monitor, 90));
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ throw new CVSServerException(status);
}
+ } finally {
+ CVSProviderPlugin.getPlugin().setQuietness(quietness);
+ monitor.done();
}
- }, monitor);
+ } finally {
+ session.close();
+ }
return (ILogEntry[])entries.toArray(new ILogEntry[entries.size()]);
}
@@ -292,18 +294,9 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
*/
public long getSize() {
if (contents == null) {
- try {
- File ioFile = getCacheFile();
- if (ioFile.exists()) {
- return ioFile.length();
- }
- } catch (IOException e) {
- // Try to purge the cache and continue
- try {
- clearCachedContents();
- } catch (IOException e2) {
- }
- CVSProviderPlugin.log(CVSException.wrapException(e));
+ File ioFile = getRemoteContentsCache().getFile(getCacheRelativePath());
+ if (ioFile.exists()) {
+ return ioFile.length();
}
}
return contents == null ? 0 : contents.length;
@@ -370,52 +363,46 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
return new ByteArrayInputStream(contents == null ? new byte[0] : contents);
}
+ private InputStream getCachedContents() throws CVSException {
+ try {
+ return getRemoteContentsCache().getContents(getCacheRelativePath());
+ } catch (TeamException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
public void setContents(InputStream stream, int responseType, boolean keepLocalHistory, IProgressMonitor monitor) throws CVSException {
try {
- try {
- byte[] buffer = new byte[1024];
- ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
- OutputStream out = byteStream;
- int read;
- try {
- try {
- while ((read = stream.read(buffer)) >= 0) {
- Policy.checkCanceled(monitor);
- out.write(buffer, 0, read);
- // Detect when the file is getting too big to keep in memory
- // and switch to a caching strategy for the contents of the file
- if (out == byteStream && byteStream.size() > CACHING_THRESHOLD) {
- // Switch streams
- byteStream.close();
- out = switchToCacheOutputStream(byteStream);
- // Continue looping until the whole file is read
- }
- }
- } finally {
- out.close();
- }
- } catch (IOException e) {
- // Make sure we don't leave the cache file around as it may not have the right contents
- if (byteStream != out) {
- clearCachedContents();
- }
- throw e;
- }
-
- // Set the contents if we didn't cache them to disk
- if (out instanceof ByteArrayOutputStream) {
- contents = ((ByteArrayOutputStream)out).toByteArray();
- } else {
- contents = null;
- }
- } finally {
- stream.close();
- }
- } catch(IOException e) {
+ getRemoteContentsCache().setContents(getCacheRelativePath(), stream, monitor);
+ } catch (TeamException e) {
throw CVSException.wrapException(e);
}
}
+ private RemoteContentsCache getRemoteContentsCache() {
+ return RemoteContentsCache.getCache(CVSProviderPlugin.ID);
+ }
+
+ /*
+ * Return the cache relative path for the receiver as
+ * host/cvs/root/module/path/.#filename revision
+ */
+ private String getCacheRelativePath() {
+ ICVSRepositoryLocation location = getRepository();
+ IPath path = new Path(location.getHost());
+ path = path.append(location.getRootDirectory());
+ path = path.append(parent.getRepositoryRelativePath());
+ path = path.append(getName() + ' ' + getRevision());
+ return path.toString();
+ }
+
+ /*
+ * Return whether there are already contents cached for the given handle
+ */
+ public boolean isContentsCached() {
+ return getRemoteContentsCache().hasContents(getCacheRelativePath());
+ }
+
/*
* @see ICVSFile#setReadOnly(boolean)
*/
@@ -476,24 +463,23 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
* The revision of the remote file is used as the base for the tagging operation
*/
public IStatus tag(final CVSTag tag, final LocalOption[] localOptions, IProgressMonitor monitor) throws CVSException {
- final IStatus[] result = new IStatus[] { null };
- Session.run(getRepository(), this.getParent(), true, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- result[0] = Command.RTAG.execute(
- Command.NO_GLOBAL_OPTIONS,
- localOptions,
- new CVSTag(getRevision(), CVSTag.VERSION),
- tag,
- new ICVSRemoteResource[] { RemoteFile.this },
- monitor);
- }
- }, monitor);
- return result[0];
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(null, 100);
+ Session session = new Session(getRepository(), getParent(), true /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ return Command.RTAG.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ localOptions,
+ new CVSTag(getRevision(), CVSTag.VERSION),
+ tag,
+ new ICVSRemoteResource[] { RemoteFile.this },
+ Policy.subMonitorFor(monitor, 90));
+ } finally {
+ session.close();
+ }
}
-
- public boolean updateRevision(CVSTag tag, IProgressMonitor monitor) throws CVSException {
- return parent.updateRevision(this, tag, monitor);
- }
public boolean equals(Object target) {
if (this == target)
@@ -503,74 +489,6 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
RemoteFile remote = (RemoteFile) target;
return super.equals(target) && remote.getRevision().equals(getRevision());
}
-
- /*
- * Return the cache relative path for the receiver as
- * host/cvs/root/module/path/.#filename revision
- */
- private String getCacheRelativePath() {
- ICVSRepositoryLocation location = getRepository();
- IPath path = new Path(location.getHost());
- path = path.append(location.getRootDirectory());
- path = path.append(parent.getRepositoryRelativePath());
- path = path.append(getName() + ' ' + getRevision());
- return path.toString();
- }
-
- private File getCacheFile() throws IOException {
- return CVSProviderPlugin.getPlugin().getCacheFileFor(getCacheRelativePath());
- }
-
- private void clearCachedContents() throws IOException {
- try {
- File ioFile = getCacheFile();
- if (ioFile.exists()) {
- ioFile.delete();
- }
- } catch (IOException e) {
- CVSProviderPlugin.log(CVSException.wrapException(e));
- }
- }
-
- private InputStream getCachedContents() throws CVSException {
- try {
- try {
- File ioFile = getCacheFile();
- if (ioFile.exists()) {
- return new BufferedInputStream(new FileInputStream(ioFile));
- }
- } catch (IOException e) {
- // Try to purge the cache and continue
- clearCachedContents();
- throw e;
- }
- } catch (IOException e) {
- // We will end up here if we couldn't read or delete the cache file
- throw new CVSException(new CVSStatus(IStatus.ERROR, 0, Policy.bind("RemoteFile.errorRetrievingFromCache", e.getMessage()), e));//$NON-NLS-1$
- }
- return null;
- }
-
- private OutputStream switchToCacheOutputStream(ByteArrayOutputStream byteStream) throws IOException {
- // Get the cache file and make sure it's parent exists
- File ioFile = getCacheFile();
- if ( ! ioFile.getParentFile().exists()) {
- ioFile.getParentFile().mkdirs();
- }
- // Switch streams
- OutputStream out;
- try {
- out = new BufferedOutputStream(new FileOutputStream(ioFile));
- } catch (FileNotFoundException e) {
- // Could not find the file. Perhaps the name is too long. (bug 20696)
- CVSProviderPlugin.log(IStatus.ERROR, Policy.bind("RemoteFile.Could_not_cache_remote_contents_to_disk._Caching_remote_file_in_memory_instead._1"), e); //$NON-NLS-1$
- // Resort to in-memory storage of the remote file
- out = new ByteArrayOutputStream();
- }
- // Write what we've read so far
- out.write(byteStream.toByteArray());
- return out;
- }
/**
* @see org.eclipse.team.internal.ccvs.core.ICVSFile#checkout(int)
@@ -651,8 +569,9 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
* @see org.eclipse.team.core.sync.IRemoteResource#getComment()
*/
public String getComment() throws CVSException {
- ILogEntry entry = getLogEntry(new NullProgressMonitor());
- return entry.getComment();
+// ILogEntry entry = getLogEntry(new NullProgressMonitor());
+// return entry.getComment();
+ return "";
}
/* (non-Javadoc)
@@ -666,7 +585,8 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
* @see org.eclipse.team.core.sync.IRemoteResource#getCreatorDisplayName()
*/
public String getCreatorDisplayName() throws CVSException {
- ILogEntry entry = getLogEntry(new NullProgressMonitor());
- return entry.getAuthor();
+// ILogEntry entry = getLogEntry(new NullProgressMonitor());
+// return entry.getAuthor();
+ return "";
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java
index 850f809aa..bf10a2259 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java
@@ -29,7 +29,6 @@ import org.eclipse.team.internal.ccvs.core.CVSStatus;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
@@ -68,6 +67,83 @@ import org.eclipse.team.internal.ccvs.core.util.Util;
*/
public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, ICVSFolder {
+ private final class FolderMembersUpdateListener implements IUpdateMessageListener {
+ List newRemoteDirectories = new ArrayList();
+ List newRemoteFiles = new ArrayList();
+ boolean exists = true;
+ List exceptions = new ArrayList();
+ protected List getNewRemoteDirectories() {
+ return newRemoteDirectories;
+ }
+ protected List getNewRemoteFiles() {
+ return newRemoteFiles;
+ }
+
+ public void directoryInformation(ICVSFolder commandRoot, String stringPath, boolean newDirectory) {
+ try {
+ IPath path = getRelativePathFromRootRelativePath(commandRoot, new Path(stringPath));
+ if (newDirectory && path.segmentCount() == 1) {
+ newRemoteDirectories.add(path.lastSegment());
+ }
+ } catch (CVSException e) {
+ exceptions.add(e);
+ }
+ }
+ public void directoryDoesNotExist(ICVSFolder parent, String stringPath) {
+ try {
+ IPath path = getRelativePathFromRootRelativePath(parent, new Path(stringPath));
+ if (path.isEmpty()) {
+ // the remote folder doesn't exist
+ exists = false;
+ }
+ } catch (CVSException e) {
+ exceptions.add(e);
+ }
+ }
+ public void fileInformation(int type, ICVSFolder parent, String filename) {
+ try {
+ IPath filePath = new Path(filename);
+ filePath = getRelativePathFromRootRelativePath(parent, filePath);
+ if( filePath.segmentCount() == 1 ) {
+ String properFilename = filePath.lastSegment();
+ newRemoteFiles.add(properFilename);
+ }
+ } catch (CVSException e) {
+ exceptions.add(e);
+ }
+ }
+ public void fileDoesNotExist(ICVSFolder parent, String filename) {
+ }
+
+ public void performErrorCheck(IStatus status) throws CVSException {
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ // Only throw the exception if no files or folders were found
+ if (newRemoteDirectories.size() + newRemoteFiles.size() == 0) {
+ throw new CVSServerException(status);
+ } else {
+ CVSProviderPlugin.log(new CVSServerException(status));
+ }
+
+ }
+ if (!exists) {
+ throw new CVSException(new CVSStatus(CVSStatus.ERROR, CVSStatus.DOES_NOT_EXIST, Policy.bind("RemoteFolder.doesNotExist", getRepositoryRelativePath()))); //$NON-NLS-1$
+ }
+
+ // Report any internal exceptions that occured fetching the members
+ if ( ! exceptions.isEmpty()) {
+ if (exceptions.size() == 1) {
+ throw (CVSException)exceptions.get(0);
+ } else {
+ MultiStatus multi = new MultiStatus(CVSProviderPlugin.ID, 0, Policy.bind("RemoteFolder.errorFetchingMembers"), null); //$NON-NLS-1$
+ for (int i = 0; i < exceptions.size(); i++) {
+ multi.merge(((CVSException)exceptions.get(i)).getStatus());
+ }
+ throw new CVSException(multi);
+ }
+ }
+ }
+ }
+
protected FolderSyncInfo folderInfo;
private ICVSRemoteResource[] children;
private ICVSRepositoryLocation repository;
@@ -118,22 +194,27 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC
};
// Perform a "cvs status..." with a listener
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(null, 100);
QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
try {
CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
- Session.run(getRepository(), this, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- IStatus status = Command.STATUS.execute(
- Command.NO_GLOBAL_OPTIONS,
- Command.NO_LOCAL_OPTIONS,
- files,
- new StatusListener(listener),
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
+ Session session = new Session(getRepository(), this, false /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ IStatus status = Command.STATUS.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ Command.NO_LOCAL_OPTIONS,
+ files,
+ new StatusListener(listener),
+ Policy.subMonitorFor(monitor, 90));
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ throw new CVSServerException(status);
}
- }, monitor);
+ } finally {
+ session.close();
+ }
} finally {
CVSProviderPlugin.getPlugin().setQuietness(quietness);
}
@@ -223,31 +304,34 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC
// Retrieve the children and any file revision numbers in a single connection
// Perform a "cvs -n update -d -r tagName folderName" with custom message and error handlers
- final boolean[] retry = new boolean[] {false};
- Session.run(getRepository(), this, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- IStatus status = Command.UPDATE.execute(
- new GlobalOption[] { Command.DO_NOT_CHANGE },
- (LocalOption[]) localOptions.toArray(new LocalOption[localOptions.size()]),
- new ICVSResource[] { child }, new UpdateListener(listener),
- monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- CVSServerException e = new CVSServerException(status);
- if (e.isNoTagException() && child.isContainer()) {
- retry[0] = true;
- } else {
- if (e.containsErrors()) {
- throw e;
- }
+ boolean retry = false;
+ Session session = new Session(getRepository(), this, false /* output to console */);
+ session.open(Policy.subMonitorFor(progress, 10));
+ try {
+ IStatus status = Command.UPDATE.execute(
+ session,
+ new GlobalOption[] { Command.DO_NOT_CHANGE },
+ (LocalOption[]) localOptions.toArray(new LocalOption[localOptions.size()]),
+ new ICVSResource[] { child }, new UpdateListener(listener),
+ Policy.subMonitorFor(progress, 70));
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ CVSServerException e = new CVSServerException(status);
+ if (e.isNoTagException() && child.isContainer()) {
+ retry = true;
+ } else {
+ if (e.containsErrors()) {
+ throw e;
}
}
}
- }, Policy.subMonitorFor(progress, 80));
+ } finally {
+ session.close();
+ }
// We now know that this is an exception caused by a cvs bug.
// If the folder has no files in it (just subfolders) CVS does not respond with the subfolders...
// Workaround: Retry the request with no tag to get the directory names (if any)
- if (retry[0]) {
+ if (retry) {
Policy.checkCanceled(progress);
return exists(child, null, Policy.subMonitorFor(progress, 20));
}
@@ -280,139 +364,81 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC
children = null;
// Create the listener for remote files and folders
- final List newRemoteDirectories = new ArrayList();
- final List newRemoteFiles = new ArrayList();
- final boolean[] exists = new boolean[] {true};
- final List exceptions = new ArrayList();
- final IUpdateMessageListener listener = new IUpdateMessageListener() {
- public void directoryInformation(ICVSFolder commandRoot, String stringPath, boolean newDirectory) {
- try {
- IPath path = getRelativePathFromRootRelativePath(commandRoot, new Path(stringPath));
- if (newDirectory && path.segmentCount() == 1) {
- newRemoteDirectories.add(path.lastSegment());
- progress.subTask(path.lastSegment().toString());
- progress.worked(1);
- }
- } catch (CVSException e) {
- exceptions.add(e);
- }
- }
- public void directoryDoesNotExist(ICVSFolder parent, String stringPath) {
- try {
- IPath path = getRelativePathFromRootRelativePath(parent, new Path(stringPath));
- if (path.isEmpty()) {
- // the remote folder doesn't exist
- exists[0] = false;
- }
- } catch (CVSException e) {
- exceptions.add(e);
- }
- }
- public void fileInformation(int type, ICVSFolder parent, String filename) {
- try {
- IPath filePath = new Path(filename);
- filePath = getRelativePathFromRootRelativePath(parent, filePath);
- if( filePath.segmentCount() == 1 ) {
- String properFilename = filePath.lastSegment();
- newRemoteFiles.add(properFilename);
- progress.subTask(properFilename);
- progress.worked(1);
- }
- } catch (CVSException e) {
- exceptions.add(e);
- }
- }
- public void fileDoesNotExist(ICVSFolder parent, String filename) {
- }
- };
+ FolderMembersUpdateListener listener = new FolderMembersUpdateListener();
+
+ // Perform an update to retrieve the child files and folders
+ IStatus status = performUpdate(tag, listener, Policy.subMonitorFor(progress, 50));
+ Policy.checkCanceled(monitor);
+
+ // Handle any errors that were identified by the listener
+ listener.performErrorCheck(status);
+
+ // Convert the file names to remote resources
+ List result = new ArrayList();
+ List remoteFiles = new ArrayList();
+ for (int i=0;i<listener.getNewRemoteFiles().size();i++) {
+ RemoteFile newFile = new RemoteFile(RemoteFolder.this, Update.STATE_NONE, (String)listener.getNewRemoteFiles().get(i), tag);
+ result.add(newFile);
+ remoteFiles.add(newFile);
+ }
+ // Convert the folder names to remote resources
+ for (int i=0;i<listener.getNewRemoteDirectories().size();i++)
+ result.add(new RemoteFolder(RemoteFolder.this, getRepository(), Util.appendPath(getRepositoryRelativePath(), (String)listener.getNewRemoteDirectories().get(i)), tag));
+ children = (ICVSRemoteResource[])result.toArray(new ICVSRemoteResource[0]);
+
+ // Get the revision numbers for the files
+ if (remoteFiles.size() > 0) {
+ updateFileRevisions((ICVSFile[])remoteFiles.toArray(new ICVSFile[remoteFiles.size()]),
+ Policy.subMonitorFor(progress, 50));
+ } else {
+ progress.worked(50);
+ }
+ } catch (CVSServerException e) {
+ if ( ! e.isNoTagException() && e.containsErrors())
+ throw e;
+ if (tag == null)
+ throw e;
+ // we now know that this is an exception caused by a cvs bug.
+ // if the folder has no files in it (just subfolders) cvs does not respond with the subfolders...
+ // workaround: retry the request with no tag to get the directory names (if any)
+ Policy.checkCanceled(progress);
+ children = getMembers(null, Policy.subMonitorFor(progress, 20));
+ // the returned children must be given the original tag
+ for (int i = 0; i < children.length; i++) {
+ ICVSRemoteResource remoteResource = children[i];
+ if(remoteResource.isContainer()) {
+ ((RemoteFolder)remoteResource).setTag(tag);
+ }
+ }
+ } finally {
+ progress.done();
+ }
+
+ // We need to remember the children that were fetched in order to support file
+ // operations that depend on the parent knowing about the child (i.e. RemoteFile#getContents)
+ return children;
+ }
+
+ private IStatus performUpdate(CVSTag tag, IUpdateMessageListener listener, IProgressMonitor progress) throws CVSException {
+ progress.beginTask(null, 100);
+ Session session = new Session(getRepository(), this, false /* output to console */);
+ session.open(Policy.subMonitorFor(progress, 10));
+ try {
// Build the local options
final List localOptions = new ArrayList();
localOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
if (tag != null) localOptions.add(Update.makeTagOption(tag));
- // Retrieve the children and any file revision numbers in a single connection
- try {
- Session.run(getRepository(), this, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- // Perform a "cvs -n update -d -r tagName folderName"
- monitor.beginTask(null, 100); //$NON-NLS-1$
- IStatus status = Command.UPDATE.execute(
- new GlobalOption[] { Command.DO_NOT_CHANGE },
- (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]),
- new ICVSResource[] { RemoteFolder.this },
- new UpdateListener(listener),
- Policy.subMonitorFor(monitor, 60));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- // Only throw the exception if no files or folders were found
- if (newRemoteDirectories.size() + newRemoteFiles.size() == 0) {
- throw new CVSServerException(status);
- } else {
- CVSProviderPlugin.log(new CVSServerException(status));
- }
-
- }
- if (! exists[0]) {
- throw new CVSException(new CVSStatus(CVSStatus.ERROR, CVSStatus.DOES_NOT_EXIST, Policy.bind("RemoteFolder.doesNotExist", getRepositoryRelativePath()))); //$NON-NLS-1$
- }
- // Report any internal exceptions that occured fetching the members
- if ( ! exceptions.isEmpty()) {
- if (exceptions.size() == 1) {
- throw (CVSException)exceptions.get(0);
- } else {
- MultiStatus multi = new MultiStatus(CVSProviderPlugin.ID, 0, Policy.bind("RemoteFolder.errorFetchingMembers"), null); //$NON-NLS-1$
- for (int i = 0; i < exceptions.size(); i++) {
- multi.merge(((CVSException)exceptions.get(i)).getStatus());
- }
- throw new CVSException(multi);
- }
- }
- // Convert the file names to remote resources
- Policy.checkCanceled(monitor);
- List result = new ArrayList();
- List remoteFiles = new ArrayList();
- for (int i=0;i<newRemoteFiles.size();i++) {
- RemoteFile newFile = new RemoteFile(RemoteFolder.this, Update.STATE_NONE, (String)newRemoteFiles.get(i), tag);
- result.add(newFile);
- remoteFiles.add(newFile);
- }
- // Convert the folder names to remote resources
- for (int i=0;i<newRemoteDirectories.size();i++)
- result.add(new RemoteFolder(RemoteFolder.this, getRepository(), Util.appendPath(getRepositoryRelativePath(), (String)newRemoteDirectories.get(i)), tag));
- children = (ICVSRemoteResource[])result.toArray(new ICVSRemoteResource[0]);
- // Get the revision numbers for the files
- if (remoteFiles.size() > 0) {
- updateFileRevisions((ICVSFile[])remoteFiles.toArray(new ICVSFile[remoteFiles.size()]),
- Policy.subMonitorFor(monitor, 40));
- } else {
- monitor.worked(40);
- }
- }
- }, Policy.subMonitorFor(progress, 80));
- } catch (CVSServerException e) {
- if ( ! e.isNoTagException() && e.containsErrors())
- throw e;
- if (tag == null)
- throw e;
- // we now know that this is an exception caused by a cvs bug.
- // if the folder has no files in it (just subfolders) cvs does not respond with the subfolders...
- // workaround: retry the request with no tag to get the directory names (if any)
- Policy.checkCanceled(progress);
- children = getMembers(null, Policy.subMonitorFor(progress, 20));
- // the returned children must be given the original tag
- for (int i = 0; i < children.length; i++) {
- ICVSRemoteResource remoteResource = children[i];
- if(remoteResource.isContainer()) {
- ((RemoteFolder)remoteResource).setTag(tag);
- }
- }
- }
-
- // We need to remember the children that were fetched in order to support file
- // operations that depend on the parent knowing about the child (i.e. RemoteFile#getContents)
- return children;
+ return Command.UPDATE.execute(
+ session,
+ new GlobalOption[] { Command.DO_NOT_CHANGE },
+ (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]),
+ new ICVSResource[] { RemoteFolder.this },
+ new UpdateListener(listener),
+ Policy.subMonitorFor(progress, 90));
} finally {
- progress.done();
+ session.close();
}
}
@@ -651,66 +677,6 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC
throw new CVSException(Policy.bind("RemoteResource.invalidOperation"));//$NON-NLS-1$
}
- /**
- * Update the file revision for the given child such that the revision is the one in the given branch.
- * Return true if the file exists and false otherwise
- */
- protected boolean updateRevision(final ICVSRemoteFile child, CVSTag tag, IProgressMonitor monitor) throws CVSException {
- final IProgressMonitor progress = Policy.monitorFor(monitor);
- progress.beginTask(null, 100); //$NON-NLS-1$
- ICVSRemoteResource[] oldChildren = children;
- try {
- children = new ICVSRemoteResource[] {child};
-
- // Create the listener for remote files and folders
- final boolean[] exists = new boolean[] {true};
- final IUpdateMessageListener listener = new IUpdateMessageListener() {
- public void directoryInformation(ICVSFolder parent, String path, boolean newDirectory) {
- }
- public void directoryDoesNotExist(ICVSFolder parent, String path) {
- // If we get this, we can assume that the parent directory no longer exists
- exists[0] = false;
- }
- public void fileInformation(int type, ICVSFolder parent, String filename) {
- // The file was found and has a different revision
- try {
- ((RemoteFile)parent.getChild(filename)).setWorkspaceSyncState(type);
- } catch(CVSException e) {
- exists[0] = false;
- }
- exists[0] = true;
- }
- public void fileDoesNotExist(ICVSFolder parent, String filename) {
- exists[0] = false;
- }
- };
-
- // Build the local options
- final List localOptions = new ArrayList();
- if (tag != null && tag.getType() != CVSTag.HEAD)
- localOptions.add(Update.makeTagOption(tag));
-
- // Retrieve the children and any file revision numbers in a single connection
- Session.run(getRepository(), this, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- // Perform a "cvs -n update -d -r tagName fileName" with custom message and error handlers
- Command.UPDATE.execute(
- new GlobalOption[] { Command.DO_NOT_CHANGE },
- (LocalOption[]) localOptions.toArray(new LocalOption[localOptions.size()]),
- new ICVSResource[] { child },
- new UpdateListener(listener),
- monitor);
- }
- }, Policy.subMonitorFor(progress, 70));
-
- if (!exists[0]) return false;
- updateFileRevisions(new ICVSFile[] {child}, Policy.subMonitorFor(progress, 30));
- return true;
- } finally {
- children = oldChildren;
- }
- }
-
/*
* @see ICVSFolder#run(ICVSRunnable, IProgressMonitor)
*/
@@ -729,19 +695,22 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC
* @see ICVSFolder#tag(CVSTag, LocalOption[], IProgressMonitor)
*/
public IStatus tag(final CVSTag tag, final LocalOption[] localOptions, IProgressMonitor monitor) throws CVSException {
- final IStatus[] result = new IStatus[] { null };
- Session.run(getRepository(), this, true, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- result[0] = Command.RTAG.execute(
- Command.NO_GLOBAL_OPTIONS,
- localOptions,
- folderInfo.getTag(),
- tag,
- new ICVSRemoteResource[] { RemoteFolder.this },
- monitor);
- }
- }, monitor);
- return result[0];
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(null, 100);
+ Session session = new Session(getRepository(), this, true /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ return Command.RTAG.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ localOptions,
+ folderInfo.getTag(),
+ tag,
+ new ICVSRemoteResource[] { RemoteFolder.this },
+ Policy.subMonitorFor(monitor, 90));
+ } finally {
+ session.close();
+ }
}
/**
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java
index 478fbbed1..5dbfd7a30 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java
@@ -110,7 +110,7 @@ public class RemoteFolderTreeBuilder {
}
- private RemoteFolderTreeBuilder(CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag) {
+ /* package */ RemoteFolderTreeBuilder(CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag) {
this.repository = repository;
this.root = root;
this.tag = tag;
@@ -174,7 +174,7 @@ public class RemoteFolderTreeBuilder {
return builder.buildTree(resources, monitor);
}
- private RemoteFolderTree buildTree(ICVSResource[] resources, IProgressMonitor monitor) throws CVSException {
+ /* package */ RemoteFolderTree buildTree(ICVSResource[] resources, IProgressMonitor monitor) throws CVSException {
// Make sure that the cvs commands are not quiet during this operations
QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
@@ -183,76 +183,17 @@ public class RemoteFolderTreeBuilder {
monitor.beginTask(null, 100);
- // Get the arguments from the files
- ArrayList arguments = new ArrayList();
- for (int i = 0; i < resources.length; i++) {
- ICVSResource resource = resources[i];
- arguments.add(resource.getRelativePath(root));
- }
-
// 1st Connection: Use local state to determine delta with server
- Policy.checkCanceled(monitor);
- Session session = new Session(repository, root, false);
- session.open(Policy.subMonitorFor(monitor, 10));
- try {
- Policy.checkCanceled(monitor);
- fetchDelta(session, (String[]) arguments.toArray(new String[arguments.size()]), Policy.subMonitorFor(monitor, 50));
- if (projectDoesNotExist) {
- // We cannot handle the case where a project (i.e. the top-most CVS folder)
- // has been deleted directly on the sever (i.e. deleted using rm -rf)
- if (root.isCVSFolder() && ! root.isManaged()) {
- throw new CVSException(Policy.bind("RemoteFolderTreeBuild.folderDeletedFromServer", root.getFolderSyncInfo().getRepository())); //$NON-NLS-1$
- } else {
- return null;
- }
- }
- } finally {
- session.close();
+ if (!fetchDelta(resources, Policy.subMonitorFor(monitor, 50))) {
+ return null;
}
// 2nd Connection: Build remote tree from above delta using 2nd connection to fetch unknown directories
// NOTE: Multiple commands may be issued over this connection.
- remoteRoot =
- new RemoteFolderTree(null, root.getName(), repository,
- root.getFolderSyncInfo().getRepository(),
- tagForRemoteFolder(root, tag));
- if (newFolderExist) {
- // New folders will require a connection for fetching their members
- session = new Session(repository, remoteRoot, false);
- session.open(Policy.subMonitorFor(monitor, 10));
- } else {
- session = null;
- }
- try {
- // Set up an infinite progress monitor for the recursive build
- IProgressMonitor subProgress = Policy.infiniteSubMonitorFor(monitor, 30);
- subProgress.beginTask(null, 512);
- // Build the remote tree
- buildRemoteTree(session, root, remoteRoot, "", subProgress); //$NON-NLS-1$
- } finally {
- if (session != null)
- session.close();
- }
+ fetchNewDirectories(Policy.subMonitorFor(monitor, 20));
- // 3rd+ Connection: Used to fetch file status in groups of 1024
- if (!changedFiles.isEmpty()) {
- String[] allChangedFiles = (String[])changedFiles.toArray(new String[changedFiles.size()]);
- int iterations = (allChangedFiles.length / MAX_REVISION_FETCHES_PER_CONNECTION)
- + (allChangedFiles.length % MAX_REVISION_FETCHES_PER_CONNECTION == 0 ? 0 : 1);
- for (int i = 0; i < iterations ; i++) {
- int length = Math.min(MAX_REVISION_FETCHES_PER_CONNECTION,
- allChangedFiles.length - (MAX_REVISION_FETCHES_PER_CONNECTION * i));
- String buffer[] = new String[length];
- System.arraycopy(allChangedFiles, i * MAX_REVISION_FETCHES_PER_CONNECTION, buffer, 0, length);
- session = new Session(repository, remoteRoot, false);
- session.open(Policy.subMonitorFor(monitor, 1));
- try {
- fetchFileRevisions(session, buffer, Policy.subMonitorFor(monitor, 2));
- } finally {
- session.close();
- }
- }
- }
+ // 3rd+ Connection: Used to fetch file status in groups of 1024
+ fetchFileRevisions(Policy.subMonitorFor(monitor, 30));
return remoteRoot;
@@ -261,7 +202,93 @@ public class RemoteFolderTreeBuilder {
monitor.done();
}
}
- private RemoteFile buildTree(ICVSFile file, IProgressMonitor monitor) throws CVSException {
+
+ private boolean fetchDelta(ICVSResource[] resources, IProgressMonitor monitor) throws CVSException {
+
+ // Get the arguments from the files
+ ArrayList arguments = new ArrayList();
+ for (int i = 0; i < resources.length; i++) {
+ ICVSResource resource = resources[i];
+ arguments.add(resource.getRelativePath(root));
+ }
+
+ // Use local state to determine delta with server
+ monitor.beginTask(null, 100);
+ Policy.checkCanceled(monitor);
+ Session session = new Session(repository, root, false);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ Policy.checkCanceled(monitor);
+ fetchDelta(session, (String[]) arguments.toArray(new String[arguments.size()]), Policy.subMonitorFor(monitor, 90));
+ if (projectDoesNotExist) {
+ // We cannot handle the case where a project (i.e. the top-most CVS folder)
+ // has been deleted directly on the sever (i.e. deleted using rm -rf)
+ if (root.isCVSFolder() && ! root.isManaged()) {
+ throw new CVSException(Policy.bind("RemoteFolderTreeBuild.folderDeletedFromServer", root.getFolderSyncInfo().getRepository())); //$NON-NLS-1$
+ } else {
+ return false;
+ }
+ }
+ } finally {
+ session.close();
+ monitor.done();
+ }
+ return true;
+ }
+
+ private void fetchNewDirectories(IProgressMonitor monitor) throws CVSException {
+ // Build remote tree from the fetched delta using a new connection to fetch unknown directories
+ // NOTE: Multiple commands may be issued over this connection.
+ monitor.beginTask(null, 100);
+ Session session;
+ remoteRoot =
+ new RemoteFolderTree(null, root.getName(), repository,
+ root.getFolderSyncInfo().getRepository(),
+ tagForRemoteFolder(root, tag));
+ if (newFolderExist) {
+ // New folders will require a connection for fetching their members
+ session = new Session(repository, remoteRoot, false);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ } else {
+ session = null;
+ }
+ try {
+ // Set up an infinite progress monitor for the recursive build
+ IProgressMonitor subProgress = Policy.infiniteSubMonitorFor(monitor, 90);
+ subProgress.beginTask(null, 512);
+ // Build the remote tree
+ buildRemoteTree(session, root, remoteRoot, "", subProgress); //$NON-NLS-1$
+ } finally {
+ if (session != null) {
+ session.close();
+ }
+ monitor.done();
+ }
+ }
+
+ private void fetchFileRevisions(IProgressMonitor monitor) throws CVSException {
+ // 3rd+ Connection: Used to fetch file status in groups of 1024
+ if (!changedFiles.isEmpty()) {
+ String[] allChangedFiles = (String[])changedFiles.toArray(new String[changedFiles.size()]);
+ int iterations = (allChangedFiles.length / MAX_REVISION_FETCHES_PER_CONNECTION)
+ + (allChangedFiles.length % MAX_REVISION_FETCHES_PER_CONNECTION == 0 ? 0 : 1);
+ for (int i = 0; i < iterations ; i++) {
+ int length = Math.min(MAX_REVISION_FETCHES_PER_CONNECTION,
+ allChangedFiles.length - (MAX_REVISION_FETCHES_PER_CONNECTION * i));
+ String buffer[] = new String[length];
+ System.arraycopy(allChangedFiles, i * MAX_REVISION_FETCHES_PER_CONNECTION, buffer, 0, length);
+ Session session = new Session(repository, remoteRoot, false);
+ session.open(Policy.subMonitorFor(monitor, 1));
+ try {
+ fetchFileRevisions(session, buffer, Policy.subMonitorFor(monitor, 2));
+ } finally {
+ session.close();
+ }
+ }
+ }
+ }
+
+ /* package */ RemoteFile buildTree(ICVSFile file, IProgressMonitor monitor) throws CVSException {
QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
try {
CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
@@ -306,7 +333,7 @@ public class RemoteFolderTreeBuilder {
}
// Add the resource to its parent
remoteRoot.setChildren(new ICVSRemoteResource[] {remoteFile});
- // If there was a delta, ftech the new revision
+ // If there was a delta, fetch the new revision
if (!changedFiles.isEmpty()) {
// Add the remote folder to the remote folder lookup table (used to update file revisions)
recordRemoteFolder(remoteRoot);
@@ -742,4 +769,13 @@ public class RemoteFolderTreeBuilder {
private RemoteFolderTree getRecoredRemoteFolder(String path) {
return (RemoteFolderTree)remoteFolderTable.get(Util.asPath(path));
}
+
+ /**
+ * This method returns an array of the files that differ between the local and remote trees.
+ * The files are represented as a String that contains the path to the file in the remote or local trees.
+ * @return an array of differing files
+ */
+ public String[] getFileDiffs() {
+ return (String[]) changedFiles.toArray(new String[changedFiles.size()]);;
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaseSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaseSynchronizer.java
index 799487ecf..0328f4b33 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaseSynchronizer.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaseSynchronizer.java
@@ -12,7 +12,9 @@ package org.eclipse.team.internal.ccvs.core.syncinfo;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
@@ -54,4 +56,17 @@ public class BaseSynchronizer extends ResourceSynchronizer {
return new QualifiedName(CVSProviderPlugin.ID, "workspace"); // $NON-NLS-1$
}
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSynchronizer#refresh(org.eclipse.core.resources.IResource[], int, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IResource[] refresh(
+ IResource[] resources,
+ int depth,
+ boolean cacheFileContentsHint,
+ IProgressMonitor monitor)
+ throws TeamException {
+
+ // TODO Ensure that file contents are cached for modified local files
+ return super.refresh(resources, depth, cacheFileContentsHint, monitor);
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteTagSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteTagSynchronizer.java
index 7c35db112..8fd648781 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteTagSynchronizer.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteTagSynchronizer.java
@@ -221,7 +221,7 @@ public class RemoteTagSynchronizer extends RemoteSynchronizer {
* @return
* @throws TeamException
*/
- public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
+ public IResource[] refresh(IResource[] resources, int depth, boolean cacheFileContentsHint, IProgressMonitor monitor) throws TeamException {
int work = 100 * resources.length;
monitor.beginTask(null, work);
resetChanges();
@@ -230,7 +230,7 @@ public class RemoteTagSynchronizer extends RemoteSynchronizer {
IResource resource = resources[i];
// build the remote tree only if an initial tree hasn't been provided
- ICVSRemoteResource tree = buildRemoteTree(resource, depth, Policy.subMonitorFor(monitor, 70));
+ ICVSRemoteResource tree = buildRemoteTree(resource, depth, cacheFileContentsHint, Policy.subMonitorFor(monitor, 70));
// update the known remote handles
IProgressMonitor sub = Policy.infiniteSubMonitorFor(monitor, 30);
@@ -253,10 +253,10 @@ public class RemoteTagSynchronizer extends RemoteSynchronizer {
/**
* Build a remote tree for the given parameters.
*/
- protected ICVSRemoteResource buildRemoteTree(IResource resource, int depth, IProgressMonitor monitor) throws TeamException {
+ protected ICVSRemoteResource buildRemoteTree(IResource resource, int depth, boolean cacheFileContentsHint, IProgressMonitor monitor) throws TeamException {
// TODO: we are currently ignoring the depth parameter because the build remote tree is
// by default deep!
- return CVSWorkspaceRoot.getRemoteTree(resource, tag, monitor);
+ return CVSWorkspaceRoot.getRemoteTree(resource, tag, cacheFileContentsHint, monitor);
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSynchronizer.java
index 2e6417b8a..e3b936a08 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSynchronizer.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSynchronizer.java
@@ -59,13 +59,17 @@ public abstract class ResourceSynchronizer {
/**
* Refreshes the contents of the resource synchronizer and returns the list
- * of resources whose remote sync state changed.
+ * of resources whose remote sync state changed. The <code>cacheFileContentsHint</code>
+ * indicates that the user of this synchronizer will be using the file contents. Subclasses can decide
+ * whether to cache file contents during the refresh or to allow them to be fetched when request.
* @param resources
* @param depth
+ * @param cacheFileContentsHint a hint which indicates whether file contents will be used
* @param monitor
* @return
+ * @throws TeamException
*/
- public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
+ public IResource[] refresh(IResource[] resources, int depth, boolean cacheFileContentsHint, IProgressMonitor monitor) throws TeamException {
return new IResource[0];
}
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/CVSLocalCompareEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLocalCompareEditorInput.java
index 800688dc1..efef0f332 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLocalCompareEditorInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLocalCompareEditorInput.java
@@ -61,7 +61,7 @@ public class CVSLocalCompareEditorInput extends CVSSyncCompareInput {
} else {
tag = tags[i];
}
- IRemoteResource remote = CVSWorkspaceRoot.getRemoteTree(resource, tag, Policy.subMonitorFor(monitor, 50));
+ IRemoteResource remote = CVSWorkspaceRoot.getRemoteTree(resource, tag, getCacheFileContentsHint(), Policy.subMonitorFor(monitor, 50));
trees[i] = new CVSRemoteSyncElement(false /* two-way */, resource, null, remote);
}
} finally {
@@ -71,6 +71,10 @@ public class CVSLocalCompareEditorInput extends CVSSyncCompareInput {
return trees;
}
+ private boolean getCacheFileContentsHint() {
+ return getSyncGranularity() != IRemoteSyncElement.GRANULARITY_TIMESTAMP;
+ }
+
public String getTitle() {
return Policy.bind("CVSLocalCompareEditorInput.title", tags[0].getName()); //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java
index 0b746d236..c82b3a125 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java
@@ -30,7 +30,6 @@ import org.eclipse.team.internal.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
import org.eclipse.team.internal.ccvs.core.client.Log;
@@ -176,28 +175,32 @@ public class RestoreFromRepositoryAction extends CVSAction {
* Fetch the RCS paths (minus the Attic segment) of all files in the Attic.
* This path includes the repository root path.
*/
- private ICVSFile[] fetchFilesInAttic(ICVSRepositoryLocation location, final ICVSFolder parent, IProgressMonitor monitor) throws CVSException {
- final AtticLogListener listener = new AtticLogListener();
- Session.run(location, parent, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
- try {
- CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
- IStatus status = Command.LOG.execute(Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] { Log.RCS_FILE_NAMES_ONLY },
- new ICVSResource[] { parent }, listener,
- Policy.subMonitorFor(monitor, 100));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- CVSProviderPlugin.getPlugin().setQuietness(quietness);
- monitor.done();
+ private ICVSFile[] fetchFilesInAttic(ICVSRepositoryLocation location, ICVSFolder parent, IProgressMonitor monitor) throws CVSException {
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(null, 100);
+ AtticLogListener listener = new AtticLogListener();
+ Session session = new Session(location, parent, true /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
+ try {
+ CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
+ IStatus status = Command.LOG.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ new LocalOption[] { Log.RCS_FILE_NAMES_ONLY },
+ new ICVSResource[] { parent }, listener,
+ Policy.subMonitorFor(monitor, 90));
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ throw new CVSServerException(status);
}
+ } finally {
+ CVSProviderPlugin.getPlugin().setQuietness(quietness);
+ monitor.done();
}
- }, monitor);
+ } finally {
+ session.close();
+ }
return listener.getAtticFilePaths();
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java
index a6a0eb624..eb6830676 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java
@@ -26,7 +26,6 @@ import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
import org.eclipse.team.internal.ccvs.core.client.Annotate;
import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.Session;
@@ -109,35 +108,39 @@ public class ShowAnnotationAction extends CVSAction {
private void fetchAnnotation(final AnnotateListener listener, final ICVSResource cvsResource, final String revision, IProgressMonitor monitor) throws InvocationTargetException {
try {
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(null, 100);
ICVSFolder folder = cvsResource.getParent();
final FolderSyncInfo info = folder.getFolderSyncInfo();
ICVSRepositoryLocation location = CVSProviderPlugin.getPlugin().getRepository(info.getRoot());
- Session.run(location, folder, false, new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- Command.QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
- try {
- CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
- final Command.LocalOption[] localOption;
- if (revision == null) {
- localOption = Command.NO_LOCAL_OPTIONS;
- } else {
- localOption = new Command.LocalOption[1];
- localOption[0] = Annotate.makeRevisionOption(revision);
- }
- IStatus status = Command.ANNOTATE.execute(Command.NO_GLOBAL_OPTIONS,
- localOption, new ICVSResource[] { cvsResource }, listener,
- Policy.subMonitorFor(monitor, 100));
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- } finally {
- CVSProviderPlugin.getPlugin().setQuietness(quietness);
- monitor.done();
+ Session session = new Session(location, folder, true /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ Command.QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
+ try {
+ CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
+ final Command.LocalOption[] localOption;
+ if (revision == null) {
+ localOption = Command.NO_LOCAL_OPTIONS;
+ } else {
+ localOption = new Command.LocalOption[1];
+ localOption[0] = Annotate.makeRevisionOption(revision);
+ }
+ IStatus status = Command.ANNOTATE.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ localOption, 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();
}
- }, monitor);
+ } finally {
+ session.close();
+ }
} catch (CVSException e) {
throw new InvocationTargetException(e);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index 8121e91da..e784af54f 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -1009,6 +1009,10 @@ UpdateOnlyMergeable.taskName=Updating mergeable changes
UpdateDialog.overwriteTitle=Overwrite Local Changes?
UpdateDialog.overwriteMessage=Some conflicting files cannot be merged automatically with the update action. Should these resources be updated, overwriting any local changes?
ReplaceOperation.taskName=Replacing...
+UpdateOperation.taskName=Updating...
+
+SafeUpdateAction.warnFilesWithConflictsTitle=Non-mergeable files
+SafeUpdateAction.warnFilesWithConflictsDescription=Some conflicting files cannot be merged automatically with the update action. They contain conflicting changes that will have to be merged manually. Use the Synchronize View to find the conflicts then merge the changes in a compare editor.
SafeUpdateAction.warnFilesWithConflictsTitle=Non-mergeable files
SafeUpdateAction.warnFilesWithConflictsDescription=Some conflicting files cannot be merged automatically with the update action. They contain conflicting changes that will have to be merged manually. Use the Synchronize View to find the conflicts then merge the changes in a compare editor.
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 27cd58399..3b60cea67 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
@@ -14,6 +14,8 @@ import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
@@ -25,12 +27,14 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSStatus;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
@@ -46,7 +50,7 @@ public abstract class CVSOperation implements IRunnableWithProgress {
private List errors = new ArrayList(); // of IStatus
- protected static final IStatus OK = new CVSStatus(IStatus.OK, Policy.bind("ok")); // $NON-NLS-1$
+ protected static final IStatus OK = new CVSStatus(IStatus.OK, Policy.bind("ok")); //$NON-NLS-1$
private IRunnableContext runnableContext;
private Shell shell;
@@ -56,6 +60,9 @@ public abstract class CVSOperation implements IRunnableWithProgress {
// instance variable used to indicate behavior while prompting for overwrite
private boolean confirmOverwrite = true;
+ // instance variable used to indicate that the operation is running in the background
+ private boolean runningAsJob = false;
+
public static void run(Shell shell, CVSOperation operation) throws CVSException, InterruptedException {
operation.setShell(shell);
operation.setRunnableContext(new ProgressMonitorDialog(shell));
@@ -90,19 +97,42 @@ public abstract class CVSOperation implements IRunnableWithProgress {
}
protected void runAsJob() {
- Job job = new Job(Policy.bind("CVSOperation.operationJobName", getTaskName())) {
+ Job job;
+ if (isModifiesWorkspace()) {
+ job = getWorkspaceJob();
+ } else {
+ job = getBasicJob();
+ }
+ runningAsJob = true;
+ job.schedule();
+ }
+
+ protected IStatus runInJob(IProgressMonitor monitor) {
+ try {
+ // Don't wrap inside the run since the WorkspaceJob will do the batching
+ CVSOperation.this.run(monitor, false /* wrap in ModifyOperation*/);
+ return Status.OK_STATUS;
+ } catch (InvocationTargetException e) {
+ return CVSException.wrapException(e).getStatus();
+ } catch (InterruptedException e) {
+ return Status.CANCEL_STATUS;
+ }
+ }
+
+ protected Job getBasicJob() {
+ return new Job(Policy.bind("CVSOperation.operationJobName", getTaskName())) { //$NON-NLS-1$
public IStatus run(IProgressMonitor monitor) {
- try {
- CVSOperation.this.run(monitor);
- return Status.OK_STATUS;
- } catch (InvocationTargetException e) {
- return CVSException.wrapException(e).getStatus();
- } catch (InterruptedException e) {
- return Status.CANCEL_STATUS;
- }
+ return CVSOperation.this.runInJob(monitor);
+ }
+ };
+ }
+
+ protected Job getWorkspaceJob() {
+ return new WorkspaceJob(Policy.bind("CVSOperation.operationJobName", getTaskName())) { //$NON-NLS-1$
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ return CVSOperation.this.runInJob(monitor);
}
};
- job.schedule();
}
/**
@@ -140,9 +170,16 @@ public abstract class CVSOperation implements IRunnableWithProgress {
* @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public final void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ run(monitor, isModifiesWorkspace());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ private void run(IProgressMonitor monitor, boolean wrapInModifiyOperation) throws InvocationTargetException, InterruptedException {
startOperation();
try {
- if (isModifiesWorkspace()) {
+ if (wrapInModifiyOperation) {
new CVSWorkspaceModifyOperation(this).run(monitor);
} else {
execute(monitor);
@@ -153,7 +190,7 @@ public abstract class CVSOperation implements IRunnableWithProgress {
throw new InvocationTargetException(e);
}
}
-
+
protected void startOperation() {
statusCount = 0;
resetErrors();
@@ -193,51 +230,49 @@ public abstract class CVSOperation implements IRunnableWithProgress {
return runnableContext != null;
}
- /**
- * @return
- */
public Shell getShell() {
+ if (isRunningAsJob()) {
+ // We can't use the assigned shell as it may have been disposed
+ // run in syncExec because callback is from an operation,
+ // which is probably not running in the UI thread.
+ final Shell[] newShell = new Shell[] { null };
+ Display.getDefault().syncExec(
+ new Runnable() {
+ public void run() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) {
+ Display display = Display.getDefault();
+ newShell[0] = new Shell(display);
+ } else {
+ newShell[0] = window.getShell();
+ }
+ }
+ });
+ return newShell[0];
+ }
return shell;
}
- /**
- * @param shell
- */
public void setShell(Shell shell) {
this.shell = shell;
}
- /**
- * @return
- */
public boolean isInterruptable() {
return interruptable;
}
- /**
- * @param b
- */
public void setInterruptable(boolean b) {
interruptable = b;
}
- /**
- * @return
- */
public boolean isModifiesWorkspace() {
return modifiesWorkspace;
}
- /**
- * @param b
- */
public void setModifiesWorkspace(boolean b) {
modifiesWorkspace = b;
}
- /**
- * @param status
- */
protected void addError(IStatus status) {
if (status.isOK()) return;
errors.add(status);
@@ -248,16 +283,10 @@ public abstract class CVSOperation implements IRunnableWithProgress {
if (!status.isOK()) addError(status);
}
- /**
- *
- */
protected void resetErrors() {
errors.clear();
}
- /**
- * @param statuses
- */
protected void handleErrors(IStatus[] errors) throws CVSException {
if (errors.length == 0) return;
if (errors.length == 1 && statusCount == 1) {
@@ -340,9 +369,6 @@ public abstract class CVSOperation implements IRunnableWithProgress {
return involvesMultipleResources;
}
- /**
- * @param b
- */
public void setInvolvesMultipleResources(boolean b) {
involvesMultipleResources = b;
}
@@ -354,4 +380,9 @@ public abstract class CVSOperation implements IRunnableWithProgress {
* @return
*/
protected abstract String getTaskName();
+
+ protected boolean isRunningAsJob() {
+ return runningAsJob;
+ }
+
}
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 eb25545f7..fc27bd4d6 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
@@ -1,9 +1,13 @@
-/*
- * Created on 2-Jun-03
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.operations;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -12,12 +16,6 @@ import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.ui.Policy;
-/**
- * @author Administrator
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
public abstract class CheckoutOperation extends RemoteOperation {
public CheckoutOperation(Shell shell, ICVSRemoteFolder[] remoteFolders) {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java
index eb1116078..4724af822 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutProjectOperation.java
@@ -396,7 +396,7 @@ public abstract class CheckoutProjectOperation extends CheckoutOperation {
/*
* Bring the provied projects into the workspace
*/
- private static void refreshProjects(IProject[] projects, IProgressMonitor monitor) throws CVSException {
+ private void refreshProjects(IProject[] projects, IProgressMonitor monitor) throws CVSException {
monitor.beginTask(null, projects.length * 100);
try {
for (int i = 0; i < projects.length; i++) {
@@ -411,7 +411,6 @@ public abstract class CheckoutProjectOperation extends CheckoutOperation {
CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId());
provider.setWatchEditEnabled(CVSProviderPlugin.getPlugin().isWatchEditEnabled());
}
-
} finally {
monitor.done();
}
@@ -429,7 +428,6 @@ public abstract class CheckoutProjectOperation extends CheckoutOperation {
*/
protected void checkout(ICVSRemoteFolder[] folders, IProgressMonitor monitor) throws CVSException {
checkout(folders, getTargetProjects(folders), monitor);
-
}
}
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 cb05dc3c1..9f4e7bb1a 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
@@ -11,42 +11,46 @@
package org.eclipse.team.internal.ccvs.ui.operations;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSStatus;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.Session;
import org.eclipse.team.internal.ccvs.core.client.Update;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.util.PrepareForReplaceVisitor;
-import org.eclipse.team.internal.ccvs.core.util.ReplaceWithBaseVisitor;
import org.eclipse.team.internal.ccvs.ui.Policy;
/**
* Thsi operation replaces the local resources with their remote contents
*/
-public class ReplaceOperation extends RepositoryProviderOperation {
+public class ReplaceOperation extends UpdateOperation {
boolean recurse = true;
-
- public ReplaceOperation(Shell shell, IResource[] resources, boolean recurse) {
- super(shell, resources);
+
+ public ReplaceOperation(Shell shell, IResource[] resources, CVSTag tag, boolean recurse) {
+ super(shell, resources, getReplaceOptions(recurse), tag);
this.recurse = recurse;
}
+ /*
+ * Create the local options required to do a replace
+ */
+ private static LocalOption[] getReplaceOptions(boolean recurse) {
+ List options = new ArrayList();
+ options.add(Update.IGNORE_LOCAL_CHANGES);
+ if(!recurse) {
+ options.add(Command.DO_NOT_RECURSE);
+ }
+ return (LocalOption[]) options.toArray(new LocalOption[options.size()]);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
*/
@@ -55,92 +59,29 @@ public class ReplaceOperation extends RepositoryProviderOperation {
}
/* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
*/
- protected void execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException {
- get(provider, resources, null, monitor);
- }
-
- public void get(final CVSTeamProvider provider, final IResource[] resources, final CVSTag tag, IProgressMonitor progress) throws CVSException {
+ protected IStatus executeCommand(
+ Session session,
+ CVSTeamProvider provider,
+ IResource[] resources,
+ IProgressMonitor monitor)
+ throws CVSException, InterruptedException {
- // Handle the retrival of the base in a special way
- if (tag != null && tag.equals(CVSTag.BASE)) {
- new ReplaceWithBaseVisitor().replaceWithBase(
- provider.getProject(),
- resources,
- recurse ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO,
- progress);
- return;
- }
-
- // Make a connection before preparing for the replace to avoid deletion of resources before a failed connection
- CVSWorkspaceRoot workspaceRoot = provider.getCVSWorkspaceRoot();
- Session.run(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */,
- new ICVSRunnable() {
- public void run(IProgressMonitor progress) throws CVSException {
- // Prepare for the replace (special handling for "cvs added" and "cvs removed" resources
- progress.beginTask(null, 100);
- try {
- new PrepareForReplaceVisitor().visitResources(
- provider.getProject(),
- resources,
- "CVSTeamProvider.scrubbingResource", // TODO: This is a key in CVS core! //$NON-NLS-1$
- recurse ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO,
- Policy.subMonitorFor(progress, 30)); //$NON-NLS-1$
+ monitor.beginTask(null, 100);
+ try {
+ new PrepareForReplaceVisitor().visitResources(
+ provider.getProject(),
+ resources,
+ "CVSTeamProvider.scrubbingResource", // TODO: This is a key in CVS core! //$NON-NLS-1$
+ recurse ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO,
+ Policy.subMonitorFor(monitor, 30)); //$NON-NLS-1$
- // Perform an update, ignoring any local file modifications
- List options = new ArrayList();
- options.add(Update.IGNORE_LOCAL_CHANGES);
- if(!recurse) {
- options.add(Command.DO_NOT_RECURSE);
- }
- LocalOption[] commandOptions = (LocalOption[]) options.toArray(new LocalOption[options.size()]);
- try {
- update(provider, resources, commandOptions, tag, true /*createBackups*/, Policy.subMonitorFor(progress, 70));
- } catch (TeamException e) {
- throw CVSException.wrapException(e);
- }
- } finally {
- progress.done();
- }
- }
- }, progress);
+ // Perform an update, ignoring any local file modifications
+ return super.executeCommand(session, provider, resources, monitor);
+ } finally {
+ monitor.done();
+ }
}
- /**
- * Generally useful update.
- *
- * The tag parameter determines any stickyness after the update is run. If tag is null, any tagging on the
- * resources being updated remain the same. If the tag is a branch, version or date tag, then the resources
- * will be appropriatly tagged. If the tag is HEAD, then there will be no tag on the resources (same as -A
- * clear sticky option).
- *
- * @param createBackups if true, creates .# files for updated files
- */
- public void update(final CVSTeamProvider provider, IResource[] resources, LocalOption[] options, CVSTag tag, final boolean createBackups, IProgressMonitor progress) throws CVSException {
- // Build the local options
- List localOptions = new ArrayList();
-
- // Use the appropriate tag options
- if (tag != null) {
- localOptions.add(Update.makeTagOption(tag));
- }
-
- // Build the arguments list
- localOptions.addAll(Arrays.asList(options));
- final LocalOption[] commandOptions = (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]);
- final ICVSResource[] arguments = getCVSArguments(resources);
-
- CVSWorkspaceRoot workspaceRoot = provider.getCVSWorkspaceRoot();
- Session.run(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */,
- new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- IStatus status = Command.UPDATE.execute(Command.NO_GLOBAL_OPTIONS, commandOptions, arguments,
- null, monitor);
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
- }
- }, progress);
- }
}
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 e337197e7..d0fbb8650 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
@@ -26,6 +26,8 @@ import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.internal.ccvs.core.ICVSFolder;
+import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.client.Session;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
@@ -146,4 +148,15 @@ public abstract class RepositoryProviderOperation extends CVSOperation {
}
return cvsResources;
}
+
+ protected ICVSRepositoryLocation getRemoteLocation(CVSTeamProvider provider) throws CVSException {
+ CVSWorkspaceRoot workspaceRoot = provider.getCVSWorkspaceRoot();
+ return workspaceRoot.getRemoteLocation();
+ }
+
+ protected ICVSFolder getLocalRoot(CVSTeamProvider provider) throws CVSException {
+ CVSWorkspaceRoot workspaceRoot = provider.getCVSWorkspaceRoot();
+ return workspaceRoot.getLocalRoot();
+ }
+
}
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
new file mode 100644
index 000000000..4ee9d2e0f
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui.operations;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.CVSStatus;
+import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.internal.ccvs.core.client.Command;
+import org.eclipse.team.internal.ccvs.core.client.Session;
+import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+
+public abstract class SingleCommandOperation extends RepositoryProviderOperation {
+
+ LocalOption[] options = Command.NO_LOCAL_OPTIONS;
+
+ public SingleCommandOperation(Shell shell, IResource[] resources, LocalOption[] options) {
+ super(shell, resources);
+ if (options != null) {
+ this.options = options;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected void execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException {
+ monitor.beginTask(null, 100);
+ Session session = new Session(getRemoteLocation(provider), getLocalRoot(provider), true /* output to console */);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ IStatus status = executeCommand(session, provider, resources, Policy.subMonitorFor(monitor, 90));
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ addError(status);
+ }
+ } finally {
+ session.close();
+ }
+ }
+
+ /**
+ * Method overridden by subclasses to issue the command to the CVS repository using the given session.
+ */
+ protected abstract IStatus executeCommand(Session session, CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException;
+
+ protected LocalOption[] getLocalOptions() {
+ return options;
+ }
+
+ protected void setLocalOptions(LocalOption[] options) {
+ this.options = options;
+ }
+
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOnlyMergableOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOnlyMergableOperation.java
index 2da01dc8b..a869a107a 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOnlyMergableOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOnlyMergableOperation.java
@@ -21,59 +21,48 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.Session;
import org.eclipse.team.internal.ccvs.core.client.UpdateMergableOnly;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.Policy;
/**
* This operation performs an update that will only effect files
* that have no conflicts or automergable conflicts.
*/
-public class UpdateOnlyMergableOperation extends RepositoryProviderOperation {
-
- private LocalOption[] localOptions;
+public class UpdateOnlyMergableOperation extends SingleCommandOperation {
List skippedFiles = new ArrayList();
public UpdateOnlyMergableOperation(Shell shell, IResource[] resources, LocalOption[] localOptions) {
- super(shell, resources);
- this.localOptions = localOptions;
+ super(shell, resources, localOptions);
}
/* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName()
+ * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
*/
- protected String getTaskName() {
- return Policy.bind("UpdateOnlyMergeable.taskName");
+ protected IStatus executeCommand(Session session, CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException {
+ UpdateMergableOnly update = new UpdateMergableOnly();
+ IStatus status = update.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ getLocalOptions(),
+ getCVSArguments(resources),
+ null,
+ Policy.subMonitorFor(monitor, 90));
+ if (status.getCode() != IStatus.ERROR) {
+ addSkippedFiles(update.getSkippedFiles());
+ return OK;
+ }
+ return status;
}
-
+
/* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName()
*/
- protected void execute(CVSTeamProvider provider, final IResource[] resources, IProgressMonitor monitor) throws CVSException, InterruptedException {
- CVSWorkspaceRoot workspaceRoot = provider.getCVSWorkspaceRoot();
- Session.run(workspaceRoot.getRemoteLocation(), workspaceRoot.getLocalRoot(), true /* output to console */,
- new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- UpdateMergableOnly update = new UpdateMergableOnly();
- IStatus status = update.execute(
- Command.NO_GLOBAL_OPTIONS,
- localOptions,
- getCVSArguments(resources),
- null,
- monitor);
- if (status.getCode() != IStatus.ERROR) {
- addSkippedFiles(update.getSkippedFiles());
- } else {
- addError(status);
- }
- }
- }, monitor);
-
+ protected String getTaskName() {
+ return Policy.bind("UpdateOnlyMergeable.taskName");
}
protected void addSkippedFiles(IFile[] files) {
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
new file mode 100644
index 000000000..da17e6076
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui.operations;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.CVSTag;
+import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.internal.ccvs.core.ICVSResource;
+import org.eclipse.team.internal.ccvs.core.client.Command;
+import org.eclipse.team.internal.ccvs.core.client.Session;
+import org.eclipse.team.internal.ccvs.core.client.Update;
+import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+
+/**
+ * Operation which performs a CVS update
+ */
+public class UpdateOperation extends SingleCommandOperation {
+
+ CVSTag tag;
+
+ /**
+ * @param shell
+ * @param resources
+ */
+ public UpdateOperation(Shell shell, IResource[] resources, LocalOption[] options, CVSTag tag) {
+ super(shell, resources, options);
+ this.tag = tag;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IStatus executeCommand(
+ Session session,
+ CVSTeamProvider provider,
+ IResource[] resources,
+ IProgressMonitor monitor)
+ throws CVSException, InterruptedException {
+
+ // Build the local options
+ List localOptions = new ArrayList();
+
+ // Use the appropriate tag options
+ if (tag != null) {
+ localOptions.add(Update.makeTagOption(tag));
+ }
+
+ // Build the arguments list
+ localOptions.addAll(Arrays.asList(getLocalOptions()));
+ LocalOption[] commandOptions = (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]);
+ ICVSResource[] arguments = getCVSArguments(resources);
+
+ return Command.UPDATE.execute(
+ session,
+ Command.NO_GLOBAL_OPTIONS,
+ commandOptions,
+ arguments,
+ null,
+ monitor);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
+ */
+ protected String getTaskName() {
+ return Policy.bind("UpdateOperation.taskName"); //$NON-NLS-1$;
+ }
+
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java
index 0746d84e3..3f7891a28 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceUpdateAction.java
@@ -67,7 +67,7 @@ public class WorkspaceUpdateAction extends SafeUpdateAction {
*/
protected void overwriteUpdate(SyncInfoSet syncSet, IProgressMonitor monitor) throws TeamException {
try {
- new ReplaceOperation(getShell(), syncSet.getResources(), false /* recurse */)
+ new ReplaceOperation(getShell(), syncSet.getResources(), null /* tag */, false /* recurse */)
.run(monitor);
} catch (InvocationTargetException e) {
throw CVSException.wrapException(e);
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];
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java
index d09eea3ab..cb3ce06b3 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java
@@ -174,19 +174,16 @@ public class CheckoutAsWizard extends Wizard {
private boolean performConfigureAndCheckout() throws CVSException, InterruptedException {
IProject newProject = getNewProject();
if (newProject == null) return false;
- new CheckoutSingleProjectOperation(getShell(), remoteFolders[0], newProject, null, true)
- .runInContext(getContainer());
+ // Run the checkout in the background
+ new CheckoutSingleProjectOperation(getShell(), remoteFolders[0], newProject, null, true).run();
return true;
}
- /**
- *
- */
private boolean performSingleCheckoutAs() throws CVSException, InterruptedException {
IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(mainPage.getProjectName());
String targetLocation = locationSelectionPage.getTargetLocation();
- new CheckoutSingleProjectOperation(getShell(), remoteFolders[0], newProject, targetLocation, false)
- .runInContext(getContainer());
+ // Run the checkout in the background
+ new CheckoutSingleProjectOperation(getShell(), remoteFolders[0], newProject, targetLocation, false).run();
return true;
}
@@ -196,14 +193,11 @@ public class CheckoutAsWizard extends Wizard {
*/
private boolean performMultipleCheckoutAs() throws CVSException, InterruptedException {
String targetLocation = locationSelectionPage.getTargetLocation();
- new CheckoutMultipleProjectsOperation(getShell(), remoteFolders, targetLocation)
- .runInContext(getContainer());
+ // Run the checkout in the background
+ new CheckoutMultipleProjectsOperation(getShell(), remoteFolders, targetLocation).run();
return true;
}
- /**
- * @return
- */
private boolean performCheckoutInto() throws CVSException, InterruptedException {
CheckoutIntoOperation operation;
boolean recursive = projectSelectionPage.isRecurse();
@@ -212,7 +206,8 @@ public class CheckoutAsWizard extends Wizard {
} else {
operation = new CheckoutIntoOperation(getShell(), remoteFolders, projectSelectionPage.getParentFolder(), recursive);
}
- operation.runInContext(getContainer());
+ // Run the checkout in the background
+ operation.run();
return true;
}

Back to the top