ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/cvslib ChangeLogTask.java
Date Thu, 11 Apr 2002 11:41:47 GMT
bodewig     02/04/11 04:41:46

  Modified:    src/main/org/apache/tools/ant/taskdefs/cvslib
                        ChangeLogTask.java
  Log:
  reset state in <cvschangelog>
  
  Revision  Changes    Path
  1.9       +74 -69    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java
  
  Index: ChangeLogTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ChangeLogTask.java	2 Apr 2002 09:17:30 -0000	1.8
  +++ ChangeLogTask.java	11 Apr 2002 11:41:46 -0000	1.9
  @@ -100,7 +100,8 @@
    *
    * @author <a href="mailto:jeff.martin@synamic.co.uk">Jeff Martin</a>
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.8 $ $Date: 2002/04/02 09:17:30 $
  + * @version $Revision: 1.9 $ $Date: 2002/04/11 11:41:46 $
  + * @since Ant 1.5
    * @ant.task name="changelog"
    */
   public class ChangeLogTask
  @@ -194,7 +195,8 @@
        */
       public void setDaysinpast( final int days )
       {
  -        final long time = System.currentTimeMillis() - (long)days * 24 * 60 * 60 * 1000;
  +        final long time = System.currentTimeMillis() 
  +            - (long)days * 24 * 60 * 60 * 1000;
           setStart( new Date( time ) );
       }
   
  @@ -213,82 +215,83 @@
        */
       public void execute() throws BuildException
       {
  -        validate();
  +        File savedDir = m_dir; // may be altered in validate
  +        try {
   
  -        final Properties userList = new Properties();
  +            validate();
   
  -        loadUserlist( userList );
  -
  -        for( Enumeration e = m_cvsUsers.elements(); e.hasMoreElements(); )
  -        {
  -            final CvsUser user = (CvsUser)e.nextElement();
  -            user.validate();
  -            userList.put( user.getUserID(), user.getDisplayname() );
  -        }
  -
  -        final Commandline command = new Commandline();
  -        command.setExecutable( "cvs" );
  -        command.createArgument().setValue( "log" );
  -
  -        if( null != m_start )
  -        {
  -            final SimpleDateFormat outputDate =
  -                new SimpleDateFormat( "yyyy-MM-dd" );
  +            final Properties userList = new Properties();
  +            
  +            loadUserlist( userList );
  +            
  +            for( Enumeration e = m_cvsUsers.elements(); 
  +                 e.hasMoreElements(); ) {
  +                final CvsUser user = (CvsUser)e.nextElement();
  +                user.validate();
  +                userList.put( user.getUserID(), user.getDisplayname() );
  +            }
  +            
  +            final Commandline command = new Commandline();
  +            command.setExecutable( "cvs" );
  +            command.createArgument().setValue( "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.createArgument().setValue( dateRange );
  +            }
   
  -            // We want something of the form: -d ">=YYYY-MM-dd"
  -            final String dateRange = "-d >=" + outputDate.format( m_start );
  -            command.createArgument().setValue( 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();
  +                    final DirectoryScanner scanner = 
  +                        fileSet.getDirectoryScanner( project );
  +                    final String[] files = scanner.getIncludedFiles();
  +                    for( int i = 0; i < files.length; i++ ) {
  +                        command.createArgument().setValue( files[ i ] );
  +                    }
  +                }
  +            }
   
  -        // 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();
  -                final DirectoryScanner scanner = fileSet.getDirectoryScanner( project );
  -                final String[] files = scanner.getIncludedFiles();
  -                for( int i = 0; i < files.length; i++ )
  -                {
  -                    command.createArgument().setValue( files[ i ] );
  +            final ChangeLogParser parser = new ChangeLogParser( userList );
  +            final RedirectingStreamHandler handler =
  +                new RedirectingStreamHandler( parser );
  +
  +            log( "ChangeLog command: [" + command.toString() + "]", 
  +                 Project.MSG_VERBOSE );
  +
  +            final Execute exe = new Execute( handler );
  +            exe.setWorkingDirectory( m_dir );
  +            exe.setCommandline( command.getCommandline() );
  +            exe.setAntRun( getProject() );
  +            try {
  +                final int resultCode = exe.execute();
  +                if( 0 != resultCode ) {
  +                    throw new BuildException( "Error running cvs log" );
                   }
  +            } catch( final IOException ioe ) {
  +                throw new BuildException( ioe.toString() );
               }
  -        }
   
  -        final ChangeLogParser parser = new ChangeLogParser( userList );
  -        final RedirectingStreamHandler handler =
  -            new RedirectingStreamHandler( parser );
  -
  -        log( "ChangeLog command: [" + command.toString() + "]", Project.MSG_VERBOSE );
  -
  -        final Execute exe = new Execute( handler );
  -        exe.setWorkingDirectory( m_dir );
  -        exe.setCommandline( command.getCommandline() );
  -        exe.setAntRun( getProject() );
  -        try
  -        {
  -            final int resultCode = exe.execute();
  -            if( 0 != resultCode )
  -            {
  -                throw new BuildException( "Error running cvs log" );
  +            final String errors = handler.getErrors();
  +            if( null != errors ) {
  +                log( errors, Project.MSG_ERR );
               }
  -        }
  -        catch( final IOException ioe )
  -        {
  -            throw new BuildException( ioe.toString() );
  -        }
   
  -        final String errors = handler.getErrors();
  -        if( null != errors )
  -        {
  -            log( errors, Project.MSG_ERR );
  -        }
  +            final CVSEntry[] entrySet = parser.getEntrySetAsArray();
  +            final CVSEntry[] filteredEntrySet = filterEntrySet( entrySet );
  +            writeChangeLog( filteredEntrySet );
   
  -        final CVSEntry[] entrySet = parser.getEntrySetAsArray();
  -        final CVSEntry[] filteredEntrySet = filterEntrySet( entrySet );
  -        writeChangeLog( filteredEntrySet );
  +        } finally {
  +            m_dir = savedDir;
  +        }
       }
   
       /**
  @@ -310,12 +313,14 @@
           }
           if( !m_dir.exists() )
           {
  -            final String message = "Cannot find base dir " + m_dir.getAbsolutePath();
  +            final String message = "Cannot find base dir " 
  +                + m_dir.getAbsolutePath();
               throw new BuildException( message );
           }
           if( null != m_usersFile && !m_usersFile.exists() )
           {
  -            final String message = "Cannot find user lookup list " + m_usersFile.getAbsolutePath();
  +            final String message = "Cannot find user lookup list " 
  +                + m_usersFile.getAbsolutePath();
               throw new BuildException( message );
           }
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message