org.tmatesoft.svn.core.wc2
Class SvnDiff

java.lang.Object
  extended by org.tmatesoft.svn.core.wc2.SvnOperation<java.lang.Void>
      extended by org.tmatesoft.svn.core.wc2.SvnDiff
All Implemented Interfaces:
ISvnOperationOptionsProvider

public class SvnDiff
extends SvnOperation<java.lang.Void>

Represents diff operation. Produces diff output which describes the delta between target in its pegRevision, as it changed between startRevision and endRevision, or between first target at startRevision and second target at endRevision. Writes the output of the diff to output stream.

If this operation object uses DefaultSVNDiffGenerator and there was a non-null base path provided to it, the original path and modified path will have this base path stripped from the front of the respective paths. If the base path is not null but is not a parent path of the target, an exception with the SVNErrorCode.BAD_RELATIVE_PATH error code is thrown.

If noDiffDeleted or old ISVNDiffGenerator.isDiffDeleted() is true, then no diff output will be generated on deleted files.

Generated headers are encoded using ISvnDiffGenerator.getEncoding().

Diffs output will not be generated for binary files, unless ISvnDiffGenerator.isForcedBinaryDiff() is true, in which case diffs will be shown regardless of the content types.

If this operation object uses DefaultSVNDiffGenerator then a caller can set SVNDiffOptions to it which will be used to pass additional options to the diff processes invoked to compare files.

If depth is SVNDepth.INFINITY, diffs fully recursively. Else if it is SVNDepth.IMMEDIATES, diffs the named paths and their file children (if any), and diffs properties of subdirectories, but does not descend further into the subdirectories. Else if SVNDepth.FILES, behaves as if for SVNDepth.IMMEDIATES except doesn't diff properties of subdirectories. If SVNDepth.EMPTY, diffs exactly the named paths but nothing underneath them.

ignoreAncestry controls whether or not items being diffed will be checked for relatedness first. Unrelated items are typically transmitted to the editor as a deletion of one thing and the addition of another, but if this flag is false, unrelated items will be diffed as if they were related.

changeLists is a collection of String changelist names, used as a restrictive filter on items whose differences are reported; that is, doesn't generate diffs about any item unless it's a member of one of those changelists. If changeLists is empty (or null), no changelist filtering occurs.

Note: changelist filtering only applies to diffs in which at least one side of the diff represents working copy data.

If both startRevision and endRevision is either SVNRevision.WORKING or SVNRevision.BASE, then it will be a url-against-wc; otherwise, a url-against-url diff.

If startRevision is neither SVNRevision.BASE, nor SVNRevision.WORKING, nor SVNRevision.COMMITTED, and if, on the contrary, endRevision is one of the aforementioned revisions, then a wc-against-url diff is performed; if endRevision also is not one of those revision constants, then a url-against-url diff is performed. Otherwise it's a url-against-wc diff.

SvnOperation.run() method throws SVNException if one of the following is true:


Constructor Summary
protected SvnDiff(SvnOperationFactory factory)
           
 
Method Summary
protected  void ensureArgumentsAreValid()
           
 org.tmatesoft.svn.core.internal.wc2.ng.ISvnDiffGenerator getDiffGenerator()
          Returns operation's diff generator.
 SVNDiffOptions getDiffOptions()
          Returns the operation's diff options controlling white-spaces and eol-styles.
 SVNRevision getEndRevision()
           
 SvnTarget getFirstSource()
           
protected  int getMaximumTargetsCount()
           
protected  int getMinimumTargetsCount()
           
