Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-05-31 16:20:26 +0000
committerMichael Valenta2002-05-31 16:20:26 +0000
commitc59d2db8ea95eee3debebea5fe1d1630fbaca342 (patch)
treeadb3f64c8240f4ad7f57ecd2c91fcb280b21c4a0
parent8a7c01a85dd045dbe74fb4b30a497c6026f9ce4c (diff)
downloadeclipse.platform.team-c59d2db8ea95eee3debebea5fe1d1630fbaca342.tar.gz
eclipse.platform.team-c59d2db8ea95eee3debebea5fe1d1630fbaca342.tar.xz
eclipse.platform.team-c59d2db8ea95eee3debebea5fe1d1630fbaca342.zip
17940: Synchronize outgoing changes opens a connection per file
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Update.java28
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java18
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java34
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java57
4 files changed, 121 insertions, 16 deletions
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 2a4f87c2a..665e4eaef 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
@@ -14,8 +14,9 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTag;
+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.Policy;
import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
@@ -125,4 +126,29 @@ public class Update extends Command {
localOptions = (LocalOption[]) newOptions.toArray(new LocalOption[newOptions.size()]);
return super.filterLocalOptions(session, globalOptions, localOptions);
}
+
+ /**
+ * We allow unmanaged resources as long as there parents are managed.
+ *
+ * @see Command#checkResourcesManaged(ICVSResource[])
+ */
+ protected void checkResourcesManaged(ICVSResource[] resources) throws CVSException {
+ for (int i = 0; i < resources.length; ++i) {
+ ICVSFolder folder;
+ if (resources[i].isFolder()) {
+ if (((ICVSFolder)resources[i]).isCVSFolder()) {
+ folder = (ICVSFolder)resources[i];
+ } else {
+ folder = resources[i].getParent();
+ }
+ }
+ else {
+ folder = resources[i].getParent();
+ }
+ if (folder==null || (!folder.isCVSFolder() && folder.exists())) {
+ throw new CVSException(Policy.bind("Command.argumentNotManaged", folder.getName()));//$NON-NLS-1$
+ }
+ }
+ }
+
} \ No newline at end of file
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 720465092..1fba6a493 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
@@ -5,6 +5,8 @@ package org.eclipse.team.internal.ccvs.core.resources;
* All Rights Reserved.
*/
+import java.util.ArrayList;
+
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -158,6 +160,22 @@ public class CVSWorkspaceRoot {
}
}
+ public static IRemoteSyncElement getRemoteSyncTree(IProject project, IResource[] resources, CVSTag tag, IProgressMonitor progress) throws TeamException {
+ ICVSResource managed = CVSWorkspaceRoot.getCVSResourceFor(project);
+ ICVSRemoteResource remote = CVSWorkspaceRoot.getRemoteResourceFor(project);
+ if (remote == null) {
+ return null;
+ }
+ ArrayList cvsResources = new ArrayList();
+ for (int i = 0; i < resources.length; i++) {
+ cvsResources.add(CVSWorkspaceRoot.getCVSResourceFor(resources[i]));
+ }
+ CVSRepositoryLocation location = (CVSRepositoryLocation)remote.getRepository();
+ ICVSRemoteResource base = RemoteFolderTreeBuilder.buildBaseTree(location, (ICVSFolder)managed, tag, progress);
+ remote = RemoteFolderTreeBuilder.buildRemoteTree(location, (ICVSFolder)managed, (ICVSResource[]) cvsResources.toArray(new ICVSResource[cvsResources.size()]), tag, progress);
+ return new CVSRemoteSyncElement(true /*three way*/, project, base, remote);
+ }
+
public static ICVSRemoteResource getRemoteTree(IResource resource, CVSTag tag, IProgressMonitor progress) throws TeamException {
ICVSResource managed = CVSWorkspaceRoot.getCVSResourceFor(resource);
ICVSRemoteResource remote = CVSWorkspaceRoot.getRemoteResourceFor(resource);
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 d758cba0e..89e8d193f 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
@@ -151,15 +151,25 @@ public class RemoteFolderTreeBuilder {
public static RemoteFolderTree buildRemoteTree(CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag, IProgressMonitor monitor) throws CVSException {
RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, root, tag);
- return builder.buildTree(monitor);
+ return builder.buildTree(new ICVSResource[] { root }, monitor);
}
-
public static RemoteFile buildRemoteTree(CVSRepositoryLocation repository, ICVSFile file, CVSTag tag, IProgressMonitor monitor) throws CVSException {
RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, file.getParent(), tag);
return builder.buildTree(file, monitor);
}
+
+ /*
+ * The provided resources must all be children of the same project
+ */
+ public static RemoteFolderTree buildRemoteTree(CVSRepositoryLocation repository, ICVSFolder root, ICVSResource[] resources, CVSTag tag, IProgressMonitor monitor) throws CVSException {
+ if (resources.length == 0) {
+ resources = new ICVSResource[] { root };
+ }
+ RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, root, tag);
+ return builder.buildTree(resources, monitor);
+ }
- private RemoteFolderTree buildTree(IProgressMonitor monitor) throws CVSException {
+ private 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();
@@ -167,13 +177,20 @@ public class RemoteFolderTreeBuilder {
CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE);
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));
+ }
+
Policy.checkCanceled(monitor);
Session session = new Session(repository, root, false);
session.open(Policy.subMonitorFor(monitor, 10));
try {
Policy.checkCanceled(monitor);
- fetchDelta(session, Session.CURRENT_LOCAL_FOLDER, Policy.subMonitorFor(monitor, 50));
+ 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)
@@ -237,7 +254,6 @@ public class RemoteFolderTreeBuilder {
monitor.done();
}
}
-
private RemoteFile buildTree(ICVSFile file, IProgressMonitor monitor) throws CVSException {
QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness();
try {
@@ -251,7 +267,7 @@ public class RemoteFolderTreeBuilder {
session.open(Policy.subMonitorFor(monitor, 10));
try {
Policy.checkCanceled(monitor);
- fetchDelta(session, file.getName(), Policy.subMonitorFor(monitor, 50));
+ fetchDelta(session, new String[] { file.getName() }, Policy.subMonitorFor(monitor, 50));
if (projectDoesNotExist) {
return null;
}
@@ -501,7 +517,7 @@ public class RemoteFolderTreeBuilder {
*
* Returns the list of changed files
*/
- private List fetchDelta(Session session, String argument, final IProgressMonitor monitor) throws CVSException {
+ private List fetchDelta(Session session, String[] arguments, final IProgressMonitor monitor) throws CVSException {
// Create an listener that will accumulate new and removed files and folders
final List newChildDirectories = new ArrayList();
@@ -561,7 +577,7 @@ public class RemoteFolderTreeBuilder {
IStatus status = Command.UPDATE.execute(session,
new GlobalOption[] { Command.DO_NOT_CHANGE },
updateLocalOptions,
- new String[] { argument },
+ arguments,
new UpdateListener(listener),
monitor);
return changedFiles;
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 601470c6d..31812252a 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
@@ -7,12 +7,16 @@ package org.eclipse.team.internal.ccvs.ui.sync;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.compare.structuremergeviewer.IDiffContainer;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
@@ -26,11 +30,13 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
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.ICVSFile;
+import org.eclipse.team.internal.ccvs.core.ICVSFolder;
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;
@@ -149,7 +155,20 @@ public class CVSSyncCompareInput extends SyncCompareInput {
if (isDirty((IFile)resource)) {
outgoing.add(resource);
}
- }
+ } else {
+ try {
+ ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)resource);
+ if (folder.isCVSFolder()) {
+ return true;
+ } else {
+ outgoing.add(resource);
+ return false;
+ }
+ } catch (CVSException e) {
+ CVSUIPlugin.log(e.getStatus());
+ return false;
+ }
+ }
return true;
}
});
@@ -159,16 +178,25 @@ public class CVSSyncCompareInput extends SyncCompareInput {
CVSUIPlugin.log(e.getStatus());
return new IRemoteSyncElement[0];
}
+
final TeamException[] exception = new TeamException[1];
- final IFile[] files = (IFile[])outgoing.toArray(new IFile[outgoing.size()]);
- final IRemoteSyncElement[] trees = new IRemoteSyncElement[files.length];
+ final Map providerMapping = getProviderMapping((IResource[])outgoing.toArray(new IResource[outgoing.size()]));
+ final IRemoteSyncElement[] trees = new IRemoteSyncElement[providerMapping.size()];
Session.run(null, null, true, new ICVSRunnable() {
public void run(IProgressMonitor monitor) throws CVSException {
- int work = 1000 * resources.length;
+ int i = 0;
+ int work = 1000 * trees.length;
monitor.beginTask(null, work);
try {
- for (int i = 0; i < trees.length; i++) {
- trees[i] = CVSWorkspaceRoot.getRemoteSyncTree(files[i], null, Policy.subMonitorFor(monitor, 1000));
+ for (Iterator iter = providerMapping.keySet().iterator(); iter.hasNext();) {
+ RepositoryProvider provider = (RepositoryProvider)iter.next();
+ List resourceList = (List)providerMapping.get(provider);
+ final TeamException[] exception = new TeamException[1];
+ trees[i] = CVSWorkspaceRoot.getRemoteSyncTree(
+ provider.getProject(),
+ (IResource[]) resourceList.toArray(new IResource[resourceList.size()]),
+ null /* tag */,
+ Policy.subMonitorFor(monitor, 1000));
}
} catch (TeamException e) {
exception[0] = e;
@@ -378,4 +406,21 @@ public class CVSSyncCompareInput extends SyncCompareInput {
private static boolean isDirty(IFile file) {
return isDirty(CVSWorkspaceRoot.getCVSFileFor(file));
}
+
+ /*
+ * Method copied from TeamAction. It should be put in a common place
+ */
+ protected Map getProviderMapping(IResource[] resources) {
+ Map result = new HashMap();
+ for (int i = 0; i < resources.length; i++) {
+ RepositoryProvider provider = RepositoryProvider.getProvider(resources[i].getProject());
+ List list = (List)result.get(provider);
+ if (list == null) {
+ list = new ArrayList();
+ result.put(provider, list);
+ }
+ list.add(resources[i]);
+ }
+ return result;
+ }
}

Back to the top