Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 355   Methods: 25
NCLOC: 133   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
P4Integrate.java 0% 0% 0% 0%
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  * Copyright (c) 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   
  * Portions of this software are based upon public domain software
 56   
  * originally written at the National Center for Supercomputing Applications,
 57   
  * University of Illinois, Urbana-Champaign.
 58   
  */
 59   
 
 60   
 package org.apache.tools.ant.taskdefs.optional.perforce;
 61   
 
 62   
 import org.apache.tools.ant.BuildException;
 63   
 
 64   
 /**
 65   
  * Integrate file(s).
 66   
  * P4Change should be used to obtain a new changelist for P4Integrate,
 67   
  * although P4Integrate can open files to the default change,
 68   
  * P4Submit cannot yet submit to it.
 69   
  * Example Usage:<br>
 70   
  * &lt;p4integrate change="${p4.change}" fromfile="//depot/project/dev/foo.txt" tofile="//depot/project/main/foo.txt" /&gt;
 71   
  *
 72   
  * @author <A HREF="mailto:levylambert@tiscali-dsl.de">Antoine Levy-Lambert</A>
 73   
  *
 74   
  * @ant.task category="scm"
 75   
  */
 76   
 
 77   
 public class P4Integrate extends P4Base {
 78   
 
 79   
     private String change = null;
 80   
     private String fromfile = null;
 81   
     private String tofile = null;
 82   
     private String branch = null;
 83   
     private boolean restoredeletedrevisions = false;
 84   
     private boolean forceintegrate = false;
 85   
     private boolean leavetargetrevision = false;
 86   
     private boolean enablebaselessmerges = false;
 87   
     private boolean simulationmode = false;
 88   
     private boolean reversebranchmappings = false;
 89   
     private boolean propagatesourcefiletype = false;
 90   
     private boolean nocopynewtargetfiles = false;
 91   
 
 92   
     /**
 93   
      * get the changelist number
 94   
      *
 95   
      * @returns the changelist number set for this task
 96   
      */
 97  0
     public String getChange() {
 98  0
         return change;
 99   
     }
 100   
 
 101   
     /**
 102   
      * set the changelist number for the operation
 103   
      *
 104   
      * @param change An existing changelist number to assign files to; optional
 105   
      * but strongly recommended.
 106   
      */
 107  0
     public void setChange(String change) {
 108  0
         this.change = change;
 109   
     }
 110   
 
 111   
     /**
 112   
      * get the from file specification
 113   
      *
 114   
      * @returns the from file specification
 115   
      */
 116  0
     public String getFromfile() {
 117  0
         return fromfile;
 118   
     }
 119   
 
 120   
     /**
 121   
      * sets the from file specification
 122   
      *
 123   
      * @param fromf the from file specification
 124   
      */
 125  0
     public void setFromfile(String fromf) {
 126  0
         this.fromfile = fromf;
 127   
     }
 128   
 
 129   
     /**
 130   
      * get the to file specification
 131   
      *
 132   
      * @returns the to file specification
 133   
      */
 134  0
     public String getTofile() {
 135  0
         return tofile;
 136   
     }
 137   
 
 138   
     /**
 139   
      * sets the to file specification
 140   
      *
 141   
      * @param tof the to file specification
 142   
      */
 143  0
     public void setTofile(String tof) {
 144  0
         this.tofile = tof;
 145   
     }
 146   
 
 147   
     /**
 148   
      * get the branch
 149   
      *
 150   
      * @returns the name of the branch
 151   
      */
 152  0
     public String getBranch() {
 153  0
         return branch;
 154   
     }
 155   
 
 156   
     /**
 157   
      * sets the branch
 158   
      *
 159   
      * @param br the name of the branch to use
 160   
      */
 161  0
     public void setBranch(String br) {
 162  0
         this.branch = br;
 163   
     }
 164   
 
 165   
     /**
 166   
      * gets the restoredeletedrevisions flag
 167   
      *
 168   
      * @returns restore deleted revisions
 169   
      */
 170  0
     public boolean isRestoreDeletedRevisions() {
 171  0
         return restoredeletedrevisions;
 172   
     }
 173   
 
 174   
     /**
 175   
      * sets the restoredeletedrevisions flag
 176   
      *
 177   
      * @param setrest value chosen for restoredeletedrevisions
 178   
      */
 179  0
     public void setRestoreDeletedRevisions(boolean setrest) {
 180  0
         this.restoredeletedrevisions = setrest;
 181   
     }
 182   
 
 183   
     /**
 184   
      * gets the forceintegrate flag
 185   
      *
 186   
      * @returns restore deleted revisions
 187   
      */
 188  0
     public boolean isForceIntegrate() {
 189  0
         return forceintegrate;
 190   
     }
 191   
 
 192   
     /**
 193   
      * sets the forceintegrate flag
 194   
      *
 195   
      * @param setrest value chosen for forceintegrate
 196   
      */
 197  0
     public void setForceIntegrate(boolean setrest) {
 198  0
         this.forceintegrate = setrest;
 199   
     }
 200   
 
 201   
     /**
 202   
      * gets the leavetargetrevision flag
 203   
      *
 204   
      * @returns flag indicating if the target revision should be preserved
 205   
      */
 206  0
     public boolean isLeaveTargetRevision() {
 207  0
         return leavetargetrevision;
 208   
     }
 209   
 
 210   
     /**
 211   
      * sets the leavetargetrevision flag
 212   
      *
 213   
      * @param setrest value chosen for leavetargetrevision
 214   
      */
 215  0
     public void setLeaveTargetRevision(boolean setrest) {
 216  0
         this.leavetargetrevision = setrest;
 217   
     }
 218   
 
 219   
     /**
 220   
      * gets the enablebaselessmerges flag
 221   
      *
 222   
      * @returns boolean indicating if baseless merges are desired
 223   
      */
 224  0
     public boolean isEnableBaselessMerges() {
 225  0
         return enablebaselessmerges;
 226   
     }
 227   
 
 228   
     /**
 229   
      * sets the enablebaselessmerges flag
 230   
      *
 231   
      * @param setrest value chosen for enablebaselessmerges
 232   
      */
 233  0
     public void setEnableBaselessMerges(boolean setrest) {
 234  0
         this.enablebaselessmerges = setrest;
 235   
     }
 236   
 
 237   
     /**
 238   
      * gets the simulationmode flag
 239   
      *
 240   
      * @returns simulation mode flag
 241   
      */
 242  0
     public boolean isSimulationMode() {
 243  0
         return simulationmode;
 244   
     }
 245   
 
 246   
     /**
 247   
      * sets the simulationmode flag
 248   
      *
 249   
      * @param setrest value chosen for simulationmode
 250   
      */
 251  0
     public void setSimulationMode(boolean setrest) {
 252  0
         this.simulationmode = setrest;
 253   
     }
 254   
     /**
 255   
      * returns the flag indicating if reverse branch mappings are sought
 256   
      *
 257   
      * @returns reversebranchmappings flag
 258   
      */
 259  0
     public boolean isReversebranchmappings() {
 260  0
         return reversebranchmappings;
 261   
     }
 262   
 
 263   
     /**
 264   
      *  sets the reversebranchmappings flag
 265   
      *
 266   
      *  @param reversebranchmappings flag indicating if reverse branch mappings are sought
 267   
      */
 268  0
     public void setReversebranchmappings(boolean reversebranchmappings) {
 269  0
         this.reversebranchmappings = reversebranchmappings;
 270   
     }
 271   
     /**
 272   
      *  returns flag indicating if propagation of source file type is sought
 273   
      *
 274   
      *  @returns flag set to true if you want to propagate source file type for existing target files
 275   
      */
 276  0
     public boolean isPropagatesourcefiletype() {
 277  0
         return propagatesourcefiletype;
 278   
     }
 279   
     /**
 280   
      *   sets flag indicating if one wants to propagate the source file type
 281   
      *
 282   
      *   @param propagatesourcefiletype set it to true if you want to change the type of existing target files according to type of source file.
 283   
      */
 284  0
     public void setPropagatesourcefiletype(boolean propagatesourcefiletype) {
 285  0
         this.propagatesourcefiletype = propagatesourcefiletype;
 286   
     }
 287   
     /**
 288   
      *   returns flag indicating if one wants to suppress the copying on the local hard disk of new target files
 289   
      *
 290   
      *   @returns flag indicating if one wants to suppress the copying on the local hard disk of new target files
 291   
      */
 292  0
     public boolean isNocopynewtargetfiles() {
 293  0
         return nocopynewtargetfiles;
 294   
     }
 295   
 
 296   
     /**
 297   
      *   sets nocopynewtargetfiles flag
 298   
      *
 299   
      *   @param nocopynewtargetfiles set it to true to gain speed in integration by not copying on the local Perforce client new target files
 300   
      */
 301  0
     public void setNocopynewtargetfiles(boolean nocopynewtargetfiles) {
 302  0
         this.nocopynewtargetfiles = nocopynewtargetfiles;
 303   
     }
 304   
 
 305   
     /**
 306   
      *  execute the p4 integrate
 307   
      */
 308  0
     public void execute() throws BuildException {
 309  0
         if (change != null) {
 310  0
             P4CmdOpts = "-c " + change;
 311   
         }
 312  0
         if (this.forceintegrate) {
 313  0
             P4CmdOpts = P4CmdOpts + " -f";
 314   
         }
 315  0
         if (this.restoredeletedrevisions) {
 316  0
                 P4CmdOpts = P4CmdOpts + " -d";
 317   
             }
 318  0
         if ( this.leavetargetrevision) {
 319  0
             P4CmdOpts = P4CmdOpts + " -h";
 320   
         }
 321  0
         if ( this.enablebaselessmerges ) {
 322  0
             P4CmdOpts = P4CmdOpts + " -i";
 323   
         }
 324  0
         if (this.simulationmode ) {
 325  0
             P4CmdOpts = P4CmdOpts + " -n";
 326   
         }
 327  0
         if ( this.reversebranchmappings ) {
 328  0
             P4CmdOpts = P4CmdOpts + " -r";
 329   
         }
 330  0
         if ( this.propagatesourcefiletype ) {
 331  0
             P4CmdOpts = P4CmdOpts + " -t";
 332   
         }
 333  0
         if ( this.nocopynewtargetfiles ) {
 334  0
             P4CmdOpts = P4CmdOpts + "-v";
 335   
         }
 336  0
         String command;
 337  0
         if (branch == null && fromfile != null && tofile != null) {
 338  0
            command = P4CmdOpts + " " + fromfile + " " + tofile;
 339   
 
 340   
         }
 341  0
         else if ( branch != null && fromfile == null && tofile != null )
 342   
             {
 343  0
             command = P4CmdOpts + " -b " + branch + " " + tofile;
 344   
         }
 345  0
         else if ( branch != null && fromfile != null )
 346   
             {
 347  0
             command = P4CmdOpts + " -b " + branch + " -s "+ fromfile + " " + tofile;
 348   
         }
 349   
         else {
 350  0
             throw new BuildException("you need to specify fromfile and tofile, or branch and tofile, or branch and fromfile, or branch and fromfile and tofile ");
 351   
         }
 352  0
         execP4Command("-s integrate " + command, new SimpleP4OutputHandler(this));
 353   
     }
 354   
 }
 355