Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 236   Methods: 12
NCLOC: 74   Classes: 2
 
 Source file Conditionals Statements Methods TOTAL
MSVSSHISTORY.java 0% 0% 0% 0%
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
 5   
  * reserved.
 6   
  *
 7   
  * Redistribution and use in source and binary forms, with or without
 8   
  * modification, are permitted provided that the following conditions
 9   
  * are met:
 10   
  *
 11   
  * 1. Redistributions of source code must retain the above copyright
 12   
  *    notice, this list of conditions and the following disclaimer.
 13   
  *
 14   
  * 2. Redistributions in binary form must reproduce the above copyright
 15   
  *    notice, this list of conditions and the following disclaimer in
 16   
  *    the documentation and/or other materials provided with the
 17   
  *    distribution.
 18   
  *
 19   
  * 3. The end-user documentation included with the redistribution, if
 20   
  *    any, must include the following acknowlegement:
 21   
  *       "This product includes software developed by the
 22   
  *        Apache Software Foundation (http://www.apache.org/)."
 23   
  *    Alternately, this acknowlegement may appear in the software itself,
 24   
  *    if and wherever such third-party acknowlegements normally appear.
 25   
  *
 26   
  * 4. The names "Ant" and "Apache Software
 27   
  *    Foundation" must not be used to endorse or promote products derived
 28   
  *    from this software without prior written permission. For written
 29   
  *    permission, please contact apache@apache.org.
 30   
  *
 31   
  * 5. Products derived from this software may not be called "Apache"
 32   
  *    nor may "Apache" appear in their names without prior written
 33   
  *    permission of the Apache Group.
 34   
  *
 35   
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 36   
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 37   
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 38   
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 39   
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 40   
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 41   
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 42   
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 43   
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 44   
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 45   
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 46   
  * SUCH DAMAGE.
 47   
  * ====================================================================
 48   
  *
 49   
  * This software consists of voluntary contributions made by many
 50   
  * individuals on behalf of the Apache Software Foundation.  For more
 51   
  * information on the Apache Software Foundation, please see
 52   
  * <http://www.apache.org/>.
 53   
  */
 54   
 
 55   
 package org.apache.tools.ant.taskdefs.optional.vss;
 56   
 
 57   
 import java.io.File;
 58   
 import java.text.SimpleDateFormat;
 59   
 
 60   
 import org.apache.tools.ant.BuildException;
 61   
 import org.apache.tools.ant.types.Commandline;
 62   
 import org.apache.tools.ant.types.EnumeratedAttribute;
 63   
 
 64   
 /**
 65   
  * Performs History commands to Microsoft Visual SourceSafe.
 66   
  *
 67   
  * @author Balazs Fejes 2
 68   
  * @author Glenn_Twiggs@bmc.com
 69   
  * @author Jesse Stockall
 70   
  *
 71   
  * @ant.task name="vsshistory" category="scm"
 72   
  */
 73   
 public class MSVSSHISTORY extends MSVSS {
 74   
 
 75   
     /**
 76   
      * Builds a command line to execute ss.
 77   
      * @return     The constructed commandline.
 78   
      */
 79  0
     Commandline buildCmdLine() {
 80  0
         Commandline commandLine = new Commandline();
 81   
 
 82   
         // first off, make sure that we've got a command and a vssdir and a label ...
 83  0
         if (getVsspath() == null) {
 84  0
             String msg = "vsspath attribute must be set!";
 85  0
             throw new BuildException(msg, getLocation());
 86   
         }
 87   
 
 88   
         // build the command line from what we got the format is
 89   
         // ss History elements [-H] [-L] [-N] [-O] [-V] [-Y] [-#] [-?]
 90   
         // as specified in the SS.EXE help
 91  0
         commandLine.setExecutable(getSSCommand());
 92  0
         commandLine.createArgument().setValue(COMMAND_HISTORY);
 93   
 
 94   
         // VSS items
 95  0
         commandLine.createArgument().setValue(getVsspath());
 96   
         // -I-
 97  0
         commandLine.createArgument().setValue(FLAG_AUTORESPONSE_DEF);  // ignore all errors
 98   
         // -Vd
 99  0
         commandLine.createArgument().setValue(getVersionDate());
 100   
         // -VL
 101  0
         commandLine.createArgument().setValue(getVersionLabel());
 102   
         // -R
 103  0
         commandLine.createArgument().setValue(getRecursive());
 104   
         // -B / -D / -F-
 105  0
         commandLine.createArgument().setValue(getStyle());
 106   
         // -Y
 107  0
         commandLine.createArgument().setValue(getLogin());
 108   
         // -O
 109  0
         commandLine.createArgument().setValue(getOutput());
 110   
 
 111  0
         return commandLine;
 112   
     }
 113   
 
 114   
     /**
 115   
      * Flag to tell the task to recurse down the tree;
 116   
      * optional, default false.
 117   
      * @param recursive  The boolean value for recursive.
 118   
      */
 119  0
     public void setRecursive(boolean recursive) {
 120  0
         super.setInternalRecursive(recursive);
 121   
     }
 122   
 
 123   
     /**
 124   
      * Sets the username of the user whose changes we would like to see.; optional
 125   
      * @param   user The username.
 126   
      */
 127  0
     public void setUser(String user) {
 128  0
         super.setInternalUser(user);
 129   
     }
 130   
 
 131   
     /**
 132   
      * Set the Start Date for the comparison of two versions in SourceSafe
 133   
      * history.; optional
 134   
      * @param   fromDate    The start date.
 135   
      */
 136  0
     public void setFromDate(String fromDate) {
 137  0
         super.setInternalFromDate(fromDate);
 138   
     }
 139   
 
 140   
     /**
 141   
      * Set the End Date for the Comparison of two versions; optional.
 142   
      * @param   toDate    The end date.
 143   
      */
 144  0
     public void setToDate(String toDate) {
 145  0
         super.setInternalToDate(toDate);
 146   
     }
 147   
 
 148   
     /**
 149   
      * Set the Start Label; optional.
 150   
      * @param   fromLabel    The start label.
 151   
      */
 152  0
     public void setFromLabel(String fromLabel) {
 153  0
         super.setInternalFromLabel(fromLabel);
 154   
     }
 155   
 
 156   
     /**
 157   
      * Set the End label; optional.
 158   
      * @param   toLabel    The end label.
 159   
      */
 160  0
     public void setToLabel(String toLabel) {
 161  0
         super.setInternalToLabel(toLabel);
 162   
     }
 163   
 
 164   
     /**
 165   
      * Set the number of days for comparison;
 166   
      * optional.
 167   
      * <p>
 168   
      * The default value is 2 days. (maybe)
 169   
      * @param   numd    The number of days.
 170   
      */
 171  0
     public void setNumdays(int numd) {
 172  0
         super.setInternalNumDays(numd);
 173   
     }
 174   
 
 175   
     /**
 176   
      * Set the output file name for the history; optional.
 177   
      * @param   outfile The output file name.
 178   
      */
 179  0
     public void setOutput(File outfile) {
 180  0
         if (outfile != null) {
 181  0
             super.setInternalOutputFilename(outfile.getAbsolutePath());
 182   
         }
 183   
     }
 184   
 
 185   
     /**
 186   
      * Format of dates in fromDate and toDate; optional.
 187   
      * Used when calculating dates with
 188   
      * the numdays attribute.
 189   
      * This string uses the formatting rules of SimpleDateFormat.
 190   
      *  Defaults to DateFormat.SHORT.
 191   
      * @param   dateFormat  The date format.
 192   
      */
 193  0
     public void setDateFormat(String dateFormat) {
 194  0
         super.setInternalDateFormat(new SimpleDateFormat(dateFormat));
 195   
     }
 196   
 
 197   
    /**
 198   
      * Specify the output style; optional.
 199   
      *
 200   
      * @param attr valid values:
 201   
      * <ul>
 202   
      * <li>brief:    -B Display a brief history.
 203   
      * <li>codediff: -D Display line-by-line file changes.
 204   
      * <li>nofile:   -F- Do not display individual file updates in the project history.
 205   
      * <li>default:  No option specified. Display in Source Safe's default format.
 206   
      * </ul>
 207   
      */
 208  0
     public void setStyle(BriefCodediffNofile attr) {
 209  0
         String option = attr.getValue();
 210  0
         if (option.equals(STYLE_BRIEF)) {
 211  0
             super.setInternalStyle(FLAG_BRIEF);
 212  0
         } else if (option.equals(STYLE_CODEDIFF)) {
 213  0
             super.setInternalStyle(FLAG_CODEDIFF);
 214  0
         } else if (option.equals(STYLE_DEFAULT)) {
 215  0
             super.setInternalStyle("");
 216  0
         } else if (option.equals(STYLE_NOFILE)) {
 217  0
             super.setInternalStyle(FLAG_NO_FILE);
 218   
         } else {
 219  0
             throw new BuildException("Style " + attr + " unknown.", getLocation());
 220   
         }
 221   
     }
 222   
 
 223   
     /**
 224   
      * Extention of EnumeratedAttribute to hold the values for style.
 225   
      */
 226   
     public static class BriefCodediffNofile extends EnumeratedAttribute {
 227   
         /**
 228   
          * Gets the list of allowable values.
 229   
          * @return The values.
 230   
          */
 231  0
         public String[] getValues() {
 232  0
             return new String[] {STYLE_BRIEF, STYLE_CODEDIFF, STYLE_NOFILE, STYLE_DEFAULT};
 233   
         }
 234   
     }
 235   
 }
 236