FileDocCategorySizeDatePackage
P4Fstat.javaAPI DocApache Ant 1.706791Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs.optional.perforce

P4Fstat

public class P4Fstat extends P4Base
P4Fstat--find out which files are under Perforce control and which are not.
Example Usage:
<project name="p4fstat" default="p4fstat"
basedir="C:\dev\gnu">
<target name="p4fstat" >
<p4fstat showfilter="all">
<fileset dir="depot" includes="**\/*"/>
</p4fstat>
</target>
</project>
ant.task
category="scm"

Fields Summary
private int
changelist
private String
addCmd
private Vector
filesets
private static final int
DEFAULT_CMD_LENGTH
private int
cmdLength
private static final int
SHOW_ALL
private static final int
SHOW_EXISTING
private static final int
SHOW_NON_EXISTING
private int
show
private FStatP4OutputHandler
handler
private StringBuffer
filelist
private int
fileNum
private int
doneFileNum
private boolean
debug
private static final String
EXISTING_HEADER
private static final String
NONEXISTING_HEADER
Constructors Summary
Methods Summary
public voidaddFileset(org.apache.tools.ant.types.FileSet set)
Adds a fileset to be examined by p4fstat.

param
set the fileset to add.

        filesets.addElement(set);
    
private voidexecP4Fstat(java.lang.StringBuffer list)

        String l = list.substring(0);
        if (debug) {
            log("Executing fstat " + P4CmdOpts + " " + addCmd + l + "\n",
                Project.MSG_INFO);
        }
        execP4Command("fstat " + P4CmdOpts + " " + addCmd + l, handler);
    
public voidexecute()
Executes the p4fstat task.

throws
BuildException if no files are specified.

        handler = new FStatP4OutputHandler(this);
        if (P4View != null) {
            addCmd = P4View;
        }
        P4CmdOpts = (changelist > 0) ? ("-c " + changelist) : "";

        filelist = new StringBuffer();

        for (int i = 0; i < filesets.size(); i++) {
            FileSet fs = (FileSet) filesets.elementAt(i);
            DirectoryScanner ds = fs.getDirectoryScanner(getProject());

            String[] srcFiles = ds.getIncludedFiles();
            fileNum = srcFiles.length;

            if (srcFiles != null) {
                for (int j = 0; j < srcFiles.length; j++) {
                    File f = new File(ds.getBasedir(), srcFiles[j]);
                    filelist.append(" ").append('"").append(f.getAbsolutePath()).append('"");
                    doneFileNum++;
                    if (filelist.length() > cmdLength) {

                        execP4Fstat(filelist);
                        filelist = new StringBuffer();
                    }
                }
                if (filelist.length() > 0) {
                    execP4Fstat(filelist);
                }
            } else {
                log("No files specified to query status on!", Project.MSG_WARN);
            }
        }
        if (show == SHOW_ALL || show == SHOW_EXISTING) {
            printRes(handler.getExisting(), EXISTING_HEADER);
        }
        if (show == SHOW_ALL || show == SHOW_NON_EXISTING) {
            printRes(handler.getNonExisting(), NONEXISTING_HEADER);
        }
    
public intgetLengthOfTask()
Return the number of files seen.

return
the number of files seen.

        return fileNum;
    
intgetPasses()
Return the number of passes to make. IS THIS BEING USED?

return
number of passes (how many filesets).

        return filesets.size();
    
private voidprintRes(java.util.ArrayList ar, java.lang.String header)

        log(header, Project.MSG_INFO);
        for (int i = 0; i < ar.size(); i++) {
            log((String) ar.get(i), Project.MSG_INFO);
        }
    
public voidsetChangelist(int changelist)
Sets optionally a change list number.

param
changelist change list that one wants information about.
throws
BuildException if the change list number is negative.

        if (changelist <= 0) {
            throw new BuildException("P4FStat: Changelist# should be a "
                + "positive number");
        }
        this.changelist = changelist;
    
public voidsetShowFilter(java.lang.String filter)
Sets the filter that one wants applied.
OptionMeaning
allall files under Perforce control or not
existingonly files under Perforce control
non-existingonly files not under Perforce control or not

param
filter should be one of all|existing|non-existing.


                                              
        
        if (filter.equalsIgnoreCase("all")) {
            show = SHOW_ALL;
        } else if (filter.equalsIgnoreCase("existing")) {
            show = SHOW_EXISTING;
        } else if (filter.equalsIgnoreCase("non-existing")) {
            show = SHOW_NON_EXISTING;
        } else {
            throw new BuildException("P4Fstat: ShowFilter should be one of: "
                + "all, existing, non-existing");
        }