diff options
author | Tomasz Zarna | 2011-02-21 13:05:08 +0000 |
---|---|---|
committer | Tomasz Zarna | 2011-02-21 13:05:08 +0000 |
commit | 712b46d034ebd6e303fc96ae78097047f18e4815 (patch) | |
tree | 195255a64f634e66bfbbc6ad98e02200c4665cda | |
parent | 64ca42e7341fe18089a849124c582db2f7aeb890 (diff) | |
download | eclipse.platform.team-712b46d034ebd6e303fc96ae78097047f18e4815.tar.gz eclipse.platform.team-712b46d034ebd6e303fc96ae78097047f18e4815.tar.xz eclipse.platform.team-712b46d034ebd6e303fc96ae78097047f18e4815.zip |
bug 330490: API and UI to configure SCM URLs for import -- comment 27
6 files changed, 45 insertions, 41 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ScmUrlImportDescription.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ScmUrlImportDescription.java index e1ffd620f..34d29ffcd 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ScmUrlImportDescription.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ScmUrlImportDescription.java @@ -13,7 +13,6 @@ package org.eclipse.team.core; import java.net.URI; import java.util.HashMap; - /** * Describes how a bundle import will be executed. A bundle importer delegate * creates bundle import descriptions when it validates bundle manifests for @@ -57,7 +56,7 @@ public class ScmUrlImportDescription { } public URI getUri() { - return URI.create(url); + return URI.create(url.replaceAll("\"", "")); //$NON-NLS-1$//$NON-NLS-2$ } public void setUrl(String url) { @@ -67,8 +66,10 @@ public class ScmUrlImportDescription { /** * Sets or removes a client property. * - * @param key property key - * @param value property value or <code>null</code> to remove the property + * @param key + * property key + * @param value + * property value or <code>null</code> to remove the property */ public synchronized void setProperty(String key, Object value) { if (properties == null) { @@ -85,7 +86,8 @@ public class ScmUrlImportDescription { /** * Returns the specified client property, or <code>null</code> if none. * - * @param key property key + * @param key + * property key * @return property value or <code>null</code> */ public synchronized Object getProperty(String key) { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/BundleImporterDelegate.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/BundleImporterDelegate.java index b04e4ac56..0cc192dc6 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/BundleImporterDelegate.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/importing/provisional/BundleImporterDelegate.java @@ -51,8 +51,7 @@ public abstract class BundleImporterDelegate implements IBundleImporterDelegate ManifestElement[] elements = ManifestElement.parseHeader(ECLIPSE_SOURCE_REFERENCES, value); for (int j = 0; j < elements.length; j++) { ManifestElement element = elements[j]; - String url = element.getValue(); - //String tag = element.getAttribute(ATTR_TAG); + String url = element.toString(); String project = element.getAttribute(ATTR_PROJECT); if (project == null) { String bsn = (String) manifests[i].get(Constants.BUNDLE_SYMBOLICNAME); @@ -77,7 +76,6 @@ public abstract class BundleImporterDelegate implements IBundleImporterDelegate * @see org.eclipse.pde.core.importing.IBundleImporterDelegate#performImport(org.eclipse.pde.core.importing.BundleImportDescription[], org.eclipse.core.runtime.IProgressMonitor) */ public IProject[] performImport(ScmUrlImportDescription[] descriptions, IProgressMonitor monitor) throws CoreException { - // TODO: import takes places when finishing contributed pages. this method can be removed List references = new ArrayList(); ProjectSetCapability psfCapability = getProviderType().getProjectSetCapability(); // collect and validate all header values @@ -86,16 +84,16 @@ public abstract class BundleImporterDelegate implements IBundleImporterDelegate references.add(psfCapability.asReference(description.getUri(), description.getProject())); } // create projects + IProject[] result = null; if (!references.isEmpty()) { SubMonitor subMonitor = SubMonitor.convert(monitor, references.size()); if (psfCapability != null) { - // TODO: specify shell - psfCapability.addToWorkspace((String[]) references.toArray(new String[references.size()]), new ProjectSetSerializationContext(), subMonitor); + result = psfCapability.addToWorkspace((String[]) references.toArray(new String[references.size()]), new ProjectSetSerializationContext(), subMonitor); } else { //TODO: error } subMonitor.done(); } - return null; + return result; } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSScmUrlImportWizardPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSScmUrlImportWizardPage.java index 7bb2c24f8..27cf75d57 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSScmUrlImportWizardPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSScmUrlImportWizardPage.java @@ -11,8 +11,6 @@ package org.eclipse.team.internal.ccvs.ui.wizards; import java.net.URI; -import java.util.ArrayList; -import java.util.List; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.viewers.*; @@ -23,7 +21,8 @@ import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.*; +import org.eclipse.team.core.RepositoryProviderType; +import org.eclipse.team.core.ScmUrlImportDescription; import org.eclipse.team.internal.ccvs.core.filesystem.CVSURI; import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; @@ -194,20 +193,6 @@ public class CVSScmUrlImportWizardPage extends WizardPage implements IScmUrlImpo } } - // TODO: same actions for all providers, this is not specific to CVS, pull up - - ProjectSetCapability c = getProvider().getProjectSetCapability(); - List references = new ArrayList(); - for (int i = 0; i < descriptions.length; i++) { - references.add(c.asReference(descriptions[i].getUri(), descriptions[i].getProject())); - } - try { - c.addToWorkspace((String[]) references.toArray(new String[references.size()]), new ProjectSetSerializationContext(), null); - } catch (TeamException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return true; } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java index 20d7da6b6..48936a549 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java @@ -168,14 +168,14 @@ public class TeamUI { for (int i = 0; i < elements.length; i++) { String repository = elements[i].getAttribute(IScmUrlImportWizardPage.ATT_REPOSITORY); RepositoryProviderType providerType = RepositoryProviderType.getProviderType(repository); - String extensionScheme = providerType.getFileSystemScheme(); + String providerScheme = providerType.getFileSystemScheme(); Set/*<URI>*/ schemeUris = new HashSet(); - // group descriptions by scheme/provider + // filter out descriptions for which provider is not known for (int j = 0; j < descriptions.length; j++) { URI scmUri = descriptions[j].getUri(); if (scmUri != null) { if (ProjectSetCapability.SCHEME_SCM.equals(scmUri.getScheme())) { - if (scmUri.getSchemeSpecificPart().startsWith(extensionScheme)) { + if (scmUri.getSchemeSpecificPart().startsWith(providerScheme)) { schemeUris.add(scmUri); } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/CVSURITest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/CVSURITest.java index c9fe16cc3..21ddfc8ba 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/CVSURITest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/CVSURITest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 IBM Corporation and others. + * Copyright (c) 2006, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,6 +16,7 @@ import java.net.URISyntaxException; import junit.framework.Test; import junit.framework.TestSuite; +import org.eclipse.team.core.ScmUrlImportDescription; import org.eclipse.team.internal.ccvs.core.CVSException; import org.eclipse.team.internal.ccvs.core.CVSProjectSetCapability; import org.eclipse.team.internal.ccvs.core.CVSTag; @@ -265,4 +266,25 @@ public class CVSURITest extends EclipseTest { assertNull(refString); } + public void testScmUri14() { + try { + URI.create("scm:cvs:pserver:host.com:/cvsroot/path:path/to/module;tag=\"tag\""); + } catch (IllegalArgumentException e) { + // expected, " are not allowed in a URI reference + } + } + + public void testScmUri15() throws CVSException { + // ScmUrlImportDescription can handle " in Strings expected to be URI refs + ScmUrlImportDescription description = new ScmUrlImportDescription("scm:cvs:pserver:host.com:/cvsroot/path:path/to/module;tag=\"tag\"", null); + URI uri = description.getUri(); + CVSURI cvsUri = CVSURI.fromUri(uri); + assertEquals("path/to/module", cvsUri.getPath().toString()); + CVSRepositoryLocation location = CVSRepositoryLocation.fromString(":pserver:host.com:/cvsroot/path"); + assertEquals(cvsUri.getRepository().getLocation(false), location.getLocation(false)); + assertEquals(cvsUri.getTag(), new CVSTag("tag", CVSTag.VERSION)); + + String refString = new CVSProjectSetCapability().asReference(uri, null); + assertEquals("1.0,:pserver:host.com:/cvsroot/path,path/to/module,module,tag", refString); + } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ProjectSetImporterTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ProjectSetImporterTests.java index bb4b0870f..cfc7237d5 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ProjectSetImporterTests.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ProjectSetImporterTests.java @@ -289,10 +289,10 @@ public class ProjectSetImporterTests extends EclipseTest { final IScmUrlImportWizardPage[] pages = TeamUI.getPages(new ScmUrlImportDescription[] {d}); assertEquals(1, pages.length); - // simulate clicking "Import from HEAD" on the CVS import page assertTrue(pages[0] instanceof CVSScmUrlImportWizardPage); Wizard wizard = new Wizard() { public boolean performFinish() { + // update SCM URLs in descriptions pages[0].finish(); return true; } @@ -301,20 +301,17 @@ public class ProjectSetImporterTests extends EclipseTest { WizardDialog wizardDialog = new WizardDialog(new Shell(Display.getCurrent()), wizard); wizardDialog.setBlockOnOpen(false); wizardDialog.open(); + // simulate clicking "Import from HEAD" on the CVS import page Button useHead = (Button) ReflectionUtils.getField(pages[0], "useHead"); useHead.setSelection(true); wizard.performFinish(); wizardDialog.close(); + // altered selection, check out from HEAD ScmUrlImportDescription[] selection = pages[0].getSelection(); - ProjectSetCapability c = pages[0].getProvider().getProjectSetCapability(); - - // this is what every bundle importer should do, should this be in PDE? - List references = new ArrayList(); - for (int i = 0; i < selection.length; i++) { - references.add(c.asReference(selection[i].getUri(), selection[i].getProject())); - } - c.addToWorkspace((String[]) references.toArray(new String[references.size()]), new ProjectSetSerializationContext(), null); + IBundleImporter cvsBundleImporter = Team.getBundleImporters()[0]; + cvsBundleImporter.performImport(selection, null); + assertExistsInWorkspace(project); IProject copy = checkoutCopy(project, CVSTag.DEFAULT); // expecting the project to be checked out from HEAD |