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 AbstractCvsTask.java Cvs.java
Date Thu, 11 Apr 2002 09:52:48 GMT
bodewig     02/04/11 02:52:48

  Modified:    docs/manual/CoreTasks cvs.html
               src/main/org/apache/tools/ant/taskdefs AbstractCvsTask.java
                        Cvs.java
  Log:
  bug 7552 audit of <cvs> - ensure command gets reset.
  
  You cannot have an attribute that accepts a boolean or an integer, at
  least not the way it has been done - split into two attributes.
  
  Revision  Changes    Path
  1.12      +10 -2     jakarta-ant/docs/manual/CoreTasks/cvs.html
  
  Index: cvs.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/cvs.html,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- cvs.html	4 Apr 2002 10:34:22 -0000	1.11
  +++ cvs.html	11 Apr 2002 09:52:48 -0000	1.12
  @@ -27,8 +27,16 @@
     </tr>
     <tr>
       <td valign="top">commpression</td>
  -    <td valign="top"><code>true</code>, <code>false</code>,
or the number 1-9 (corresponding to possible values for CVS&apos; <code>-z#</code>
argument). Any other value is treated as false</td>
  -    <td align="center" valign="top">No. Defaults to no compression. if passed <code>true</code>,
level 3 compression is assumed.</td>
  +    <td valign="top"><code>true</code> or <code>false</code>
