Made a few changes to try and resolve Bug #24569

- RCSFile checkstyle changes
- Name hiding in ChangeLogParser, loc reduce

- rewrite of ChangeLogWriter.printEntry()
Uses a stringbuffer and prints at the end of the method, doesn't print line by line. May help with the bug, but it may indeed do nothing. It shouldn't be a problem, unless there's an error, in which case instead of a half complete entry being printed, there'll be no output at all, I doubt that this will break BC.



Index: ChangeLogParser.java
===================================================================
RCS file: 
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java,v
retrieving revision 1.28
diff -u -r1.28 ChangeLogParser.java
--- ChangeLogParser.java        6 Dec 2004 17:35:42 -0000       1.28
+++ ChangeLogParser.java        17 Jan 2005 11:48:27 -0000
@@ -60,7 +60,6 @@
 
     /**
      * Get a list of rcs entries as an array.
-     *
      * @return a list of rcs entries as an array
      */
     public CVSEntry[] getEntrySetAsArray() {
@@ -110,7 +109,6 @@
 
     /**
      * Process a line while in "GET_COMMENT" state.
-     *
      * @param line the line
      */
     private void processComment(final String line) {
@@ -136,7 +134,6 @@
 
     /**
      * Process a line while in "GET_FILE" state.
-     *
      * @param line the line to process
      */
     private void processFile(final String line) {
@@ -148,7 +145,6 @@
 
     /**
      * Process a line while in "REVISION" state.
-     *
      * @param line the line to process
      */
     private void processRevision(final String line) {
@@ -156,15 +152,14 @@
             revision = line.substring(9);
             status = GET_DATE;
         } else if (line.startsWith("======")) {
-            //There was no revisions in this changelog
-            //entry so lets move unto next file
+            //There were no revisions in this changelog
+            //entry so lets move onto next file
             status = GET_FILE;
         }
     }
 
     /**
      * Process a line while in "DATE" state.
-     *
      * @param line the line to process
      */
     private void processDate(final String line) {
@@ -183,7 +178,6 @@
 
     /**
      * Process a line while in "GET_PREVIOUS_REVISION" state.
-     *
      * @param line the line to process
      */
     private void processGetPreviousRevision(final String line) {
@@ -217,13 +211,12 @@
 
     /**
      * Parse date out from expected format.
-     *
      * @param date the string holding date
      * @return the date object or null if unknown date format
      */
-    private Date parseDate(final String date) {
+    private Date parseDate(final String dateString) {
         try {
-            return INPUT_DATE.parse(date);
+            return INPUT_DATE.parse(dateString);
         } catch (ParseException e) {
             //final String message = REZ.getString( 
"changelog.bat-date.error", date );
             //getContext().error( message );
Index: ChangeLogTask.java
===================================================================
RCS file: 
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java,v
retrieving revision 1.31
diff -u -r1.31 ChangeLogTask.java
--- ChangeLogTask.java  6 Dec 2004 17:41:32 -0000       1.31
+++ ChangeLogTask.java  17 Jan 2005 11:48:27 -0000
@@ -93,7 +93,6 @@
 
     /**
      * Set the base dir for cvs.
-     *
      * @param inputDir The new dir value
      */
     public void setDir(final File inputDir) {
@@ -103,7 +102,6 @@
 
     /**
      * Set the output file for the log.
-     *
      * @param destFile The new destfile value
      */
     public void setDestfile(final File destFile) {
@@ -113,7 +111,6 @@
 
     /**
      * Set a lookup list of user names & addresses
-     *
      * @param usersFile The file containing the users info.
      */
     public void setUsersfile(final File usersFile) {
@@ -123,7 +120,6 @@
 
     /**
      * Add a user to list changelog knows about.
-     *
      * @param user the user
      */
     public void addUser(final CvsUser user) {
@@ -133,7 +129,6 @@
 
     /**
      * Set the date at which the changelog should start.
-     *
      * @param start The date at which the changelog should start.
      */
     public void setStart(final Date start) {
@@ -143,7 +138,6 @@
 
     /**
      * Set the date at which the changelog should stop.
-     *
      * @param endDate The date at which the changelog should stop.
      */
     public void setEnd(final Date endDate) {
@@ -153,7 +147,6 @@
 
     /**
      * Set the number of days worth of log entries to process.
-     *
      * @param days the number of days of log to process.
      */
     public void setDaysinpast(final int days) {
@@ -166,7 +159,6 @@
 
     /**
      * Adds a set of files about which cvs logs will be generated.
-     *
      * @param fileSet a set of files about which cvs logs will be generated.
      */
     public void addFileset(final FileSet fileSet) {
@@ -176,7 +168,6 @@
 
     /**
      * Execute task
-     *
      * @exception BuildException if something goes wrong executing the
      *            cvs command
      */
Index: ChangeLogWriter.java
===================================================================
RCS file: 
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriter.java,v
retrieving revision 1.16
diff -u -r1.16 ChangeLogWriter.java
--- ChangeLogWriter.java        6 Dec 2004 17:45:57 -0000       1.16
+++ ChangeLogWriter.java        17 Jan 2005 11:48:27 -0000
@@ -68,35 +68,43 @@
      * @param output writer to which to send output.
      */
     private void printEntry(final PrintWriter output, final CVSEntry entry) {
-        output.println("\t<entry>");
-        output.println("\t\t<date>" + OUTPUT_DATE.format(entry.getDate())
-            + "</date>");
-        output.println("\t\t<time>" + OUTPUT_DATE.format(entry.getDate())
-            + "</time>");
-        output.println("\t\t<author><![CDATA[" + entry.getAuthor()
-            + "]]></author>");
+       final StringBuffer sb = new StringBuffer("\n\t<entry>");
+       sb.append("\n\t\t<date>");
+       sb.append(OUTPUT_DATE.format(entry.getDate()));
+       sb.append("</date>");
+       sb.append("\n\t\t<time>");
+       sb.append(OUTPUT_DATE.format(entry.getDate()));
+       sb.append("</time>");
+       sb.append("\n\t\t<author><![CDATA[");
+       sb.append(entry.getAuthor());
+       sb.append("]]></author>");
 
         final Enumeration enumeration = entry.getFiles().elements();
 
         while (enumeration.hasMoreElements()) {
             final RCSFile file = (RCSFile) enumeration.nextElement();
-
-            output.println("\t\t<file>");
-            output.println("\t\t\t<name><![CDATA[" + file.getName() + 
"]]></name>");
-            output.println("\t\t\t<revision>" + file.getRevision()
-                + "</revision>");
-
+            
+            sb.append("\n\t\t<file>");
+            sb.append("\n\t\t\t<name><![CDATA[");
+            sb.append(file.getName());
+            sb.append("]]></name>");
+            sb.append("\n\t\t\t<revision>");
+            sb.append(file.getRevision());
+            sb.append("</revision>");
             final String previousRevision = file.getPreviousRevision();
 
             if (previousRevision != null) {
-                output.println("\t\t\t<prevrevision>" + previousRevision
-                    + "</prevrevision>");
+               sb.append("\n\t\t\t<prevrevision>");
+               sb.append(previousRevision);
+               sb.append("</prevrevision>");
             }
-
-            output.println("\t\t</file>");
+            sb.append("\n\t\t</file>");
         }
-        output.println("\t\t<msg><![CDATA[" + entry.getComment() + 
"]]></msg>");
-        output.println("\t</entry>");
+        sb.append("\n\t\t<msg><![CDATA[");
+        sb.append(entry.getComment());
+        sb.append("]]></msg>");
+        sb.append("\n\t</entry>");    
+        output.print(sb.toString());
     }
 }
 
Index: RCSFile.java
===================================================================
RCS file: 
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/cvslib/RCSFile.java,v
retrieving revision 1.9
diff -u -r1.9 RCSFile.java
--- RCSFile.java        9 Mar 2004 16:48:14 -0000       1.9
+++ RCSFile.java        17 Jan 2005 11:48:27 -0000
@@ -22,9 +22,9 @@
  * @version $Revision: 1.9 $ $Date: 2004/03/09 16:48:14 $
  */
 class RCSFile {
-    private String m_name;
-    private String m_revision;
-    private String m_previousRevision;
+    private String name;
+    private String revision;
+    private String previousRevision;
 
 
     RCSFile(final String name, final String rev) {
@@ -35,26 +35,35 @@
     RCSFile(final String name,
                   final String revision,
                   final String previousRevision) {
-        m_name = name;
-        m_revision = revision;
+        this.name = name;
+        this.revision = revision;
         if (!revision.equals(previousRevision)) {
-            m_previousRevision = previousRevision;
+            this.previousRevision = previousRevision;
         }
     }
 
-
+    /**
+     * Gets the name of the RCSFile
+     * @return name of the file
+     */
     String getName() {
-        return m_name;
+        return name;
     }
 
-
+    /**
+     * Gets the revision number of the RCSFile
+     * @return the revision number (as String)
+     */
     String getRevision() {
-        return m_revision;
+        return revision;
     }
 
-
+    /**
+     * Gets the previous revision of the RCSFile
+     * @return the previous revision number (as String)
+     */
     String getPreviousRevision() {
-        return m_previousRevision;
+        return previousRevision;
     }
 }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to