antoine 2004/01/28 14:47:14 Modified: src/main/org/apache/tools/ant/taskdefs/cvslib ChangeLogTask.java docs/manual/CoreTasks changelog.html src/main/org/apache/tools/ant/taskdefs AbstractCvsTask.java defaults.properties docs/manual coretasklist.html . WHATSNEW Added: src/main/org/apache/tools/ant/taskdefs/cvslib CvsVersion.java docs/manual/CoreTasks cvsversion.html Log: Add a new cvsversion task Modify CvsChangeLog to accept a branch as the tag attribute ChangeLogTask.java now inherits from AbstractCvsTask PR: 13510 Revision Changes Path 1.26 +26 -28 ant/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java Index: ChangeLogTask.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- ChangeLogTask.java 17 Sep 2003 20:11:43 -0000 1.25 +++ ChangeLogTask.java 28 Jan 2004 22:47:13 -0000 1.26 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002-2003 The Apache Software Foundation. All rights + * Copyright (c) 2002-2004 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,8 +68,8 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.taskdefs.AbstractCvsTask; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.FileSet; @@ -102,9 +102,9 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a> * @version $Revision$ $Date$ * @since Ant 1.5 - * @ant.task name="cvschangelog" + * @ant.task name="cvschangelog" category="scm" */ -public class ChangeLogTask extends Task { +public class ChangeLogTask extends AbstractCvsTask { /** User list */ private File m_usersFile; @@ -226,7 +226,6 @@ try { validate(); - final Properties userList = new Properties(); loadUserlist(userList); @@ -239,11 +238,22 @@ userList.put(user.getUserID(), user.getDisplayname()); } - final Commandline command = new Commandline(); - command.setExecutable("cvs"); - command.createArgument().setValue("log"); + setCommand("log"); + if (getTag() != null) { + CvsVersion myCvsVersion = new CvsVersion(); + myCvsVersion.setProject(getProject()); + myCvsVersion.setTaskName("cvsversion"); + myCvsVersion.setCvsRoot(getCvsRoot()); + myCvsVersion.setCvsRsh(getCvsRsh()); + myCvsVersion.setPassfile(getPassFile()); + myCvsVersion.setDest(m_dir); + myCvsVersion.execute(); + if (myCvsVersion.supportsCvsLogWithSOption()) { + addCommandArgument("-S"); + } + } if (null != m_start) { final SimpleDateFormat outputDate = new SimpleDateFormat("yyyy-MM-dd"); @@ -252,8 +262,8 @@ final String dateRange = ">=" + outputDate.format(m_start); // Supply '-d' as a separate argument - Bug# 14397 - command.createArgument().setValue("-d"); - command.createArgument().setValue(dateRange); + addCommandArgument("-d"); + addCommandArgument(dateRange); } // Check if list of files to check has been specified @@ -267,7 +277,7 @@ final String[] files = scanner.getIncludedFiles(); for (int i = 0; i < files.length; i++) { - command.createArgument().setValue(files[i]); + addCommandArgument(files[i]); } } } @@ -276,23 +286,11 @@ final RedirectingStreamHandler handler = new RedirectingStreamHandler(parser); - log(command.describeCommand(), 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 (Execute.isFailure(resultCode)) { - throw new BuildException("Error running cvs log"); - } - } catch (final IOException ioe) { - throw new BuildException(ioe.toString()); - } + log(getCommand(), Project.MSG_VERBOSE); + setDest(m_dir); + setExecuteStreamHandler(handler); + super.execute(); final String errors = handler.getErrors(); if (null != errors) { 1.1 ant/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java Index: CvsVersion.java =================================================================== /* * The Apache Software License, Version 1.1 * * Copyright (c) 2004 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "Ant" and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.tools.ant.taskdefs.cvslib; import org.apache.tools.ant.taskdefs.AbstractCvsTask; import java.io.ByteArrayOutputStream; import java.util.StringTokenizer; /** * this task allows to find out the client and the server version of a * CVS installation * * example usage : * <cvsversion * cvsRoot=":pserver:[EMAIL PROTECTED]:/home/cvspublic" * passfile="c:/programme/cygwin/home/antoine/.cvspass" * clientversionproperty="apacheclient" * serverversionproperty="apacheserver" /> * * the task can be used also in the API by calling its execute method, * then calling getServerVersion and/or getClientVersion * * @ant.task category="scm" * @author Antoine Levy-Lambert */ public class CvsVersion extends AbstractCvsTask { static final long VERSION_1_11_2 = 11102; static final long MULTIPLY = 100; private String clientVersion; private String serverVersion; private String clientVersionProperty; private String serverVersionProperty; /** * get the CVS client version * @return CVS client version */ public String getClientVersion() { return clientVersion; } /** * get the CVS server version * @return CVS server version */ public String getServerVersion() { return serverVersion; } /** * set a property where to store the CVS client version * @param clientVersionProperty property for CVS client version */ public void setClientVersionProperty(String clientVersionProperty) { this.clientVersionProperty = clientVersionProperty; } /** * set a property where to store the CVS server version * @param serverVersionProperty property for CVS server version */ public void setServerVersionProperty(String serverVersionProperty) { this.serverVersionProperty = serverVersionProperty; } /** * find out if the server version supports log with S option * @return boolean indicating if the server version supports log with S option */ public boolean supportsCvsLogWithSOption() { if (serverVersion == null) { return false; } StringTokenizer mySt = new StringTokenizer(serverVersion, "."); long versionNumber; long counter = MULTIPLY * MULTIPLY; long version = 0; while (mySt.hasMoreTokens()) { String s = mySt.nextToken(); int i = 0; for (i = 0; i < s.length(); i++) { if (!Character.isDigit(s.charAt(i))) { break; } } String s2 = s.substring(0, i); version = version + counter * Long.parseLong(s2); if (counter == 1) { break; } counter = counter / MULTIPLY; } return (version >= VERSION_1_11_2); } /** * the execute method running CvsVersion */ public void execute() { ByteArrayOutputStream bos = new ByteArrayOutputStream(); this.setOutputStream(bos); ByteArrayOutputStream berr = new ByteArrayOutputStream(); this.setErrorStream(berr); setCommand("version"); super.execute(); String output = bos.toString(); StringTokenizer st = new StringTokenizer(output); boolean client = false; boolean server = false; boolean cvs = false; while (st.hasMoreTokens()) { String currentToken = st.nextToken(); if (currentToken.equals("Client:")) { client = true; } else if (currentToken.equals("Server:")) { server = true; } else if (currentToken.equals("(CVS)")) { cvs = true; } if (client && cvs) { if (st.hasMoreTokens()) { clientVersion = st.nextToken(); } client = false; cvs = false; } else if (server && cvs) { if (st.hasMoreTokens()) { serverVersion = st.nextToken(); } server = false; cvs = false; } } if (clientVersionProperty != null) { getProject().setNewProperty(clientVersionProperty, clientVersion); } if (serverVersionProperty != null) { getProject().setNewProperty(serverVersionProperty, serverVersion); } } } 1.14 +49 -1 ant/docs/manual/CoreTasks/changelog.html Index: changelog.html =================================================================== RCS file: /home/cvs/ant/docs/manual/CoreTasks/changelog.html,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- changelog.html 22 Apr 2003 15:31:03 -0000 1.13 +++ changelog.html 28 Jan 2004 22:47:13 -0000 1.14 @@ -22,6 +22,49 @@ <td align="center" valign="top"><b>Required</b></td> </tr> <tr> + <td colspan="3">Attributes from parent Cvs task which are meaningful here<br/> + Since ant 1.6.1</td> + </tr> + <tr> + <td valign="top">cvsRoot</td> + <td valign="top">the <code>CVSROOT</code> variable.</td> + <td align="center" valign="top">No</td> + </tr> + <tr> + <td valign="top">cvsRsh</td> + <td valign="top">the <code>CVS_RSH</code> variable.</td> + <td align="center" valign="top">No</td> + </tr> + <tr> + <td valign="top">package</td> + <td valign="top">the package/module to check out.</td> + <td align="center" valign="top">No</td> + </tr> + <tr> + <td valign="top">port</td> + <td valign="top">Port used by CVS to communicate with the server.</td> + <td align="center" valign="top">No, default port 2401.</td> + </tr> + <tr> + <td valign="top">passfile</td> + <td valign="top">Password file to read passwords from.</td> + <td align="center" valign="top">No, default file ~/.cvspass.</td> + </tr> + <tr> + <td valign="top">failonerror</td> + <td valign="top">Stop the build process if the command exits with a + return code other than <code>0</code>. Defaults to false</td> + <td align="center" valign="top">No</td> + </tr> + <tr> + <td valign="top">tag</td> + <td valign="top">query the changelog for a specific branch.</td> + <td align="center" valign="top">No</td> + </tr> + <tr> + <td colspan="3">Specific attributes</td> + </tr> + <tr> <td valign="top">dir</td> <td valign="top">The directory from which to run the CVS <em>log</em> command.</td> @@ -138,6 +181,11 @@ anytime it encounters a change made by the user ID "donaldp". It writes these changes into the file <code>changelog.xml</code>.</p> +<p>Generates a change log report on the <code>ANT_16_BRANCH</code>.</p> +<pre> + <cvschangelog dir="c:/dev/asf/ant.head" passfile="c:/home/myself/.cvspass" + destfile="changelogant.xml" tag="ANT_16_BRANCH" /> +</pre> <h4>Generate Report</h4> <p>Ant includes a basic XSLT stylesheet that you can use to generate a HTML report based on the xml output. The following example illustrates @@ -172,7 +220,7 @@ </changelog> </pre> -<hr><p align="center">Copyright © 2002-2003 Apache Software Foundation. All rights +<hr><p align="center">Copyright © 2002-2004 Apache Software Foundation. All rights Reserved.</p> </body> 1.1 ant/docs/manual/CoreTasks/cvsversion.html Index: cvsversion.html =================================================================== <html> <head> <meta http-equiv="Content-Language" content="en-us"> <title>CVSVersion Task</title> <link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css"> </head> <body> <h2><a name="cvs">CvsVersion</a></h2> <h3>Description</h3> <p> This task allows to retrieve a CVS client and server version </p> <h3>Parameters</h3> <table border="1" cellpadding="2" cellspacing="0"> <tr> <td valign="top"><b>Attribute</b></td> <td valign="top"><b>Description</b></td> <td align="center" valign="top"><b>Required</b></td> </tr> <tr> <td colspan="3">Attributes from parent Cvs task which are meaningful here</td> </tr> <tr> <td valign="top">cvsRoot</td> <td valign="top">the <code>CVSROOT</code> variable.</td> <td align="center" valign="top">No</td> </tr> <tr> <td valign="top">cvsRsh</td> <td valign="top">the <code>CVS_RSH</code> variable.</td> <td align="center" valign="top">No</td> </tr> <tr> <td valign="top">dest</td> <td valign="top">directory containing the checked out version of the project</td> <td align="center" valign="top">No, default is project's basedir.</td> </tr> <tr> <td valign="top">package</td> <td valign="top">the package/module to check out.</td> <td align="center" valign="top">No</td> </tr> <tr> <td valign="top">port</td> <td valign="top">Port used by CVS to communicate with the server.</td> <td align="center" valign="top">No, default port 2401.</td> </tr> <tr> <td valign="top">passfile</td> <td valign="top">Password file to read passwords from.</td> <td align="center" valign="top">No, default file ~/.cvspass.</td> </tr> <tr> <td valign="top">failonerror</td> <td valign="top">Stop the build process if the command exits with a return code other than <code>0</code>. Defaults to false</td> <td align="center" valign="top">No</td> </tr> <tr> <td colspan="3">Specific attributes</td> </tr> <tr> <td valign="top">cvsclientproperty</td> <td valign="top">Name of a property where the cvsclient version should be stored</td> <td align="center" valign="top">No</td> </tr> <tr> <td valign="top">cvsserverproperty</td> <td valign="top">Name of a property where the cvs server version should be stored</td> <td align="center" valign="top">No</td> </tr> </table> <h3>Examples</h3> <pre> <cvsversion cvsRoot=":pserver:[EMAIL PROTECTED]:/home/cvspublic" passfile="/home/myself/.cvspass" cvsserverproperty="apachecvsversion" cvsclientproperty="localcvsversion" /></pre> <p>finds out the cvs client and server versions and stores the versions in the properties called apachecvsversion and localcvsversion</p> <hr> <p align="center">Copyright © 2004 Apache Software Foundation. All rights Reserved.</p> </body> </html> 1.28 +14 -4 ant/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java Index: AbstractCvsTask.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- AbstractCvsTask.java 22 Sep 2003 15:41:44 -0000 1.27 +++ AbstractCvsTask.java 28 Jan 2004 22:47:13 -0000 1.28 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002-2003 The Apache Software Foundation. All rights + * Copyright (c) 2002-2004 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -111,7 +111,10 @@ * the package/module to check out. */ private String cvsPackage; - + /** + * the tag + */ + private String tag; /** * the default command. */ @@ -609,6 +612,13 @@ return this.cvsPackage; } + /** + * tag or branch + * @return tag or branch + */ + public String getTag() { + return tag; + } /** * The tag of the package/module to operate upon. @@ -617,8 +627,8 @@ public void setTag(String p) { // Check if not real tag => set it to null if (p != null && p.trim().length() > 0) { - addCommandArgument("-r"); - addCommandArgument(p); + tag = p; + addCommandArgument("-r" + p); } } 1.156 +1 -0 ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties Index: defaults.properties =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties,v retrieving revision 1.155 retrieving revision 1.156 diff -u -r1.155 -r1.156 --- defaults.properties 21 Jan 2004 12:55:52 -0000 1.155 +++ defaults.properties 28 Jan 2004 22:47:13 -0000 1.156 @@ -66,6 +66,7 @@ basename=org.apache.tools.ant.taskdefs.Basename dirname=org.apache.tools.ant.taskdefs.Dirname cvschangelog=org.apache.tools.ant.taskdefs.cvslib.ChangeLogTask +cvsversion=org.apache.tools.ant.tasksdefs.cvslib.CvsVersion buildnumber=org.apache.tools.ant.taskdefs.BuildNumber concat=org.apache.tools.ant.taskdefs.Concat cvstagdiff=org.apache.tools.ant.taskdefs.cvslib.CvsTagDiff 1.52 +1 -0 ant/docs/manual/coretasklist.html Index: coretasklist.html =================================================================== RCS file: /home/cvs/ant/docs/manual/coretasklist.html,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- coretasklist.html 29 Sep 2003 14:28:04 -0000 1.51 +++ coretasklist.html 28 Jan 2004 22:47:14 -0000 1.52 @@ -34,6 +34,7 @@ <a href="CoreTasks/copyfile.html"><i>Copyfile</i></a><br> <a href="CoreTasks/cvs.html">Cvs</a><br> <a href="CoreTasks/changelog.html">CvsChangeLog</a><br> +<a href="CoreTasks/cvsversion.html">CvsVersion</a><br> <a href="CoreTasks/cvspass.html">CVSPass</a><br> <a href="CoreTasks/cvstagdiff.html">CvsTagDiff</a><br> <a href="CoreTasks/defaultexcludes.html">Defaultexcludes</a><br> 1.532 +5 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.531 retrieving revision 1.532 diff -u -r1.531 -r1.532 --- WHATSNEW 28 Jan 2004 10:01:17 -0000 1.531 +++ WHATSNEW 28 Jan 2004 22:47:14 -0000 1.532 @@ -66,6 +66,11 @@ detected by Ant and treated just like Java 1.4. You can now specify source="1.5" in the <javac> task. +* created new task <cvsversion> + +* added support for branch logging via the tag attribute in <cvschangelog> + Bugzilla Report 13510. + Changes from Ant 1.5.4 to Ant 1.6.0 ===================================
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]