Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-03-05 09:21:16 -0500
committerMichael Valenta2002-03-05 09:21:16 -0500
commit12a61255ddb434ac4a10b8e3640361fc870dc89b (patch)
tree813f70e9fd8830380175d257461c5887d888fad7
parent6e002137f6f34296e738085a27e9f8b09ebdc81e (diff)
downloadeclipse.platform.team-12a61255ddb434ac4a10b8e3640361fc870dc89b.tar.gz
eclipse.platform.team-12a61255ddb434ac4a10b8e3640361fc870dc89b.tar.xz
eclipse.platform.team-12a61255ddb434ac4a10b8e3640361fc870dc89b.zip
10279: Problems with progress monitoring in CVSTeamProvider
- getRemoteSyncTree and RemoteFolderTreeBuilder have been improved
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java23
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties6
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/RemoteFolderTreeBuilder.java101
3 files changed, 94 insertions, 36 deletions
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 0ba8ed2b9..3d43943ed 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
@@ -571,18 +571,22 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
* wasn't added remotely by a third party
*/
private ICVSRemoteResource getRemoteTreeFromParent(IResource resource, ICVSResource managed, CVSTag tag, IProgressMonitor progress) throws TeamException {
+
// If the parent isn't mapped to CVS, there's nothing we can do
ICVSFolder parent = managed.getParent();
if (!parent.isCVSFolder()) {
// Check to make sure the project still has the CVS information
if (managedProject.getFolderSyncInfo() == null) {
// This is a catastrophic error. The project should have CVS information
- TeamPlugin.getManager().removeProvider(project, Policy.monitorFor(null));
+ TeamPlugin.getManager().removeProvider(project, progress);
throw new CVSException(new CVSStatus(CVSStatus.ERROR, project.getFullPath(), Policy.bind("CVSTeamProvider.invalidProjectState", managedProject.getName()), null)); //$NON-NLS-1$
} else {
throw new CVSException(new CVSStatus(CVSStatus.ERROR, resource.getFullPath(), Policy.bind("CVSTeamProvider.unmanagedParent", resource.getFullPath().toString()), null)); //$NON-NLS-1$
}
}
+
+ // Fetch the parent tree.
+ // The progress monitor is only passed to one method so no wrapping is needed
ICVSRepositoryLocation location = CVSProvider.getInstance().getRepository(parent.getFolderSyncInfo().getRoot());
// XXX We build and fetch the whole tree from the parent. We could restrict the search to just the desired child
RemoteFolder remoteParent = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, parent, tag, progress);
@@ -609,14 +613,22 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
// The resource doesn't have a remote base.
// However, we still need to check to see if its been created remotely by a third party.
if (remote == null) {
+ // The progress monitor is only passed to one method so no wrapping is needed
remote = getRemoteTreeFromParent(resource, managed, tag, progress);
} else if(resource.getType() == IResource.FILE) {
+ // The progress monitor is only passed to one method so no wrapping is needed
baseTree = remote;
remote = RemoteFile.getLatest((RemoteFolder)getRemoteResource(resource.getParent()), (ICVSFile)managed, tag, progress);
} else {
- ICVSRepositoryLocation location = remote.getRepository();
- baseTree = RemoteFolderTreeBuilder.buildBaseTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress);
- remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress);
+ try {
+ progress.setTaskName(Policy.bind("CVSTeamProvider.fetchingRemote", resource.getFullPath().toString()));
+ progress.beginTask(null, 100);
+ ICVSRepositoryLocation location = remote.getRepository();
+ baseTree = RemoteFolderTreeBuilder.buildBaseTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, Policy.subMonitorFor(progress, 20));
+ remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, Policy.subMonitorFor(progress, 80));
+ } finally {
+ progress.done();
+ }
}
return new CVSRemoteSyncElement(false, resource, baseTree, remote);
}
@@ -626,10 +638,13 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
ICVSResource managed = getChild(resource);
ICVSRemoteResource remote = getRemoteResource(resource);
if (remote == null) {
+ // The progress monitor is only passed to one method so no wrapping is needed
remote = getRemoteTreeFromParent(resource, managed, tag, progress);
} else if(resource.getType() == IResource.FILE) {
+ // The progress monitor is only passed to one method so no wrapping is needed
remote = RemoteFile.getLatest((RemoteFolder)getRemoteResource(resource.getParent()), (ICVSFile)managed, tag, progress);
} else {
+ // The progress monitor is only passed to one method so no wrapping is needed
ICVSRepositoryLocation location = remote.getRepository();
remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress);
}
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 338f27fd4..d2265c2b5 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
@@ -61,6 +61,7 @@ CVSTeamProvider.typesDiffer=Error retrieving remote resource tree. Local and rem
CVSTeamProvider.connectionInfo=Updating connection information for project {0}
CVSTeamProvider.folderInfo=Updating folder synchronization information for project {0}
CVSTeamProvider.updatingFolder=Updating {0}
+CVSTeamProvider.fetchingRemote=Fetching remote synchronization information for {0}
CVSTeamProvider.tagNotVersionOrBranchError=Error applying tag: the tag provided is not a version or branch tag.
@@ -90,6 +91,11 @@ RemoteFolder.invalidChild=Invalid folder {0} received during remote operation
RemoteFolder.errorFetchingRevisions=Error fetching file revisions
RemoteFile.noContentsReceived=No contents received from server for {0}
+RemoteFolderTreeBuilder.buildingBaseTree=Building base tree for {0}
+RemoteFolderTreeBuilder.buildingRemoteTree=Building remote tree for {0}
+RemoteFolderTreeBuilder.receivingDelta=Receiving delta for {0}
+RemoteFolderTreeBuilder.receivingRevision=Receiving revision for {0}
+
Session.readError=Read finished prematurely
Session.badInt="Malformed file transmission received"
Session.receiving=Receiving file: {0}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/RemoteFolderTreeBuilder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/RemoteFolderTreeBuilder.java
index 10ce7a171..1bf45f5e1 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/RemoteFolderTreeBuilder.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/RemoteFolderTreeBuilder.java
@@ -129,9 +129,17 @@ public class RemoteFolderTreeBuilder {
return (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]);
}
- public static RemoteFolderTree buildBaseTree(CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag, IProgressMonitor monitor) throws CVSException {
- RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, root, tag);
- return builder.buildBaseTree(null, root, monitor);
+ public static RemoteFolderTree buildBaseTree(CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag, IProgressMonitor progress) throws CVSException {
+ try {
+ RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, root, tag);
+ progress.setTaskName(Policy.bind("RemoteFolderTreeBuilder.buildingBaseTree", root.getName()));
+ progress.beginTask(null, 100);
+ IProgressMonitor subProgress = Policy.infiniteSubMonitorFor(progress, 100);
+ subProgress.beginTask(null, 512); //$NON-NLS-1$
+ return builder.buildBaseTree(null, root, subProgress);
+ } finally {
+ progress.done();
+ }
}
public static RemoteFolderTree buildRemoteTree(CVSRepositoryLocation repository, IContainer root, CVSTag tag, IProgressMonitor monitor) throws CVSException {
@@ -144,32 +152,44 @@ public class RemoteFolderTreeBuilder {
}
private RemoteFolderTree buildTree(IProgressMonitor monitor) throws CVSException {
- Session session = new Session(repository, root, false);
- session.open(monitor);
+
try {
- fetchDelta(session, monitor);
- if (projectDoesNotExist) {
- return null;
+ monitor.setTaskName(Policy.bind("RemoteFolderTreeBuilder.buildingRemoteTree", root.getName()));
+ monitor.beginTask(null, 100);
+
+ Session session = new Session(repository, root, false);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ try {
+ fetchDelta(session, Policy.subMonitorFor(monitor, 50));
+ if (projectDoesNotExist) {
+ return null;
+ }
+ } finally {
+ session.close();
+ }
+ // FIXME: We need a second session because of the use of a different handle on the same remote resource
+ // We didn't need one before!!! Perhaps we could support the changing of a sessions root as long as
+ // the folder sync info is the same
+ remoteRoot =
+ new RemoteFolderTree(null, root.getName(), repository,
+ new Path(root.getFolderSyncInfo().getRepository()),
+ tagForRemoteFolder(root, tag));
+ session = new Session(repository, remoteRoot, false);
+ session.open(Policy.subMonitorFor(monitor, 10));
+ 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, Path.EMPTY, subProgress);
+ if (!changedFiles.isEmpty())
+ fetchFileRevisions(session, (String[])changedFiles.toArray(new String[changedFiles.size()]), Policy.subMonitorFor(monitor, 20));
+ return remoteRoot;
+ } finally {
+ session.close();
}
} finally {
- session.close();
- }
- // FIXME: We need a second session because of the use of a different handle on the same remote resource
- // We didn't need one before!!! Perhaps we could support the changing of a sessions root as long as
- // the folder sync info is the same
- remoteRoot =
- new RemoteFolderTree(null, root.getName(), repository,
- new Path(root.getFolderSyncInfo().getRepository()),
- tagForRemoteFolder(root, tag));
- session = new Session(repository, remoteRoot, false);
- session.open(monitor);
- try {
- buildRemoteTree(session, root, remoteRoot, Path.EMPTY, monitor);
- if (!changedFiles.isEmpty())
- fetchFileRevisions(session, (String[])changedFiles.toArray(new String[changedFiles.size()]), monitor);
- return remoteRoot;
- } finally {
- session.close();
+ monitor.done();
}
}
@@ -178,6 +198,7 @@ public class RemoteFolderTreeBuilder {
*
* The localPath is used to retrieve deltas from the recorded deltas
*
+ * Does 1 work for each managed file and folder
*/
private RemoteFolderTree buildBaseTree(RemoteFolderTree parent, ICVSFolder local, IProgressMonitor monitor) throws CVSException {
@@ -191,6 +212,8 @@ public class RemoteFolderTreeBuilder {
ICVSFolder[] folders = local.getFolders();
for (int i=0;i<folders.length;i++) {
if (folders[i].isManaged() && folders[i].isCVSFolder()) {
+ monitor.subTask("Building base for " + folders[i].getRelativePath(root));
+ monitor.worked(1);
children.add(buildBaseTree(remote, folders[i], monitor));
}
}
@@ -210,6 +233,7 @@ public class RemoteFolderTreeBuilder {
if (info.isDeleted())
info = new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions());
children.add(new RemoteFile(remote, info));
+ monitor.worked(1);
}
// Add the children to the remote folder tree
@@ -223,6 +247,7 @@ public class RemoteFolderTreeBuilder {
*
* The localPath is used to retrieve deltas from the recorded deltas
*
+ * Does 1 work for each file and folder delta processed
*/
private void buildRemoteTree(Session session, ICVSFolder local, RemoteFolderTree remote, IPath localPath, IProgressMonitor monitor) throws CVSException {
@@ -304,6 +329,7 @@ public class RemoteFolderTreeBuilder {
} else {
// We should never get here
}
+ monitor.worked(1);
}
// Add the children to the remote folder tree
@@ -358,7 +384,7 @@ public class RemoteFolderTreeBuilder {
*
* Returns the list of changed files
*/
- private List fetchDelta(Session session, IProgressMonitor monitor) throws CVSException {
+ private List fetchDelta(Session session, final IProgressMonitor monitor) throws CVSException {
// Create an listener that will accumulate new and removed files and folders
final List newChildDirectories = new ArrayList();
@@ -367,6 +393,7 @@ public class RemoteFolderTreeBuilder {
if (newDirectory) {
// Record new directory with parent so it can be retrieved when building the parent
recordDelta(path, FOLDER, Update.STATE_NONE);
+ monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", path.toString()));
// Record new directory to be used as a parameter to fetch its contents
newChildDirectories.add(path.toString());
}
@@ -377,6 +404,7 @@ public class RemoteFolderTreeBuilder {
projectDoesNotExist = true;
} else {
recordDelta(path, DELETED, Update.STATE_NONE);
+ monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", path.toString()));
}
}
public void fileInformation(int type, String filename) {
@@ -400,11 +428,13 @@ public class RemoteFolderTreeBuilder {
case Update.STATE_REMOTE_CHANGES : // We have an remote change to an unmodified local file
changedFiles.add(filename);
recordDelta(new Path(filename), UNKNOWN, type);
+ monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", filename));
break;
}
}
public void fileDoesNotExist(String filename) {
recordDelta(new Path(filename), DELETED, Update.STATE_NONE);
+ monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", filename));
}
};
@@ -419,8 +449,12 @@ public class RemoteFolderTreeBuilder {
monitor);
return changedFiles;
}
-
- private void fetchNewDirectory(Session session, RemoteFolderTree newFolder, IPath localPath, IProgressMonitor monitor) throws CVSException {
+ /*
+ * Fetch the children of a previously unknown directory.
+ *
+ * The fetch may do up to 2 units of work in the provided monitor.
+ */
+ private void fetchNewDirectory(Session session, RemoteFolderTree newFolder, IPath localPath, final IProgressMonitor monitor) throws CVSException {
// Create an listener that will accumulate new files and folders
IUpdateMessageListener listener = new IUpdateMessageListener() {
@@ -429,6 +463,7 @@ public class RemoteFolderTreeBuilder {
// Record new directory with parent so it can be retrieved when building the parent
// NOTE: Check path prefix
recordDelta(path, FOLDER, Update.STATE_NONE);
+ monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", path.toString()));
}
}
public void directoryDoesNotExist(IPath path) {
@@ -437,6 +472,7 @@ public class RemoteFolderTreeBuilder {
// NOTE: Check path prefix
changedFiles.add(filename);
recordDelta(new Path(filename), ADDED, type);
+ monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingDelta", filename));
}
public void fileDoesNotExist(String filename) {
}
@@ -449,7 +485,7 @@ public class RemoteFolderTreeBuilder {
updateLocalOptions,
new String[] { localPath.toString() },
new UpdateListener(listener),
- monitor);
+ Policy.subMonitorFor(monitor, 1));
if (status.getCode() == CVSStatus.SERVER_ERROR) {
// FIXME: This should be refactored (maybe static methods on CVSException?)
CVSServerException e = new CVSServerException(status);
@@ -464,7 +500,7 @@ public class RemoteFolderTreeBuilder {
getOptionsWithoutTag(),
new String[] { localPath.toString() },
new UpdateListener(listener),
- monitor);
+ Policy.subMonitorFor(monitor, 1));
if (status.getCode() == CVSStatus.SERVER_ERROR) {
throw new CVSServerException(status);
}
@@ -472,7 +508,7 @@ public class RemoteFolderTreeBuilder {
}
// Get the file revisions for the given filenames
- private void fetchFileRevisions(Session session, String[] fileNames, IProgressMonitor monitor) throws CVSException {
+ private void fetchFileRevisions(Session session, String[] fileNames, final IProgressMonitor monitor) throws CVSException {
// Create a listener for receiving the revision info
final int[] count = new int[] {0};
@@ -481,6 +517,7 @@ public class RemoteFolderTreeBuilder {
public void fileStatus(IPath path, String remoteRevision) {
try {
updateRevision(path, remoteRevision);
+ monitor.subTask(Policy.bind("RemoteFolderTreeBuilder.receivingRevision", path.toString()));
count[0]++;
} catch (CVSException e) {
// The count will be off which will trigger another exception

Back to the top