Modify CvsChangeLog to accept a branch as the tag attribute ChangeLogTask.java now inherits from AbstractCvsTask PR: 13510 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275969 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -66,6 +66,11 @@ Other changes: | |||
| 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 | |||
| =================================== | |||
| @@ -21,6 +21,49 @@ from the command line in the target directory in which you are working. | |||
| <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<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> | |||
| @@ -138,6 +181,11 @@ under the <code>dve/network</code> directory, substituting the name | |||
| 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 @@ This allows temp[lates to be stored inside jar]]></msg> | |||
| </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> | |||
| @@ -0,0 +1,93 @@ | |||
| <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:anoncvs@cvs.apache.org:/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> | |||
| @@ -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,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 @@ public abstract class AbstractCvsTask extends Task { | |||
| * the package/module to check out. | |||
| */ | |||
| private String cvsPackage; | |||
| /** | |||
| * the tag | |||
| */ | |||
| private String tag; | |||
| /** | |||
| * the default command. | |||
| */ | |||
| @@ -609,6 +612,13 @@ public abstract class AbstractCvsTask extends Task { | |||
| 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 abstract class AbstractCvsTask extends Task { | |||
| 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,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 java.util.Vector; | |||
| 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 @@ import org.apache.tools.ant.types.FileSet; | |||
| * @author <a href="mailto:peter@apache.org">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 @@ public class ChangeLogTask extends Task { | |||
| try { | |||
| validate(); | |||
| final Properties userList = new Properties(); | |||
| loadUserlist(userList); | |||
| @@ -239,11 +238,22 @@ public class ChangeLogTask extends Task { | |||
| 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 @@ public class ChangeLogTask extends Task { | |||
| 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 @@ public class ChangeLogTask extends Task { | |||
| 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 @@ public class ChangeLogTask extends Task { | |||
| 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) { | |||
| @@ -0,0 +1,189 @@ | |||
| /* | |||
| * 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 apache@apache.org. | |||
| * | |||
| * 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:anoncvs@cvs.apache.org:/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); | |||
| } | |||
| } | |||
| } | |||
| @@ -66,6 +66,7 @@ loadproperties=org.apache.tools.ant.taskdefs.LoadProperties | |||
| 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 | |||