com.perforce.p4java.ant.tasks
Class Diff2Task

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.perforce.p4java.ant.tasks.PerforceTask
              extended by com.perforce.p4java.ant.tasks.ServerTask
                  extended by com.perforce.p4java.ant.tasks.ClientTask
                      extended by com.perforce.p4java.ant.tasks.Diff2Task
All Implemented Interfaces:
java.lang.Cloneable

public class Diff2Task
extends ClientTask

Run diff (on the server) of two files in the depot. Both files may optionally include a revision specification; the default is to compare the head revision. Wildcards may be used, but they must match between file1 and file2. Note if using clients or labels as file arguments they must be preceded with a file path e.g. //...@mylabel //...@yourlabel.

See Also:
PerforceTask, ServerTask

Nested Class Summary
 
Nested classes/interfaces inherited from class com.perforce.p4java.ant.tasks.ServerTask
ServerTask.GlobalOption
 
Nested classes/interfaces inherited from class com.perforce.p4java.ant.tasks.PerforceTask
PerforceTask.Field, PerforceTask.File
 
Field Summary
protected  java.lang.String branch
          If not null, it causes diff2 to use the branch view to specify the pairs of files to compare.
protected  int diffContext
          If positive, specifies the number of context diff lines; if zero, lets server pick context number; if negative, no options are generated.
protected  java.lang.String file1
          The first depot file and revision specifier for diff2.
protected  IFileSpec file1FileSpec
          Left depot file and revision specifier used as input for this Perforce command.
protected  java.lang.String file2
          The second depot file and revision specifier for diff2.
protected  IFileSpec file2FileSpec
          Right depot file and revision specifier used as input for this Perforce command.
protected  boolean ignoreLineEndings
          If true, ignore line endings; corresponds to -dl.
protected  boolean ignoreWhitespace
          If true, ignore whitespace; corresponds to -dw.
protected  boolean ignoreWhitespaceChanges
          If true, ignore whitespace changes; corresponds to -db.
protected  boolean includeNonTextDiffs
          If true, diff even files with non-text (binary) types.
protected  boolean quiet
          If true, suppresses the display of the header lines of files whose content and types are identical and suppresses the actual diff for all files.
protected  boolean rcsDiffs
          If true, use RCS diff; corresponds to -dn.
protected  java.util.List<IFileDiff> retFileDiffs
          Collection of file diffs returned from the Perforce command.
protected  boolean summaryDiff
          If true, perform summary diff; corresponds to -ds.
protected  int unifiedDiff
          If true, do a unified diff; corresponds to -du[n] with -du generated for unifiedDiff == 0, -dun for unifiedDiff > 0, where "n" is of course the value of unifiedDiff.
 
Fields inherited from class com.perforce.p4java.ant.tasks.ClientTask
p4Client
 
Fields inherited from class com.perforce.p4java.ant.tasks.ServerTask
allHosts, commandOptions, globaloptions, hostName, P4_SERVER_PROTOCOL_PROPERTIES_FILE, P4_SERVER_USAGE_PROPERTIES_FILE, p4Server, programName, programVersion, protocolPropertiesFile, protocolProps, textLanguage, unsetClientName, unsetUserName, usagePropertiesFile, usageProps, workingDirectory
 
Fields inherited from class com.perforce.p4java.ant.tasks.PerforceTask
charset, client, failOnError, fields, FILE_TOKEN_REGEX_PATTERN, fileList, files, fileSpecs, LINE_PADDING, LINE_SEPARATOR, p4Messages, passwd, port, protocol, retFileSpecs, retStatusMessage, user
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
Diff2Task()
          Default constructor.
 
