Author: dennisl
Date: Sat Oct 28 16:57:18 2006
New Revision: 468790

URL: http://svn.apache.org/viewvc?view=rev&rev=468790
Log:
[MCHANGELOG-16] when using svn, links are wrong.

o Rearrange the code so that "displayFileDetailUrl" is used if and only if it 
is supplied in the configuration.

o Add a special token %FILE% that can be put anywhere in 
"displayFileDetailUrl". The token will be replaced with the actual path to the 
file when the report is generated. This enables the user to have more complex 
URLs than was previously possible.

Modified:
    
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java

Modified: 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java?view=diff&rev=468790&r1=468789&r2=468790
==============================================================================
--- 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
 (original)
+++ 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
 Sat Oct 28 16:57:18 2006
@@ -69,6 +69,12 @@
     extends AbstractMavenReport
 {
     /**
+     * A special token that represents the SCM relative path for a file.
+     * It can be used in <code>displayFileDetailUrl</code>.
+     */
+    private static final String FILE_TOKEN = "%FILE%";
+
+    /**
      * Used to specify whether to build the log using range, tag or date.
      *
      * @parameter expression="${changelog.type}" default-value="range"
@@ -244,7 +250,19 @@
     private String connectionType;
 
     /**
-     * Allows the user to specify the file detail URL to use when viewing an 
scm file.
+     * A template string that is used to create the URL to the file details.
+     * There is a special token that you can use in your template:
+     * <ul>
+     * <li><code>%FILE%</code> - this is the path to a file</li>
+     * </ul>
+     * <p>
+     * Example:
+     * 
<code>http://checkstyle.cvs.sourceforge.net/checkstyle%FILE%?view=markup</code>
+     * </p>
+     * <p>
+     * <strong>Note:</strong> If you don't supply the token in your template,
+     * the path of the file will simply be appended to your template URL.
+     * </p>
      *
      * @parameter expression="${project.scm.url}"
      */
@@ -987,29 +1005,6 @@
 
                     rpt_MultiRepoParam = "&" + 
rpt_TmpMultiRepoParam.substring( 1 );
                 }
-                else
-                {
-                    idx = displayFileDetailUrl.indexOf( "?" );
-
-                    if ( idx > 0 )
-                    {
-                        String fileDetailUrl = displayFileDetailUrl.substring( 
0, idx );
-
-                        String rpt_TmpMultiRepoParam = 
displayFileDetailUrl.substring( idx + 1 );
-
-                        displayFileDetailUrl = fileDetailUrl;
-
-                        rpt_OneRepoParam = "?" + rpt_TmpMultiRepoParam;
-
-                        rpt_MultiRepoParam = "&" + rpt_TmpMultiRepoParam;
-                    }
-                    else
-                    {
-                        rpt_OneRepoParam = "";
-
-                        rpt_MultiRepoParam = "";
-                    }
-                }
             }
             else
             {
@@ -1090,7 +1085,21 @@
 
         if ( displayFileDetailUrl != null )
         {
-            if ( connection.startsWith( "scm:perforce" ) )
+            if ( !scmUrl.equals( displayFileDetailUrl ) )
+            {
+                // Use the given URL to create links to the files
+                if( displayFileDetailUrl.indexOf( FILE_TOKEN ) > 0 )
+                {
+                    linkFile = displayFileDetailUrl.replaceAll( FILE_TOKEN, 
name );
+                }
+                else
+                {
+                    // This is here so that we are backwards compatible with 
the
+                    // format used before the special token was introduced
+                    linkFile = displayFileDetailUrl + name;
+                }
+            }
+            else if ( connection.startsWith( "scm:perforce" ) )
             {
                 String path = getAbsolutePath( displayFileDetailUrl, name );
                 linkFile = path + "?ac=22";


Reply via email to