Browse Source

Make cvstagdiff inherit from AbstractCvsTask

PR: 12119
Submitted by:	Rob van Oostrum <rvanoo@xs4all.nl>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273295 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
f0c70acd8f
2 changed files with 23 additions and 84 deletions
  1. +18
    -0
      docs/manual/CoreTasks/cvstagdiff.html
  2. +5
    -84
      src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java

+ 18
- 0
docs/manual/CoreTasks/cvstagdiff.html View File

@@ -42,6 +42,11 @@
<td valign="top">The file in which to write the diff report.</td>
<td align="center" valign="top">Yes</td>
</tr>
<tr>
<td valign="top">rootdir</td>
<td valign="top">Root directory for the package, if different from the package name.</td>
<td align="center" valign="top">No</td>
</tr>
</table>

<h3>Parameters inherited from the <code>cvs</code> task</h3>
@@ -119,6 +124,19 @@ has not been set. The current <code>cvsRoot</code> will be used (assuming the bu
from a folder stored in <code>cvs</code>.
It writes these changes into the file <code>tagdiff.xml</code>.</p>

<pre> &lt;cvstagdiff
destfile=&quot;tagdiff.xml&quot;
package=&quot;jakarta-ant&quot;
rootdir=&quot;jakarta/ant&quot;
startDate=&quot;2002-01-01&quot;
endDate=&quot;2002-31-01&quot;
/&gt;</pre>

<p>Generates a tagdiff report for all the changes that have been made
in the <code>jakarta-ant</code> module in january 2002, with <code>rootdir</code> indicating that
the actual location of the <code>jakarta-ant</code> module in cvs is <code>jakarta/ant</code>
rather than <code>jakarta-ant</code>.

<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


+ 5
- 84
src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java View File

@@ -64,8 +64,7 @@ import java.io.UnsupportedEncodingException;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Cvs;
import org.apache.tools.ant.taskdefs.AbstractCvsTask;
import org.apache.tools.ant.util.FileUtils;

/**
@@ -100,9 +99,8 @@ import org.apache.tools.ant.util.FileUtils;
* @version $Revision$ $Date$
* @since Ant 1.5
* @ant.task name="cvstagdiff"
* @todo Why doesn't this task extend from AbstractCvsTask?
*/
public class CvsTagDiff extends Task {
public class CvsTagDiff extends AbstractCvsTask {

/**
* Token to identify a new file in the rdiff log
@@ -119,11 +117,6 @@ public class CvsTagDiff extends Task {
*/
static final String FILE_WAS_REMOVED = " is removed";

/**
* The cvs task which will perform the rdiff.
*/
private Cvs m_cvs;

/**
* The cvs package/module to analyse
*/
@@ -159,48 +152,6 @@ public class CvsTagDiff extends Task {
*/
private FileUtils m_fileUtils = FileUtils.newFileUtils();

/**
* Initialize this task.
* CvsTagDiff initializes a member cvs task in init() to perform the
* rdiff in execute().
*
* @exception BuildException if an error occurs
*/
public void init() throws BuildException {
m_cvs = (Cvs) getProject().createTask("cvs");
}

/**
* If set to a value 1-9 it adds -zN to the cvs command line, else
* it disables compression.
*
* @see org.apache.tools.ant.taskdefs.AbstractCvsTask#setCompressionLevel(int)
*/
public void setCompressionLevel(int level) {
m_cvs.setCompressionLevel(level);
}

/**
* If true, this is the same as compressionlevel="3".
*/
public void setCompression(boolean usecomp) {
m_cvs.setCompression(usecomp);
}

/**
* The CVSROOT variable.
*/
public void setCvsRoot(String cvsRoot) {
m_cvs.setCvsRoot(cvsRoot);
}

/**
* The CVS_RSH variable.
*/
public void setCvsRsh(String rsh) {
m_cvs.setCvsRsh(rsh);
}

/**
* The package/module to analyze.
*/
@@ -208,36 +159,6 @@ public class CvsTagDiff extends Task {
m_package = p;
}

/**
* If true, suppress informational messages.
*/
public void setQuiet(boolean quiet) {
m_cvs.setQuiet(quiet);
}

/**
* Port used by CVS to communicate with the server.
*/
public void setPort(int port) {
m_cvs.setPort(port);
}

/**
* Password file to read passwords from.
*/
public void setPassfile(File f) {
m_cvs.setPassfile(f);
}

/**
* Stop the build process if the command exits with
* a return code other than 0.
* Defaults to false.
*/
public void setFailOnError(boolean b) {
m_cvs.setFailOnError(b);
}

/**
* Set the start tag.
*
@@ -299,15 +220,15 @@ public class CvsTagDiff extends Task {
+ (m_endTag != null ? ("-r " + m_endTag) : ("-D " + m_endDate))
+ " " + m_package;
log("Cvs command is " + rdiff, Project.MSG_VERBOSE);
m_cvs.setCommand(rdiff);
setCommand(rdiff);

File tmpFile = null;
try {
tmpFile = m_fileUtils.createTempFile("cvstagdiff", ".log", null);
m_cvs.setOutput(tmpFile);
setOutput(tmpFile);

// run the cvs command
m_cvs.execute();
super.execute();

// parse the rdiff
CvsTagEntry[] entries = parseRDiff(tmpFile);


Loading…
Cancel
Save