Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2011-06-05 13:53:33 +0000
committerCode Review2011-06-05 13:53:33 +0000
commitcec7309c12f5b9faa5838fec0b3b0179e4a5c66f (patch)
treef5f533e52156bb3153cb1c8a877f148b87884824
parent989344ad766ad3c4490cf76e589bc48c5525b981 (diff)
parent5f8010c46bda0af8cca4fd452f8654f486aee52a (diff)
downloadegit-cec7309c12f5b9faa5838fec0b3b0179e4a5c66f.tar.gz
egit-cec7309c12f5b9faa5838fec0b3b0179e4a5c66f.tar.xz
egit-cec7309c12f5b9faa5838fec0b3b0179e4a5c66f.zip
Merge changes Ie4e1787b,I87825799 into stable-1.0
* changes: SharingWizard: Conditionally suggest moving project Fix cleanup of tests in SharingWizardTest
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java35
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java18
2 files changed, 45 insertions, 8 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java
index 5e35bf53d..04303d58b 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java
@@ -16,14 +16,19 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
+import java.util.Collections;
+import java.util.Set;
+import java.util.TreeSet;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.egit.core.op.DisconnectProviderOperation;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
@@ -45,6 +50,7 @@ import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.util.FileUtils;
import org.eclipse.jgit.util.SystemReader;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
@@ -54,6 +60,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import static org.junit.Assert.*;
import org.junit.runner.RunWith;
@RunWith(SWTBotJunit4ClassRunner.class)
@@ -99,21 +106,37 @@ public class SharingWizardTest extends LocalRepositoryTestCase {
@After
public void after() throws Exception {
- erase(projectName0);
- erase(projectName1);
- erase(projectName2);
- erase(projectName3);
+ Set<File> d = new TreeSet<File>();
+ erase(projectName0, d);
+ erase(projectName1, d);
+ erase(projectName2, d);
+ erase(projectName3, d);
+ for (File f : d)
+ if (f.exists())
+ FileUtils.delete(f, FileUtils.RECURSIVE);
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(
IResource.DEPTH_INFINITE, null);
new Eclipse().reset();
}
- private void erase(String projectName) throws CoreException {
+ private void erase(String projectName, Set<File> dirs) throws CoreException, IOException {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
projectName);
if (project.exists()) {
+ RepositoryMapping repo = RepositoryMapping.getMapping(project);
+ if (repo != null) {
+ IPath gitDirAbsolutePath = repo.getGitDirAbsolutePath();
+ File canonicalFile = gitDirAbsolutePath.toFile().getCanonicalFile();
+ dirs.add(canonicalFile);
+ File workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getCanonicalFile();
+ File gitDirParent = canonicalFile.getParentFile();
+ if (!(gitDirParent.toString()+"/").startsWith(workspacePath.toString()+"/"))
+ if (!(gitDirParent.toString()+"/").startsWith(getTestDirectory().getCanonicalPath().toString()+"/"))
+ fail("Attempting cleanup of directory neither in workspace nor test directory" + canonicalFile);
+ new DisconnectProviderOperation(Collections.singleton(project)).execute(null);
+ }
project.close(null);
- project.delete(false, null);
+ project.delete(true, true, null);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java
index e0205a682..5023f7cfa 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (C) 2009, Robin Rosenberg
+ * Copyright (C) 2009, 2011 Robin Rosenberg
* Copyright (C) 2009, Mykola Nikishov <mn@mn.com.ua>
* Copyright (C) 2011, Mathias Kinzler <mathias.kinzler@sap.com>
*
@@ -74,6 +74,7 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
@@ -249,7 +250,20 @@ class ExistingOrNewPage extends WizardPage {
updateControls();
}
});
- projectMoveViewer.setAllChecked(true);
+ TableItem[] children = projectMoveViewer.getTable().getItems();
+ for (int i = 0; i < children.length; i++) {
+ TableItem item = children[i];
+ IProject data = (IProject) item.getData();
+ RepositoryFinder repositoryFinder = new RepositoryFinder(data);
+ try {
+ Collection<RepositoryMapping> find = repositoryFinder
+ .find(new NullProgressMonitor());
+ if (find.size() != 1)
+ item.setChecked(true);
+ } catch (CoreException e1) {
+ item.setText(2, e1.getMessage());
+ }
+ }
parentRepoComposite = new Composite(main, SWT.NONE);
parentRepoComposite.setLayout(new GridLayout(3, false));

Back to the top