From 3d3b941aa7dd1e582d95c63df93ecd61423fa41d Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sat, 30 Mar 2002 03:10:20 +0000 Subject: [PATCH] Fix bug where a log of a single file without other logs in between would only retrieve first change git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272104 13f79535-47bb-0310-9956-ffa450edef68 --- .../ant/taskdefs/cvslib/ChangeLogParser.java | 68 +++++++++++-------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java b/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java index 6c6b2a3b0..d3dcc699c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java +++ b/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java @@ -127,7 +127,8 @@ class ChangeLogParser case GET_REVISION: processRevision( line ); //Was a fall through .... - //break; + break; + case GET_DATE: processDate( line ); break; @@ -150,7 +151,17 @@ class ChangeLogParser private void processComment( final String line ) { final String lineSeparator = System.getProperty( "line.separator" ); - if( line.startsWith( "======" ) || line.startsWith( "------" ) ) + if( line.startsWith( "======" ) ) + { + //We have ended changelog for that particular file + //so we can save it + final int end = m_comment.length() - lineSeparator.length(); //was -1 + m_comment = m_comment.substring( 0, end ); + m_comment = ""; + saveEntry(); + m_status = GET_FILE; + } + else if( line.startsWith( "------" ) ) { final int end = m_comment.length() - lineSeparator.length(); //was -1 m_comment = m_comment.substring( 0, end ); @@ -224,39 +235,36 @@ class ChangeLogParser */ private void processGetPreviousRevision( final String line ) { - final String entryKey = m_date + m_author + m_comment; - if( line.startsWith( "revision" ) ) + if( !line.startsWith( "revision" ) ) { - m_previousRevision = line.substring( 9 ); - m_status = GET_FILE; + throw new IllegalStateException( "Unexpected line from CVS: " + line ); + } + m_previousRevision = line.substring( 9 ); - CVSEntry entry; - if( !m_entries.containsKey( entryKey ) ) - { - entry = new CVSEntry( parseDate( m_date ), m_author, m_comment ); - m_entries.put( entryKey, entry ); - } - else - { - entry = (CVSEntry)m_entries.get( entryKey ); - } - entry.addFile( m_file, m_revision, m_previousRevision ); + saveEntry(); + + m_revision = m_previousRevision; + m_status = GET_COMMENT; + } + + /** + * Utility method that saves the current entry. + */ + private void saveEntry() + { + final String entryKey = m_date + m_author + m_comment; + CVSEntry entry; + if( !m_entries.containsKey( entryKey ) ) + { + entry = new CVSEntry( parseDate( m_date ), m_author, m_comment ); + m_entries.put( entryKey, entry ); } - else if( line.startsWith( "======" ) ) + else { - m_status = GET_FILE; - CVSEntry entry; - if( !m_entries.containsKey( entryKey ) ) - { - entry = new CVSEntry( parseDate( m_date ), m_author, m_comment ); - m_entries.put( entryKey, entry ); - } - else - { - entry = (CVSEntry)m_entries.get( entryKey ); - } - entry.addFile( m_file, m_revision ); + entry = (CVSEntry)m_entries.get( entryKey ); } + + entry.addFile( m_file, m_revision, m_previousRevision ); } /**