protected  java.io.File getOperationalWorkingCopy()
           
 java.io.OutputStream getOutput()
          Returns output stream where the differences will be written to.
 java.io.File getRelativeToDirectory()
           
 SvnTarget getSecondSource()
           
 SvnTarget getSource()
          Gets the diff's source with start and end revisions for one-target type of operation.
 SVNRevision getStartRevision()
           
 boolean isChangesWorkingCopy()
          Gets whether the operation changes working copy
 boolean isIgnoreAncestry()
          Returns the paths ancestry should not be noticed while calculating differences.
 boolean isIgnoreContentType()
           
 boolean isNoDiffDeleted()
          Returns whether to generate differences for deleted files.
 boolean isShowCopiesAsAdds()
          Returns whether to report copies and moves as it were adds.
 boolean isUseGitDiffFormat()
          Returns whether to report in Git diff format.
 void setDiffGenerator(org.tmatesoft.svn.core.internal.wc2.ng.ISvnDiffGenerator diffGenerator)
          Sets operation's diff generator.
 void setDiffGenerator(ISVNDiffGenerator diffGenerator)
          Sets operation's diff generator of type ISVNDiffGenerator.
 void setDiffOptions(SVNDiffOptions diffOptions)
          Sets the operation's diff options controlling white-spaces and eol-styles.
 void setIgnoreAncestry(boolean ignoreAncestry)
          Sets whether or not items being diffed should be checked for relatedness first.
 void setIgnoreContentType(boolean ignoreContentType)
           
 void setNoDiffDeleted(boolean noDiffDeleted)
          Sets whether to generate differences for deleted files.
 void setOutput(java.io.OutputStream output)
          Sets output stream where the differences will be written to.
 void setRelativeToDirectory(java.io.File relativeToDirectory)
           
 void setShowCopiesAsAdds(boolean showCopiesAsAdds)
          Sets whether to report copies and moves as it were adds.
 void setSource(SvnTarget source, SVNRevision start, SVNRevision end)
          Sets the diff's source with start and end revisions for one-source type of operation.
 void setSources(SvnTarget source1, SvnTarget source2)
          Sets both diff's sources.
 void setUseGitDiffFormat(boolean useGitDiffFormat)
          Sets whether to report in Git diff format.
 
Methods inherited from class org.tmatesoft.svn.core.wc2.SvnOperation
addTarget, cancel, ensureEnoughTargets, ensureHomohenousTargets, getApplicableChangelists, getAuthenticationManager, getCanceller, getDepth, getEventHandler, getFirstTarget, getOperationFactory, getOptions, getRepositoryPool, getRevision, getTargets, hasFileTargets, hasLocalTargets, hasRemoteTargets, initDefaults, isCancelled, isSleepForTimestamp, isUseParentWcFormat, needsHomohenousTargets, run, setApplicalbeChangelists, setDepth, setRevision, setSingleTarget, setSleepForTimestamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SvnDiff

protected SvnDiff(SvnOperationFactory factory)
Method Detail

setSource

public void setSource(SvnTarget source,
                      SVNRevision start,
                      SVNRevision end)
Sets the diff's source with start and end revisions for one-source type of operation.

Parameters:
source - source of the diff
start - start revision of the diff
end - end revision of the diff

setSources

public void setSources(SvnTarget source1,
                       SvnTarget source2)
Sets both diff's sources.

Parameters:
source1 - first source of the diff
source2 - second source of the diff

getSource

public SvnTarget getSource()
Gets the diff's source with start and end revisions for one-target type of operation.

Returns:
source of the diff

getStartRevision

public SVNRevision getStartRevision()

getEndRevision

public SVNRevision getEndRevision()

getFirstSource

public SvnTarget getFirstSource()

getSecondSource

public SvnTarget getSecondSource()

setRelativeToDirectory

public void setRelativeToDirectory(java.io.File relativeToDirectory)

getRelativeToDirectory

public java.io.File getRelativeToDirectory()

getDiffGenerator

public org.tmatesoft.svn.core.internal.wc2.ng.ISvnDiffGenerator getDiffGenerator()
Returns operation's diff generator. If not set, DefaultSVNDiffGenerator is used.

Returns:
diff generator of the operation

setDiffGenerator

public void setDiffGenerator(ISVNDiffGenerator diffGenerator)
Sets operation's diff generator of type ISVNDiffGenerator. Used for compatibility with 1.6 version.

Parameters:
diffGenerator - diff generator of the operation of type ISVNDiffGenerator

setDiffGenerator

public void setDiffGenerator(org.tmatesoft.svn.core.internal.wc2.ng.ISvnDiffGenerator diffGenerator)
Sets operation's diff generator.

