diff options
Diffstat (limited to 'framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib')
11 files changed, 0 insertions, 2159 deletions
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CVSEntry.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CVSEntry.java deleted file mode 100644 index b1a9a123..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CVSEntry.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.cvslib; - -import java.util.Date; -import java.util.Vector; - -/** - * CVS Entry. - * - */ -public class CVSEntry { - private Date date; - private String author; - private final String comment; - private final Vector files = new Vector(); - - /** - * Creates a new instance of a CVSEntry - * @param date the date - * @param author the author - * @param comment a comment to be added to the revision - */ - public CVSEntry(final Date date, final String author, final String comment) { - this.date = date; - this.author = author; - this.comment = comment; - } - - /** - * Adds a file to the CVSEntry - * @param file the file to add - * @param revision the revision - */ - public void addFile(final String file, final String revision) { - files.addElement(new RCSFile(file, revision)); - } - - /** - * Adds a file to the CVSEntry - * @param file the file to add - * @param revision the revision - * @param previousRevision the previous revision - */ - public void addFile(final String file, final String revision, final String previousRevision) { - files.addElement(new RCSFile(file, revision, previousRevision)); - } - - /** - * Gets the date of the CVSEntry - * @return the date - */ - public Date getDate() { - return date; - } - - /** - * Sets the author of the CVSEntry - * @param author the author - */ - public void setAuthor(final String author) { - this.author = author; - } - - /** - * Gets the author of the CVSEntry - * @return the author - */ - public String getAuthor() { - return author; - } - - /** - * Gets the comment for the CVSEntry - * @return the comment - */ - public String getComment() { - return comment; - } - - /** - * Gets the files in this CVSEntry - * @return the files - */ - public Vector getFiles() { - return files; - } - - /** - * Gets a String containing author, date, files and comment - * @return a string representation of this CVSEntry - */ - public String toString() { - return getAuthor() + "\n" + getDate() + "\n" + getFiles() + "\n" - + getComment(); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java deleted file mode 100644 index 0096aadf..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.cvslib; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.StringTokenizer; -import java.util.TimeZone; - -import org.apache.tools.ant.taskdefs.AbstractCvsTask; -import org.apache.tools.ant.util.CollectionUtils; - -/** - * A class used to parse the output of the CVS log command. - * - */ -class ChangeLogParser { - //private static final int GET_ENTRY = 0; - private static final int GET_FILE = 1; - private static final int GET_DATE = 2; - private static final int GET_COMMENT = 3; - private static final int GET_REVISION = 4; - private static final int GET_PREVIOUS_REV = 5; - -// FIXME formatters are not thread-safe - - /** input format for dates read in from cvs log */ - private static final SimpleDateFormat INPUT_DATE - = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.US); - /** - * New formatter used to parse CVS date/timestamp. - */ - private static final SimpleDateFormat CVS1129_INPUT_DATE = - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", Locale.US); - - static { - TimeZone utc = TimeZone.getTimeZone("UTC"); - INPUT_DATE.setTimeZone(utc); - CVS1129_INPUT_DATE.setTimeZone(utc); - } - - //The following is data used while processing stdout of CVS command - private String file; - private String date; - private String author; - private String comment; - private String revision; - private String previousRevision; - - private int status = GET_FILE; - - /** rcs entries */ - private final Hashtable entries = new Hashtable(); - - private final boolean remote; - private final String[] moduleNames; - private final int[] moduleNameLengths; - - public ChangeLogParser() { - this(false, "", CollectionUtils.EMPTY_LIST); - } - - public ChangeLogParser(boolean remote, String packageName, List modules) { - this.remote = remote; - - ArrayList names = new ArrayList(); - if (packageName != null) { - for (StringTokenizer tok = new StringTokenizer(packageName); - tok.hasMoreTokens();) { - names.add(tok.nextToken()); - } - } - for (Iterator iter = modules.iterator(); iter.hasNext();) { - AbstractCvsTask.Module m = (AbstractCvsTask.Module) iter.next(); - names.add(m.getName()); - } - - moduleNames = (String[]) names.toArray(new String[names.size()]); - moduleNameLengths = new int[moduleNames.length]; - for (int i = 0; i < moduleNames.length; i++) { - moduleNameLengths[i] = moduleNames[i].length(); - } - } - - /** - * Get a list of rcs entries as an array. - * - * @return a list of rcs entries as an array - */ - public CVSEntry[] getEntrySetAsArray() { - final CVSEntry[] array = new CVSEntry[ entries.size() ]; - int i = 0; - for (Enumeration e = entries.elements(); e.hasMoreElements();) { - array[i++] = (CVSEntry) e.nextElement(); - } - return array; - } - - /** - * Receive notification about the process writing - * to standard output. - * @param line the line to process - */ - public void stdout(final String line) { - switch(status) { - case GET_FILE: - // make sure attributes are reset when - // working on a 'new' file. - reset(); - processFile(line); - break; - case GET_REVISION: - processRevision(line); - break; - - case GET_DATE: - processDate(line); - break; - - case GET_COMMENT: - processComment(line); - break; - - case GET_PREVIOUS_REV: - processGetPreviousRevision(line); - break; - - default: - // Do nothing - break; - } - } - - /** - * Process a line while in "GET_COMMENT" state. - * - * @param line the line - */ - private void processComment(final String line) { - final String lineSeparator = System.getProperty("line.separator"); - if (line.equals( - "=============================================================================")) { - //We have ended changelog for that particular file - //so we can save it - final int end - = comment.length() - lineSeparator.length(); //was -1 - comment = comment.substring(0, end); - saveEntry(); - status = GET_FILE; - } else if (line.equals("----------------------------")) { - final int end - = comment.length() - lineSeparator.length(); //was -1 - comment = comment.substring(0, end); - status = GET_PREVIOUS_REV; - } else { - comment += line + lineSeparator; - } - } - - /** - * Process a line while in "GET_FILE" state. - * - * @param line the line to process - */ - private void processFile(final String line) { - if (!remote && line.startsWith("Working file:")) { - // CheckStyle:MagicNumber OFF - file = line.substring(14, line.length()); - // CheckStyle:MagicNumber ON - status = GET_REVISION; - } else if (remote && line.startsWith("RCS file:")) { - // exclude the part of the RCS filename up to and - // including the module name (and the path separator) - int startOfFileName = 0; - for (int i = 0; i < moduleNames.length; i++) { - int index = line.indexOf(moduleNames[i]); - if (index >= 0) { - startOfFileName = index + moduleNameLengths[i] + 1; - break; - } - } - int endOfFileName = line.indexOf(",v"); - if (endOfFileName == -1) { - file = line.substring(startOfFileName); - } else { - file = line.substring(startOfFileName, endOfFileName); - } - status = GET_REVISION; - } - } - - /** - * Process a line while in "REVISION" state. - * - * @param line the line to process - */ - private void processRevision(final String line) { - if (line.startsWith("revision")) { - // CheckStyle:MagicNumber OFF - revision = line.substring(9); - // CheckStyle:MagicNumber ON - status = GET_DATE; - } else if (line.startsWith("======")) { - //There were no revisions in this changelog - //entry so lets move onto next file - status = GET_FILE; - } - } - - /** - * Process a line while in "DATE" state. - * - * @param line the line to process - */ - private void processDate(final String line) { - if (line.startsWith("date:")) { - // The date format is using a - format since 1.12.9 so we have: - // 1.12.9-: 'date: YYYY/mm/dd HH:mm:ss; author: name;' - // 1.12.9+: 'date: YYYY-mm-dd HH:mm:ss Z; author: name' - int endOfDateIndex = line.indexOf(';'); - date = line.substring("date: ".length(), endOfDateIndex); - - int startOfAuthorIndex = line.indexOf("author: ", endOfDateIndex + 1); - int endOfAuthorIndex = line.indexOf(';', startOfAuthorIndex + 1); - author = line.substring("author: ".length() + startOfAuthorIndex, endOfAuthorIndex); - - status = GET_COMMENT; - - //Reset comment to empty here as we can accumulate multiple lines - //in the processComment method - comment = ""; - } - } - - /** - * Process a line while in "GET_PREVIOUS_REVISION" state. - * - * @param line the line to process - */ - private void processGetPreviousRevision(final String line) { - if (!line.startsWith("revision ")) { - throw new IllegalStateException("Unexpected line from CVS: " - + line); - } - previousRevision = line.substring("revision ".length()); - - saveEntry(); - - revision = previousRevision; - status = GET_DATE; - } - - /** - * Utility method that saves the current entry. - */ - private void saveEntry() { - final String entryKey = date + author + comment; - CVSEntry entry; - if (!entries.containsKey(entryKey)) { - Date dateObject = parseDate(date); - entry = new CVSEntry(dateObject, author, comment); - entries.put(entryKey, entry); - } else { - entry = (CVSEntry) entries.get(entryKey); - } - - entry.addFile(file, revision, previousRevision); - } - - /** - * Parse date out from expected format. - * - * @param date the string holding date - * @return the date object or null if unknown date format - */ - private Date parseDate(final String date) { - try { - return INPUT_DATE.parse(date); - } catch (ParseException e) { - try { - return CVS1129_INPUT_DATE.parse(date); - } catch (ParseException e2) { - throw new IllegalStateException("Invalid date format: " + date); - } - } - } - - /** - * Reset all internal attributes except status. - */ - public void reset() { - this.file = null; - this.date = null; - this.author = null; - this.comment = null; - this.revision = null; - this.previousRevision = null; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java deleted file mode 100644 index b4b51ced..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java +++ /dev/null @@ -1,489 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.cvslib; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Enumeration; -import java.util.Properties; -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.taskdefs.AbstractCvsTask; -import org.apache.tools.ant.types.FileSet; -import org.apache.tools.ant.util.FileUtils; - -/** - * Examines the output of cvs log and group related changes together. - * - * It produces an XML output representing the list of changes. - * <pre> - * <font color=#0000ff><!-- Root element --></font> - * <font color=#6a5acd><!ELEMENT</font> changelog <font color=#ff00ff> - * (entry</font><font color=#ff00ff>+</font><font color=#ff00ff>) - * </font><font color=#6a5acd>></font> - * <font color=#0000ff><!-- CVS Entry --></font> - * <font color=#6a5acd><!ELEMENT</font> entry <font color=#ff00ff> - * (date,author,file</font><font color=#ff00ff>+</font><font color=#ff00ff>,msg) - * </font><font color=#6a5acd>></font> - * <font color=#0000ff><!-- Date of cvs entry --></font> - * <font color=#6a5acd><!ELEMENT</font> date <font color=#ff00ff>(#PCDATA) - * </font><font color=#6a5acd>></font> - * <font color=#0000ff><!-- Author of change --></font> - * <font color=#6a5acd><!ELEMENT</font> author <font color=#ff00ff>(#PCDATA) - * </font><font color=#6a5acd>></font> - * <font color=#0000ff><!-- List of files affected --></font> - * <font color=#6a5acd><!ELEMENT</font> msg <font color=#ff00ff>(#PCDATA) - * </font><font color=#6a5acd>></font> - * <font color=#0000ff><!-- File changed --></font> - * <font color=#6a5acd><!ELEMENT</font> file <font color=#ff00ff> - * (name,revision,prevrevision</font><font color=#ff00ff>?</font> - * <font color=#ff00ff>)</font><font color=#6a5acd>></font> - * <font color=#0000ff><!-- Name of the file --></font> - * <font color=#6a5acd><!ELEMENT</font> name <font color=#ff00ff>(#PCDATA) - * </font><font color=#6a5acd>></font> - * <font color=#0000ff><!-- Revision number --></font> - * <font color=#6a5acd><!ELEMENT</font> revision <font color=#ff00ff> - * (#PCDATA)</font><font color=#6a5acd>></font> - * <font color=#0000ff><!-- Previous revision number --></font> - * <font color=#6a5acd><!ELEMENT</font> prevrevision <font color=#ff00ff> - * (#PCDATA)</font><font color=#6a5acd>></font> - * </pre> - * - * @since Ant 1.5 - * @ant.task name="cvschangelog" category="scm" - */ -public class ChangeLogTask extends AbstractCvsTask { - /** User list */ - private File usersFile; - - /** User list */ - private Vector cvsUsers = new Vector(); - - /** Input dir */ - private File inputDir; - - /** Output file */ - private File destFile; - - /** The earliest date at which to start processing entries. */ - private Date startDate; - - /** The latest date at which to stop processing entries. */ - private Date endDate; - - /** Determines whether log (false) or rlog (true) is used */ - private boolean remote = false; - - /** Start tag when doing tag ranges. */ - private String startTag; - - /** End tag when doing tag ranges. */ - private String endTag; - - /** - * Filesets containing list of files against which the cvs log will be - * performed. If empty then all files in the working directory will - * be checked. - */ - private final Vector filesets = new Vector(); - - - /** - * Set the base dir for cvs. - * - * @param inputDir The new dir value - */ - public void setDir(final File inputDir) { - this.inputDir = inputDir; - } - - - /** - * Set the output file for the log. - * - * @param destFile The new destfile value - */ - public void setDestfile(final File destFile) { - this.destFile = destFile; - } - - - /** - * Set a lookup list of user names & addresses - * - * @param usersFile The file containing the users info. - */ - public void setUsersfile(final File usersFile) { - this.usersFile = usersFile; - } - - - /** - * Add a user to list changelog knows about. - * - * @param user the user - */ - public void addUser(final CvsUser user) { - cvsUsers.addElement(user); - } - - - /** - * Set the date at which the changelog should start. - * - * @param start The date at which the changelog should start. - */ - public void setStart(final Date start) { - this.startDate = start; - } - - - /** - * Set the date at which the changelog should stop. - * - * @param endDate The date at which the changelog should stop. - */ - public void setEnd(final Date endDate) { - this.endDate = endDate; - } - - - /** - * Set the number of days worth of log entries to process. - * - * @param days the number of days of log to process. - */ - public void setDaysinpast(final int days) { - // CheckStyle:MagicNumber OFF - final long time = System.currentTimeMillis() - - (long) days * 24 * 60 * 60 * 1000; - // CheckStyle:MagicNumber ON - - setStart(new Date(time)); - } - - /** - * Whether to use rlog against a remote repository instead of log - * in a working copy's directory. - * - * @since Ant 1.8.0 - */ - public void setRemote(final boolean remote) { - this.remote = remote; - } - - /** - * Set the tag at which the changelog should start. - * - * @param start The date at which the changelog should start. - */ - public void setStartTag(final String start) { - this.startTag = start; - } - - - /** - * Set the tag at which the changelog should stop. - * - * @param end The date at which the changelog should stop. - */ - public void setEndTag(final String end) { - this.endTag = end; - } - - /** - * Adds a set of files about which cvs logs will be generated. - * - * @param fileSet a set of files about which cvs logs will be generated. - */ - public void addFileset(final FileSet fileSet) { - filesets.addElement(fileSet); - } - - - /** - * Execute task - * - * @exception BuildException if something goes wrong executing the - * cvs command - */ - public void execute() throws BuildException { - File savedDir = inputDir; // may be altered in validate - - try { - - validate(); - final Properties userList = new Properties(); - - loadUserlist(userList); - - final int size = cvsUsers.size(); - for (int i = 0; i < size; i++) { - final CvsUser user = (CvsUser) cvsUsers.get(i); - user.validate(); - userList.put(user.getUserID(), user.getDisplayname()); - } - - if (!remote) { - 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(inputDir); - myCvsVersion.execute(); - if (myCvsVersion.supportsCvsLogWithSOption()) { - addCommandArgument("-S"); - } - } - } else { - // supply 'rlog' as argument instead of command - setCommand(""); - addCommandArgument("rlog"); - // Do not print name/header if no revisions - // selected. This is quicker: less output to parse. - addCommandArgument("-S"); - // Do not list tags. This is quicker: less output to - // parse. - addCommandArgument("-N"); - } - if (null != startTag || null != endTag) { - // man, do I get spoiled by C#'s ?? operator - String startValue = startTag == null ? "" : startTag; - String endValue = endTag == null ? "" : endTag; - addCommandArgument("-r" + startValue + "::" + endValue); - } else if (null != startDate) { - final SimpleDateFormat outputDate = - new SimpleDateFormat("yyyy-MM-dd"); - - // We want something of the form: -d ">=YYYY-MM-dd" - final String dateRange = ">=" + outputDate.format(startDate); - - // Supply '-d' as a separate argument - Bug# 14397 - addCommandArgument("-d"); - addCommandArgument(dateRange); - } - - // Check if list of files to check has been specified - if (!filesets.isEmpty()) { - final Enumeration e = filesets.elements(); - - while (e.hasMoreElements()) { - final FileSet fileSet = (FileSet) e.nextElement(); - final DirectoryScanner scanner = - fileSet.getDirectoryScanner(getProject()); - final String[] files = scanner.getIncludedFiles(); - - for (int i = 0; i < files.length; i++) { - addCommandArgument(files[i]); - } - } - } - - final ChangeLogParser parser = new ChangeLogParser(remote, - getPackage(), - getModules()); - final RedirectingStreamHandler handler = - new RedirectingStreamHandler(parser); - - log(getCommand(), Project.MSG_VERBOSE); - - setDest(inputDir); - setExecuteStreamHandler(handler); - try { - super.execute(); - } finally { - final String errors = handler.getErrors(); - - if (null != errors) { - log(errors, Project.MSG_ERR); - } - } - final CVSEntry[] entrySet = parser.getEntrySetAsArray(); - final CVSEntry[] filteredEntrySet = filterEntrySet(entrySet); - - replaceAuthorIdWithName(userList, filteredEntrySet); - - writeChangeLog(filteredEntrySet); - - } finally { - inputDir = savedDir; - } - } - - /** - * Validate the parameters specified for task. - * - * @throws BuildException if fails validation checks - */ - private void validate() - throws BuildException { - if (null == inputDir) { - inputDir = getProject().getBaseDir(); - } - if (null == destFile) { - final String message = "Destfile must be set."; - - throw new BuildException(message); - } - if (!inputDir.exists()) { - final String message = "Cannot find base dir " - + inputDir.getAbsolutePath(); - - throw new BuildException(message); - } - if (null != usersFile && !usersFile.exists()) { - final String message = "Cannot find user lookup list " - + usersFile.getAbsolutePath(); - - throw new BuildException(message); - } - if ((null != startTag || null != endTag) - && (null != startDate || null != endDate)) { - final String message = "Specify either a tag or date range," - + " not both"; - throw new BuildException(message); - } - } - - /** - * Load the userlist from the userList file (if specified) and add to - * list of users. - * - * @param userList the file of users - * @throws BuildException if file can not be loaded for some reason - */ - private void loadUserlist(final Properties userList) - throws BuildException { - if (null != usersFile) { - try { - userList.load(new FileInputStream(usersFile)); - } catch (final IOException ioe) { - throw new BuildException(ioe.toString(), ioe); - } - } - } - - /** - * Filter the specified entries according to an appropriate rule. - * - * @param entrySet the entry set to filter - * @return the filtered entry set - */ - private CVSEntry[] filterEntrySet(final CVSEntry[] entrySet) { - final Vector results = new Vector(); - - for (int i = 0; i < entrySet.length; i++) { - final CVSEntry cvsEntry = entrySet[i]; - final Date date = cvsEntry.getDate(); - - //bug#30471 - //this is caused by Date.after throwing a NullPointerException - //for some reason there's no date set in the CVSEntry - //Java 1.3.1 API - //http://java.sun.com/j2se/1.3/docs/api/java/util/Date.html#after(java.util.Date) - //doesn't throw NullPointerException - //Java 1.4.2 + 1.5 API - //http://java.sun.com/j2se/1.4.2/docs/api/java/util/Date.html#after(java.util.Date) - //according to the docs it doesn't throw, according to the bug report it does - //http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html#after(java.util.Date) - //according to the docs it does throw - - //for now skip entries which are missing a date - if (null == date) { - continue; - } - - if (null != startDate && startDate.after(date)) { - //Skip dates that are too early - continue; - } - if (null != endDate && endDate.before(date)) { - //Skip dates that are too late - continue; - } - results.addElement(cvsEntry); - } - - final CVSEntry[] resultArray = new CVSEntry[results.size()]; - - results.copyInto(resultArray); - return resultArray; - } - - /** - * replace all known author's id's with their maven specified names - */ - private void replaceAuthorIdWithName(final Properties userList, - final CVSEntry[] entrySet) { - for (int i = 0; i < entrySet.length; i++) { - - final CVSEntry entry = entrySet[ i ]; - if (userList.containsKey(entry.getAuthor())) { - entry.setAuthor(userList.getProperty(entry.getAuthor())); - } - } - } - - /** - * Print changelog to file specified in task. - * - * @param entrySet the entry set to write. - * @throws BuildException if there is an error writing changelog. - */ - private void writeChangeLog(final CVSEntry[] entrySet) - throws BuildException { - FileOutputStream output = null; - - try { - output = new FileOutputStream(destFile); - - final PrintWriter writer = - new PrintWriter(new OutputStreamWriter(output, "UTF-8")); - - final ChangeLogWriter serializer = new ChangeLogWriter(); - - serializer.printChangeLog(writer, entrySet); - - if (writer.checkError()) { - throw new IOException("Encountered an error writing changelog"); - } - } catch (final UnsupportedEncodingException uee) { - getProject().log(uee.toString(), Project.MSG_ERR); - } catch (final IOException ioe) { - throw new BuildException(ioe.toString(), ioe); - } finally { - FileUtils.close(output); - } - } -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriter.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriter.java deleted file mode 100644 index 2385e51f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriter.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.cvslib; - -import java.io.IOException; -import java.io.PrintWriter; -import java.text.SimpleDateFormat; -import java.util.Enumeration; -import java.util.TimeZone; - -import org.apache.tools.ant.util.DOMElementWriter; -import org.apache.tools.ant.util.DOMUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -/** - * Class used to generate an XML changelog. - * - */ -public class ChangeLogWriter { - /** output format for dates written to xml file */ - private static final SimpleDateFormat OUTPUT_DATE - = new SimpleDateFormat("yyyy-MM-dd"); - /** output format for times written to xml file */ - private static final SimpleDateFormat OUTPUT_TIME - = new SimpleDateFormat("HH:mm"); - /** stateless helper for writing the XML document */ - private static final DOMElementWriter DOM_WRITER = new DOMElementWriter(); - - static { - TimeZone utc = TimeZone.getTimeZone("UTC"); - OUTPUT_DATE.setTimeZone(utc); - OUTPUT_TIME.setTimeZone(utc); - } - - /** - * Print out the specified entries. - * - * @param output writer to which to send output. - * @param entries the entries to be written. - */ - public void printChangeLog(final PrintWriter output, - final CVSEntry[] entries) { - try { - output.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); - Document doc = DOMUtils.newDocument(); - Element root = doc.createElement("changelog"); - DOM_WRITER.openElement(root, output, 0, "\t"); - output.println(); - for (int i = 0; i < entries.length; i++) { - final CVSEntry entry = entries[i]; - - printEntry(doc, output, entry); - } - DOM_WRITER.closeElement(root, output, 0, "\t", true); - output.flush(); - output.close(); - } catch (IOException e) { - throw new org.apache.tools.ant.BuildException(e); - } - } - - - /** - * Print out an individual entry in changelog. - * - * @param doc Document used to create elements. - * @param entry the entry to print - * @param output writer to which to send output. - */ - private void printEntry(Document doc, final PrintWriter output, - final CVSEntry entry) throws IOException { - Element ent = doc.createElement("entry"); - DOMUtils.appendTextElement(ent, "date", - OUTPUT_DATE.format(entry.getDate())); - DOMUtils.appendTextElement(ent, "time", - OUTPUT_TIME.format(entry.getDate())); - DOMUtils.appendCDATAElement(ent, "author", entry.getAuthor()); - - final Enumeration enumeration = entry.getFiles().elements(); - - while (enumeration.hasMoreElements()) { - final RCSFile file = (RCSFile) enumeration.nextElement(); - - Element f = DOMUtils.createChildElement(ent, "file"); - DOMUtils.appendCDATAElement(f, "name", file.getName()); - DOMUtils.appendTextElement(f, "revision", file.getRevision()); - - final String previousRevision = file.getPreviousRevision(); - if (previousRevision != null) { - DOMUtils.appendTextElement(f, "prevrevision", - previousRevision); - } - } - DOMUtils.appendCDATAElement(ent, "msg", entry.getComment()); - DOM_WRITER.write(ent, output, 1, "\t"); - } -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java deleted file mode 100644 index a90bcc01..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java +++ /dev/null @@ -1,576 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.cvslib; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.StringTokenizer; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.AbstractCvsTask; -import org.apache.tools.ant.util.CollectionUtils; -import org.apache.tools.ant.util.DOMElementWriter; -import org.apache.tools.ant.util.DOMUtils; -import org.apache.tools.ant.util.FileUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -/** - * Examines the output of cvs rdiff between two tags. - * - * It produces an XML output representing the list of changes. - * <PRE> - * <!-- Root element --> - * <!ELEMENT tagdiff ( entry+ ) > - * <!-- Start tag of the report --> - * <!ATTLIST tagdiff startTag NMTOKEN #IMPLIED > - * <!-- End tag of the report --> - * <!ATTLIST tagdiff endTag NMTOKEN #IMPLIED > - * <!-- Start date of the report --> - * <!ATTLIST tagdiff startDate NMTOKEN #IMPLIED > - * <!-- End date of the report --> - * <!ATTLIST tagdiff endDate NMTOKEN #IMPLIED > - * - * <!-- CVS tag entry --> - * <!ELEMENT entry ( file ) > - * <!-- File added, changed or removed --> - * <!ELEMENT file ( name, revision?, prevrevision? ) > - * <!-- Name of the file --> - * <!ELEMENT name ( #PCDATA ) > - * <!-- Revision number --> - * <!ELEMENT revision ( #PCDATA ) > - * <!-- Previous revision number --> - * <!ELEMENT prevrevision ( #PCDATA ) > - * </PRE> - * - * @since Ant 1.5 - * @ant.task name="cvstagdiff" - */ -public class CvsTagDiff extends AbstractCvsTask { - - /** - * Used to create the temp file for cvs log - */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - /** stateless helper for writing the XML document */ - private static final DOMElementWriter DOM_WRITER = new DOMElementWriter(); - - /** - * Token to identify the word file in the rdiff log - */ - static final String FILE_STRING = "File "; - /** - * Length of token to identify the word file in the rdiff log - */ - static final int FILE_STRING_LENGTH = FILE_STRING.length(); - /** - * 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 - */ - static final String FILE_IS_NEW = " is new;"; - /** - * Token to identify the revision - */ - static final String REVISION = "revision "; - - /** - * Token to identify a modified file in the rdiff log - */ - static final String FILE_HAS_CHANGED = " changed from revision "; - - /** - * Token to identify a removed file in the rdiff log - */ - static final String FILE_WAS_REMOVED = " is removed"; - - /** - * The cvs package/module to analyse - */ - private String mypackage; - - /** - * The earliest tag from which diffs are to be included in the report. - */ - private String mystartTag; - - /** - * The latest tag from which diffs are to be included in the report. - */ - private String myendTag; - - /** - * The earliest date from which diffs are to be included in the report. - */ - private String mystartDate; - - /** - * The latest date from which diffs are to be included in the report. - */ - private String myendDate; - - /** - * The file in which to write the diff report. - */ - private File mydestfile; - - /** - * Used to skip over removed files - */ - private boolean ignoreRemoved = false; - - /** - * temporary list of package names. - */ - private List packageNames = new ArrayList(); - - /** - * temporary list of "File:" + package name + "/" for all packages. - */ - private String[] packageNamePrefixes = null; - - /** - * temporary list of length values for prefixes. - */ - private int[] packageNamePrefixLengths = null; - - /** - * The package/module to analyze. - * @param p the name of the package to analyse - */ - @Override - public void setPackage(String p) { - mypackage = p; - } - - /** - * Set the start tag. - * - * @param s the start tag. - */ - public void setStartTag(String s) { - mystartTag = s; - } - - /** - * Set the start date. - * - * @param s the start date. - */ - public void setStartDate(String s) { - mystartDate = s; - } - - /** - * Set the end tag. - * - * @param s the end tag. - */ - public void setEndTag(String s) { - myendTag = s; - } - - /** - * Set the end date. - * - * @param s the end date. - */ - public void setEndDate(String s) { - myendDate = s; - } - - /** - * Set the output file for the diff. - * - * @param f the output file for the diff. - */ - public void setDestFile(File f) { - mydestfile = f; - } - - /** - * Set the ignore removed indicator. - * - * @param b the ignore removed indicator. - * - * @since Ant 1.8.0 - */ - public void setIgnoreRemoved(boolean b) { - ignoreRemoved = b; - } - - - /** - * Execute task. - * - * @exception BuildException if an error occurs - */ - @Override - public void execute() throws BuildException { - // validate the input parameters - validate(); - - // build the rdiff command - addCommandArgument("rdiff"); - addCommandArgument("-s"); - if (mystartTag != null) { - addCommandArgument("-r"); - addCommandArgument(mystartTag); - } else { - addCommandArgument("-D"); - addCommandArgument(mystartDate); - } - if (myendTag != null) { - addCommandArgument("-r"); - addCommandArgument(myendTag); - } else { - addCommandArgument("-D"); - addCommandArgument(myendDate); - } - - // force command not to be null - setCommand(""); - File tmpFile = null; - try { - handlePackageNames(); - - tmpFile = FILE_UTILS.createTempFile("cvstagdiff", ".log", null, - true, true); - setOutput(tmpFile); - - // run the cvs command - super.execute(); - - // parse the rdiff - CvsTagEntry[] entries = parseRDiff(tmpFile); - - // write the tag diff - writeTagDiff(entries); - - } finally { - packageNamePrefixes = null; - packageNamePrefixLengths = null; - packageNames.clear(); - if (tmpFile != null) { - tmpFile.delete(); - } - } - } - - /** - * Parse the tmpFile and return and array of CvsTagEntry to be - * written in the output. - * - * @param tmpFile the File containing the output of the cvs rdiff command - * @return the entries in the output - * @exception BuildException if an error occurs - */ - private CvsTagEntry[] parseRDiff(File tmpFile) throws BuildException { - // parse the output of the command - BufferedReader reader = null; - - try { - reader = new BufferedReader(new FileReader(tmpFile)); - - // entries are of the form: - //CVS 1.11 - // File module/filename is new; current revision 1.1 - //CVS 1.11.9 - // File module/filename is new; cvstag_2003_11_03_2 revision 1.1 - // or - // File module/filename changed from revision 1.4 to 1.6 - // or - // File module/filename is removed; not included in - // release tag SKINLF_12 - //CVS 1.11.9 - // File testantoine/antoine.bat is removed; TESTANTOINE_1 revision 1.1.1.1 - // - // get rid of 'File module/" - Vector entries = new Vector(); - - String line = reader.readLine(); - - while (null != line) { - line = removePackageName(line, packageNamePrefixes, - packageNamePrefixLengths); - if (line != null) { - // use || in a perl like fashion - boolean processed - = doFileIsNew(entries, line) - || doFileHasChanged(entries, line) - || doFileWasRemoved(entries, line); - } - line = reader.readLine(); - } - - CvsTagEntry[] array = new CvsTagEntry[entries.size()]; - entries.copyInto(array); - - return array; - } catch (IOException e) { - throw new BuildException("Error in parsing", e); - } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException e) { - log(e.toString(), Project.MSG_ERR); - } - } - } - } - - private boolean doFileIsNew(Vector entries, String line) { - int index = line.indexOf(FILE_IS_NEW); - if (index == -1) { - return false; - } - // it is a new file - // set the revision but not the prevrevision - String filename = line.substring(0, index); - String rev = null; - int indexrev = line.indexOf(REVISION, index); - if (indexrev != -1) { - rev = line.substring(indexrev + REVISION.length()); - } - CvsTagEntry entry = new CvsTagEntry(filename, rev); - entries.addElement(entry); - log(entry.toString(), Project.MSG_VERBOSE); - return true; - } - - private boolean doFileHasChanged(Vector entries, String line) { - int index = line.indexOf(FILE_HAS_CHANGED); - if (index == -1) { - return false; - } - // it is a modified file - // set the revision and the prevrevision - String filename = line.substring(0, index); - int revSeparator = line.indexOf(" to ", index); - String prevRevision = - line.substring(index + FILE_HAS_CHANGED.length(), - revSeparator); - String revision = line.substring(revSeparator + TO_STRING.length()); - CvsTagEntry entry = new CvsTagEntry(filename, - revision, - prevRevision); - entries.addElement(entry); - log(entry.toString(), Project.MSG_VERBOSE); - return true; - } - - private boolean doFileWasRemoved(Vector entries, String line) { - if (ignoreRemoved) { - return false; - } - int index = line.indexOf(FILE_WAS_REMOVED); - if (index == -1) { - return false; - } - // it is a removed file - String filename = line.substring(0, index); - String rev = null; - int indexrev = line.indexOf(REVISION, index); - if (indexrev != -1) { - rev = line.substring(indexrev + REVISION.length()); - } - CvsTagEntry entry = new CvsTagEntry(filename, null, rev); - entries.addElement(entry); - log(entry.toString(), Project.MSG_VERBOSE); - return true; - } - - /** - * Write the rdiff log. - * - * @param entries a <code>CvsTagEntry[]</code> value - * @exception BuildException if an error occurs - */ - private void writeTagDiff(CvsTagEntry[] entries) throws BuildException { - FileOutputStream output = null; - try { - output = new FileOutputStream(mydestfile); - PrintWriter writer = new PrintWriter( - new OutputStreamWriter(output, "UTF-8")); - writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); - Document doc = DOMUtils.newDocument(); - Element root = doc.createElement("tagdiff"); - if (mystartTag != null) { - root.setAttribute("startTag", mystartTag); - } else { - root.setAttribute("startDate", mystartDate); - } - if (myendTag != null) { - root.setAttribute("endTag", myendTag); - } else { - root.setAttribute("endDate", myendDate); - } - - root.setAttribute("cvsroot", getCvsRoot()); - root.setAttribute("package", - CollectionUtils.flattenToString(packageNames)); - DOM_WRITER.openElement(root, writer, 0, "\t"); - writer.println(); - for (int i = 0, c = entries.length; i < c; i++) { - writeTagEntry(doc, writer, entries[i]); - } - DOM_WRITER.closeElement(root, writer, 0, "\t", true); - writer.flush(); - if (writer.checkError()) { - throw new IOException("Encountered an error writing tagdiff"); - } - writer.close(); - } catch (UnsupportedEncodingException uee) { - log(uee.toString(), Project.MSG_ERR); - } catch (IOException ioe) { - throw new BuildException(ioe.toString(), ioe); - } finally { - if (null != output) { - try { - output.close(); - } catch (IOException ioe) { - log(ioe.toString(), Project.MSG_ERR); - } - } - } - } - - /** - * Write a single entry to the given writer. - * - * @param doc Document used to create elements. - * @param writer a <code>PrintWriter</code> value - * @param entry a <code>CvsTagEntry</code> value - */ - private void writeTagEntry(Document doc, PrintWriter writer, - CvsTagEntry entry) - throws IOException { - Element ent = doc.createElement("entry"); - Element f = DOMUtils.createChildElement(ent, "file"); - DOMUtils.appendCDATAElement(f, "name", entry.getFile()); - if (entry.getRevision() != null) { - DOMUtils.appendTextElement(f, "revision", entry.getRevision()); - } - if (entry.getPreviousRevision() != null) { - DOMUtils.appendTextElement(f, "prevrevision", - entry.getPreviousRevision()); - } - DOM_WRITER.write(ent, writer, 1, "\t"); - } - - /** - * Validate the parameters specified for task. - * - * @exception BuildException if a parameter is not correctly set - */ - private void validate() throws BuildException { - if (null == mypackage && getModules().size() == 0) { - throw new BuildException("Package/module must be set."); - } - - if (null == mydestfile) { - throw new BuildException("Destfile must be set."); - } - - if (null == mystartTag && null == mystartDate) { - throw new BuildException("Start tag or start date must be set."); - } - - if (null != mystartTag && null != mystartDate) { - throw new BuildException("Only one of start tag and start date " - + "must be set."); - } - - if (null == myendTag && null == myendDate) { - throw new BuildException("End tag or end date must be set."); - } - - if (null != myendTag && null != myendDate) { - throw new BuildException("Only one of end tag and end date must " - + "be set."); - } - } - - /** - * collects package names from the package attribute and nested - * module elements. - */ - private void handlePackageNames() { - if (mypackage != null) { - // support multiple packages - StringTokenizer myTokenizer = new StringTokenizer(mypackage); - while (myTokenizer.hasMoreTokens()) { - String pack = myTokenizer.nextToken(); - packageNames.add(pack); - addCommandArgument(pack); - } - } - for (Iterator iter = getModules().iterator(); iter.hasNext();) { - AbstractCvsTask.Module m = (AbstractCvsTask.Module) iter.next(); - packageNames.add(m.getName()); - // will be added to command line in super.execute() - } - packageNamePrefixes = new String[packageNames.size()]; - packageNamePrefixLengths = new int[packageNames.size()]; - for (int i = 0; i < packageNamePrefixes.length; i++) { - packageNamePrefixes[i] = FILE_STRING + packageNames.get(i) + "/"; - packageNamePrefixLengths[i] = packageNamePrefixes[i].length(); - } - } - - - /** - * removes a "File: module/" prefix if present. - * - * @return null if the line was shorter than expected. - */ - private static String removePackageName(String line, - String[] packagePrefixes, - int[] prefixLengths) { - if (line.length() < FILE_STRING_LENGTH) { - return null; - } - boolean matched = false; - for (int i = 0; i < packagePrefixes.length; i++) { - if (line.startsWith(packagePrefixes[i])) { - matched = true; - line = line.substring(prefixLengths[i]); - break; - } - } - if (!matched) { - line = line.substring(FILE_STRING_LENGTH); - } - return line; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagEntry.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagEntry.java deleted file mode 100644 index 6e349c7d..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagEntry.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.cvslib; - -/** - * Holds the information of a line of rdiff - */ -public class CvsTagEntry { - - /** the filename */ - private String filename; - - /** the previous revision */ - private String prevRevision; - - /** the revision */ - private String revision; - - /** - * Creates a new CvsTagEntry - * @param filename the filename to add - */ - public CvsTagEntry(final String filename) { - this(filename, null, null); - } - - /** - * Creates a new CvsTagEntry - * @param filename the filename to add - * @param revision the revision - */ - public CvsTagEntry(final String filename, final String revision) { - this(filename, revision, null); - } - - /** - * Creates a new CvsTagEntry - * @param filename the filename to add - * @param revision the revision - * @param prevRevision the previous revision - */ - public CvsTagEntry(final String filename, final String revision, - final String prevRevision) { - this.filename = filename; - this.revision = revision; - this.prevRevision = prevRevision; - } - - /** - * Gets the filename for this CvsTagEntry - * @return the filename - */ - public String getFile() { - return filename; - } - - /** - * Gets the revision for this CvsTagEntry - * @return the revision - */ - public String getRevision() { - return revision; - } - - /** - * Gets the previous revision for this CvsTagEntry - * @return the previous revision - */ - public String getPreviousRevision() { - return prevRevision; - } - - /** - * Gets a String containing filename and difference from previous version - * @return a string representation of this CVSTagEntry - */ - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append(filename); - if (revision == null) { - buffer.append(" was removed"); - if (prevRevision != null) { - buffer.append("; previous revision was ").append(prevRevision); - } - } else if (prevRevision == null) { - buffer.append(" is new; current revision is ") - .append(revision); - } else { - buffer.append(" has changed from ") - .append(prevRevision).append(" to ").append(revision); - } - return buffer.toString(); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsUser.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsUser.java deleted file mode 100644 index 85a2fc6b..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsUser.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.cvslib; - -import org.apache.tools.ant.BuildException; - -/** - * Represents a CVS user with a userID and a full name. - * - */ -public class CvsUser { - /** The user's Id */ - private String userID; - /** The user's full name */ - private String displayName; - - - /** - * Set the user's fullname - * - * @param displayName the user's full name - */ - public void setDisplayname(final String displayName) { - this.displayName = displayName; - } - - - /** - * Set the user's id - * - * @param userID the user's new id value. - */ - public void setUserid(final String userID) { - this.userID = userID; - } - - - /** - * Get the user's id. - * - * @return The userID value - */ - public String getUserID() { - return userID; - } - - - /** - * Get the user's full name - * - * @return the user's full name - */ - public String getDisplayname() { - return displayName; - } - - - /** - * Validate that this object is configured. - * - * @exception BuildException if the instance has not be correctly - * configured. - */ - public void validate() throws BuildException { - if (null == userID) { - final String message = "Username attribute must be set."; - - throw new BuildException(message); - } - if (null == displayName) { - final String message = - "Displayname attribute must be set for userID " + userID; - - throw new BuildException(message); - } - } -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java deleted file mode 100644 index 618da4ec..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.cvslib; - -import java.io.ByteArrayOutputStream; -import java.util.StringTokenizer; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.AbstractCvsTask; - -/** - * 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" - * @since ant 1.6.1 - */ -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 tokenizer = new StringTokenizer(serverVersion, "."); - long counter = MULTIPLY * MULTIPLY; - long version = 0; - while (tokenizer.hasMoreTokens()) { - String s = tokenizer.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(); - log("Received version response \"" + output + "\"", - Project.MSG_DEBUG); - StringTokenizer st = new StringTokenizer(output); - boolean client = false; - boolean server = false; - String cvs = null; - String cachedVersion = null; - boolean haveReadAhead = false; - while (haveReadAhead || st.hasMoreTokens()) { - String currentToken = haveReadAhead ? cachedVersion : st.nextToken(); - haveReadAhead = false; - if (currentToken.equals("Client:")) { - client = true; - } else if (currentToken.equals("Server:")) { - server = true; - } else if (currentToken.startsWith("(CVS") - && currentToken.endsWith(")")) { - cvs = currentToken.length() == 5 ? "" : " " + currentToken; - } - if (!client && !server && cvs != null - && cachedVersion == null && st.hasMoreTokens()) { - cachedVersion = st.nextToken(); - haveReadAhead = true; - } else if (client && cvs != null) { - if (st.hasMoreTokens()) { - clientVersion = st.nextToken() + cvs; - } - client = false; - cvs = null; - } else if (server && cvs != null) { - if (st.hasMoreTokens()) { - serverVersion = st.nextToken() + cvs; - } - server = false; - cvs = null; - } else if (currentToken.equals("(client/server)") - && cvs != null && cachedVersion != null - && !client && !server) { - client = server = true; - clientVersion = serverVersion = cachedVersion + cvs; - cachedVersion = cvs = null; - } - } - if (clientVersionProperty != null) { - getProject().setNewProperty(clientVersionProperty, clientVersion); - } - if (serverVersionProperty != null) { - getProject().setNewProperty(serverVersionProperty, serverVersion); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/RCSFile.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/RCSFile.java deleted file mode 100644 index 70a8cf36..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/RCSFile.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.cvslib; - -/** - * Represents a RCS File change. - * - */ -class RCSFile { - private String name; - private String revision; - private String previousRevision; - - - RCSFile(final String name, final String rev) { - this(name, rev, null); - } - - - RCSFile(final String name, - final String revision, - final String previousRevision) { - this.name = name; - this.revision = revision; - if (!revision.equals(previousRevision)) { - this.previousRevision = previousRevision; - } - } - - /** - * Gets the name of the RCSFile - * @return name of the file - */ - String getName() { - return name; - } - - /** - * Gets the revision number of the RCSFile - * @return the revision number (as String) - */ - String getRevision() { - return revision; - } - - /** - * Gets the previous revision of the RCSFile - * @return the previous revision number (as String) - */ - String getPreviousRevision() { - return previousRevision; - } -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingOutputStream.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingOutputStream.java deleted file mode 100644 index f2b61cf9..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingOutputStream.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.cvslib; - -import org.apache.tools.ant.util.LineOrientedOutputStream; - -/** - * A dummy stream that just passes stuff to the parser. - */ -class RedirectingOutputStream extends LineOrientedOutputStream { - private final ChangeLogParser parser; - - /** - * Creates a new instance of this class. - * - * @param parser the parser to which output is sent. - */ - public RedirectingOutputStream(final ChangeLogParser parser) { - this.parser = parser; - } - - /** - * Logs a line to the log system of ant. - * - * @param line the line to log. - */ - protected void processLine(final String line) { - parser.stdout(line); - } -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingStreamHandler.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingStreamHandler.java deleted file mode 100644 index 713de0c4..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingStreamHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.cvslib; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.taskdefs.PumpStreamHandler; - -/** - * A dummy stream handler that just passes stuff to the parser. - * - */ -class RedirectingStreamHandler - extends PumpStreamHandler { - RedirectingStreamHandler(final ChangeLogParser parser) { - super(new RedirectingOutputStream(parser), - new ByteArrayOutputStream()); - } - - - String getErrors() { - try { - final ByteArrayOutputStream error - = (ByteArrayOutputStream) getErr(); - - return error.toString("ASCII"); - } catch (final Exception e) { - return null; - } - } - - - public void stop() { - super.stop(); - try { - getErr().close(); - getOut().close(); - } catch (final IOException e) { - // plain impossible - throw new BuildException(e); - } - } -} - |