donaldp     02/03/29 19:21:52

  Modified:    proposal/myrmidon/src/java/org/apache/antlib/cvslib
                        Resources.properties ChangeLogParser.java
                        ChangeLog.java
  Log:
  Carry across changelog enhancements
  
  Revision  Changes    Path
  1.4       +1 -0      
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/cvslib/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/cvslib/Resources.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Resources.properties      24 Mar 2002 02:04:22 -0000      1.3
  +++ Resources.properties      30 Mar 2002 03:21:52 -0000      1.4
  @@ -5,6 +5,7 @@
   changelog.bad-basedir.error=Cannot find base dir {0}
   changelog.bad-userlist.error=Cannot find user lookup list {0}.
   changelog.bat-date.error=I don't understand this date -> {0}
  +changelog.unexpected.line=Unexpected line from CVS: {0}
   
   cvspass.nopassword.error=Password is required.
   cvspass.noroot.error=Cvsroot is required.
  
  
  
  1.2       +54 -39    
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/cvslib/ChangeLogParser.java
  
  Index: ChangeLogParser.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/cvslib/ChangeLogParser.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChangeLogParser.java      24 Mar 2002 02:24:00 -0000      1.1
  +++ ChangeLogParser.java      30 Mar 2002 03:21:52 -0000      1.2
  @@ -2,7 +2,7 @@
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
    * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included  with this distribution in
  + * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE.txt file.
    */
   package org.apache.antlib.cvslib;
  @@ -12,17 +12,22 @@
   import java.util.Date;
   import java.util.Hashtable;
   import java.util.Properties;
  +import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.aut.nativelib.ExecOutputHandler;
   
   /**
    * A class used to parse the output of the CVS log command.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2002/03/24 02:24:00 $
  + * @version $Revision: 1.2 $ $Date: 2002/03/30 03:21:52 $
    */
   class ChangeLogParser
       implements ExecOutputHandler
   {
  +    private final static Resources REZ =
  +        ResourceManager.getPackageResources( ChangeLogParser.class );
  +
       //private static final int GET_ENTRY = 0;
       private static final int GET_FILE = 1;
       private static final int GET_DATE = 2;
  @@ -71,6 +76,15 @@
   
       /**
        * Receive notification about the process writing
  +     * to standard error.
  +     */
  +    public void stderr( String line )
  +    {
  +        //ignore
  +    }
  +
  +    /**
  +     * Receive notification about the process writing
        * to standard output.
        */
       public void stdout( final String line )
  @@ -83,7 +97,8 @@
               case GET_REVISION:
                   processRevision( line );
                   //Was a fall through ....
  -                //break;
  +                break;
  +
               case GET_DATE:
                   processDate( line );
                   break;
  @@ -106,7 +121,17 @@
       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 = "<![CDATA[" + 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 );
  @@ -180,48 +205,38 @@
        */
       private void processGetPreviousRevision( final String line )
       {
  -        final String entryKey = m_date + m_author + m_comment;
  -        if( line.startsWith( "revision" ) )
  -        {
  -            m_previousRevision = line.substring( 9 );
  -            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, m_previousRevision );
  -        }
  -        else if( line.startsWith( "======" ) )
  +        if( !line.startsWith( "revision" ) )
           {
  -            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 );
  +            final String message =
  +                REZ.getString( "changelog.unexpected.line", line );
  +            throw new IllegalStateException( message );
           }
  +        m_previousRevision = line.substring( 9 );
  +
  +        saveEntry();
  +
  +        m_revision = m_previousRevision;
  +        m_status = GET_COMMENT;
       }
   
       /**
  -     * Receive notification about the process writing
  -     * to standard error.
  +     * Utility method that saves the current entry.
        */
  -    public void stderr( String line )
  +    private void saveEntry()
       {
  -        //ignored
  +        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
  +        {
  +            entry = (CVSEntry)m_entries.get( entryKey );
  +        }
  +
  +        entry.addFile( m_file, m_revision, m_previousRevision );
       }
   
       /**
  
  
  
  1.5       +60 -1     
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/cvslib/ChangeLog.java
  
  Index: ChangeLog.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/cvslib/ChangeLog.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ChangeLog.java    29 Mar 2002 12:57:21 -0000      1.4
  +++ ChangeLog.java    30 Mar 2002 03:21:52 -0000      1.5
  @@ -19,13 +19,16 @@
   import java.util.Vector;
   import java.util.ArrayList;
   import java.util.Date;
  +import java.text.SimpleDateFormat;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.excalibur.io.IOUtil;
   import org.apache.myrmidon.api.AbstractTask;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.framework.Execute;
  +import org.apache.myrmidon.framework.FileSet;
   import org.apache.tools.todo.types.Commandline;
  +import org.apache.tools.todo.types.DirectoryScanner;
   
   /**
    * Change log task.
  @@ -54,7 +57,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jeff Martin</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
  - * @version $Revision: 1.4 $ $Date: 2002/03/29 12:57:21 $
  + * @version $Revision: 1.5 $ $Date: 2002/03/30 03:21:52 $
    * @ant.task name="changelog"
    */
   public class ChangeLog
  @@ -86,6 +89,13 @@
       private Date m_stop;
   
       /**
  +     * Filesets containting list of files against which the cvs log will be
  +     * performed. If empty then all files will in the working directory will
  +     * be checked.
  +     */
  +    private final Vector m_filesets = new Vector();
  +
  +    /**
        * Set the base dir for cvs.
        */
       public void setBasedir( final File basedir )
  @@ -140,6 +150,25 @@
       }
   
       /**
  +     * Set the numbers of days worth of log entries to process.
  +     */
  +    public void setDaysinpast( final int days )
  +    {
  +        final long time = System.currentTimeMillis() - (long)days * 24 * 60 
* 60 * 1000;
  +        setStart( new Date( time ) );
  +    }
  +
  +    /**
  +     * 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 )
  +    {
  +        m_filesets.addElement( fileSet );
  +    }
  +
  +    /**
        * Execute task
        */
       public void execute() throws TaskException
  @@ -160,6 +189,36 @@
           final Commandline command = new Commandline();
           command.setExecutable( "cvs" );
           command.addArgument( "log" );
  +
  +        if( null != m_start )
  +        {
  +            final SimpleDateFormat outputDate =
  +                new SimpleDateFormat( "yyyy-MM-dd" );
  +
  +            // We want something of the form: -d ">=YYYY-MM-dd"
  +            final String dateRange = "-d >=" + outputDate.format( m_start );
  +            command.addArgument( dateRange );
  +        }
  +
  +        // Check if list of files to check has been specified
  +        /*
  +        if( !m_filesets.isEmpty() )
  +        {
  +            final Enumeration e = m_filesets.elements();
  +            while( e.hasMoreElements() )
  +            {
  +                final FileSet fileSet = (FileSet)e.nextElement();
  +                //FIXME: DOES NOT WORK
  +                final DirectoryScanner scanner = new DirectoryScanner();
  +                //fileSet.getDirectoryScanner( null );
  +                final String[] files = scanner.getIncludedFiles();
  +                for( int i = 0; i < files.length; i++ )
  +                {
  +                    command.addArgument( files[ i ] );
  +                }
  +            }
  +        }
  +        */
   
           final ChangeLogParser parser = new ChangeLogParser( userList );
           final Execute exe = new Execute();
  
  
  

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

Reply via email to