You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by sb...@apache.org on 2002/08/28 14:06:09 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/cvslib CvsTagDiff.java

sbailliez    2002/08/28 05:06:09

  Modified:    docs/manual/CoreTasks Tag: ANT_15_BRANCH cvstagdiff.html
               src/main/org/apache/tools/ant/taskdefs/cvslib Tag:
                        ANT_15_BRANCH CvsTagDiff.java
  Log:
  Accomodate parsing for the following cases
  - the specified module might be an ampersand module
  - the specified module might have a differently named (root) directory
  
  PR: 11967
  Submitted by: rvanoo@xs4all.nl (Rob van Oostrum)
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +168 -159  jakarta-ant/docs/manual/CoreTasks/cvstagdiff.html
  
  Index: cvstagdiff.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/cvstagdiff.html,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- cvstagdiff.html	15 Apr 2002 09:53:24 -0000	1.1
  +++ cvstagdiff.html	28 Aug 2002 12:06:08 -0000	1.1.2.1
  @@ -1,159 +1,168 @@
  -<html>
  -
  -<head>
  -<meta http-equiv="Content-Language" content="en-us">
  -<title>CvsTagDiff Task</title>
  -</head>
  -
  -<body>
  -
  -<h2><a name="cvstagdiff">CvsTagDiff</a></h2>
  -<h3>Description</h3>
  -<p>Generates an XML-formatted report file of the changes between two tags or dates recorded in a
  -<a href="http://www.cvshome.org/" target="_top">CVS</a> repository. </p>
  -<h3>Parameters</h3>
  -<table border="1" cellpadding="2" cellspacing="0">
  -  <tr>
  -    <td valign="top"><b>Attribute</b></td>
  -    <td valign="top"><b>Description</b></td>
  -    <td align="center" valign="top"><b>Required</b></td>
  -  </tr>
  -  <tr>
  -    <td valign="top">startTag</td>
  -    <td valign="top">The earliest tag from which diffs are to be
  -     included in the report.</td>
  -    <td align="center" valign="top" rowspan="2">exactly one of the two.</td>
  -  </tr>
  -  <tr>
  -    <td valign="top">startDate</td>
  -    <td valign="top">The earliest date from which diffs are to be
  -     included in the report.</td>
  -  </tr>
  -  <tr>
  -    <td valign="top">endTag</td>
  -    <td valign="top">The latest tag from which diffs are to be
  -     included in the report.</td>
  -    <td align="center" valign="top" rowspan="2">exactly one of the two.</td>
  -  </tr>
  -  <tr>
  -    <td valign="top">endDate</td>
  -    <td valign="top">The latest date from which diffs are to be
  -     included in the report.</td>
  -  </tr>
  -  <tr>
  -    <td valign="top">destfile</td>
  -    <td valign="top">The file in which to write the diff report.</td>
  -    <td align="center" valign="top">Yes</td>
  -  </tr>
  -</table>
  -
  -<h3>Parameters inherited from the <code>cvs</code> task</h3>
  -<table border="1" cellpadding="2" cellspacing="0">
  -  <tr>
  -    <td valign="top"><b>Attribute</b></td>
  -    <td valign="top"><b>Description</b></td>
  -    <td align="center" valign="top"><b>Required</b></td>
  -  </tr>
  -  <tr>
  -    <td valign="top">compression</td>
  -    <td valign="top"><code>true</code>, <code>false</code>, or the number 1-9 (corresponding to possible values for CVS <code>-z#</code> argument). Any other value is treated as false</td>
  -    <td align="center" valign="top">No. Defaults to no compression. if passed <code>true</code>, level 3 compression is assumed.</td>
  -  </tr>
  -  <tr>
  -    <td valign="top">cvsRoot</td>
  -    <td valign="top">the CVSROOT variable.</td>
  -    <td align="center" valign="top">No</td>
  -  </tr>
  -  <tr>
  -    <td valign="top">cvsRsh</td>
  -    <td valign="top">the CVS_RSH variable.</td>
  -    <td align="center" valign="top">No</td>
  -  </tr>
  -  <tr>
  -    <td valign="top">package</td>
  -    <td valign="top">the package/module to analyze.</td>
  -    <td align="center" valign="top">Yes</td>
  -  </tr>
  -  <tr>
  -    <td valign="top">quiet</td>
  -    <td valign="top">suppress informational messages.</td>
  -    <td align="center" valign="top">No, default &quot;false&quot;</td>
  -  </tr>
  -  <tr>
  -    <td valign="top">port</td>
  -    <td valign="top">Port used by CVS to communicate with the server.</td>
  -    <td align="center" valign="top">No, default port 2401.</td>
  -  </tr>
  -  <tr>
  -    <td valign="top">passfile</td>
  -    <td valign="top">Password file to read passwords from.</td>
  -    <td align="center" valign="top">No, default file ~/.cvspass.</td>
  -  </tr>
  -  <tr>
  -    <td valign="top">failonerror</td>
  -    <td valign="top">Stop the buildprocess if the command exits with a
  -      returncode other than 0. Defaults to false</td>
  -    <td align="center" valign="top">No</td>
  -  </tr>
  -</table>
  -
  -<h3>Examples</h3>
  -<pre>  &lt;cvstagdiff cvsRoot=&quot;:pserver:anoncvs@cvs.apache.org:/home/cvspublic&quot;
  -                destfile=&quot;tagdiff.xml&quot;
  -                package=&quot;jakarta-ant&quot;
  -                startTag=&quot;ANT_14&quot;
  -                endTag=&quot;ANT_141&quot;
  -  /&gt;</pre>
  -
  -<p>Generates a tagdiff report for all the changes that have been made
  -in the <code>jakarta-ant</code> module between the tags <code>ANT_14</code> and <code>ANT_141</code>.
  -It writes these changes into the file <code>tagdiff.xml</code>.</p>
  -
  -<pre>  &lt;cvstagdiff
  -                destfile=&quot;tagdiff.xml&quot;
  -                package=&quot;jakarta-ant&quot;
  -                startDate=&quot;2002-01-01&quot;
  -                endDate=&quot;2002-31-01&quot;
  -  /&gt;</pre>
  -
  -<p>Generates a tagdiff report for all the changes that have been made
  -in the <code>jakarta-ant</code> module in january 2002. In this example <code>cvsRoot</code>
  -has not been set. The current <code>cvsRoot</code> will be used (assuming the build is started
  -from a folder stored in <code>cvs</code>.
  -It writes these changes into the file <code>tagdiff.xml</code>.</p>
  -
  -<h4>Generate Report</h4>
  -<p>Ant includes a basic XSLT stylesheet that you can use to generate 
  -a HTML report based on the xml output. The following example illustrates
  -how to generate a HTML report from the XML report.</p>
  -
  -<pre>
  -        &lt;style in="tagdiff.xml" 
  -               out="tagdiff.html" 
  -               style="${ant.home}/etc/tagdiff.xsl"&gt;
  -          &lt;param name="title" expression="Ant Diff"/&gt;
  -          &lt;param name="module" expression="jakarta-ant"/&gt;
  -          &lt;param name="cvsweb" expression="http://cvs.apache.org/viewcvs/"/&gt;
  -        &lt;/style&gt;
  -</pre>
  -
  -<h4>Sample Output</h4>
  -<pre>
  -&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  -&lt;tagdiff startTag=&quot;ANT_14&quot; endTag=&quot;ANT_141&quot;&gt;
  -  &lt;entry&gt;
  -    &lt;file&gt;
  -      &lt;name&gt;src/main/org/apache/tools/ant/DirectoryScanner.java&lt;/name&gt;
  -      &lt;revision&gt;1.15.2.1&lt;/revision&gt;
  -      &lt;prevrevision&gt;1.15&lt;/prevrevision&gt;
  -    &lt;/file&gt;
  -  &lt;/entry&gt;
  -&lt;/tagdiff&gt;
  -</pre>
  -
  -<hr><p align="center">Copyright &copy; 2002 Apache Software Foundation. All rights
  -Reserved.</p>
  -
  -</body>
  -</html>
  -
  +<html>
  +
  +<head>
  +<meta http-equiv="Content-Language" content="en-us">
  +<title>CvsTagDiff Task</title>
  +</head>
  +
  +<body>
  +
  +<h2><a name="cvstagdiff">CvsTagDiff</a></h2>
  +<h3>Description</h3>
  +<p>Generates an XML-formatted report file of the changes between two tags or dates recorded in a
  +<a href="http://www.cvshome.org/" target="_top">CVS</a> repository. </p>
  +<h3>Parameters</h3>
  +<table border="1" cellpadding="2" cellspacing="0">
  +  <tr>
  +    <td valign="top"><b>Attribute</b></td>
  +    <td valign="top"><b>Description</b></td>
  +    <td align="center" valign="top"><b>Required</b></td>
  +  </tr>
  +  <tr>
  +    <td valign="top">startTag</td>
  +    <td valign="top">The earliest tag from which diffs are to be
  +     included in the report.</td>
  +    <td align="center" valign="top" rowspan="2">exactly one of the two.</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">startDate</td>
  +    <td valign="top">The earliest date from which diffs are to be
  +     included in the report.</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">endTag</td>
  +    <td valign="top">The latest tag from which diffs are to be
  +     included in the report.</td>
  +    <td align="center" valign="top" rowspan="2">exactly one of the two.</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">endDate</td>
  +    <td valign="top">The latest date from which diffs are to be
  +     included in the report.</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">destfile</td>
  +    <td valign="top">The file in which to write the diff report.</td>
  +    <td align="center" valign="top">Yes</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">rootdir</td>
  +    <td valign="top">Root directory for the package, if different from the package name.</td>
  +    <td align="center" valign="top">No</td>
  +  </tr>  
  +</table>
  +
  +<h3>Parameters inherited from the <code>cvs</code> task</h3>
  +<table border="1" cellpadding="2" cellspacing="0">
  +  <tr>
  +    <td valign="top"><b>Attribute</b></td>
  +    <td valign="top"><b>Description</b></td>
  +    <td align="center" valign="top"><b>Required</b></td>
  +  </tr>
  +  <tr>
  +    <td valign="top">compression</td>
  +    <td valign="top"><code>true</code>, <code>false</code>, or the number 1-9 (corresponding to possible values for CVS <code>-z#</code> argument). Any other value is treated as false</td>
  +    <td align="center" valign="top">No. Defaults to no compression. if passed <code>true</code>, level 3 compression is assumed.</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">cvsRoot</td>
  +    <td valign="top">the CVSROOT variable.</td>
  +    <td align="center" valign="top">No</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">cvsRsh</td>
  +    <td valign="top">the CVS_RSH variable.</td>
  +    <td align="center" valign="top">No</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">package</td>
  +    <td valign="top">the package/module to analyze.</td>
  +    <td align="center" valign="top">Yes</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">quiet</td>
  +    <td valign="top">suppress informational messages.</td>
  +    <td align="center" valign="top">No, default &quot;false&quot;</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">port</td>
  +    <td valign="top">Port used by CVS to communicate with the server.</td>
  +    <td align="center" valign="top">No, default port 2401.</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">passfile</td>
  +    <td valign="top">Password file to read passwords from.</td>
  +    <td align="center" valign="top">No, default file ~/.cvspass.</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">failonerror</td>
  +    <td valign="top">Stop the buildprocess if the command exits with a
  +      returncode other than 0. Defaults to false</td>
  +    <td align="center" valign="top">No</td>
  +  </tr>
  +</table>
  +
  +<h3>Examples</h3>
  +<pre>  &lt;cvstagdiff cvsRoot=&quot;:pserver:anoncvs@cvs.apache.org:/home/cvspublic&quot;
  +                destfile=&quot;tagdiff.xml&quot;
  +                package=&quot;jakarta-ant&quot;
  +                startTag=&quot;ANT_14&quot;
  +                endTag=&quot;ANT_141&quot;
  +  /&gt;</pre>
  +
  +<p>Generates a tagdiff report for all the changes that have been made
  +in the <code>jakarta-ant</code> module between the tags <code>ANT_14</code> and <code>ANT_141</code>.
  +It writes these changes into the file <code>tagdiff.xml</code>.</p>
  +
  +
  +<pre>  &lt;cvstagdiff
  +                destfile=&quot;tagdiff.xml&quot;
  +                package=&quot;jakarta-ant&quot;
  +                rootdir=&quot;jakarta/ant&quot;
  +                startDate=&quot;2002-01-01&quot;
  +                endDate=&quot;2002-31-01&quot;
  +  /&gt;</pre>
  +
  +<p>Generates a tagdiff report for all the changes that have been made
  +in the <code>jakarta-ant</code> module in january 2002, with <code>rootdir</code> indicating that 
  +the actual location of the <code>jakarta-ant</code> module in cvs is <code>jakarta/ant</code> 
  +rather than <code>jakarta-ant</code>. In this example <code>cvsRoot</code>
  +has not been set. The current <code>cvsRoot</code> will be used (assuming the build is started
  +from a folder stored in <code>cvs</code>.
  +It writes these changes into the file <code>tagdiff.xml</code>.</p>
  +
  +<h4>Generate Report</h4>
  +<p>Ant includes a basic XSLT stylesheet that you can use to generate 
  +a HTML report based on the xml output. The following example illustrates
  +how to generate a HTML report from the XML report.</p>
  +
  +<pre>
  +        &lt;style in="tagdiff.xml" 
  +               out="tagdiff.html" 
  +               style="${ant.home}/etc/tagdiff.xsl"&gt;
  +          &lt;param name="title" expression="Ant Diff"/&gt;
  +          &lt;param name="module" expression="jakarta-ant"/&gt;
  +          &lt;param name="cvsweb" expression="http://cvs.apache.org/viewcvs/"/&gt;
  +        &lt;/style&gt;
  +</pre>
  +
  +<h4>Sample Output</h4>
  +<pre>
  +&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  +&lt;tagdiff startTag=&quot;ANT_14&quot; endTag=&quot;ANT_141&quot;&gt;
  +  &lt;entry&gt;
  +    &lt;file&gt;
  +      &lt;name&gt;src/main/org/apache/tools/ant/DirectoryScanner.java&lt;/name&gt;
  +      &lt;revision&gt;1.15.2.1&lt;/revision&gt;
  +      &lt;prevrevision&gt;1.15&lt;/prevrevision&gt;
  +    &lt;/file&gt;
  +  &lt;/entry&gt;
  +&lt;/tagdiff&gt;
  +</pre>
  +
  +<hr><p align="center">Copyright &copy; 2002 Apache Software Foundation. All rights
  +Reserved.</p>
  +
  +</body>
  +</html>
  +
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.6.2.3   +59 -19    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
  
  Index: CvsTagDiff.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java,v
  retrieving revision 1.6.2.2
  retrieving revision 1.6.2.3
  diff -u -r1.6.2.2 -r1.6.2.3
  --- CvsTagDiff.java	24 Jun 2002 02:28:08 -0000	1.6.2.2
  +++ CvsTagDiff.java	28 Aug 2002 12:06:08 -0000	1.6.2.3
  @@ -53,12 +53,6 @@
    */
   package org.apache.tools.ant.taskdefs.cvslib;
   
  -import org.apache.tools.ant.BuildException;
  -import org.apache.tools.ant.Project;
  -import org.apache.tools.ant.Task;
  -import org.apache.tools.ant.taskdefs.Cvs;
  -import org.apache.tools.ant.util.FileUtils;
  -
   import java.io.BufferedReader;
   import java.io.File;
   import java.io.FileOutputStream;
  @@ -68,6 +62,11 @@
   import java.io.PrintWriter;
   import java.io.UnsupportedEncodingException;
   import java.util.Vector;
  +import org.apache.tools.ant.BuildException;
  +import org.apache.tools.ant.Project;
  +import org.apache.tools.ant.Task;
  +import org.apache.tools.ant.taskdefs.Cvs;
  +import org.apache.tools.ant.util.FileUtils;
   
   /**
    * Examines the output of cvs rdiff between two tags.
  @@ -98,6 +97,7 @@
    * </PRE>
    *
    * @author <a href="mailto:fred@castify.net">Frederic Lavigne</a>
  + * @author <a href="mailto:rvanoo@xs4all.nl">Rob van Oostrum</a>
    * @version $Revision$ $Date$
    * @since Ant 1.5
    * @ant.task name="cvstagdiff"
  @@ -131,6 +131,11 @@
       private String m_package;
   
       /**
  +     * The root directory in the rdiff output for the cvs package/module
  +     */
  +    private String m_rootDir;
  +
  +    /**
        * The earliest tag from which diffs are to be included in the report.
        */
       private String m_startTag;
  @@ -210,6 +215,13 @@
       }
   
       /**
  +     * The root directory for the package/module to analyze.
  +     */
  +    public void setRootDir(String dir) {
  +        m_rootDir = dir;
  +    }
  +
  +    /**
        * If true, suppress informational messages.
        */
       public void setQuiet(boolean quiet) {
  @@ -338,20 +350,11 @@
           try {
               reader = new BufferedReader(new FileReader(tmpFile));
   
  -            // entries are of the form:
  -            // File module/filename is new; current revision 1.1
  -            // or
  -            // File module/filename changed from revision 1.4 to 1.6
  -            // or
  -            // File module/filename is removed; not included in
  -            // release tag SKINLF_12
  -
  -            // get rid of 'File module/"
  -            int headerLength = 5 + m_package.length() + 1;
  -            Vector entries = new Vector();
  -
               String line = reader.readLine();
  +            int headerLength = getHeaderLength(line);
  +
               int index;
  +            Vector entries = new Vector();
               CvsTagEntry entry = null;
   
               while (null != line) {
  @@ -404,6 +407,43 @@
                   }
               }
           }
  +    }
  +
  +    /**
  +     * Return the size of the header from a given line that is the output
  +     * from <tt>cvs rdiff -s ...</tt>.
  +     * @param line the line of text containing the 'File module/filename is ...'
  +     * @return the header length
  +     */
  +    private int getHeaderLength(String line) {
  +        // entries are of the form:
  +        // File module/filename is new; current revision 1.1
  +        // or
  +        // File module/filename changed from revision 1.4 to 1.6
  +        // or
  +        // File module/filename is removed; not included in
  +        // release tag SKINLF_12
  +
  +        // get rid of 'File module/"
  +        final boolean trimFileName = line.startsWith( "File " + m_package );
  +
  +        final int prefixLength = "File ".length();
  +        int suffixLength = 0;
  +        int rootDirLength = 0;
  +
  +        if (null != m_rootDir) {
  +            // if root directory is set
  +            rootDirLength = m_rootDir.length();
  +            suffixLength = ( rootDirLength > 0 && m_rootDir.endsWith( "/" ) ) ? 1 : 0;
  +        } else if (trimFileName) {
  +            // if root directory wasn't set, and the rdiff output is of
  +            // the format File module/filename
  +            rootDirLength = m_package.length();
  +            suffixLength = 1;
  +        }
  +
  +        int headerLength = prefixLength + rootDirLength + suffixLength;
  +        return headerLength;
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>