Method Summary
protected  void execP4Command()
          Execute the Perforce diff2 command with file spec 1, file spec 2, branch and options.
 IFileSpec getFile1FileSpec()
          Gets the file1 file spec.
 IFileSpec getFile2FileSpec()
          Gets the file2 file spec.
 java.util.List<IFileDiff> getRetFileDiffs()
          Gets the ret file diffs.
 void setBranch(java.lang.String branch)
          Sets the branch.
 void setDiffContext(int diffContext)
          Sets the diff context.
 void setFile1(java.lang.String file1)
          Sets the file1.
 void setFile2(java.lang.String file2)
          Sets the file2.
 void setGnuDiffs(boolean gnuDiffs)
          Sets the gnu diffs.
 void setIgnoreLineEndings(boolean ignoreLineEndings)
          Sets the ignore line endings.
 void setIgnoreWhitespace(boolean ignoreWhitespace)
          Sets the ignore whitespace.
 void setIgnoreWhitespaceChanges(boolean ignoreWhitespaceChanges)
          Sets the ignore whitespace changes.
 void setIncludeNonTextDiffs(boolean includeNonTextDiffs)
          Sets the include non text diffs.
 void setQuiet(boolean quiet)
          Sets the quiet.
 void setRcsDiffs(boolean rcsDiffs)
          Sets the rcs diffs.
 void setSummaryDiff(boolean summaryDiff)
          Sets the summary diff.
 void setUnifiedDiff(int unifiedDiff)
          Sets the unified diff.
 
Methods inherited from class com.perforce.p4java.ant.tasks.ClientTask
cleanupP4, getP4Client, initP4, setP4Client
 
Methods inherited from class com.perforce.p4java.ant.tasks.ServerTask
cleanupP4Server, createGlobalOption, getGlobalOptions, getP4Server, initP4Server, initP4ServerOptions, setAllHosts, setHostName, setP4Server, setProgramName, setProgramVersion, setProtocolPropertiesFile, setProtocolProps, setTextLanguage, setUnsetClientName, setUnsetUserName, setUsagePropertiesFile, setUsageProps, setWorkingDirectory
 
Methods inherited from class com.perforce.p4java.ant.tasks.PerforceTask
addFileset, createField, createFile, execute, getFields, getFiles, getFileSpecs, getRetFileSpecs, getRetStatusMessage, init, isEmpty, logChangelistSummaries, logChangelistSummary, logExtendedFileSpec, logExtendedFileSpecs, logFileDiff, logFileDiffs, logFileLineMatch, logFileLineMatches, logFileSpec, logFileSpecs, logFix, logFixes, logJob, logJobs, parseChangelist, setCharset, setClient, setFailOnError, setFiles, setPasswd, setPort, setProtocol, setUser
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file1

protected java.lang.String file1
The first depot file and revision specifier for diff2.


file2

protected java.lang.String file2
The second depot file and revision specifier for diff2.


branch

protected java.lang.String branch
If not null, it causes diff2 to use the branch view to specify the pairs of files to compare. If file arguments are also present, they can further limit the files and specify the revisions for comparison. Note that if only one file is given, it restricts the right-hand side of the branch view.


quiet

protected boolean quiet
If true, suppresses the display of the header lines of files whose content and types are identical and suppresses the actual diff for all files. Corresponds to the -q flag.


includeNonTextDiffs

protected boolean includeNonTextDiffs
If true, diff even files with non-text (binary) types. Corresponds to the -t flag.


rcsDiffs

protected boolean rcsDiffs
If true, use RCS diff; corresponds to -dn.


diffContext

protected int diffContext
If positive, specifies the number of context diff lines; if zero, lets server pick context number; if negative, no options are generated. Corresponds to -dc[n], with -dc generated for diffContext == 0, -dcn for diffContext > 0, where "n" is of course the value of diffContext.


summaryDiff

protected boolean summaryDiff
If true, perform summary diff; corresponds to -ds.


unifiedDiff

protected int unifiedDiff
If true, do a unified diff; corresponds to -du[n] with -du generated for unifiedDiff == 0, -dun for unifiedDiff > 0, where "n" is of course the value of unifiedDiff.


ignoreWhitespaceChanges

