dion        02/04/21 04:05:14

  Modified:    src/java/org/apache/maven/cvslib ChangeLogParser.java
               src/test/org/apache/maven/cvslib ChangeLogParserTest.java
  Log:
  'Fixed' the Parser so that it no longer just kept a note of the previous revision 
number,
  but instead, treated the previous revision(s) as if they were as important as the
  current revision, giving a truer picture of the changes that have occurred
  
  Revision  Changes    Path
  1.17      +10 -30    
jakarta-turbine-maven/src/java/org/apache/maven/cvslib/ChangeLogParser.java
  
  Index: ChangeLogParser.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/cvslib/ChangeLogParser.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ChangeLogParser.java      21 Apr 2002 07:22:34 -0000      1.16
  +++ ChangeLogParser.java      21 Apr 2002 11:05:14 -0000      1.17
  @@ -67,15 +67,14 @@
   /**
    * A class to parse cvs log output
    *
  - * @todo make previous revisions processing same as current revision
    * @author <a href="mailto:[EMAIL PROTECTED]";>dIon Gillard</a>
  - * @version $Id: ChangeLogParser.java,v 1.16 2002/04/21 07:22:34 dion Exp $
  + * @version $Id: ChangeLogParser.java,v 1.17 2002/04/21 11:05:14 dion Exp $
    */
   public class ChangeLogParser 
   {
       
       /**
  -     * rcs entries, in reverse (date, author, comment) order
  +     * rcs entries, in reverse (date, time, author, comment) order
        */
       private Map entries = new TreeMap(Collections.reverseOrder());
   
  @@ -88,8 +87,6 @@
       private static final int GET_COMMENT = 3;
       /** expecting revision */
       private static final int GET_REVISION = 4;
  -    /** expecting additional (previous) revision */
  -    private static final int GET_PREVIOUS_REV = 5;
       /** Marks start of file data*/
       private static final String START_FILE = "Working file: ";
       /** Marks end of file */
  @@ -132,8 +129,7 @@
           //      Get File                -> Get Revision
           //      Get Revision            -> Get Date or Get File
           //      Get Date                -> Get Comment
  -        //      Get Comment             -> Get Comment or Get Previous Revision
  -        //      Get Previous Revision   -> Get File
  +        //      Get Comment             -> Get Comment or Get Revision
           String line = null;
           while ((line = stream.readLine()) != null)
           {
  @@ -151,9 +147,6 @@
                   case GET_COMMENT:
                       processGetComment(line);
                       break;
  -                case GET_PREVIOUS_REV:
  -                    processGetPreviousRevision(line);
  -                    break;
                   default:
                       throw new IllegalStateException("Unknown state: " + status);
               }
  @@ -251,7 +244,13 @@
       {
           if (line.startsWith(START_REVISION))
           {
  -            setStatus(GET_PREVIOUS_REV);
  +            // add entry, and set state to get revision
  +            addEntry(getCurrentLogEntry(), getCurrentFile());
  +            // new change log entry
  +            setCurrentLogEntry(new ChangeLogEntry());
  +            // same file name, but different rev
  +            setCurrentFile(new ChangeLogFile(getCurrentFile().getName()));
  +            setStatus(GET_REVISION);
           }
           else if (line.startsWith(END_FILE))
           {
  @@ -267,24 +266,6 @@
       }
   
       /**
  -     * Process the current input line in the Get Previous Revision state.
  -     */
  -    private void processGetPreviousRevision(String line)
  -    {
  -        if (line.startsWith(REVISION_TAG) || 
  -            line.startsWith(END_FILE))
  -        {
  -            if (line.startsWith(REVISION_TAG))
  -            {
  -                getCurrentFile().setPreviousRevision(
  -                    line.substring(REVISION_TAG.length()));
  -            }
  -            setStatus(GET_FILE);
  -            addEntry(getCurrentLogEntry(), getCurrentFile());
  -        }
  -    }
  -    
  -    /**
        * Getter for property currentFile.
        * @return Value of property currentFile.
        */
  @@ -335,5 +316,4 @@
       private void setStatus(int status) {
           this.status = status;
       }
  -    
   }
  
  
  
  1.2       +2 -2      
jakarta-turbine-maven/src/test/org/apache/maven/cvslib/ChangeLogParserTest.java
  
  Index: ChangeLogParserTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/test/org/apache/maven/cvslib/ChangeLogParserTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChangeLogParserTest.java  15 Apr 2002 15:56:51 -0000      1.1
  +++ ChangeLogParserTest.java  21 Apr 2002 11:05:14 -0000      1.2
  @@ -72,7 +72,7 @@
   /**
    * Test cases for {@link ChangeLogParser}
    * @author dion
  - * @version $Id: ChangeLogParserTest.java,v 1.1 2002/04/15 15:56:51 dion Exp $
  + * @version $Id: ChangeLogParserTest.java,v 1.2 2002/04/21 11:05:14 dion Exp $
    */
   public class ChangeLogParserTest extends TestCase {
       
  @@ -125,7 +125,7 @@
       public void testParse() throws Exception {
           FileInputStream fis = new FileInputStream(testFile);
           Collection entries = instance.parse(fis);
  -        assertEquals("Wrong number of entries returned", 2, entries.size());
  +        assertEquals("Wrong number of entries returned", 3, entries.size());
           ChangeLogEntry entry = null;
           int countPrevRevision = 0;
           int countRevOnly = 0;
  
  
  


Reply via email to