You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by lt...@apache.org on 2006/01/23 02:11:44 UTC

svn commit: r371429 - in /maven/maven-1/plugins/trunk/changelog: src/main/org/apache/maven/changelog/ src/main/org/apache/maven/util/ src/test/org/apache/maven/cvslib/ src/test/org/apache/maven/util/ xdocs/

Author: ltheussl
Date: Sun Jan 22 17:11:41 2006
New Revision: 371429

URL: http://svn.apache.org/viewcvs?rev=371429&view=rev
Log:
PR: MPCHANGELOG-81
Submitted by: Dennis Lundberg
Some valid scm urls are not allowed.
A valid scm url should be of the form scm:<provider><delimiter><provider-parameters>,
ie it has to start with 'scm:', but <delimiter> can be either ':' or '|'.

Modified:
    maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java
    maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/util/RepositoryUtils.java
    maven/maven-1/plugins/trunk/changelog/src/test/org/apache/maven/cvslib/CvsChangeLogGeneratorTest.java
    maven/maven-1/plugins/trunk/changelog/src/test/org/apache/maven/util/RepositoryTest.java
    maven/maven-1/plugins/trunk/changelog/xdocs/changes.xml

Modified: maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java?rev=371429&r1=371428&r2=371429&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java Sun Jan 22 17:11:41 2006
@@ -39,6 +39,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.maven.project.Developer;
+import org.apache.maven.util.RepositoryUtils;
 
 /**
  * Change log task. It uses a ChangeLogGenerator and ChangeLogParser to create
@@ -503,7 +504,7 @@
     {
         if ( clFactoryClass == null )
         {
-            //Connection Format: scm:<provider>[:<provider specific connection string>]
+            // Connection Format: scm:<provider><separator><provider specific connection string>
             if ( ( connection == null ) || ( connection.length() < 5 )
                 || !connection.startsWith( "scm:" ) )
             {
@@ -511,7 +512,7 @@
             }
             else
             {
-                int iProviderEnd = connection.indexOf( ":", 4 );
+                int iProviderEnd = connection.indexOf( RepositoryUtils.getSCMConnectionSeparator( connection ) , 4 );
                 if ( iProviderEnd == -1 )
                 {
                     // Connection = scm:<provider>
@@ -523,7 +524,7 @@
 
             if ( clFactoryClass == null )
             {
-                LOG.warn( 
+                LOG.warn(
                     "Could not derive factory from connection: using CVS (valid factories are: "
                     + FACTORIES.keySet() + ")" );
                 clFactoryClass = "org.apache.maven.cvslib.CvsChangeLogFactory";

Modified: maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/util/RepositoryUtils.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/util/RepositoryUtils.java?rev=371429&r1=371428&r2=371429&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/util/RepositoryUtils.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/util/RepositoryUtils.java Sun Jan 22 17:11:41 2006
@@ -32,6 +32,27 @@
 public final class RepositoryUtils
 {
     /**
+     * Get the separator used in an SCM string
+     * @param connection
+     * @return String that can be either ":" or "|"
+     */
+    public static String getSCMConnectionSeparator( String connection )
+    {
+        if ( connection == null )
+        {
+            throw new NullPointerException( "repository connection is null" );
+        }
+
+        if( connection.indexOf( "|" ) != -1 ) {
+            return "|";
+        }
+        else
+        {
+            return ":";
+        }
+    }
+
+    /**
      * Splits an SCM string into parts
      * @param connection
      * @return String[]
@@ -43,22 +64,27 @@
             throw new NullPointerException( "repository connection is null" );
         }
 
-        if ( connection.length() < 4 )
+        if ( connection.length() < 5 )
         {
             throw new IllegalArgumentException( 
                 "repository connection is too short" );
         }
 
-        if ( !connection.startsWith( "scm" ) )
+        if ( !connection.startsWith( "scm:" ) )
         {
             throw new IllegalArgumentException( 
-                "repository connection must start with scm[delim]" );
+                "repository connection must start with scm:" );
         }
 
-        String delimiter = "" + connection.charAt( 3 );
+        String delimiter = getSCMConnectionSeparator( connection );
+
+        // If the tokenizer is going to work correctly then the character
+        // following "scm" must be the same as the delimiter, which is not
+        // always the case. Therefor we give it a modified connection.
+        String modifiedConnection = "scm" + delimiter + connection.substring( 4 );
 
         EnhancedStringTokenizer tok =
-            new EnhancedStringTokenizer( connection, delimiter );
+            new EnhancedStringTokenizer( modifiedConnection, delimiter );
 
         String[] tokens = tokenizerToArray( tok );
 

Modified: maven/maven-1/plugins/trunk/changelog/src/test/org/apache/maven/cvslib/CvsChangeLogGeneratorTest.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/test/org/apache/maven/cvslib/CvsChangeLogGeneratorTest.java?rev=371429&r1=371428&r2=371429&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/test/org/apache/maven/cvslib/CvsChangeLogGeneratorTest.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/test/org/apache/maven/cvslib/CvsChangeLogGeneratorTest.java Sun Jan 22 17:11:41 2006
@@ -106,12 +106,12 @@
                 IllegalArgumentException.class),
             new Test(
                 null,
-                "scm|cvs|pserver|anoncvs@cvs.apache.org|D:\\home\\cvspublic|maven",
+                "scm:cvs|pserver|anoncvs@cvs.apache.org|D:\\home\\cvspublic|maven",
                 "cvs|-d|:pserver:anoncvs@cvs.apache.org:D:\\home\\cvspublic|log",
                 null),
             new Test(
                 null,
-                "scm|cvs|pserver|anoncvs@cvs.apache.org|D:/home/cvspublic|maven",
+                "scm:cvs|pserver|anoncvs@cvs.apache.org|D:/home/cvspublic|maven",
                 "cvs|-d|:pserver:anoncvs@cvs.apache.org:D:/home/cvspublic|log",
                 null),
             new Test(
@@ -121,7 +121,7 @@
                 null) ,
             new Test(
                 null,
-                "scm|cvs|local|local|D:/home/cvspublic|maven",
+                "scm:cvs|local|local|D:/home/cvspublic|maven",
                 "cvs|-d|D:/home/cvspublic|log",
                 null),
             new Test(

Modified: maven/maven-1/plugins/trunk/changelog/src/test/org/apache/maven/util/RepositoryTest.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/test/org/apache/maven/util/RepositoryTest.java?rev=371429&r1=371428&r2=371429&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/test/org/apache/maven/util/RepositoryTest.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/test/org/apache/maven/util/RepositoryTest.java Sun Jan 22 17:11:41 2006
@@ -22,6 +22,20 @@
 public class RepositoryTest
     extends TestCase
 {
+    public void testGetScmConnectionSeparatorColon()
+    {
+        String con = "scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:module";
+        String separator = RepositoryUtils.getSCMConnectionSeparator( con );
+        assertEquals( "Wrong SCM connection separator", ":", separator );
+    }
+
+    public void testGetScmConnectionSeparatorVerticalBar()
+    {
+        String con = "scm:cvs|pserver|anoncvs@cvs.apache.org|/home/cvspublic|module";
+        String separator = RepositoryUtils.getSCMConnectionSeparator( con );
+        assertEquals( "Wrong SCM connection separator", "|", separator );
+    }
+
     public void testSplitScmConnectionCvsPserver()
     {
         String con = "scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:module";
@@ -94,7 +108,7 @@
 
     public void testSplitScmConnectionSvn()
     {
-        String con = "scm|svn|http://svn.apache.org/repos";
+        String con = "scm:svn|http://svn.apache.org/repos";
         String[] tokens = RepositoryUtils.splitSCMConnection(con);
         assertEquals("Wrong number of tokens split", 3, tokens.length);
     }

Modified: maven/maven-1/plugins/trunk/changelog/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/xdocs/changes.xml?rev=371429&r1=371428&r2=371429&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/xdocs/changes.xml (original)
+++ maven/maven-1/plugins/trunk/changelog/xdocs/changes.xml Sun Jan 22 17:11:41 2006
@@ -25,6 +25,7 @@
   </properties>
   <body>
     <release version="1.9-SNAPSHOT" date="in SVN">
+      <action dev="ltheussl" type="fix" issue="MPCHANGELOG-81" due-to="Dennis Lundberg">Some valid scm urls are not allowed.</action>
       <action dev="ltheussl" type="fix" issue="MPCHANGELOG-72" due-to="Pascal Larin">Auto select factory from connection doesn't work if provider name length different from 3.</action>
       <action dev="ltheussl" type="add" issue="MPCHANGELOG-80" due-to="Christoph Jerolimov">Add MKS SI support.</action>
       <action dev="ltheussl" type="fix" issue="MPCHANGELOG-69">Changelog returns 0 entries on Windows with CVS (not CVSNT). New property <code>maven.changelog.quoteDate</code>.</action>