protected boolean ignoreWhitespaceChanges
If true, ignore whitespace changes; corresponds to -db.


ignoreWhitespace

protected boolean ignoreWhitespace
If true, ignore whitespace; corresponds to -dw.


ignoreLineEndings

protected boolean ignoreLineEndings
If true, ignore line endings; corresponds to -dl.


file1FileSpec

protected IFileSpec file1FileSpec
Left depot file and revision specifier used as input for this Perforce command.


file2FileSpec

protected IFileSpec file2FileSpec
Right depot file and revision specifier used as input for this Perforce command.


retFileDiffs

protected java.util.List<IFileDiff> retFileDiffs
Collection of file diffs returned from the Perforce command.

Constructor Detail

Diff2Task

public Diff2Task()
Default constructor.

Method Detail

setFile1

public void setFile1(java.lang.String file1)
Sets the file1.

Parameters:
file1 - the new file1

setFile2

public void setFile2(java.lang.String file2)
Sets the file2.

Parameters:
file2 - the new file2

setBranch

public void setBranch(java.lang.String branch)
Sets the branch.

Parameters:
branch - the new branch

setQuiet

public void setQuiet(boolean quiet)
Sets the quiet.

Parameters:
quiet - the new quiet

setIncludeNonTextDiffs

public void setIncludeNonTextDiffs(boolean includeNonTextDiffs)
Sets the include non text diffs.

Parameters:
includeNonTextDiffs - the new include non text diffs

setGnuDiffs

public void setGnuDiffs(boolean gnuDiffs)
Sets the gnu diffs.

Parameters:
gnuDiffs - the new gnu diffs

setRcsDiffs

public void setRcsDiffs(boolean rcsDiffs)
Sets the rcs diffs.

Parameters:
rcsDiffs - the new rcs diffs

setDiffContext

public void setDiffContext(int diffContext)
Sets the diff context.

Parameters:
diffContext - the new diff context

setSummaryDiff

public void setSummaryDiff(boolean summaryDiff)
Sets the summary diff.

Parameters:
summaryDiff - the new summary diff

setUnifiedDiff

public void setUnifiedDiff(int unifiedDiff)
Sets the unified diff.

Parameters:
unifiedDiff - the new unified diff

setIgnoreWhitespaceChanges

public void setIgnoreWhitespaceChanges(boolean ignoreWhitespaceChanges)
Sets the ignore whitespace changes.

Parameters:
ignoreWhitespaceChanges - the new ignore whitespace changes

setIgnoreWhitespace

public void setIgnoreWhitespace(boolean ignoreWhitespace)
Sets the ignore whitespace.

Parameters:
ignoreWhitespace - the new ignore whitespace

setIgnoreLineEndings

public void setIgnoreLineEndings(boolean ignoreLineEndings)
Sets the ignore line endings.

Parameters:
ignoreLineEndings - the new ignore line endings

getFile1FileSpec

public IFileSpec getFile1FileSpec()
Gets the file1 file spec.

Returns:
the file1 file spec

getFile2FileSpec

public IFileSpec getFile2FileSpec()
Gets the file2 file spec.

Returns:
the file2 file spec

getRetFileDiffs

public java.util.List<IFileDiff> getRetFileDiffs()
Gets the ret file diffs.

Returns:
the ret file diffs

execP4Command

protected void execP4Command()
                      throws org.apache.tools.ant.BuildException
Execute the Perforce diff2 command with file spec 1, file spec 2, branch and options. Log the returned file diffs. This command is perform on the server side.

Run diff on the Perforce server of two files in the depot.

This method corresponds closely to the standard diff2 command, and that command's documentation should be consulted for the overall and detailed semantics

Specified by:
execP4Command in class PerforceTask
Throws:
org.apache.tools.ant.BuildException - the build exception
See Also:
PerforceTask.execP4Command()


Copyright (c) 2010 Perforce Software. All rights reserved.