Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-04-05 09:20:57 -0500
committerMichael Valenta2002-04-05 09:20:57 -0500
commitbb5cf9edb27ceb36a9b22dfa361ff2330cc9c1ed (patch)
treebcdb5b38ce6c82e3e54ef81c99d2152471f55e97
parent08596da4d1d8092127d596d2d6a5d07671e4dc7b (diff)
downloadeclipse.platform.team-bb5cf9edb27ceb36a9b22dfa361ff2330cc9c1ed.tar.gz
eclipse.platform.team-bb5cf9edb27ceb36a9b22dfa361ff2330cc9c1ed.tar.xz
eclipse.platform.team-bb5cf9edb27ceb36a9b22dfa361ff2330cc9c1ed.zip
11469: Error loading project from repository
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java20
-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.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java74
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties3
4 files changed, 73 insertions, 30 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 d9254c57e..12734728d 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
@@ -35,7 +35,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSStatus;
import org.eclipse.team.ccvs.core.CVSTag;
-import org.eclipse.team.ccvs.core.ICVSFile;
import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSListener;
import org.eclipse.team.ccvs.core.ICVSProvider;
@@ -46,7 +45,6 @@ import org.eclipse.team.ccvs.core.IConnectionMethod;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.Team;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.internal.ccvs.core.client.Checkout;
import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.Import;
@@ -130,7 +128,7 @@ public class CVSProvider implements ICVSProvider {
try {
for (int i=0;i<projects.length;i++) {
IProject project = projects[i];
- if(project != null && project.exists()) {
+ if (project != null && project.exists()) {
if(!project.isOpen()) {
project.open(Policy.subMonitorFor(monitor, 10));
}
@@ -149,6 +147,12 @@ public class CVSProvider implements ICVSProvider {
subMonitor.done();
}
CVSWorkspaceRoot.getCVSFolderFor(project).unmanage(Policy.subMonitorFor(monitor, 10));
+ } else if (project != null) {
+ // Make sure there is no directory in the local file system.
+ File location = new File(project.getParent().getLocation().toFile(), project.getName());
+ if (location.exists()) {
+ deepDelete(location);
+ }
}
}
} catch (CoreException e) {
@@ -158,6 +162,16 @@ public class CVSProvider implements ICVSProvider {
}
}
+ private void deepDelete(File resource) {
+ if (resource.isDirectory()) {
+ File[] fileList = resource.listFiles();
+ for (int i = 0; i < fileList.length; i++) {
+ deepDelete(fileList[i]);
+ }
+ }
+ resource.delete();
+ }
+
/*
* Bring the provied projects into the workspace
*/
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 69dee8690..eb40cb870 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
@@ -39,6 +39,9 @@ public interface ICVSProvider {
* then the project name will be used as the module to
* check out. If both are absent, an exception is thrown.
*
+ * Resources existing in the local file system at the target project location but now
+ * known to the workbench will be overwritten.
+ *
* After the successful completion of this method, the project will exist
* and be open.
*/
@@ -48,6 +51,9 @@ public interface ICVSProvider {
* Checkout the remote resources into the local workspace. Each resource will
* be checked out into the corresponding project. If the corresponding project is
* null or if projects is null, the name of the remote resource is used as the name of the project.
+ *
+ * Resources existing in the local file system at the target project location but now
+ * known to the workbench will be overwritten.
*/
public void checkout(ICVSRemoteFolder[] resources, IProject[] projects, IProgressMonitor monitor) throws TeamException;
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 2d9f1298d..8552360f9 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
@@ -5,6 +5,7 @@ package org.eclipse.team.internal.ccvs.ui.actions;
* All Rights Reserved.
*/
+import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Iterator;
@@ -14,7 +15,6 @@ 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;
@@ -81,35 +81,36 @@ public class AddToWorkspaceAction extends TeamAction {
boolean yesToAll = false;
+ boolean yesToAllExternal = false;
+ int action;
List targetProjects = new ArrayList();
List targetFolders = new ArrayList();
for (int i = 0; i < folders.length; i++) {
String name = folders[i].getName();
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:
- yesToAll = true;
- targetFolders.add(folders[i]);
- targetProjects.add(project);
- break;
- // cancel
- case 3:
- default:
- return;
- }
+ if (project.exists()) {
+ action = confirmOverwrite(project, yesToAll);
+ yesToAll = action == 2;
} else {
- targetFolders.add(folders[i]);
- targetProjects.add(project);
+ File location = new File(project.getParent().getLocation().toFile(), project.getName());
+ action = confirmOverwriteExternalFile(location, yesToAllExternal);
+ yesToAllExternal = action == 2;
+ }
+ switch (action) {
+ // no
+ case 1:
+ break;
+ // yes to all
+ case 2:
+ // yes
+ case 0:
+ targetFolders.add(folders[i]);
+ targetProjects.add(project);
+ break;
+ // cancel
+ case 3:
+ default:
+ return;
}
}
if (targetFolders.size() > 0) {
@@ -134,8 +135,9 @@ public class AddToWorkspaceAction extends TeamAction {
}
}
- private int confirmOverwrite(IProject project) {
- if (!project.exists()) return 0;
+ private int confirmOverwrite(IProject project, boolean yesToAll) {
+ if (yesToAll) return 2;
+ if ( ! project.exists()) return 0;
final MessageDialog dialog =
new MessageDialog(shell, Policy.bind("AddToWorkspaceAction.confirmOverwrite"), null, Policy.bind("AddToWorkspaceAction.thisResourceExists", project.getName()), MessageDialog.QUESTION,
new String[] {
@@ -152,6 +154,26 @@ public class AddToWorkspaceAction extends TeamAction {
});
return result[0];
}
+
+ private int confirmOverwriteExternalFile(File location, boolean yesToAll) {
+ if (yesToAll) return 2;
+ if ( ! location.exists()) return 0;
+ final MessageDialog dialog =
+ new MessageDialog(shell, Policy.bind("AddToWorkspaceAction.confirmOverwrite"), null, Policy.bind("AddToWorkspaceAction.thisExternalFileExists", location.getName()), MessageDialog.QUESTION,
+ new String[] {
+ IDialogConstants.YES_LABEL,
+ IDialogConstants.NO_LABEL,
+ IDialogConstants.YES_TO_ALL_LABEL,
+ IDialogConstants.CANCEL_LABEL},
+ 0);
+ final int[] result = new int[1];
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ result[0] = dialog.open();
+ }
+ });
+ return result[0];
+ }
/*
* @see TeamAction#isEnabled()
*/
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index 1c7f802e8..c44b1d6a0 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -17,7 +17,8 @@ AddAction.add=Add
AddAction.adding=Adding...
AddToWorkspaceAction.checkoutFailed=Problems encountered performing checkout
-AddToWorkspaceAction.thisResourceExists=The resource "{0}" already exists in the workspace. Overwrite?
+AddToWorkspaceAction.thisResourceExists=The resource ''{0}'' already exists in the workspace. Overwrite?
+AddToWorkspaceAction.thisExternalFileExists=The folder ''{0}'' exists in the local file system. Overwrite?
AddToWorkspaceAction.confirmOverwrite=Confirm Overwrite
AutoDefineTagsAction.defineTags = Auto-discover tags

Back to the top