Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 183958 Details for
Bug 326926
API to configure and import SCM URLs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix v03
clipboard.txt (text/plain), 20.40 KB, created by
Tomasz Zarna
on 2010-11-26 15:33:51 EST
(
hide
)
Description:
Fix v03
Filename:
MIME Type:
Creator:
Tomasz Zarna
Created:
2010-11-26 15:33:51 EST
Size:
20.40 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.team.core >Index: src/org/eclipse/team/core/ProjectSetCapability.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java,v >retrieving revision 1.19 >diff -u -r1.19 ProjectSetCapability.java >--- src/org/eclipse/team/core/ProjectSetCapability.java 2 Aug 2010 14:33:14 -0000 1.19 >+++ src/org/eclipse/team/core/ProjectSetCapability.java 26 Nov 2010 20:31:32 -0000 >@@ -34,6 +34,13 @@ > public abstract class ProjectSetCapability { > > /** >+ * Scheme constant (value "scm") indicating the SCM URI. >+ * >+ * @since 3.7 >+ */ >+ public static final String SCHEME_SCM = "scm"; //$NON-NLS-1$ >+ >+ /** > * Ensure that the provider type is backwards compatible by > * passing the project set serializer to the type if a serializer > * is registered. This is required for repository providers >@@ -303,13 +310,23 @@ > > /** > * Convert the given URI and projectName to a reference string that can be >- * passed to the {@link #addToWorkspace(String[], ProjectSetSerializationContext, IProgressMonitor)} >- * method. The scheme of the provided URI must match the scheme of the >- * repository provider type from which this capability was obtained. >- * @param uri the uri that identifies the location of the project in the repository. >- * @param projectName the name of the project. >- * @return the reference string representing a project that can be loaded into the workspace >- * or <code>null</code> if the URI and name cannot be translated into a reference string >+ * passed to the >+ * {@link #addToWorkspace(String[], ProjectSetSerializationContext, IProgressMonitor)} >+ * method. The scheme of the provided URI must either match the scheme >+ * indicating the SCM URI or the scheme of the repository provider type from >+ * which this capability was obtained. >+ * >+ * @see #SCHEME_SCM >+ * @param uri >+ * the uri that identifies the location of the project in the >+ * repository. >+ * @param projectName >+ * the name of the project or <code>null</code> if project name >+ * from the URI should be used. If the URI doesn't suggest a >+ * project name the last segment of the URI's path. >+ * @return the reference string representing a project that can be loaded >+ * into the workspace or <code>null</code> if the URI and name >+ * cannot be translated into a reference string > * @since 3.2 > */ > public String asReference(URI uri, String projectName) { >#P org.eclipse.team.cvs.core >Index: src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java,v >retrieving revision 1.28 >diff -u -r1.28 CVSProjectSetCapability.java >--- src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java 11 Feb 2010 11:09:01 -0000 1.28 >+++ src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java 26 Nov 2010 20:31:36 -0000 >@@ -629,6 +629,13 @@ > CVSURI cvsURI = CVSURI.fromUri(uri); > ICVSRepositoryLocation location = cvsURI.getRepository(); > ICVSFolder folder = cvsURI.toFolder(); >+ if (projectName == null) { >+ if (cvsURI.getProjectName() != null) { >+ projectName = cvsURI.getProjectName(); >+ } else { >+ projectName = cvsURI.getPath().lastSegment(); >+ } >+ } > IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); > return asReference((CVSRepositoryLocation)location, folder, project); > } catch (TeamException e) { >Index: src/org/eclipse/team/internal/ccvs/core/filesystem/CVSURI.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filesystem/CVSURI.java,v >retrieving revision 1.15 >diff -u -r1.15 CVSURI.java >--- src/org/eclipse/team/internal/ccvs/core/filesystem/CVSURI.java 4 Jun 2007 14:58:55 -0000 1.15 >+++ src/org/eclipse/team/internal/ccvs/core/filesystem/CVSURI.java 26 Nov 2010 20:31:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 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 org.eclipse.core.runtime.*; > import org.eclipse.osgi.util.NLS; >+import org.eclipse.team.core.ProjectSetCapability; > import org.eclipse.team.internal.ccvs.core.*; > import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; > import org.eclipse.team.internal.ccvs.core.resources.RemoteFile; >@@ -24,35 +25,48 @@ > > public class CVSURI { > >- private static final String SCHEME = "cvs"; //$NON-NLS-1$ >+ private static final String SCHEME_CVS = "cvs"; //$NON-NLS-1$ > private final ICVSRepositoryLocation repository; > private final IPath path; > private final CVSTag tag; > private final String revision; >+ private final String projectName; > > /** >- * Convert the given URI to a CVSURI. There are two supported formats: the >- * original opaque format and a newer hierarchical format. >+ * Convert the given URI to a CVSURI. There are three supported formats: the >+ * original opaque format, a newer hierarchical format and a CVS SCM URL >+ * format. >+ * >+ * In the last format, as delimiter you can use either colon ':' or, if you >+ * use a colon for one of the variables (e.g. a windows path), a pipe '|'. >+ * For more information visit http://maven.apache.org/scm/cvs.html. >+ * > * <ul> > * <li>cvs://[:]method:user[:password]@host:[port]/root/path#project/path[,tagName]</li> > * <li>cvs://_method_user[_password]~host_[port]!root!path/project/path[?<version,branch,date,revision>=tagName]</li> >+ * <li>scm:cvs<delimiter>method<delimiter>[user[<delimiter>password]@]host[<delimiter>port]<delimiter>/root/path<delimiter>project/path[;project="projectName"][;tag=tagName]</li> > * </ul> > * @param uri the URI > * @return a CVS URI > */ > public static CVSURI fromUri(URI uri) { > try { >+ if (ProjectSetCapability.SCHEME_SCM.equals(uri.getScheme())) { >+ uri = convert(uri); >+ } > ICVSRepositoryLocation repository = getRepository(uri); > if (repository != null) { > IPath path = new Path(null, uri.getPath()); > CVSTag tag = getTag(uri); > String revision = getRevision(uri); >- return new CVSURI(repository, path, tag, revision); >+ String projectName = getProjectName(uri); >+ return new CVSURI(repository, path, tag, revision, projectName); > } else { > repository = getOldRepository(uri); > IPath path = getOldPath(uri); > CVSTag tag = getOldTag(uri); >- return new CVSURI(repository, path, tag); >+ String projectName = getProjectName(uri); >+ return new CVSURI(repository, path, tag, null, projectName); > } > } catch (CVSException e) { > CVSProviderPlugin.log(e); >@@ -60,11 +74,43 @@ > } > } > >+ private static URI convert(URI uri) { >+ StringBuffer sb = new StringBuffer(); >+ String ssp = uri.getSchemeSpecificPart(); >+ int i = ssp.lastIndexOf(':'); >+ sb.append(ssp.substring(0, i)).append('#'); >+ int j = ssp.indexOf(';'); >+ if (j != -1) { >+ sb.append(ssp.substring(i + 1, j)); >+ String[] params = ssp.substring(j).split(";"); //$NON-NLS-1$ >+ String projectName = ""; //$NON-NLS-1$ >+ for (int k = 0; k < params.length; k++) { >+ // PDE way of providing tags >+ if (params[k].startsWith("tag=")) { //$NON-NLS-1$ >+ sb.append(",version="); //$NON-NLS-1$ >+ sb.append(params[k].substring(params[k].indexOf('=') + 1)); >+ } else if (params[k].startsWith("version=")) { //$NON-NLS-1$ >+ sb.append(',').append(params[k]); >+ } else if (params[k].startsWith("project=")) { //$NON-NLS-1$ >+ projectName = params[k].substring(params[k].indexOf('=') + 1); >+ } >+ } >+ sb.append(',').append(projectName); // can be "" >+ } else { >+ sb.append(ssp.substring(i + 1)); >+ } >+ return URI.create(sb.toString()); >+ } >+ > private static CVSTag getTag(URI uri) { > String query = uri.getQuery(); > if (query == null) > return null; >- StringTokenizer tokens = new StringTokenizer(query, ","); //$NON-NLS-1$ >+ return getTag(query); >+ } >+ >+ private static CVSTag getTag(String s) { >+ StringTokenizer tokens = new StringTokenizer(s, ","); //$NON-NLS-1$ > while (tokens.hasMoreTokens()) { > String token = tokens.nextToken(); > int index = token.indexOf('='); >@@ -116,6 +162,8 @@ > > private static ICVSRepositoryLocation getRepository(URI uri) throws CVSException { > String authority = uri.getAuthority(); >+ if (authority == null) >+ return null; > if (authority.indexOf('/') != -1) > return null; > if (authority.indexOf('!') == -1) >@@ -123,6 +171,19 @@ > authority = decodeAuthority(authority); > return CVSRepositoryLocation.fromString(authority); > } >+ >+ private static String getProjectName(URI uri) { >+ String f = uri.getFragment(); >+ if (f != null) { >+ int i = f.lastIndexOf(','); >+ if (i != -1) { >+ String s = f.substring(i + 1); >+ if (!s.equals("")) //$NON-NLS-1$ >+ return s; >+ } >+ } >+ return null; >+ } > > private static CVSTag getOldTag(URI uri) { > String f = uri.getFragment(); >@@ -130,6 +191,9 @@ > if (i == -1) { > return CVSTag.DEFAULT; > } >+ CVSTag tag = getTag(f.substring(i + 1)); >+ if (tag != null) >+ return tag; > > return CVSTag.DEFAULT;//just use HEAD for now (name, CVSTag.BRANCH); > } >@@ -152,10 +216,14 @@ > } > > public CVSURI(ICVSRepositoryLocation repository, IPath path, CVSTag tag) { >- this(repository, path, tag, null); >+ this(repository, path, tag, null, null); > } > > public CVSURI(ICVSRepositoryLocation repository, IPath path, CVSTag tag, String revision) { >+ this(repository, path, tag, revision, null); >+ } >+ >+ public CVSURI(ICVSRepositoryLocation repository, IPath path, CVSTag tag, String revision, String projectName) { > this.repository = repository; > this.path = path; > this.tag = tag; >@@ -163,8 +231,9 @@ > this.revision = revision; > else > this.revision = null; >+ this.projectName = projectName; > } >- >+ > public CVSURI append(String name) { > return new CVSURI(repository, path.append(name), tag); > } >@@ -197,7 +266,15 @@ > query = query + "," + string; //$NON-NLS-1$ > } > } >- return new URI(SCHEME, authority, pathString, query, null); >+ if (projectName != null) { >+ String string = "project=" + projectName; //$NON-NLS-1$ >+ if (query == null) { >+ query = string; >+ } else { >+ query = query + "," + string; //$NON-NLS-1$ >+ } >+ } >+ return new URI(SCHEME_CVS, authority, pathString, query, null); > } catch (URISyntaxException e) { > CVSProviderPlugin.log(IStatus.ERROR, NLS.bind("An error occurred while creating a URI for {0} {1}", repository, path), e); //$NON-NLS-1$ > throw new IllegalStateException(e.getMessage()); >@@ -305,4 +382,8 @@ > public String getRevision() { > return revision; > } >+ >+ public String getProjectName() { >+ return projectName; >+ } > } >#P org.eclipse.team.tests.cvs.core >Index: src/org/eclipse/team/tests/ccvs/core/cvsresources/CVSURITest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/CVSURITest.java,v >retrieving revision 1.4 >diff -u -r1.4 CVSURITest.java >--- src/org/eclipse/team/tests/ccvs/core/cvsresources/CVSURITest.java 28 May 2008 17:58:19 -0000 1.4 >+++ src/org/eclipse/team/tests/ccvs/core/cvsresources/CVSURITest.java 26 Nov 2010 20:31:39 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2008 IBM Corporation and others. >+ * Copyright (c) 2006, 2010 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 >@@ -17,6 +17,7 @@ > import junit.framework.TestSuite; > > import org.eclipse.team.internal.ccvs.core.CVSException; >+import org.eclipse.team.internal.ccvs.core.CVSProjectSetCapability; > import org.eclipse.team.internal.ccvs.core.CVSTag; > import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; > import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; >@@ -115,5 +116,138 @@ > assertEquals(null, cvsUri.getTag()); > assertEquals(cvsUri.toURI(), uri); > } >+ >+ // CVS SCM URL tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=231190 >+ public void testScmUri1() throws CVSException { >+ URI uri = URI.create("scm:cvs:pserver:host.com:/cvsroot/path:module;tag=tag"); >+ CVSURI cvsUri = CVSURI.fromUri(uri); >+ assertEquals("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, "project"); >+ assertEquals("1.0,:pserver:host.com:/cvsroot/path,module,project,tag", refString); >+ } >+ >+ public void testScmUri2() throws CVSException { >+ URI uri = URI.create("scm:cvs:pserver:host.com:/cvsroot/path:module;version=version"); >+ CVSURI cvsUri = CVSURI.fromUri(uri); >+ assertEquals("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("version", CVSTag.VERSION)); >+ >+ String refString = new CVSProjectSetCapability().asReference(uri, "project"); >+ assertEquals("1.0,:pserver:host.com:/cvsroot/path,module,project,version", refString); >+ } >+ >+ public void testScmUri3() throws CVSException { >+ URI uri = URI.create("scm:cvs:pserver:host.com:/cvsroot/path:path/to/module;version=version;project=project1"); >+ 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("version", CVSTag.VERSION)); >+ >+ String refString = new CVSProjectSetCapability().asReference(uri, "project2"); >+ assertEquals("1.0,:pserver:host.com:/cvsroot/path,path/to/module,project2,version", refString); >+ } >+ >+ public void testScmUri4() throws CVSException { >+ URI uri = URI.create("scm:cvs:pserver:host.com:/cvsroot/path:path/to/module;version=version;project=project1"); >+ 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("version", CVSTag.VERSION)); >+ >+ String refString = new CVSProjectSetCapability().asReference(uri, null); >+ assertEquals("1.0,:pserver:host.com:/cvsroot/path,path/to/module,project1,version", refString); >+ } >+ >+ public void testScmUri5() throws CVSException { >+ URI uri = URI.create("scm:cvs:pserver:host.com:/cvsroot/path:path/to/module;project=project1;version=version"); >+ 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("version", CVSTag.VERSION)); >+ >+ String refString = new CVSProjectSetCapability().asReference(uri, null); >+ assertEquals("1.0,:pserver:host.com:/cvsroot/path,path/to/module,project1,version", refString); >+ } >+ >+ public void testScmUri6() throws CVSException { >+ URI uri = URI.create("scm:cvs:pserver:host.com:/cvsroot/path:path/to/module;tag=tag"); >+ 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); >+ } >+ >+ public void testScmUri7() throws CVSException { >+ URI uri = URI.create("scm:cvs:pserver:host.com:/cvsroot/path:path/to/module;version=version"); >+ 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("version", CVSTag.VERSION)); >+ >+ String refString = new CVSProjectSetCapability().asReference(uri, null); >+ assertEquals("1.0,:pserver:host.com:/cvsroot/path,path/to/module,module,version", refString); >+ } > >+ public void testScmUri8() throws CVSException { >+ URI uri = URI.create("scm:cvs:pserver:host.com:/cvsroot/path:path/to/module;project="); >+ 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(), CVSTag.DEFAULT); >+ >+ String refString = new CVSProjectSetCapability().asReference(uri, null); >+ assertEquals("1.0,:pserver:host.com:/cvsroot/path,path/to/module,module", refString); >+ } >+ >+ public void testScmUri9() throws CVSException { >+ URI uri = URI.create("scm:cvs:pserver:host.com:/cvsroot/path:path/to/module"); >+ 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(), CVSTag.DEFAULT); >+ >+ String refString = new CVSProjectSetCapability().asReference(uri, "project"); >+ assertEquals("1.0,:pserver:host.com:/cvsroot/path,path/to/module,project", refString); >+ } >+ >+ public void testScmUri10() throws URISyntaxException, CVSException { >+ URI uri = new URI("scm:cvs:pserver:anonymous:@host.com:/cvsroot/path:module"); >+ CVSURI cvsUri = CVSURI.fromUri(uri); >+ assertEquals("module", cvsUri.getPath().toString()); >+ CVSRepositoryLocation location = CVSRepositoryLocation.fromString(":pserver:anonymous:@host.com:/cvsroot/path"); >+ assertEquals(cvsUri.getRepository().getLocation(false), location.getLocation(false)); >+ assertEquals(cvsUri.getTag(), CVSTag.DEFAULT); >+ >+ String refString = new CVSProjectSetCapability().asReference(uri, "project"); >+ assertEquals("1.0,:pserver:anonymous:@host.com:/cvsroot/path,module,project", refString); >+ } >+ >+ public void testScmUri11() throws URISyntaxException, CVSException { >+ URI uri = new URI("scm:cvs:pserver:username@host.com:/cvsroot/path:module"); >+ CVSURI cvsUri = CVSURI.fromUri(uri); >+ assertEquals("module", cvsUri.getPath().toString()); >+ CVSRepositoryLocation location = CVSRepositoryLocation.fromString(":pserver:username@host.com:/cvsroot/path"); >+ assertEquals(cvsUri.getRepository().getLocation(false), location.getLocation(false)); >+ assertEquals(cvsUri.getTag(), CVSTag.DEFAULT); >+ >+ String refString = new CVSProjectSetCapability().asReference(uri, "project"); >+ assertEquals("1.0,:pserver:username@host.com:/cvsroot/path,module,project", refString); >+ } >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 326926
:
182292
|
182293
|
182994
|
183958
|
184262