Parameters:
diffGenerator - diff generator of the operation

getDiffOptions

public SVNDiffOptions getDiffOptions()
Returns the operation's diff options controlling white-spaces and eol-styles.

Returns:
diff options of the operation

setDiffOptions

public void setDiffOptions(SVNDiffOptions diffOptions)
Sets the operation's diff options controlling white-spaces and eol-styles.

Parameters:
diffOptions - diff options of the operation

getOutput

public java.io.OutputStream getOutput()
Returns output stream where the differences will be written to.

Returns:
output stream of the diff's result

setOutput

public void setOutput(java.io.OutputStream output)
Sets output stream where the differences will be written to.

Parameters:
output - output stream of the diff's result

isIgnoreAncestry

public boolean isIgnoreAncestry()
Returns the paths ancestry should not be noticed while calculating differences.

Returns:
true if the paths ancestry should not be noticed while calculating differences, otherwise false
See Also:
setIgnoreAncestry(boolean)

setIgnoreAncestry

public void setIgnoreAncestry(boolean ignoreAncestry)
Sets whether or not items being diffed should be checked for relatedness first. Unrelated items are typically transmitted to the editor as a deletion of one thing and the addition of another, but if this flag is false, unrelated items will be diffed as if they were related.

Parameters:
ignoreAncestry - true if the paths ancestry should not be noticed while calculating differences, otherwise false

isNoDiffDeleted

public boolean isNoDiffDeleted()
Returns whether to generate differences for deleted files. In 1.6 version it was ISVNDiffGenerator.isDiffDeleted().

Returns:
true if deleted files should not be diffed, otherwise false

setNoDiffDeleted

public void setNoDiffDeleted(boolean noDiffDeleted)
Sets whether to generate differences for deleted files. In 1.6 version it was ISVNDiffGenerator.setDiffDeleted(boolean).

Parameters:
noDiffDeleted - true if deleted files should not be diffed, otherwise false

isShowCopiesAsAdds

public boolean isShowCopiesAsAdds()
Returns whether to report copies and moves as it were adds.

Returns:
true if copies and moves should be reported as adds, otherwise false
Since:
1.7, SVN 1.7

setShowCopiesAsAdds

public void setShowCopiesAsAdds(boolean showCopiesAsAdds)
Sets whether to report copies and moves as it were adds.

Parameters:
showCopiesAsAdds - true if copies and moves should be reported as adds, otherwise false
Since:
1.7, SVN 1.7

isIgnoreContentType

public boolean isIgnoreContentType()

setIgnoreContentType

public void setIgnoreContentType(boolean ignoreContentType)

isUseGitDiffFormat

public boolean isUseGitDiffFormat()
Returns whether to report in Git diff format.

Returns:
true if report should be in report in Git diff format, otherwise false
Since:
1.7

setUseGitDiffFormat

public void setUseGitDiffFormat(boolean useGitDiffFormat)
Sets whether to report in Git diff format.

Parameters:
useGitDiffFormat - true if report should be in report in Git diff format, otherwise false
Since:
1.7

getMinimumTargetsCount

protected int getMinimumTargetsCount()
Overrides:
getMinimumTargetsCount in class SvnOperation<java.lang.Void>

getMaximumTargetsCount

protected int getMaximumTargetsCount()
Overrides:
getMaximumTargetsCount in class SvnOperation<java.lang.Void>

ensureArgumentsAreValid

protected void ensureArgumentsAreValid()
                                throws SVNException
Overrides:
ensureArgumentsAreValid in class SvnOperation<java.lang.Void>
Throws:
SVNException

getOperationalWorkingCopy

protected java.io.File getOperationalWorkingCopy()
Overrides:
getOperationalWorkingCopy in class SvnOperation<java.lang.Void>

isChangesWorkingCopy

public boolean isChangesWorkingCopy()
Gets whether the operation changes working copy

Overrides:
isChangesWorkingCopy in class SvnOperation<java.lang.Void>
Returns:
true if the operation changes the working copy, otherwise false