Browse Source

Carry across changelog enhancements

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272105 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
18234144e7
3 changed files with 113 additions and 38 deletions
  1. +59
    -0
      proposal/myrmidon/src/java/org/apache/antlib/cvslib/ChangeLog.java
  2. +53
    -38
      proposal/myrmidon/src/java/org/apache/antlib/cvslib/ChangeLogParser.java
  3. +1
    -0
      proposal/myrmidon/src/java/org/apache/antlib/cvslib/Resources.properties

+ 59
- 0
proposal/myrmidon/src/java/org/apache/antlib/cvslib/ChangeLog.java View File

@@ -19,13 +19,16 @@ import java.util.Properties;
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.
@@ -85,6 +88,13 @@ public class ChangeLog
*/
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.
*/
@@ -139,6 +149,25 @@ public class ChangeLog
m_stop = stop;
}

/**
* 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
*/
@@ -161,6 +190,36 @@ public class ChangeLog
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();
exe.setWorkingDirectory( m_basedir );


+ 53
- 38
proposal/myrmidon/src/java/org/apache/antlib/cvslib/ChangeLogParser.java View File

@@ -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,6 +12,8 @@ import java.text.SimpleDateFormat;
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;

/**
@@ -23,6 +25,9 @@ import org.apache.aut.nativelib.ExecOutputHandler;
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;
@@ -69,6 +74,15 @@ class ChangeLogParser
return (CVSEntry[])m_entries.values().toArray( array );
}

/**
* Receive notification about the process writing
* to standard error.
*/
public void stderr( String line )
{
//ignore
}

/**
* Receive notification about the process writing
* to standard output.
@@ -83,7 +97,8 @@ class ChangeLogParser
case GET_REVISION:
processRevision( line );
//Was a fall through ....
//break;
break;

case GET_DATE:
processDate( line );
break;
@@ -106,7 +121,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 = "<![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 @@ class ChangeLogParser
*/
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
- 0
proposal/myrmidon/src/java/org/apache/antlib/cvslib/Resources.properties View File

@@ -5,6 +5,7 @@ changelog.missing-destfile.error=Destfile must be set.
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.


Loading…
Cancel
Save