diff --git a/docs/manual/OptionalTasks/vsshistory.html b/docs/manual/OptionalTasks/vsshistory.html new file mode 100644 index 000000000..dc7421614 --- /dev/null +++ b/docs/manual/OptionalTasks/vsshistory.html @@ -0,0 +1,128 @@ + + + + +Ant User Manual + + + + +

VssHistory

+

Description

+Task to perform HISTORY commands to Microsoft Visual Source Safe. +

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeValuesRequired
loginusername,passwordNo
vsspathSourceSafe pathYes
ssdirdirectory where ss.exe resides. By default the task + expects it to be in the PATH.No
serverPathdirectory where srssafe.ini resides.No
fromDateStart date for comparisonSee below
toDateStart date for comparisonSee below
fromLabelStart label for comparisonNo
toLabelStart label for comparisonNo
numdaysThe number of days for comparison.See below
outputfilenameFile to write the diff.No
recursivetrue or falseNo
stylebrief or codediff or nofile. The default is brief.No
+ +

Specifying the time-frame

+

There are different ways to specify what time-frame you wish to evaluate:

+ + + +

Examples

+
+
+<vsshistory recursive="true" 
+        fromLabel="Release1"
+        toLabel="Release2"/>
+
+
+

Shows all changes between "Release1" and "Release2".

+ +
+
+<vsshistory recursive="true" 
+        fromDate="01.01.2001"
+        toDate="31.03.2001"/>
+
+
+

Shows all changes between January 1st 2001 and March 31st 2001 (in Germany, date must be specified according to your locale).

+ +
+
+<vsshistory recursive="true" 
+        numDays="-14"
+        toDate="31.01.2001"/>
+
+
+

Shows all changes in the 14 days before January 31st 2001 (in Germany, date must be specified according to your locale).

+ +
+

Copyright © 2000,2001 Apache Software Foundation. All rights +Reserved.

+ + + + diff --git a/docs/manual/optionaltasklist.html b/docs/manual/optionaltasklist.html index 5a2608c83..87cbdb07e 100644 --- a/docs/manual/optionaltasklist.html +++ b/docs/manual/optionaltasklist.html @@ -40,6 +40,7 @@ Test
Visual Age for Java Tasks
VssGet
+VssHistory
VssLabel
diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties index 936c578a6..a19c74cb1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -91,6 +91,7 @@ ccuncheckout=org.apache.tools.ant.taskdefs.optional.clearcase.CCUnCheckout sound=org.apache.tools.ant.taskdefs.optional.sound.SoundTask junitreport=org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator vsslabel=org.apache.tools.ant.taskdefs.optional.vss.MSVSSLABEL +vsshistory=org.apache.tools.ant.taskdefs.optional.vss.MSVSSHISTORY # deprecated ant tasks (kept for back compatibility) javadoc2=org.apache.tools.ant.taskdefs.Javadoc diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java new file mode 100644 index 000000000..47ecdf063 --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java @@ -0,0 +1,409 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 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 "The Jakarta Project", "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 + * . + */ + +package org.apache.tools.ant.taskdefs.optional.vss; + +import org.apache.tools.ant.*; +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.types.EnumeratedAttribute; +import java.util.*; +import java.text.*; +/** + * Task to perform HISTORY commands to Microsoft Visual Source Safe. + *

