You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2002/11/15 14:14:40 UTC

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

bodewig     2002/11/15 05:14:40

  Modified:    .        Tag: ANT_15_BRANCH WHATSNEW
               docs/manual/CoreTasks Tag: ANT_15_BRANCH cvstagdiff.html
               src/main/org/apache/tools/ant/taskdefs/cvslib Tag:
                        ANT_15_BRANCH CvsTagDiff.java
  Log:
  Merge cvstagdiff version from HEAD as it also fixes
  
  PR: 13514
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.263.2.99 +3 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.263.2.98
  retrieving revision 1.263.2.99
  diff -u -r1.263.2.98 -r1.263.2.99
  --- WHATSNEW	12 Nov 2002 08:41:39 -0000	1.263.2.98
  +++ WHATSNEW	15 Nov 2002 13:14:40 -0000	1.263.2.99
  @@ -26,6 +26,9 @@
   
   * <javadoc> will now pass -source to custom doclets as well.
   
  +* <cvstagdiff> would throw a NullPointException if there had been no
  +  differences.
  +
   Other changes:
   --------------
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +13 -4     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.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- cvstagdiff.html	28 Aug 2002 12:06:08 -0000	1.1.2.1
  +++ cvstagdiff.html	15 Nov 2002 13:14:40 -0000	1.1.2.2
  @@ -1,12 +1,9 @@
   <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
  @@ -49,7 +46,7 @@
       <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>  
  +  </tr>
   </table>
   
   <h3>Parameters inherited from the <code>cvs</code> task</h3>
  @@ -114,6 +111,18 @@
   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>
   
   <pre>  &lt;cvstagdiff
                   destfile=&quot;tagdiff.xml&quot;
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.6.2.4   +18 -137   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.3
  retrieving revision 1.6.2.4
  diff -u -r1.6.2.3 -r1.6.2.4
  --- CvsTagDiff.java	28 Aug 2002 12:06:08 -0000	1.6.2.3
  +++ CvsTagDiff.java	15 Nov 2002 13:14:40 -0000	1.6.2.4
  @@ -64,8 +64,7 @@
   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.taskdefs.AbstractCvsTask;
   import org.apache.tools.ant.util.FileUtils;
   
   /**
  @@ -101,9 +100,8 @@
    * @version $Revision$ $Date$
    * @since Ant 1.5
    * @ant.task name="cvstagdiff"
  - * @todo Why doesn't this task extend from AbstractCvsTask?
    */
  -public class CvsTagDiff extends Task {
  +public class CvsTagDiff extends AbstractCvsTask {
   
       /**
        * Token to identify a new file in the rdiff log
  @@ -121,21 +119,11 @@
       static final String FILE_WAS_REMOVED = " is removed";
   
       /**
  -     * The cvs task which will perform the rdiff.
  -     */
  -    private Cvs m_cvs;
  -
  -    /**
        * The cvs package/module to analyse
        */
       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;
  @@ -166,48 +154,6 @@
       private FileUtils m_fileUtils = FileUtils.newFileUtils();
   
       /**
  -     * Initialize this task.
  -     * CvsTagDiff initializes a member cvs task in init() to perform the
  -     * rdiff in execute().
  -     *
  -     * @exception BuildException if an error occurs
  -     */
  -    public void init() throws BuildException {
  -        m_cvs = (Cvs) getProject().createTask("cvs");
  -    }
  -
  -    /**
  -     * If set to a value 1-9 it adds -zN to the cvs command line, else
  -     * it disables compression.
  -     *
  -     * @see org.apache.tools.ant.taskdefs.AbstractCvsTask#setCompressionLevel(int)
  -     */
  -    public void setCompressionLevel(int level) {
  -        m_cvs.setCompressionLevel(level);
  -    }
  -
  -    /**
  -     * If true, this is the same as compressionlevel="3".
  -     */
  -    public void setCompression(boolean usecomp) {
  -        m_cvs.setCompression(usecomp);
  -    }
  -
  -    /**
  -     * The CVSROOT variable.
  -     */
  -    public void setCvsRoot(String cvsRoot) {
  -        m_cvs.setCvsRoot(cvsRoot);
  -    }
  -
  -    /**
  -     * The CVS_RSH variable.
  -     */
  -    public void setCvsRsh(String rsh) {
  -        m_cvs.setCvsRsh(rsh);
  -    }
  -
  -    /**
        * The package/module to analyze.
        */
       public void setPackage(String p) {
  @@ -215,43 +161,6 @@
       }
   
       /**
  -     * 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) {
  -        m_cvs.setQuiet(quiet);
  -    }
  -
  -    /**
  -     * Port used by CVS to communicate with the server.
  -     */
  -    public void setPort(int port) {
  -        m_cvs.setPort(port);
  -    }
  -
  -    /**
  -     * Password file to read passwords from.
  -     */
  -    public void setPassfile(File f) {
  -        m_cvs.setPassfile(f);
  -    }
  -
  -    /**
  -     * Stop the build process if the command exits with
  -     * a return code other than 0.
  -     * Defaults to false.
  -     */
  -    public void setFailOnError(boolean b) {
  -        m_cvs.setFailOnError(b);
  -    }
  -
  -    /**
        * Set the start tag.
        *
        * @param s the start tag.
  @@ -312,15 +221,15 @@
               + (m_endTag != null ? ("-r " + m_endTag) : ("-D " + m_endDate))
               + " " + m_package;
           log("Cvs command is " + rdiff, Project.MSG_VERBOSE);
  -        m_cvs.setCommand(rdiff);
  +        setCommand(rdiff);
   
           File tmpFile = null;
           try {
               tmpFile = m_fileUtils.createTempFile("cvstagdiff", ".log", null);
  -            m_cvs.setOutput(tmpFile);
  +            setOutput(tmpFile);
   
               // run the cvs command
  -            m_cvs.execute();
  +            super.execute();
   
               // parse the rdiff
               CvsTagEntry[] entries = parseRDiff(tmpFile);
  @@ -350,11 +259,20 @@
           try {
               reader = new BufferedReader(new FileReader(tmpFile));
   
  -            String line = reader.readLine();
  -            int headerLength = getHeaderLength(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
   
  -            int index;
  +            // get rid of 'File module/"
  +            int headerLength = 5 + m_package.length() + 1;
               Vector entries = new Vector();
  +
  +            String line = reader.readLine();
  +            int index;
               CvsTagEntry entry = null;
   
               while (null != line) {
  @@ -407,43 +325,6 @@
                   }
               }
           }
  -    }
  -
  -    /**
  -     * 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>