- if set
  +    to true, this is the same as copmressionlevel=&quot;3&quot;</td>
  +    <td align="center" valign="top">No. Defaults to false.</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">commpressionlevel</td>
  +    <td valign="top">A number between 1 and 9 (corresponding to
  +    possible values for CVS&apos; <code>-z#</code> argument). Any
  +    other value is treated as compression=&qupt;false&quot;</td>
  +    <td align="center" valign="top">No. Defaults to no compression.</td>
     </tr>
   
     <tr>
  
  
  
  1.7       +56 -29    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java
  
  Index: AbstractCvsTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractCvsTask.java	4 Apr 2002 10:20:19 -0000	1.6
  +++ AbstractCvsTask.java	11 Apr 2002 09:52:48 -0000	1.7
  @@ -71,18 +71,24 @@
   /**
    * original Cvs.java 1.20
    *
  - *  NOTE: This implementation has been moved here from Cvs.java with the addition of
  - *          some accessors for extensibility.  Another task can extend this with
  - *          some customized output processing.
  + *  NOTE: This implementation has been moved here from Cvs.java with
  + *  the addition of some accessors for extensibility.  Another task
  + *  can extend this with some customized output processing.
    *
    * @author costin@dnt.ro
    * @author stefano@apache.org
    * @author Wolfgang Werner <a href="mailto:wwerner@picturesafe.de">wwerner@picturesafe.de</a>
    * @author Kevin Ross <a href="mailto:kevin.ross@bredex.com">kevin.ross@bredex.com</a>
  + *
  + * @since Ant 1.5
    */
   public abstract class AbstractCvsTask extends Task {
  -    /** Default compression level to use, if compression is enabled via setCompression(
true ). */
  +    /** 
  +     * Default compression level to use, if compression is enabled via
  +     * setCompression( true ). 
  +     */
       public static final int DEFAULT_COMPRESSION_LEVEL = 3;
  +
       private Commandline cmd = new Commandline();
   
       /** list of Commandline children */
  @@ -175,7 +181,6 @@
       }
   
       public void setExecuteStreamHandler(ExecuteStreamHandler executeStreamHandler){
  -
           this.executeStreamHandler = executeStreamHandler;
       }
   
  @@ -183,7 +188,8 @@
   
           if(this.executeStreamHandler == null){
   
  -            setExecuteStreamHandler(new PumpStreamHandler(getOutputStream(), getErrorStream()));
  +            setExecuteStreamHandler(new PumpStreamHandler(getOutputStream(), 
  +                                                          getErrorStream()));
           }
   
           return this.executeStreamHandler;
  @@ -201,13 +207,15 @@
   
               if (output != null) {
                   try {
  -                    setOutputStream(new PrintStream(new BufferedOutputStream(new FileOutputStream(output.getPath(),
append))));
  -                }
  -                catch (IOException e) {
  +                    setOutputStream(new PrintStream(
  +                                        new BufferedOutputStream(
  +                                            new FileOutputStream(output
  +                                                                 .getPath(), 
  +                                                                 append))));
  +                } catch (IOException e) {
                       throw new BuildException(e, location);
                   }
  -            }
  -            else {
  +            } else {
                   setOutputStream(new LogOutputStream(this, Project.MSG_INFO));
               }
           }
  @@ -227,13 +235,14 @@
               if (error != null) {
   
                   try {
  -                    setErrorStream(new PrintStream(new BufferedOutputStream(new FileOutputStream(error.getPath(),
append))));
  -                }
  -                catch (IOException e) {
  +                    setErrorStream(new PrintStream(
  +                                       new BufferedOutputStream(
  +                                           new FileOutputStream(error.getPath(),
  +                                                                append))));
  +                } catch (IOException e) {
                       throw new BuildException(e, location);
                   }
  -            }
  -            else {
  +            } else {
                   setErrorStream(new LogOutputStream(this, Project.MSG_WARN));
               }
           }
  @@ -246,8 +255,9 @@
        * @throws BuildException
        */
       protected void runCommand( Commandline toExecute ) throws BuildException {
  -        // XXX: we should use JCVS (www.ice.com/JCVS) instead of command line
  -        // execution so that we don't rely on having native CVS stuff around (SM)
  +        // XXX: we should use JCVS (www.ice.com/JCVS) instead of
  +        // command line execution so that we don't rely on having
  +        // native CVS stuff around (SM)
   
           // We can't do it ourselves as jCVS is GPLed, a third party task
           // outside of jakarta repositories would be possible though (SB).
  @@ -262,9 +272,11 @@
           }
   
           /**
  -         * Need a better cross platform integration with <cvspass>, so use the same
filename.
  +         * Need a better cross platform integration with <cvspass>, so
  +         * use the same filename.
            */
  -        /* But currently we cannot because 'cvs log' is not working with a pass file.
  +        /* But currently we cannot because 'cvs log' is not working
  +         * with a pass file.
           if(passFile == null){
   
               File defaultPassFile = new File(System.getProperty("user.home") + File.separatorChar
+ ".cvspass");
  @@ -279,7 +291,8 @@
               var.setKey("CVS_PASSFILE");
               var.setValue(String.valueOf(passFile));
               env.addVariable(var);
  -            log("Using cvs passfile: " + String.valueOf(passFile), Project.MSG_INFO);
  +            log("Using cvs passfile: " + String.valueOf(passFile), 
  +                Project.MSG_INFO);
           }
   
           if (cvsRsh!=null) {
  @@ -289,7 +302,6 @@
               env.addVariable(var);
           }
   
  -
           //
           // Just call the getExecuteStreamHandler() and let it handle
           //     the semantics of instantiation or retrieval.
  @@ -368,6 +380,7 @@
   
       public void execute() throws BuildException {
   
  +        String savedCommand = getCommand();
   
           if( this.getCommand() == null
               && vecCommandlines.size() == 0 ) {
  @@ -376,13 +389,22 @@
           }
   
           String c = this.getCommand();
  +        Commandline cloned = null;
           if( c != null ) {
  -            this.cmd.createArgument(true).setLine(c);
  -            this.addConfiguredCommandline( this.cmd, true );
  +            cloned = (Commandline) cmd.clone();
  +            cloned.createArgument(true).setLine(c);
  +            this.addConfiguredCommandline(cloned, true);
           }
   
  -        for( int i = 0; i < vecCommandlines.size(); i++ ) {
  -            this.runCommand( (Commandline)vecCommandlines.elementAt( i ) );
  +        try {
  +            for( int i = 0; i < vecCommandlines.size(); i++ ) {
  +                this.runCommand( (Commandline)vecCommandlines.elementAt( i ) );
  +            }
  +        } finally {
  +            if (cloned != null) {
  +                removeCommandline(cloned);
  +            }
  +            setCommand(savedCommand);
           }
       }
   
  @@ -567,6 +589,10 @@
           }
       }
   
  +    protected void removeCommandline(Commandline c) {
  +        vecCommandlines.removeElement( c );
  +    }
  +
       public void addConfiguredCommandline( Commandline c ) {
           this.addConfiguredCommandline( c, false );
       }
  @@ -575,7 +601,8 @@
       * Configures and adds the given Commandline.
       * @param insertAtStart If true, c is
       */
  -    public void addConfiguredCommandline( Commandline c, boolean insertAtStart ) {
  +    public void addConfiguredCommandline( Commandline c, 
  +                                          boolean insertAtStart ) {
           if( c == null ) { return; }
           this.configureCommandline( c );
           if( insertAtStart ) {
  @@ -590,7 +617,7 @@
       * If set to a value 1-9 it adds -zN to the cvs command line, else
       * it disables compression.
       */
  -    public void setCompression( int level ) {
  +    public void setCompressionLevel( int level ) {
           this.compression = level;
       }
   
  @@ -599,7 +626,7 @@
        * level, AbstractCvsTask.DEFAULT_COMPRESSION_LEVEL.
        */
       public void setCompression( boolean usecomp ) {
  -        this.setCompression( usecomp ? 
  +        setCompressionLevel( usecomp ? 
                                AbstractCvsTask.DEFAULT_COMPRESSION_LEVEL : 0 );
       }
   
  
  
  
  1.25      +6 -6      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Cvs.java
  
  Index: Cvs.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Cvs.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Cvs.java	3 Mar 2002 01:46:20 -0000	1.24
  +++ Cvs.java	11 Apr 2002 09:52:48 -0000	1.25
  @@ -53,11 +53,12 @@
    */
   
   package org.apache.tools.ant.taskdefs;
  +
   /**
    * original 1.20
    *
  - *  NOTE: This implementation has been moved to AbstractCvsTask with the addition of
  - *           some accessors for extensibility.
  + *  NOTE: This implementation has been moved to AbstractCvsTask with
  + *  the addition of some accessors for extensibility.
    *
    *
    * @author costin@dnt.ro
  @@ -65,14 +66,13 @@
    * @author Wolfgang Werner <a href="mailto:wwerner@picturesafe.de">wwerner@picturesafe.de</a>
    * @author Kevin Ross <a href="mailto:kevin.ross@bredex.com">kevin.ross@bredex.com</a>
    *
  + * @since Ant 1.1
  + * 
    * @ant.task category="scm"
    */
   public class Cvs extends AbstractCvsTask {
   
  -    public Cvs(){
  -
  +    public Cvs() {
           setTaskName("cvs");
       }
   }
  -
  -
  
  
  

--
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