Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-02-27 17:11:34 -0500
committerMichael Valenta2002-02-27 17:11:34 -0500
commitfd8787a996bd844702a4b06414c3a2f4ad29ea1c (patch)
tree2e1b859cf93f8406bb942a102e092c5dc5b4f8a4
parent351b23ebe2644fb90a5588fe680d510e0ae6d372 (diff)
downloadeclipse.platform.team-fd8787a996bd844702a4b06414c3a2f4ad29ea1c.tar.gz
eclipse.platform.team-fd8787a996bd844702a4b06414c3a2f4ad29ea1c.tar.xz
eclipse.platform.team-fd8787a996bd844702a4b06414c3a2f4ad29ea1c.zip
8492: Checkout does not support loading of multiple projects
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java237
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSProvider.java7
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java9
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java16
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java6
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java5
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java7
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java77
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java36
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java8
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java4
13 files changed, 283 insertions, 133 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
index 824d4dd99..cb55bf037 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
@@ -59,8 +59,10 @@ import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTree;
+import org.eclipse.team.internal.ccvs.core.resources.RemoteModule;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.Util;
+import org.eclipse.team.internal.ccvs.core.Policy;
public class CVSProvider implements ICVSProvider {
@@ -109,79 +111,84 @@ public class CVSProvider implements ICVSProvider {
CVSTag tag,
IProgressMonitor monitor)
throws TeamException {
-
- // Create the project if one wasn't passed.
- // NOTE: This will need to be fixed for module alias support
- if (project == null)
- project = ResourcesPlugin.getWorkspace().getRoot().getProject(new Path(sourceModule).lastSegment());
-
- // Get the location of the workspace root
- ICVSFolder root = Session.getManagedFolder(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile());
- // Build the local options
- List localOptions = new ArrayList();
- // Add the option to load into a directory of a different name
- String module = project.getName();
- if (sourceModule != null) {
- localOptions.add(Checkout.makeDirectoryNameOption(module));
- module = sourceModule;
+ if (sourceModule == null)
+ sourceModule = project.getName();
+ checkout(new ICVSRemoteFolder[] { new RemoteFolder(null, repository, new Path(sourceModule), tag)},
+ new IProject[] { project }, monitor);
+ }
+
+ /*
+ * Delete the target projects before checking out
+ */
+ private void scrubProjects(IProject[] projects, IProgressMonitor monitor) throws CoreException {
+ if (projects == null) {
+ monitor.done();
+ return;
}
- // Prune empty directories if pruning enabled
- if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories())
- localOptions.add(Checkout.PRUNE_EMPTY_DIRECTORIES);
- // Add the options related to the CVSTag
- if (tag != null && tag.getType() != CVSTag.HEAD) {
- localOptions.add(Checkout.makeTagOption(tag));
+ monitor.beginTask(Policy.bind("CVSProvider.Scrubbing_projects_1"), projects.length * 100); //$NON-NLS-1$
+ try {
+ for (int i=0;i<projects.length;i++) {
+ IProject project = projects[i];
+ if(project != null && project.exists()) {
+ if(!project.isOpen()) {
+ project.open(Policy.subMonitorFor(monitor, 10));
+ }
+ // XXX: temporary code to support creating a java project for sources in CVS
+ // should be removed once nature support is added to the UI.
+ // delete children, keep project
+ monitor.subTask(Policy.bind("CVSProvider.Scrubbing_local_project_1")); //$NON-NLS-1$
+ IResource[] children = project.members();
+ IProgressMonitor subMonitor = Policy.subMonitorFor(monitor, 90);
+ subMonitor.beginTask(null, children.length * 100);
+ try {
+ for (int j = 0; j < children.length; j++) {
+ children[j].delete(true /*force*/, Policy.subMonitorFor(subMonitor, 100));
+ }
+ } finally {
+ subMonitor.done();
+ }
+ }
+ }
+ } finally {
+ monitor.done();
}
-
- // Perform a checkout
- IStatus status;
- Session s = new Session(repository, root);
- monitor.beginTask(null, 100);
+ }
+
+ /*
+ * Bring the provied projects into the workspace
+ */
+ private void refreshProjects(IProject[] projects, IProgressMonitor monitor) throws CoreException, TeamException {
+ monitor.beginTask(Policy.bind("CVSProvider.Creating_projects_2"), projects.length * 100); //$NON-NLS-1$
try {
- // Opening the session takes 10% of the time
- s.open(Policy.subMonitorFor(monitor, 10));
- try {
- status = Command.CHECKOUT.execute(s,
- getDefaultGlobalOptions(),
- (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]),
- new String[]{module},
- null,
- Policy.subMonitorFor(monitor, 80));
- } finally {
- s.close();
- }
- if (status.getCode() == CVSStatus.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
-
- try {
+ for (int i = 0; i < projects.length; i++) {
+ IProject project = projects[i];
+
// Create, open and/or refresh the project
if (!project.exists())
- project.create(Policy.subMonitorFor(monitor, 1));
+ project.create(Policy.subMonitorFor(monitor, 40));
if (!project.isOpen())
- project.open(Policy.subMonitorFor(monitor, 5));
+ project.open(Policy.subMonitorFor(monitor, 40));
else
- project.refreshLocal(IResource.DEPTH_INFINITE, Policy.subMonitorFor(monitor, 5));
+ project.refreshLocal(IResource.DEPTH_INFINITE, Policy.subMonitorFor(monitor, 40));
// Register the project with Team
// (unless the project already has the proper nature from the project meta-information)
if (!project.getDescription().hasNature(CVSProviderPlugin.NATURE_ID)) {
- TeamPlugin.getManager().setProvider(project, CVSProviderPlugin.NATURE_ID, null, Policy.subMonitorFor(monitor, 1));
+ TeamPlugin.getManager().setProvider(project, CVSProviderPlugin.NATURE_ID, null, Policy.subMonitorFor(monitor, 10));
}
-
- } catch (CoreException e) {
- throw wrapException(e);
}
+
} finally {
monitor.done();
}
}
-
+
+
/**
* @see ICVSProvider#checkout(ICVSRemoteResource[], IProject[], IProgressMonitor)
*/
- public void checkout(final ICVSRemoteFolder[] resources, final IProject[] projects, IProgressMonitor monitor) throws TeamException {
+ public void checkout(final ICVSRemoteFolder[] resources, final IProject[] projects, final IProgressMonitor monitor) throws TeamException {
final TeamException[] eHolder = new TeamException[1];
try {
IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
@@ -189,32 +196,89 @@ public class CVSProvider implements ICVSProvider {
try {
pm.setTaskName(Policy.bind("Checking_out_from_CVS..._5")); //$NON-NLS-1$
pm.beginTask(null, 1000 * resources.length);
+
+ // Get the location of the workspace root
+ ICVSFolder root = (ICVSFolder)Session.getManagedResource(ResourcesPlugin.getWorkspace().getRoot());
+
for (int i=0;i<resources.length;i++) {
IProject project = null;
RemoteFolder resource = (RemoteFolder)resources[i];
+
+ // Determine the provided target project if there is one
if (projects != null)
project = projects[i];
- // delete the project in the workbench first, this will allow us to retreive a clean
- // copy of the project.
- if(project != null && project.exists()) {
- if(!project.isOpen()) {
- project.open(Policy.subMonitorFor(pm, 10));
+ // Determine the remote module to be checked out
+ String moduleName;
+ if (resource instanceof RemoteModule) {
+ moduleName = ((RemoteModule)resource).getName();
+ } else {
+ moduleName = resource.getRepositoryRelativePath();
+ }
+
+ // Open a connection session to the repository
+ ICVSRepositoryLocation repository = resource.getRepository();
+ Session session = new Session(repository, root);
+ try {
+ session.open(monitor);
+
+ // Determine the local target projects (either the project provider or the module expansions)
+ Set targetProjects = new HashSet();
+ if (project == null) {
+
+ // Fetch the module expansions
+ IStatus status = Command.EXPAND_MODULES.execute(session, new String[] {moduleName}, monitor);
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ // XXX Should we cleanup any partially checked out projects?
+ throw new CVSServerException(status);
+ }
+
+ // Convert the module expansions to local projects
+ String[] expansions = session.getModuleExpansions();
+ for (int j = 0; j < expansions.length; j++) {
+ targetProjects.add(ResourcesPlugin.getWorkspace().getRoot().getProject(new Path(expansions[j]).segment(0)));
+ }
+
+ } else {
+ targetProjects.add(project);
+ }
+
+ // Prepare the target projects to receive resources
+ scrubProjects((IProject[]) targetProjects.toArray(new IProject[targetProjects.size()]), Policy.subMonitorFor(pm, 100));
+
+ // Build the local options
+ List localOptions = new ArrayList();
+ // Add the option to load into the target project if one was supplied
+ if (project != null) {
+ localOptions.add(Checkout.makeDirectoryNameOption(project.getName()));
}
- // XXX: temporary code to support creating a java project for sources in CVS
- // should be removed once nature support is added to the UI.
- // delete children, keep project
- pm.subTask(Policy.bind("CVSProvider.Scrubbing_local_project_1")); //$NON-NLS-1$
- IResource[] children = project.members();
- IProgressMonitor subMonitor = Policy.subMonitorFor(pm, 90);
- subMonitor.beginTask(null, children.length * 100);
- for (int j = 0; j < children.length; j++) {
- children[j].delete(true /*force*/, Policy.subMonitorFor(subMonitor, 100));
+ // Prune empty directories if pruning enabled
+ if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories())
+ localOptions.add(Checkout.PRUNE_EMPTY_DIRECTORIES);
+ // Add the options related to the CVSTag
+ CVSTag tag = resource.getTag();
+ if (tag != null && tag.getType() != CVSTag.HEAD) {
+ localOptions.add(Checkout.makeTagOption(tag));
}
- subMonitor.done();
+
+ // Perform the checkout
+ IStatus status = Command.CHECKOUT.execute(session,
+ getDefaultGlobalOptions(),
+ (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]),
+ new String[]{moduleName},
+ null,
+ Policy.subMonitorFor(pm, 800));
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ // XXX Should we cleanup any partially checked out projects?
+ throw new CVSServerException(status);
+ }
+
+ // Bring the project into the workspace
+ refreshProjects((IProject[])targetProjects.toArray(new IProject[targetProjects.size()]), Policy.subMonitorFor(pm, 100));
+
+ } finally {
+ session.close();
}
-
- checkout(resource.getRepository(), project, resource.getRepositoryRelativePath(), resource.getTag(), Policy.subMonitorFor(pm, 900));
}
}
catch (TeamException e) {
@@ -281,6 +345,7 @@ public class CVSProvider implements ICVSProvider {
public boolean isKnownRepository(String location) {
return repositories.get(location) != null;
}
+
/*
* Returns all patterns in the given project that should be treated as binary
*/
@@ -323,6 +388,40 @@ public class CVSProvider implements ICVSProvider {
return instance;
}
+ public String[] getExpansions(ICVSRemoteFolder[] resources, IProgressMonitor monitor) throws CVSException {
+
+ if (resources.length == 0) return new String[0];
+
+ // Get the location of the workspace root
+ ICVSFolder root = Session.getManagedFolder(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile());
+
+ // Get the command arguments
+ String[] arguments = new String[resources.length];
+ for (int i = 0; i < resources.length; i++) {
+ ICVSRemoteFolder iCVSRemoteFolder = resources[i];
+ if (resources[i] instanceof RemoteModule) {
+ arguments[i] = ((RemoteModule)resources[i]).getName();
+ } else {
+ arguments[i] = resources[i].getRepositoryRelativePath();
+ }
+ }
+
+ // Perform the Expand-Modules command
+ IStatus status;
+ Session s = new Session(resources[0].getRepository(), root);
+ s.open(monitor);
+ try {
+ status = Command.EXPAND_MODULES.execute(s, arguments, monitor);
+ } finally {
+ s.close();
+ }
+ if (status.getCode() == CVSStatus.SERVER_ERROR) {
+ throw new CVSServerException(status);
+ }
+
+ return s.getModuleExpansions();
+ }
+
/**
* @see ICVSProvider#getKnownRepositories()
*/
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSProvider.java
index 2877e9c39..eb82f7dda 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSProvider.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSProvider.java
@@ -98,6 +98,13 @@ public interface ICVSProvider {
*/
public boolean isKnownRepository(String location);
+ /**
+ * Answer the list of directories that a checkout of the given resources would expand to.
+ * In other words, the returned strings represent the root paths that the given resources would
+ * be loaded into.
+ */
+ public String[] getExpansions(ICVSRemoteFolder[] resources, IProgressMonitor monitor) throws CVSException;
+
/**
* Return a list of the know repository locations
*/
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java
index b69d0bf58..db243a4f8 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFolder.java
@@ -37,4 +37,13 @@ public interface ICVSRemoteFolder extends ICVSRemoteResource {
* Command.DO_NOT_RECURSE
*/
public LocalOption[] getLocalOptions();
+
+ /**
+ * Indicates whether the remote folder can be expanded.
+ *
+ * This is a temporary (hopefully) means of indicating certain types of folders
+ * (i.e. module definitions) that are not expandable due to lack of mdoule expansion.
+ * They can still be checked out.
+ */
+ public boolean isExpandable();
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java
index 419e1b0fc..f06abf583 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java
@@ -50,6 +50,7 @@ public class Checkout extends Command {
// We can determine the local directories using either the -d option or the module expansions
Option dOption = findOption(localOptions, "-d"); //$NON-NLS-1$
if (dOption != null) {
+ // XXX Should we append the expansions to the -d argument?
return new ICVSResource[] {session.getLocalRoot().getFolder(dOption.argument)};
}
String[] modules = session.getModuleExpansions();
@@ -102,7 +103,7 @@ public class Checkout extends Command {
for (int i=0; i<resources.length; i++) {
resources[i].accept(visitor);
}
- }
+ }
}
/**
@@ -118,8 +119,8 @@ public class Checkout extends Command {
if (status.getCode() == CVSStatus.SERVER_ERROR)
return status;
- // Do not shorten paths if there is more than one expansion
- if (session.getModuleExpansions().length > 1) {
+ // Do not shorten paths if -d is specified
+ if (findOption(localOptions, "-d") == null) { //$NON-NLS-1$
if ( ! DO_NOT_SHORTEN.isElementOf(localOptions)) {
LocalOption[] newLocalOptions = new LocalOption[localOptions.length + 1];
newLocalOptions[0] = DO_NOT_SHORTEN;
@@ -128,7 +129,14 @@ public class Checkout extends Command {
}
}
- return super.execute(session, globalOptions, localOptions, arguments, listener, Policy.subMonitorFor(monitor, 90));
+ // Execute the checkout command
+ status = super.execute(session, globalOptions, localOptions, arguments, listener, Policy.subMonitorFor(monitor, 90));
+ if (status.getCode() == CVSStatus.SERVER_ERROR)
+ return status;
+
+ // Make the checked out resources known to the workbench
+
+ return status;
}
/**
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 bbaf2f28c..9fa6040c5 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
@@ -638,7 +638,7 @@ public abstract class Command {
* @param option the option string to search for
* @return the first element matching the option string, or null if none
*/
- protected static Option findOption(Option[] array, String option) {
+ public static Option findOption(Option[] array, String option) {
for (int i = 0; i < array.length; ++i) {
// FIXME: can be optimized using identity
if (array[i].option.equals(option)) return array[i];
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java
index 9d8ffb4c7..5bad4d19f 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ExpandModules.java
@@ -21,6 +21,12 @@ public class ExpandModules extends Command {
return "expand-modules"; //$NON-NLS-1$
}
+ protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions,
+ String[] arguments) throws CVSException {
+
+ return new ICVSResource[0];
+ }
+
/*
* @see Command#sendLocalResourceState(Session, GlobalOption[], LocalOption[], ICVSResource[], IProgressMonitor)
*/
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 722881b06..5553f19e5 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
@@ -218,7 +218,10 @@ public class Session {
}
/**
- * Return the list of module expansions communicated from the server
+ * Return the list of module expansions communicated from the server.
+ *
+ * The modules expansions are typically a directory path of length 1
+ * but can be of greater length on occasion.
*/
public String[] getModuleExpansions() {
if (expansions == null) return new String[0];
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 3875ee244..5e07d1689 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
@@ -180,3 +180,5 @@ Util.Internal_error,_resource_does_not_start_with_root_3=Internal error, resourc
CVSProvider.Scrubbing_local_project_1=Scrubbing local project
+CVSProvider.Scrubbing_projects_1=Scrubbing projects
+CVSProvider.Creating_projects_2=Creating projects
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 a86058f4d..ce3d34d51 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
@@ -389,6 +389,13 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC
}
/**
+ * @see ICVSRemoteFolder#isExpandable()
+ */
+ public boolean isExpandable() {
+ return true;
+ }
+
+ /**
* @see ICVSResource#isFolder()
*/
public boolean isFolder() {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java
index ac14521cb..b85a273e2 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteModule.java
@@ -37,6 +37,7 @@ public class RemoteModule extends RemoteFolder {
private String label;
private ICVSRemoteResource[] referencedModules;
private LocalOption[] localOptions;
+ private boolean expandable;
public static RemoteModule[] getRemoteModules(ICVSRepositoryLocation repository, CVSTag tag, IProgressMonitor monitor) throws TeamException {
@@ -74,7 +75,6 @@ public class RemoteModule extends RemoteFolder {
// Read the options associated with the module
List localOptionsList = new ArrayList();
String next = tokenizer.nextToken();
- String localName = null;
while (next.charAt(0) == '-') {
switch (next.charAt(1)) {
case 'a': // alias
@@ -84,7 +84,7 @@ public class RemoteModule extends RemoteFolder {
localOptionsList.add(Checkout.DO_NOT_RECURSE);
break;
case 'd': // directory
- localName = tokenizer.nextToken();
+ localOptionsList.add(Checkout.makeDirectoryNameOption(tokenizer.nextToken()));
break;
case 'e':
case 'i':
@@ -115,11 +115,11 @@ public class RemoteModule extends RemoteFolder {
expansions.add(tokenizer.nextToken());
moduleAliases.put(moduleName, (String[]) expansions.toArray(new String[expansions.size()]));
- modules.put(moduleName, new RemoteModule(moduleName, null, null, repository, null, localOptions, tag, true));
+ modules.put(moduleName, new RemoteModule(moduleName, null, repository, null, localOptions, tag, true));
} else {
- // The module definition must have a leading directory which can be followed by some files
+ // The module definition may have a leading directory which can be followed by some files
if (!(next.charAt(0) == '&')) {
String directory = next;
List files = new ArrayList();
@@ -128,7 +128,7 @@ public class RemoteModule extends RemoteFolder {
if ((next.charAt(0) != '&'))
files.add(next);
}
- RemoteModule remoteModule = new RemoteModule(moduleName, null, localName, repository, new Path(directory), localOptions, tag, ! files.isEmpty());
+ RemoteModule remoteModule = new RemoteModule(moduleName, null, repository, new Path(directory), localOptions, tag, ! files.isEmpty());
modules.put(moduleName, remoteModule);
if ( ! files.isEmpty()) {
ICVSRemoteResource[] children = new ICVSRemoteResource[files.size()];
@@ -138,7 +138,7 @@ public class RemoteModule extends RemoteFolder {
}
}
} else {
- modules.put(moduleName, new RemoteModule(moduleName, null, localName, repository, null, localOptions, tag, true));
+ modules.put(moduleName, new RemoteModule(moduleName, null, repository, null, localOptions, tag, true));
}
// Record any referenced modules so that can be cross-referenced below
@@ -160,35 +160,37 @@ public class RemoteModule extends RemoteFolder {
RemoteModule module = (RemoteModule)modules.get(moduleName);
String[] expansion = (String[])moduleAliases.get(moduleName);
List referencedFolders = new ArrayList();
- boolean acceptable = true;
+ boolean expandable = true;
for (int i = 0; i < expansion.length; i++) {
if (expansion[i].charAt(0) == '!') {
// XXX Unsupported for now
- acceptable = false;
+ expandable = false;
} else {
IPath path = new Path(expansion[i]);
if (path.segmentCount() > 1) {
// XXX Unsupported for now
- acceptable = false;
+ expandable = false;
} else {
RemoteModule child = (RemoteModule)modules.get(expansion[i]);
if (child == null) {
referencedFolders.add(new RemoteFolder(null, repository, path, tag));
} else {
- acceptable = false;
// Need to check if the child is a module alias
-// if (child.isAlias()) {
-// // XXX Unsupported for now
-// } else {
-// referencedFolders.add(child);
-// }
+ if (child.isAlias()) {
+ // XXX Unsupported for now
+ expandable = false;
+ } else {
+ referencedFolders.add(child);
+ }
}
}
}
}
- module.setChildren((ICVSRemoteResource[]) referencedFolders.toArray(new ICVSRemoteResource[referencedFolders.size()]));
- if (acceptable)
- acceptableModules.add(module);
+ if (expandable) {
+ module.setChildren((ICVSRemoteResource[]) referencedFolders.toArray(new ICVSRemoteResource[referencedFolders.size()]));
+ } else {
+ module.setExpandable(false);
+ }
}
// Third pass: Cross reference remote modules where necessary
@@ -199,32 +201,43 @@ public class RemoteModule extends RemoteFolder {
if (children != null) {
RemoteModule module = (RemoteModule)modules.get(moduleName);
List referencedFolders = new ArrayList();
+ boolean expandable = true;
for (int i = 0; i < children.length; i++) {
RemoteModule child = (RemoteModule)modules.get(children[i].substring(1));
if (child.isAlias()) {
// Include alias children in-line
- referencedFolders.addAll(Arrays.asList(child.getChildren()));
+ expandable = false;
+// referencedFolders.addAll(Arrays.asList(child.getChildren()));
} else {
- referencedFolders.add(child);
+ // XXX not expandable if child has local directory option (-d)
+ if (Command.findOption(child.getLocalOptions(), "-d") != null) {
+ expandable = false;
+ } else {
+ referencedFolders.add(child);
+ }
}
}
- module.setReferencedModules((ICVSRemoteResource[]) referencedFolders.toArray(new ICVSRemoteResource[referencedFolders.size()]));
+ if (expandable) {
+ module.setReferencedModules((ICVSRemoteResource[]) referencedFolders.toArray(new ICVSRemoteResource[referencedFolders.size()]));
+ } else {
+ module.setExpandable(false);
+ }
}
}
- // return (RemoteModule[])modules.values().toArray(new RemoteModule[modules.size()]);
- return (RemoteModule[])acceptableModules.toArray(new RemoteModule[acceptableModules.size()]);
+ return (RemoteModule[])modules.values().toArray(new RemoteModule[modules.size()]);
}
- public RemoteModule(String label, RemoteFolder parent, String localName, ICVSRepositoryLocation repository, IPath repositoryRelativePath, LocalOption[] localOptions, CVSTag tag, boolean isStatic) {
+ public RemoteModule(String label, RemoteFolder parent, ICVSRepositoryLocation repository, IPath repositoryRelativePath, LocalOption[] localOptions, CVSTag tag, boolean isStatic) {
super(parent,
- localName == null ? label : localName,
+ label,
repository,
repositoryRelativePath == null ? new Path(FolderSyncInfo.VIRTUAL_DIRECTORY) : repositoryRelativePath,
tag,
isStatic);
this.localOptions = localOptions;
this.label = label;
+ this.expandable = true;
}
public LocalOption[] getLocalOptions() {
@@ -234,6 +247,9 @@ public class RemoteModule extends RemoteFolder {
* Override of inherited getMembers in order to combine the physical members with any referenced modules
*/
public ICVSRemoteResource[] getMembers(CVSTag tagName, IProgressMonitor monitor) throws TeamException {
+
+ if ( ! expandable) return new ICVSRemoteResource[0];
+
ICVSRemoteResource[] physicalChildren;
if ( folderInfo.getIsStatic()) {
physicalChildren = getChildren();
@@ -279,4 +295,15 @@ public class RemoteModule extends RemoteFolder {
return Checkout.ALIAS.isElementOf(localOptions);
}
+ /**
+ * @see ICVSRemoteFolder#isExpandable()
+ */
+ public boolean isExpandable() {
+ return expandable;
+ }
+
+ private void setExpandable(boolean expandable) {
+ this.expandable = expandable;
+ }
+
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java
index b5a89b0b1..771c4e95b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java
@@ -14,6 +14,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -44,18 +45,14 @@ public class AddToWorkspaceAction extends TeamAction {
while (elements.hasNext()) {
Object next = elements.next();
if (next instanceof ICVSRemoteFolder) {
- if (!Checkout.ALIAS.isElementOf(((ICVSRemoteFolder)next).getLocalOptions())) {
- resources.add(next);
- }
+ resources.add(next);
continue;
}
if (next instanceof IAdaptable) {
IAdaptable a = (IAdaptable) next;
Object adapter = a.getAdapter(ICVSRemoteFolder.class);
if (adapter instanceof ICVSRemoteFolder) {
- if (!Checkout.ALIAS.isElementOf(((ICVSRemoteFolder)adapter).getLocalOptions())) {
- resources.add(adapter);
- }
+ resources.add(adapter);
continue;
}
}
@@ -75,40 +72,26 @@ public class AddToWorkspaceAction extends TeamAction {
try {
ICVSRemoteFolder[] folders = getSelectedRemoteFolders();
boolean yesToAll = false;
- List targetProjects = new ArrayList();
- List targetFolders = new ArrayList();
- for (int i = 0; i < folders.length; i++) {
- String name = folders[i].getName();
+ String [] expansions = CVSProviderPlugin.getProvider().getExpansions(folders, Policy.subMonitorFor(monitor, 10));
+ for (int i = 0; i < expansions.length; i++) {
+ String name = new Path(expansions[i]).segment(0);
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
if (!yesToAll) {
switch (confirmOverwrite(project)) {
// yes
case 0:
- targetFolders.add(folders[i]);
- targetProjects.add(project);
- break;
- // no
- case 1:
break;
// yes to all
- case 2:
+ case 1:
yesToAll = true;
- targetFolders.add(folders[i]);
- targetProjects.add(project);
break;
// cancel
- case 3:
default:
return;
}
- } else {
- targetFolders.add(folders[i]);
- targetProjects.add(project);
}
}
- if (targetFolders.size() > 0) {
- CVSProviderPlugin.getProvider().checkout((ICVSRemoteFolder[]) targetFolders.toArray(new ICVSRemoteFolder[targetFolders.size()]), (IProject[])targetProjects.toArray(new IProject[targetProjects.size()]), monitor);
- }
+ CVSProviderPlugin.getProvider().checkout(folders, null, Policy.subMonitorFor(monitor, 90));
} catch (TeamException e) {
throw new InvocationTargetException(e);
}
@@ -120,8 +103,7 @@ public class AddToWorkspaceAction extends TeamAction {
final MessageDialog dialog =
new MessageDialog(shell, Policy.bind("AddToWorkspaceAction.confirmOverwrite"), null, Policy.bind("AddToWorkspaceAction.thisResourceExists", project.getName()), MessageDialog.QUESTION,
new String[] {
- IDialogConstants.YES_LABEL,
- IDialogConstants.NO_LABEL,
+ IDialogConstants.YES_LABEL,
IDialogConstants.YES_TO_ALL_LABEL,
IDialogConstants.CANCEL_LABEL},
0);
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java
index c7fd6d09c..001ddee44 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java
@@ -43,18 +43,14 @@ public class CheckoutAsAction extends TeamAction {
while (elements.hasNext()) {
Object next = elements.next();
if (next instanceof ICVSRemoteFolder) {
- if (!Checkout.ALIAS.isElementOf(((ICVSRemoteFolder)next).getLocalOptions())) {
- resources.add(next);
- }
+ resources.add(next);
continue;
}
if (next instanceof IAdaptable) {
IAdaptable a = (IAdaptable) next;
Object adapter = a.getAdapter(ICVSRemoteFolder.class);
if (adapter instanceof ICVSRemoteFolder) {
- if (!Checkout.ALIAS.isElementOf(((ICVSRemoteFolder)adapter).getLocalOptions())) {
- resources.add(adapter);
- }
+ resources.add(adapter);
continue;
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java
index d96a121dc..061c5e6ad 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java
@@ -5,6 +5,7 @@ package org.eclipse.team.internal.ccvs.ui.model;
* All Rights Reserved.
*/
+import org.eclipse.team.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
import org.eclipse.ui.model.WorkbenchContentProvider;
@@ -25,6 +26,9 @@ public class RemoteContentProvider extends WorkbenchContentProvider {
// the + box will always appear, but then disappear
// if not needed after you first click on it.
if (element instanceof ICVSRemoteResource) {
+ if (element instanceof ICVSRemoteFolder) {
+ return ((ICVSRemoteFolder)element).isExpandable();
+ }
return ((ICVSRemoteResource)element).isContainer();
}
return true;

Back to the top