Description:
Accepts cvs commands, one command per line, and executes them in order
after any
other commands. Example:
<cvs>
up -r 1.8 some/file
status some/other/file
; comment lines, too.
# and for Perl/shell fans... sorry, no // support
</cvs>
note that 'command' becomes optional and is, in fact, ignored when cdata
is set. i would like it NOT to be ignored, and will implement it that way
soon (if 'command' didn't have a default value then it would already work
that way, but i didn't want to muck with any default behaviours).
The patch is attached.
----- [EMAIL PROTECTED]
http://qub.sourceforge.net - http://radioaqtiph.sourceforge.net
http://www.countermoves.net - http://stephan.rootonfire.org
"Unix: the shell is your oyster."
Index: src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java,v
retrieving revision 1.2
diff -r1.2 AbstractCvsTask.java
103c103,104
< private String command = "checkout";
---
> private String default_command = "checkout";
> private String command = default_command;
148a150,159
> /**
> * Please don't ask. ([EMAIL PROTECTED])
> */
> private boolean horribleCDataProcessingKludge = false;
>
> /**
> * see addText()
> *
> */
> private String cdata = null;
224a236,282
> /**
> This reads in any data set via addText() and treats each line as one cvs command,
> executing it via execute(). It is horribly inefficient because it calls execute()
> for every line, causing a lot of unnecessary object crunching. The simple fact is
> that i'm not yet comfortable enough with the Ant APIs yet to try to deal with
> CommandLine, Execute, etc. in a loop inside execute() itself. It would be much more
> efficient to do so, though.
> */
> protected synchronized void processCData() throws BuildException {
> if( this.horribleCDataProcessingKludge ) {
> return;
> // this is cuz we keep re-running execute() from this function, which
> // is going to try to re-run this function. i chose to put this wimp-out measure
> // here rather than deal with it in execute(). i know the extra function
> // calls to processCData() are overhead, but this is more maintainable.
> // [EMAIL PROTECTED]
> }
> if( this.cdata == null || this.cdata.length() < 1 ) return;
> this.horribleCDataProcessingKludge = true;
> java.util.StringTokenizer st = new java.util.StringTokenizer( this.cdata, org.apache.tools.ant.util.StringUtils.LINE_SEP );
> String mycmd = null;
> try {
> while( st.hasMoreElements() )
> {
> mycmd = ((String)st.nextElement()).trim();
> if( mycmd.length() < 1 ) continue;
> if( mycmd.startsWith( ";" ) ) { continue; }
> if( mycmd.startsWith( "#" ) ) { continue; }
> log( "processCData() cvs command: ["+mycmd+"]", Project.MSG_DEBUG );
> this.setCommand( mycmd );
> this.execute();
> }
> }
> catch( BuildException e ) {
> this.horribleCDataProcessingKludge = false;
> throw( e );
> }
> catch( Exception e ) {
> this.horribleCDataProcessingKludge = false;
> throw new BuildException( e, location );
> }
> finally {
> this.horribleCDataProcessingKludge = false;
> }
> this.horribleCDataProcessingKludge = false; // just to be ABSOLUTELY certain.
> }
>
247c305
< toExecute.createArgument().setLine(command);
---
> toExecute.createArgument().setLine(command);
310a369
> String warning = "ACHTUNG, BABY: proceeding only by the grace of failonerror='false': ";
312,314c371,382
< log("Executing: " + executeToString(exe), Project.MSG_DEBUG);
<
< int retCode = exe.execute();
---
> String actualCommandLine = this.executeToString(exe);
> log("Executing: " + actualCommandLine, Project.MSG_DEBUG);
> int retCode = 0;
> if( this.command == null && cdata == null ) {
> throw new BuildException( "No command and no command list set!", location );
> }
> if( this.command != null ) {
> retCode = exe.execute();
> }
> if( retCode == 0 && this.cdata != null ) {
> this.processCData();
> }
317c385,388
< throw new BuildException("cvs exited with error code "+ retCode);
---
> throw new BuildException("cvs exited with error code "+ retCode +
> org.apache.tools.ant.util.StringUtils.LINE_SEP+
> "Command line was ["+actualCommandLine+"]",
> location );
321c392,413
< throw new BuildException(e, location);
---
> if( failOnError ) {
> throw new BuildException(e, location);
> }
> else {
> log( warning+e.getMessage(), Project.MSG_INFO);
> }
> }
> catch (BuildException e) {
> if( failOnError ) {
> throw( e );
> }
> else {
> log( warning+e.getMessage(), Project.MSG_INFO);
> }
> }
> catch (Exception e) {
> if( failOnError ) {
> throw new BuildException(e, location);
> }
> else {
> log( warning+e.getMessage(), Project.MSG_INFO);
> }
323c415
< finally {
---
> finally {
333d424
<
352,357d442
< stringBuffer.append(newLine);
< stringBuffer.append(newLine);
< stringBuffer.append("environment:");
< stringBuffer.append(newLine);
<
<
360a446,449
> stringBuffer.append(newLine);
> stringBuffer.append(newLine);
> stringBuffer.append("environment:");
> stringBuffer.append(newLine);
362d450
<
492,493d579
< }
<
494a581,598
> /**
> * Accepts cvs commands, one command per line, and executes them in order after any
> * other commands. Example:
> * <code>
> * <cvs>
> * up -r 1.8 some/file
> * status some/other/file
> * ; comment lines, too.
> * # and for Perl fans...
> *</cvs>
> * </code>
> */
> public void addText( String text ) {
> this.cdata = text;
> if( text == null ) return;
> this.setCommand( null ); // this is a very lame workaround. Ask me someday. ([EMAIL PROTECTED])
> }
> }
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>