Browse Source

checkstyle

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274807 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 22 years ago
parent
commit
ff0739c9ea
1 changed files with 59 additions and 75 deletions
  1. +59
    -75
      src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java

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

@@ -102,7 +102,14 @@ import org.apache.tools.ant.util.FileUtils;
* @ant.task name="cvstagdiff" * @ant.task name="cvstagdiff"
*/ */
public class CvsTagDiff extends AbstractCvsTask { public class CvsTagDiff extends AbstractCvsTask {

/**
* Token to identify the word file in the rdiff log
*/
static final String FILE_STRING = "File ";
/**
* Token to identify the word file in the rdiff log
*/
static final String TO_STRING = " to ";
/** /**
* Token to identify a new file in the rdiff log * Token to identify a new file in the rdiff log
*/ */
@@ -121,43 +128,44 @@ public class CvsTagDiff extends AbstractCvsTask {
/** /**
* The cvs package/module to analyse * The cvs package/module to analyse
*/ */
private String m_package;
private String mypackage;


/** /**
* The earliest tag from which diffs are to be included in the report. * The earliest tag from which diffs are to be included in the report.
*/ */
private String m_startTag;
private String mystartTag;


/** /**
* The latest tag from which diffs are to be included in the report. * The latest tag from which diffs are to be included in the report.
*/ */
private String m_endTag;
private String myendTag;


/** /**
* The earliest date from which diffs are to be included in the report. * The earliest date from which diffs are to be included in the report.
*/ */
private String m_startDate;
private String mystartDate;


/** /**
* The latest date from which diffs are to be included in the report. * The latest date from which diffs are to be included in the report.
*/ */
private String m_endDate;
private String myendDate;


/** /**
* The file in which to write the diff report. * The file in which to write the diff report.
*/ */
private File m_destfile;
private File mydestfile;


/** /**
* Used to create the temp file for cvs log * Used to create the temp file for cvs log
*/ */
private FileUtils m_fileUtils = FileUtils.newFileUtils();
private FileUtils myfileUtils = FileUtils.newFileUtils();


/** /**
* The package/module to analyze. * The package/module to analyze.
* @param p the name of the package to analyse
*/ */
public void setPackage(String p) { public void setPackage(String p) {
m_package = p;
mypackage = p;
} }


/** /**
@@ -166,7 +174,7 @@ public class CvsTagDiff extends AbstractCvsTask {
* @param s the start tag. * @param s the start tag.
*/ */
public void setStartTag(String s) { public void setStartTag(String s) {
m_startTag = s;
mystartTag = s;
} }


/** /**
@@ -175,7 +183,7 @@ public class CvsTagDiff extends AbstractCvsTask {
* @param s the start date. * @param s the start date.
*/ */
public void setStartDate(String s) { public void setStartDate(String s) {
m_startDate = s;
mystartDate = s;
} }


/** /**
@@ -184,7 +192,7 @@ public class CvsTagDiff extends AbstractCvsTask {
* @param s the end tag. * @param s the end tag.
*/ */
public void setEndTag(String s) { public void setEndTag(String s) {
m_endTag = s;
myendTag = s;
} }


/** /**
@@ -193,7 +201,7 @@ public class CvsTagDiff extends AbstractCvsTask {
* @param s the end date. * @param s the end date.
*/ */
public void setEndDate(String s) { public void setEndDate(String s) {
m_endDate = s;
myendDate = s;
} }


/** /**
@@ -202,7 +210,7 @@ public class CvsTagDiff extends AbstractCvsTask {
* @param f the output file for the diff. * @param f the output file for the diff.
*/ */
public void setDestFile(File f) { public void setDestFile(File f) {
m_destfile = f;
mydestfile = f;
} }


/** /**
@@ -217,52 +225,26 @@ public class CvsTagDiff extends AbstractCvsTask {
// build the rdiff command // build the rdiff command
addCommandArgument("rdiff"); addCommandArgument("rdiff");
addCommandArgument("-s"); addCommandArgument("-s");
if (m_startTag != null) {
if (mystartTag != null) {
addCommandArgument("-r"); addCommandArgument("-r");
addCommandArgument(m_startTag);
} else
{
addCommandArgument(mystartTag);
} else {
addCommandArgument("-D"); addCommandArgument("-D");
addCommandArgument(m_startDate);
addCommandArgument(mystartDate);
} }
if (m_endTag != null) {
if (myendTag != null) {
addCommandArgument("-r"); addCommandArgument("-r");
addCommandArgument(m_endTag);
} else
{
addCommandArgument(myendTag);
} else {
addCommandArgument("-D"); addCommandArgument("-D");
addCommandArgument(m_endDate);
addCommandArgument(myendDate);
} }
addCommandArgument(m_package);
addCommandArgument(mypackage);
// force command not to be null // force command not to be null
setCommand(""); setCommand("");
/*
StringBuffer rdiff = new StringBuffer();
rdiff.append("rdiff");
rdiff.append(" -s");
if (m_startTag != null) {
rdiff.append(" -r");
rdiff.append(" " + m_startTag);
} else
{
rdiff.append(" -D");
rdiff.append(" '" + m_startDate + "'");
}
if (m_endTag != null) {
rdiff.append(" -r");
rdiff.append(" " + m_endTag);
} else
{
rdiff.append(" -D");
rdiff.append(" '" + m_endDate + "'");
}
rdiff.append(" " + m_package);
log("Cvs command is " + rdiff.toString(), Project.MSG_VERBOSE);
setCommand(rdiff.toString());
*/
File tmpFile = null; File tmpFile = null;
try { try {
tmpFile = m_fileUtils.createTempFile("cvstagdiff", ".log", null);
tmpFile = myfileUtils.createTempFile("cvstagdiff", ".log", null);
setOutput(tmpFile); setOutput(tmpFile);


// run the cvs command // run the cvs command
@@ -305,7 +287,7 @@ public class CvsTagDiff extends AbstractCvsTask {
// release tag SKINLF_12 // release tag SKINLF_12


// get rid of 'File module/" // get rid of 'File module/"
int headerLength = 5 + m_package.length() + 1;
int headerLength = FILE_STRING.length() + mypackage.length() + 1;
Vector entries = new Vector(); Vector entries = new Vector();


String line = reader.readLine(); String line = reader.readLine();
@@ -321,8 +303,8 @@ public class CvsTagDiff extends AbstractCvsTask {
// set the revision but not the prevrevision // set the revision but not the prevrevision
String filename = line.substring(0, index); String filename = line.substring(0, index);
String rev = line.substring(index + FILE_IS_NEW.length()); String rev = line.substring(index + FILE_IS_NEW.length());
entries.addElement(entry = new CvsTagEntry(filename, rev));
entry = new CvsTagEntry(filename, rev);
entries.addElement(entry);
log(entry.toString(), Project.MSG_VERBOSE); log(entry.toString(), Project.MSG_VERBOSE);
} else if ((index = line.indexOf(FILE_HAS_CHANGED)) != -1) { } else if ((index = line.indexOf(FILE_HAS_CHANGED)) != -1) {
// it is a modified file // it is a modified file
@@ -332,18 +314,17 @@ public class CvsTagDiff extends AbstractCvsTask {
String prevRevision = String prevRevision =
line.substring(index + FILE_HAS_CHANGED.length(), line.substring(index + FILE_HAS_CHANGED.length(),
revSeparator); revSeparator);
// 4 is " to " length
String revision = line.substring(revSeparator + 4);

entries.addElement(entry = new CvsTagEntry(filename,
String revision = line.substring(revSeparator + TO_STRING.length());
entry = new CvsTagEntry(filename,
revision, revision,
prevRevision));
prevRevision);
entries.addElement(entry);
log(entry.toString(), Project.MSG_VERBOSE); log(entry.toString(), Project.MSG_VERBOSE);
} else if ((index = line.indexOf(FILE_WAS_REMOVED)) != -1) { } else if ((index = line.indexOf(FILE_WAS_REMOVED)) != -1) {
// it is a removed file // it is a removed file
String filename = line.substring(0, index); String filename = line.substring(0, index);
entries.addElement(entry = new CvsTagEntry(filename));
entry = new CvsTagEntry(filename);
entries.addElement(entry);
log(entry.toString(), Project.MSG_VERBOSE); log(entry.toString(), Project.MSG_VERBOSE);
} }
} }
@@ -361,6 +342,7 @@ public class CvsTagDiff extends AbstractCvsTask {
try { try {
reader.close(); reader.close();
} catch (IOException e) { } catch (IOException e) {
log(e.toString(), Project.MSG_ERR);
} }
} }
} }
@@ -375,24 +357,24 @@ public class CvsTagDiff extends AbstractCvsTask {
private void writeTagDiff(CvsTagEntry[] entries) throws BuildException { private void writeTagDiff(CvsTagEntry[] entries) throws BuildException {
FileOutputStream output = null; FileOutputStream output = null;
try { try {
output = new FileOutputStream(m_destfile);
output = new FileOutputStream(mydestfile);
PrintWriter writer = new PrintWriter( PrintWriter writer = new PrintWriter(
new OutputStreamWriter(output, "UTF-8")); new OutputStreamWriter(output, "UTF-8"));
writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
writer.print("<tagdiff "); writer.print("<tagdiff ");
if (m_startTag != null) {
writer.print("startTag=\"" + m_startTag + "\" ");
if (mystartTag != null) {
writer.print("startTag=\"" + mystartTag + "\" ");
} else { } else {
writer.print("startDate=\"" + m_startDate + "\" ");
writer.print("startDate=\"" + mystartDate + "\" ");
} }
if (m_endTag != null) {
writer.print("endTag=\"" + m_endTag + "\" ");
if (myendTag != null) {
writer.print("endTag=\"" + myendTag + "\" ");
} else { } else {
writer.print("endDate=\"" + m_endDate + "\" ");
writer.print("endDate=\"" + myendDate + "\" ");
} }


writer.print("cvsroot=\"" + getCvsRoot() + "\" "); writer.print("cvsroot=\"" + getCvsRoot() + "\" ");
writer.print("package=\"" + m_package + "\" ");
writer.print("package=\"" + mypackage + "\" ");


writer.println(">"); writer.println(">");
for (int i = 0, c = entries.length; i < c; i++) { for (int i = 0, c = entries.length; i < c; i++) {
@@ -409,7 +391,9 @@ public class CvsTagDiff extends AbstractCvsTask {
if (null != output) { if (null != output) {
try { try {
output.close(); output.close();
} catch (IOException ioe) { }
} catch (IOException ioe) {
log(ioe.toString(), Project.MSG_ERR);
}
} }
} }
} }
@@ -442,28 +426,28 @@ public class CvsTagDiff extends AbstractCvsTask {
* @exception BuildException if a parameter is not correctly set * @exception BuildException if a parameter is not correctly set
*/ */
private void validate() throws BuildException { private void validate() throws BuildException {
if (null == m_package) {
if (null == mypackage) {
throw new BuildException("Package/module must be set."); throw new BuildException("Package/module must be set.");
} }


if (null == m_destfile) {
if (null == mydestfile) {
throw new BuildException("Destfile must be set."); throw new BuildException("Destfile must be set.");
} }


if (null == m_startTag && null == m_startDate) {
if (null == mystartTag && null == mystartDate) {
throw new BuildException("Start tag or start date must be set."); throw new BuildException("Start tag or start date must be set.");
} }


if (null != m_startTag && null != m_startDate) {
if (null != mystartTag && null != mystartDate) {
throw new BuildException("Only one of start tag and start date " throw new BuildException("Only one of start tag and start date "
+ "must be set."); + "must be set.");
} }


if (null == m_endTag && null == m_endDate) {
if (null == myendTag && null == myendDate) {
throw new BuildException("End tag or end date must be set."); throw new BuildException("End tag or end date must be set.");
} }


if (null != m_endTag && null != m_endDate) {
if (null != myendTag && null != myendDate) {
throw new BuildException("Only one of end tag and end date must " throw new BuildException("Only one of end tag and end date must "
+ "be set."); + "be set.");
} }


Loading…
Cancel
Save