Hi,

this is a repost of Wolfgang Werner's <[EMAIL PROTECTED]> patch
from mid April (thanks Vitaly). It has been edited to minimize the
number of changed lines and to reflect a change that has been commited
since then.

This patch adds quiet and noexec attributes (for the -q and -n
switches) and a command attribute that specifies which CVS command to
execute.

The default command is "checkout" to remain compatible to the existing
task.

cvsroot and package are no longer required attributes as most CVS
commands can and will retrieve the values from the CVS/ dirs in the
destination directory.

One thing I'm still missing here is the MatchingTask functionality to
specify only a set of files to commit/tag etc. I just wanted to wait
whether Exec (Cvs's parent class) becomes a MatchingTask - which would
add the funcionality almost automatically.

Stefan

Index: docs/index.html
===================================================================
RCS file: /home/cvspublic/jakarta-ant/docs/index.html,v
retrieving revision 1.21
diff -u -r1.21 index.html
--- docs/index.html	2000/06/01 06:54:52	1.21
+++ docs/index.html	2000/06/02 15:14:32
@@ -713,10 +723,10 @@
 <hr>
 <h2><a name="cvs">Cvs</a></h2>
 <h3>Description</h3>
-<p>Checks out a package/module from a <a href="http://www.cyclic.com/";>CVS</a>
-repository.</p>
+<p>Handles packages/modules retrieved from a 
+<a href="http://www.cyclic.com/";>CVS</a> repository.</p>
 <p>When doing automated builds, the <a href="#get">get task</a> should be
-preferred, because of speed.</p>
+preferred over the <i>checkout</i> command, because of speed.</p>
 <h3>Parameters</h3>
 <table border="1" cellpadding="2" cellspacing="0">
   <tr>
@@ -725,9 +735,14 @@
     <td align="center" valign="top"><b>Required</b></td>
   </tr>
   <tr>
+    <td valign="top">command</td>
+    <td valign="top">the CVS command to execute.</td>
+    <td align="center" valign="top">No, default &quot;checkout&quot;</td>
+  </tr>
+  <tr>
     <td valign="top">cvsRoot</td>
     <td valign="top">the CVSROOT variable.</td>
-    <td align="center" valign="top">Yes</td>
+    <td align="center" valign="top">No</td>
   </tr>
   <tr>
     <td valign="top">dest</td>
@@ -737,13 +752,23 @@
   <tr>
     <td valign="top">package</td>
     <td valign="top">the package/module to check out.</td>
-    <td align="center" valign="top">Yes</td>
+    <td align="center" valign="top">No</td>
   </tr>
   <tr>
     <td valign="top">tag</td>
     <td valign="top">the tag of the package/module to check out.</td>
     <td align="center" valign="top">No</td>
   </tr>
+  <tr>
+    <td valign="top">quiet</td>
+    <td valign="top">supress informational messages.</td>
+    <td align="center" valign="top">No, default &quot;false&quot;</td>
+  </tr>
+  <tr>
+    <td valign="top">noexec</td>
+    <td valign="top">report only, don't change any files.</td>
+    <td align="center" valign="top">No, default &quot;false&quot;</td>
+  </tr>
 </table>
 <h3>Examples</h3>
 <pre>  &lt;cvs cvsRoot=&quot;:pserver:[EMAIL PROTECTED]:/home/cvspublic&quot;
@@ -752,6 +777,9 @@
   /&gt;</pre>
 <p>checks out the package/module &quot;jakarta-tools&quot; from the CVS
 repository pointed to by the cvsRoot attribute, and stores the files in &quot;${ws.dir}&quot;.</p>
+<pre>  &lt;cvs dest=&quot;${ws.dir}&quot; command=&quot;update&quot; /&gt;</pre>
+<p>updates the package/module that has previously been checked out into
+&quot;${ws.dir}&quot;.</p>
 <hr>
 <h2><a name="delete">Delete</a></h2>
 <h3>Description</h3>
Index: src/main/org/apache/tools/ant/taskdefs/Cvs.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Cvs.java,v
retrieving revision 1.4
diff -u -r1.4 Cvs.java
--- src/main/org/apache/tools/ant/taskdefs/Cvs.java	2000/05/24 06:45:05	1.4
+++ src/main/org/apache/tools/ant/taskdefs/Cvs.java	2000/06/02 15:14:33
@@ -69,6 +69,9 @@
     private String cvsRoot;
     private String pack;
     private String tag;
+    private String command = "checkout";
+    private boolean quiet = false;
+    private boolean noexec = false;
     
     public void execute() throws BuildException {
 
@@ -76,16 +79,32 @@
 	// execution so that we don't rely on having native CVS stuff around (SM)
 	
 	StringBuffer sb=new StringBuffer();
-	sb.append(" cvs -d ").append( cvsRoot ).append(" checkout ");
+	sb.append(" cvs -d ");
+        if (cvsRoot != null) { 
+            sb.append(cvsRoot).append(" ");
+        }
+
+        sb.append(noexec ? "-n " : "")
+            .append(quiet  ? "-q " : "")
+            .append(command).append(" ");
+		
 	if (tag!=null)
             sb.append("-r ").append(tag).append(" ");
 
-	sb.append( pack );
+	if (pack != null) {
+            sb.append(pack);
+	}
 
         run(sb.toString());
     }
 
     public void setCvsRoot(String root) {
+        // Check if not real cvsroot => set it to null 
+        if (root != null) { 
+            if (root.trim().equals("")) 
+                root = null; 
+        } 
+
 	this.cvsRoot = root;
     }
 
@@ -107,6 +126,17 @@
         this.tag = p; 
     } 
 
+    public void setCommand(String c) {
+	this.command = c;
+    }
+    
+    public void setQuiet(String q) {
+        quiet = Project.toBoolean(q);
+    }
+    
+    public void setNoexec(String ne) {
+        noexec = Project.toBoolean(ne);
+    }
 }
 
 

Reply via email to