+ * The following attributes are interpreted: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
AttributeValuesRequired
loginusername,passwordNo
vsspathSourceSafe pathYes
ssdirdirectory where ss.exe resides. By default the task + * expects it to be in the PATH.No
startdateStart date for comparisonYes
outputfilenameFile to write the diff.Yes
numdaysThe number of days for comparison. The default value is -2 days.No
recursivetrue or falseNo
stylebrief or codediff or nofile. The default is brief.No
+ * + * @author Balazs Fejes 2 + */ + +public class MSVSSHISTORY extends MSVSS { + + private String m_FromDate = null; + private String m_ToDate = null; + private String m_FromLabel = null; + private String m_ToLabel = null; + private String m_OutputFileName = null; + private String m_User = null; + private int m_NumDays = Integer.MIN_VALUE; + private String m_Style = "-B"; + private boolean m_Recursive = false; + + public static final String VALUE_FROMDATE = "~d"; + public static final String VALUE_FROMLABEL = "~L"; + + public static final String FLAG_OUTPUT = "-O"; + public static final String FLAG_USER = "-U"; + + /** + * Executes the task. + *

+ * Builds a command line to execute ss and then calls Exec's run method + * to execute the command line. + */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + int result = 0; + + // first off, make sure that we've got a command and a vssdir and a label ... + if (getVsspath() == null) { + String msg = "vsspath attribute must be set!"; + throw new BuildException(msg, location); + } + + // now look for illegal combinations of things ... + + // build the command line from what we got the format is + // ss History elements [-H] [-L] [-N] [-O] [-V] [-Y] [-#] [-?] + // as specified in the SS.EXE help + commandLine.setExecutable(getSSCommand()); + commandLine.createArgument().setValue(COMMAND_HISTORY); + + // VSS items + commandLine.createArgument().setValue(getVsspath()); + + // -I- + commandLine.createArgument().setValue("-I-"); // ignore all errors + + // -R + getRecursiveCommand(commandLine); + + // -V + // Label an existing file or project version + getVersionDateCommand(commandLine); + getVersionLabelCommand(commandLine); + + // -R + if (m_Recursive) { + commandLine.createArgument().setValue(FLAG_RECURSION); + } + + // -B / -D / -F- + commandLine.createArgument().setValue(m_Style); + + // -Y + getLoginCommand(commandLine); + + // -O + getOutputCommand(commandLine); + + System.out.println("***: " + commandLine); + + result = run(commandLine); + if ( result != 0 ) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, location); + } + + } + + /** + * Set the Start Date for the Comparison of two versions in SourceSafe History + */ + public void setFromDate(String fromDate) { + if ( fromDate.equals("") || fromDate == null ) { + m_FromDate = null; + } else { + m_FromDate = fromDate; + } + } + + /** + * Set the Start Label + */ + public void setFromLabel(String fromLabel) { + if ( fromLabel.equals("") || fromLabel == null ) { + m_FromLabel = null; + } else { + m_FromLabel = fromLabel; + } + } + + /** + * Set the End Label + */ + public void setToLabel(String toLabel) { + if ( toLabel.equals("") || toLabel == null ) { + m_ToLabel = null; + } else { + m_ToLabel = toLabel; + } + } + + /** + * Set the End Date for the Comparison of two versions in SourceSafe History + */ + public void setToDate(String toDate) { + if ( toDate.equals("") || toDate == null ) { + m_ToDate = null; + } else { + m_ToDate = toDate; + } + } + + /** + * Set the number of days to go back for Comparison + *

+ * The default value is 2 days. + */ + public void setNumdays(int numd) { + m_NumDays = numd; + } + + /** + * Set the output file name for SourceSafe output + */ + public void setOutputfilename(String outfile) { + if ( outfile.equals("") || outfile == null ) { + m_OutputFileName = null; + } else { + m_OutputFileName = outfile; + } + } + + /** + * Builds the version date command. + * @param cmd the commandline the command is to be added to + */ + private void getVersionDateCommand(Commandline cmd) throws BuildException { + if ( m_FromDate == null && m_ToDate == null && m_NumDays == Integer.MIN_VALUE) { + return; + } + + if ( m_FromDate != null && m_ToDate != null) { + cmd.createArgument().setValue(FLAG_VERSION_DATE + m_ToDate + VALUE_FROMDATE + m_FromDate); + } else if (m_ToDate != null && m_NumDays != Integer.MIN_VALUE) { + String startDate = null; + try { + startDate = calcDate(m_ToDate, m_NumDays); + } catch (ParseException ex) { + String msg = "Error parsing date: " + m_ToDate; + throw new BuildException(msg, location); + } + cmd.createArgument().setValue(FLAG_VERSION_DATE + m_ToDate + VALUE_FROMDATE + startDate); + } else if (m_FromDate != null && m_NumDays != Integer.MIN_VALUE) { + String endDate = null; + try { + endDate = calcDate(m_FromDate, m_NumDays); + } catch (ParseException ex) { + String msg = "Error parsing date: " + m_FromDate; + throw new BuildException(msg, location); + } + cmd.createArgument().setValue(FLAG_VERSION_DATE + endDate + VALUE_FROMDATE + m_FromDate); + } else { + if (m_FromDate != null) { + cmd.createArgument().setValue(FLAG_VERSION + VALUE_FROMDATE + m_FromDate); + } else { + cmd.createArgument().setValue(FLAG_VERSION_DATE + m_ToDate); + } + } + } + + /** + * Builds the version date command. + * @param cmd the commandline the command is to be added to + */ + private void getVersionLabelCommand(Commandline cmd) throws BuildException { + if ( m_FromLabel == null && m_ToLabel == null ) { + return; + } + + if ( m_FromLabel != null && m_ToLabel != null) { + cmd.createArgument().setValue(FLAG_VERSION_LABEL + m_ToLabel + VALUE_FROMLABEL + m_FromLabel); + } else if (m_FromLabel != null) { + cmd.createArgument().setValue(FLAG_VERSION + VALUE_FROMLABEL + m_FromLabel); + } else { + cmd.createArgument().setValue(FLAG_VERSION_LABEL + m_ToLabel); + } + } + + /** + * Builds the version date command. + * @param cmd the commandline the command is to be added to + */ + private void getOutputCommand(Commandline cmd) { + if ( m_OutputFileName != null) { + cmd.createArgument().setValue(FLAG_OUTPUT + m_OutputFileName); + } + } + + /** + * Builds the User command. + * @param cmd the commandline the command is to be added to + */ + private void getUserCommand(Commandline cmd) { + if ( m_User != null) { + cmd.createArgument().setValue(FLAG_USER + m_User); + } + } + + /** + * Calculates the start date for version comparison. + *

+ * Calculates the date numDay days earlier than startdate. + */ + private String calcDate(String fromDate, int numDays) throws ParseException { + String toDate = null; + Date currdate = new Date(); + Calendar calend= new GregorianCalendar(); + DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); + currdate = df.parse(fromDate); + calend.setTime(currdate); + calend.add(Calendar.DATE, numDays); + toDate = df.format(calend.getTime()); + return toDate; + } + + /** + * Set behaviour recursive or non-recursive + */ + public void setRecursive(boolean recursive) { + m_Recursive = recursive; + } + + /** + * Set the Username of the user whose changes we would like to see. + */ + public void setUser(String user) { + m_User = user; + } + + /** + * @return the 'recursive' command if the attribute was 'true', otherwise an empty string + */ + private void getRecursiveCommand(Commandline cmd) { + if ( !m_Recursive ) { + return; + } else { + cmd.createArgument().setValue(FLAG_RECURSION); + } + } + + /** + * Specify the detail of output + * + * @param option valid values: + *

+ */ + public void setStyle(BriefCodediffNofile attr) { + String option = attr.getValue(); + if (option.equals("brief")) { + m_Style = "-B"; + } else if (option.equals("codediff")) { + m_Style = "-D"; + } else { + // must be "nofile" + m_Style = "-F-"; + } + } + + public static class BriefCodediffNofile extends EnumeratedAttribute { + public String[] getValues() { + return new String[] {"brief", "codediff", "nofile"}; + } + } + + +}