Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-08-19 15:31:19 +0000
committerMichael Valenta2003-08-19 15:31:19 +0000
commitee17311d6c675dd799029fc64ba311c1a94b6d4c (patch)
tree4193112cf80da91bdef0f68fbc78c24249667ea6
parentc54f967d1a3b203c9986b3d3b50dd7f21f68587e (diff)
downloadeclipse.platform.team-ee17311d6c675dd799029fc64ba311c1a94b6d4c.tar.gz
eclipse.platform.team-ee17311d6c675dd799029fc64ba311c1a94b6d4c.tar.xz
eclipse.platform.team-ee17311d6c675dd799029fc64ba311c1a94b6d4c.zip
Added support for file contents caching
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java16
-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/resources/CVSWorkspaceRoot.java28
-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.java20
-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.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLocalCompareEditorInput.java6
11 files changed, 309 insertions, 95 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java
index 78074e0b6..9749ecf87 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java
@@ -29,6 +29,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.subscribers.ContentComparisonCriteria;
import org.eclipse.team.core.subscribers.ITeamResourceChangeListener;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.core.subscribers.TeamDelta;
@@ -107,14 +108,13 @@ public class CVSMergeSubscriber extends CVSSyncTreeSubscriber implements IResour
baseSynchronizer = new RemoteTagSynchronizer(syncKeyPrefix + start.getName(), start);
mergedSynchronizer = new RemoteSynchronizer(syncKeyPrefix + "0merged");
- // TODO: must use revision comparison until bugs 40035 and 40129 are addressed
-// try {
-// setCurrentComparisonCriteria(ContentComparisonCriteria.ID_IGNORE_WS);
-// } catch (TeamException e) {
-// // use the default but log an exception because the content comparison should
-// // always be available.
-// CVSProviderPlugin.log(e);
-// }
+ try {
+ setCurrentComparisonCriteria(ContentComparisonCriteria.ID_IGNORE_WS);
+ } catch (TeamException e) {
+ // use the default but log an exception because the content comparison should
+ // always be available.
+ CVSProviderPlugin.log(e);
+ }
ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().addListener(this);
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/resources/CVSWorkspaceRoot.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java
index 0fcb7744d..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
@@ -599,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/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 b1e9dd926..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
@@ -22,7 +22,6 @@ 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;
@@ -175,7 +174,7 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
return new ByteArrayInputStream(contents);
}
- private void fetchContents(IProgressMonitor monitor) throws CVSException {
+ /* 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));
@@ -398,6 +397,13 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
}
/*
+ * Return whether there are already contents cached for the given handle
+ */
+ public boolean isContentsCached() {
+ return getRemoteContentsCache().hasContents(getCacheRelativePath());
+ }
+
+ /*
* @see ICVSFile#setReadOnly(boolean)
*/
public void setReadOnly(boolean readOnly) throws CVSException {
@@ -563,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)
@@ -578,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/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.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$
}

Back to the top