Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-01-24 21:25:38 +0000
committerMichael Valenta2002-01-24 21:25:38 +0000
commit339c579161e8541c1f4f117a3f92698c463ccdbc (patch)
tree1f2bf2559ed5788f4f4145525939172a602fa8d8
parent02d303b15f7a620a69e89440285dd98597f1d668 (diff)
downloadeclipse.platform.team-339c579161e8541c1f4f117a3f92698c463ccdbc.tar.gz
eclipse.platform.team-339c579161e8541c1f4f117a3f92698c463ccdbc.tar.xz
eclipse.platform.team-339c579161e8541c1f4f117a3f92698c463ccdbc.zip
Changed the way importing projects works
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java115
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSProvider.java6
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java7
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java98
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java23
6 files changed, 136 insertions, 117 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 717b3cd06..62c1455a9 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,6 +59,7 @@ import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
import org.eclipse.team.internal.ccvs.core.resources.FolderSyncInfo;
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.Synchronizer;
import org.eclipse.team.internal.ccvs.core.util.Util;
@@ -372,7 +373,7 @@ public class CVSProvider implements ICVSProvider {
/*
* @see ICVSProvider#importAndCheckout(IProject, Properties, IProgressMonitor)
*/
- public void importAndCheckout(
+ public void createModule(
IProject project,
Properties configuration,
IProgressMonitor monitor)
@@ -382,8 +383,55 @@ public class CVSProvider implements ICVSProvider {
boolean alreadyExists = isCached(location);
addToCache(location);
try {
- importProject(location, project, configuration, monitor);
- checkout(location, project, configuration.getProperty("module"), getTagFromProperties(configuration), monitor); //$NON-NLS-1$
+
+ // Get the import properties
+ String message = configuration.getProperty("message"); //$NON-NLS-1$
+ if (message == null)
+ message = Policy.bind("CVSProvider.initialImport");
+ String vendor = configuration.getProperty("vendor"); //$NON-NLS-1$
+ if (vendor == null)
+ vendor = location.getUsername();
+ // Get the vendor
+ String tag = configuration.getProperty("tag"); //$NON-NLS-1$
+ if (tag == null)
+ tag = "start"; //$NON-NLS-1$
+ // Get the module name
+ String projectName = project.getName();
+ String moduleName = configuration.getProperty("module"); //$NON-NLS-1$
+ if (moduleName == null)
+ moduleName = projectName;
+
+ // Perform the import using a dummy root so the local project is not traversed
+ Session s = new Session(location, new RemoteFolderTree(null, location, Path.EMPTY, null));
+ s.open(monitor);
+ try {
+ IStatus status = Command.IMPORT.execute(s,
+ getDefaultGlobalOptions(),
+ new LocalOption[] {Import.makeMessageOption(message)},
+ new String[] { moduleName, vendor, tag },
+ null,
+ monitor);
+ if (status.getCode() == CVSException.SERVER_ERROR) {
+ throw new CVSServerException(status);
+ }
+ } finally {
+ s.close();
+ }
+
+ // Set the folder sync info of the project to point to the remote module
+ ICVSFolder folder = (ICVSFolder)Session.getManagedResource(project);
+ folder.setFolderSyncInfo(new FolderSyncInfo(moduleName, location.getLocation(), null, false));
+ Synchronizer.getInstance().save(monitor);
+
+ // Register the project with Team
+ // (unless the project already has the proper nature from the project meta-information)
+ try {
+ if (!project.getDescription().hasNature(CVSProviderPlugin.NATURE_ID)) {
+ TeamPlugin.getManager().setProvider(project, CVSProviderPlugin.NATURE_ID, null, Policy.subMonitorFor(monitor, 1));
+ }
+ } catch (CoreException e) {
+ throw wrapException(e);
+ }
} catch (TeamException e) {
// The checkout may have triggered password caching
// Therefore, if this is a newly created location, we want to clear its cache
@@ -407,67 +455,6 @@ public class CVSProvider implements ICVSProvider {
return CVSTag.DEFAULT;
return new CVSTag(tagName, CVSTag.BRANCH);
}
- public void importProject(
- ICVSRepositoryLocation location,
- IProject project,
- Properties configuration,
- IProgressMonitor monitor)
- throws TeamException {
-
- // Get the location of the workspace root
- ICVSFolder root = Session.getManagedFolder(project.getLocation().toFile());
-
- // Get the message
- String message = configuration.getProperty("message"); //$NON-NLS-1$
- if (message == null)
- message = Policy.bind("CVSProvider.initialImport");
-
- // Get the vendor
- String vendor = configuration.getProperty("vendor"); //$NON-NLS-1$
- if (vendor == null)
- vendor = location.getUsername();
-
- // Get the vendor
- String tag = configuration.getProperty("tag"); //$NON-NLS-1$
- if (tag == null)
- tag = "start"; //$NON-NLS-1$
-
- // Get the module name
- String module = configuration.getProperty("module"); //$NON-NLS-1$
- if (module == null)
- module = project.getName();
-
- // Build the local options
- List localOptions = new ArrayList();
- localOptions.add(Import.makeMessageOption(message));
-
- // Create filters for all known text files
- String[] patterns = getBinaryFilePatterns(project);
- for (int i = 0; i < patterns.length ; i++) {
- localOptions.add(Import.makeBinaryWrapperOption(patterns[i]));
- }
-
- // Perform a import
- IStatus status;
- Session s = new Session(location, root);
- s.open(monitor);
- try {
- status = Command.IMPORT.execute(s,
- getDefaultGlobalOptions(),
- (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]),
- new String[] { module, vendor, tag },
- null,
- monitor);
- } finally {
- s.close();
- }
-
- if (status.getCode() == CVSException.SERVER_ERROR) {
- throw new CVSServerException(status);
- }
-
- // NOTE: we should check to see the results of the import
- }
private boolean isCached(ICVSRepositoryLocation repository) {
return repositories.containsKey(repository.getLocation());
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 51a483755..f9a16e198 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
@@ -168,9 +168,7 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
* @see ITeamNature#configureProvider(Properties)
*/
public void configureProvider(Properties configuration) throws TeamException {
- // For now, perform an import and checkout.
- // NOTE: We'll need to revisit this once we start using the Team test framework
- CVSProviderPlugin.getProvider().importAndCheckout(project, configuration, Policy.monitorFor(null));
+ // Do nothing
}
/*
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 064520a0a..5bdb1d2e4 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
@@ -51,7 +51,8 @@ public interface ICVSProvider {
public void checkout(ICVSRemoteFolder[] resources, IProject[] projects, IProgressMonitor monitor) throws TeamException;
/**
- * Import a project into a CVS repository and then check out a local copy.
+ * Create a remote module in the CVS repository and link the project directory to this remote module.
+ * The contents of the project are not imported.
*
* Consideration: What if the project already exists?
*
@@ -65,8 +66,9 @@ public interface ICVSProvider {
* message The message to be attached (optional)
* vendor The vendor tag (optional)
* tag The version tag (optional)
+ *
*/
- public void importAndCheckout(IProject project, Properties configuration, IProgressMonitor monitor) throws TeamException;
+ public void createModule(IProject project, Properties configuration, IProgressMonitor monitor) throws TeamException;
/**
* Create a repository instance from the given properties.
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java
index c80933a68..111922730 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java
@@ -31,9 +31,10 @@ public class Import extends Command {
protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions,
LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
- throws CVSException {
- // if the called does not specify a branch option, then the CVS client
- // enforces a default value of 1.1.1 upon the server
+ throws CVSException {
+
+ // If the branch option is not provided, a default value of 1.1.1 is used.
+ // This is done to maintain reference cliet compatibility
if (findOption(localOptions, "-b") == null) {
session.sendArgument("-b");
session.sendArgument("1.1.1");
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java
index 4a815115c..5b0fbeb13 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java
@@ -1,43 +1,55 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.ccvs.core.CVSTag;
-import org.eclipse.team.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.core.TeamException;
-
-/**
- * Whereas the RemoteFolder class provides access to a remote hierarchy using
- * lazy retrieval via <code>getMembers()</code>, the RemoteFolderTree will force
- * a recursive retrieval of the remote hierarchy in one round trip.
- */
-public class RemoteFolderTree extends RemoteFolder {
-
- public RemoteFolderTree(RemoteFolder parent, ICVSRepositoryLocation repository, IPath repositoryRelativePath, CVSTag tag) {
- super(parent, repository, repositoryRelativePath, tag);
- }
-
- /*
- * Override of inherited method which persists the children
- */
- public ICVSRemoteResource[] getMembers(CVSTag tagName, IProgressMonitor monitor) throws TeamException {
- if (getChildren() == null)
- setChildren(super.getMembers(tagName, monitor));
- return getChildren();
- }
-
- /*
- * This method is public to allow access by the RemoteFolderTreeBuilder utility class.
- * No other external classes should use this method.
- */
- public void setChildren(ICVSRemoteResource[] children) {
- super.setChildren(children);
- }
-}
-
+package org.eclipse.team.internal.ccvs.core.resources;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSRemoteResource;
+import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+
+/**
+ * Whereas the RemoteFolder class provides access to a remote hierarchy using
+ * lazy retrieval via <code>getMembers()</code>, the RemoteFolderTree will force
+ * a recursive retrieval of the remote hierarchy in one round trip.
+ */
+public class RemoteFolderTree extends RemoteFolder {
+
+ public RemoteFolderTree(RemoteFolder parent, ICVSRepositoryLocation repository, IPath repositoryRelativePath, CVSTag tag) {
+ super(parent, repository, repositoryRelativePath, tag);
+ }
+
+ /*
+ * Override of inherited method which persists the children
+ */
+ public ICVSRemoteResource[] getMembers(CVSTag tagName, IProgressMonitor monitor) throws TeamException {
+ if (getChildren() == null)
+ setChildren(super.getMembers(tagName, monitor));
+ return getChildren();
+ }
+
+ /*
+ * This method is public to allow access by the RemoteFolderTreeBuilder utility class.
+ * No other external classes should use this method.
+ */
+ public void setChildren(ICVSRemoteResource[] children) {
+ super.setChildren(children);
+ }
+
+ /*
+ * @see ICVSFolder#acceptChildren(ICVSResourceVisitor)
+ */
+ public void acceptChildren(ICVSResourceVisitor visitor) throws CVSException {
+ ICVSRemoteResource[] children = getChildren();
+ if (children == null) return;
+ for (int i=0; i<children.length; i++) {
+ ((ICVSResource)children[i]).accept(visitor);
+ }
+ }
+}
+
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java
index 9d2e7cdc4..f561c911f 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizard.java
@@ -9,6 +9,7 @@ import java.lang.reflect.InvocationTargetException;
import java.util.Properties;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.ErrorDialog;
@@ -26,9 +27,13 @@ import org.eclipse.team.internal.ccvs.core.client.Session;
import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.resources.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.sync.CVSSyncCompareInput;
import org.eclipse.team.ui.IConfigurationWizard;
+import org.eclipse.team.ui.sync.SyncView;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
/**
@@ -171,14 +176,27 @@ public class SharingWizard extends Wizard implements IConfigurationWizard {
result[0] = false;
return;
}
- // Import and Checkout. This associates the project with a provider automatically.
- CVSProviderPlugin.getProvider().importAndCheckout(project, getProperties(), monitor);
+ // Create the remote module for the project
+ CVSProviderPlugin.getProvider().createModule(project, getProperties(), monitor);
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
}
}
});
+ // Sync of the project
+ SyncView view = (SyncView)CVSUIPlugin.getActivePage().findView(SyncView.VIEW_ID);
+ if (view == null) {
+ view = SyncView.findInActivePerspective();
+ }
+ if (view != null) {
+ try {
+ CVSUIPlugin.getActivePage().showView(SyncView.VIEW_ID);
+ } catch (PartInitException e) {
+ CVSUIPlugin.log(e.getStatus());
+ }
+ view.showSync(new CVSSyncCompareInput(new IResource[] {project}));
+ }
} catch (InterruptedException e) {
return true;
} catch (InvocationTargetException e) {
@@ -192,6 +210,7 @@ public class SharingWizard extends Wizard implements IConfigurationWizard {
ErrorDialog.openError(getContainer().getShell(), null, null, ((TeamException)target).getStatus());
}
}
+
return result[0];
}
/**

Back to the top