Package org.tmatesoft.svn.core.wc2
Class SvnDiff
- java.lang.Object
-
- org.tmatesoft.svn.core.wc2.SvnOperation<java.lang.Void>
-
- 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 betweentargetin itspegRevision, as it changed betweenstartRevisionandendRevision, or between firsttargetatstartRevisionand secondtargetatendRevision. Writes the output of the diff tooutputstream.-
If it is diff between
startRevisionandendRevisionof onetarget:Targetcan be either working copy path or URL. IfpegRevisionisinvalid, behaves identically to diff between two targets, usingtarget's path for both targets. -
If it is diff between first
targetand secondtarget: First and secondtargetscan be either working copy path or URL, but cannot be both URLs. If soUnsupportedOperationExceptionis thrown. Bothtargetsmust represent the same node kind -- that is, if firsttargetis a directory, secondtargetmust also be, and if firsttargetis a file, secondtargetmust also be.
DefaultSVNDiffGeneratorand there was a non-nullbase pathprovided 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 notnull but is not a parent path of the target, an exception with theSVNErrorCode.BAD_RELATIVE_PATHerror code is thrown. IfnoDiffDeletedor oldISVNDiffGenerator.isDiffDeleted()istrue, then no diff output will be generated on deleted files. Generated headers are encoded usingISvnDiffGenerator.getEncoding(). Diffs output will not be generated for binary files, unlessISvnDiffGenerator.isForcedBinaryDiff()istrue, in which case diffs will be shown regardless of the content types. If this operation object usesDefaultSVNDiffGeneratorthen a caller can setSVNDiffOptionsto it which will be used to pass additional options to the diff processes invoked to compare files. IfdepthisSVNDepth.INFINITY, diffs fully recursively. Else if it isSVNDepth.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 ifSVNDepth.FILES, behaves as if forSVNDepth.IMMEDIATESexcept doesn't diff properties of subdirectories. IfSVNDepth.EMPTY, diffs exactly the named paths but nothing underneath them.ignoreAncestrycontrols 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 isfalse, unrelated items will be diffed as if they were related.changeListsis a collection ofStringchangelist 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. IfchangeListsis empty (ornull), 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 bothstartRevisionandendRevisionis eitherSVNRevision.WORKINGorSVNRevision.BASE, then it will be a url-against-wc; otherwise, a url-against-url diff. IfstartRevisionis neitherSVNRevision.BASE, norSVNRevision.WORKING, norSVNRevision.COMMITTED, and if, on the contrary,endRevisionis one of the aforementioned revisions, then a wc-against-url diff is performed; ifendRevisionalso 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 throwsSVNExceptionif one of the following is true:- exception with
SVNErrorCode.CLIENT_BAD_REVISIONerror code - if either ofstartRevisionandendRevisionisinvalid; if bothstartRevisionandendRevisionare eitherSVNRevision.WORKINGorSVNRevision.BASE - exception with
SVNErrorCode.FS_NOT_FOUNDerror code -targetcan not be found in eitherstartRevisionorendRevision
- Version:
- 1.7
- Author:
- TMate Software Ltd.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSvnDiff(SvnOperationFactory factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidensureArgumentsAreValid()org.tmatesoft.svn.core.internal.wc2.ng.ISvnDiffGeneratorgetDiffGenerator()Returns operation's diff generator.SVNDiffOptionsgetDiffOptions()Returns the operation's diff options controlling white-spaces and eol-styles.SVNRevisiongetEndRevision()SvnTargetgetFirstSource()protected intgetMaximumTargetsCount()protected intgetMinimumTargetsCount()protected java.io.FilegetOperationalWorkingCopy()java.io.OutputStreamgetOutput()Returns output stream where the differences will be written to.java.io.FilegetRelativeToDirectory()SvnTargetgetSecondSource()SvnTargetgetSource()Gets the diff'ssourcewith start and end revisions for one-target type of operation.SVNRevisiongetStartRevision()booleanisChangesWorkingCopy()Gets whether the operation changes working copybooleanisIgnoreAncestry()Returns the paths ancestry should not be noticed while calculating differences.booleanisIgnoreContentType()booleanisNoDiffDeleted()Returns whether to generate differences for deleted files.booleanisRecurseIntoDeletedDirectories()booleanisShowCopiesAsAdds()Returns whether to report copies and moves as it were adds.booleanisUseGitDiffFormat()Returns whether to report in Git diff format.voidsetDiffGenerator(org.tmatesoft.svn.core.internal.wc2.ng.ISvnDiffGenerator diffGenerator)Sets operation's diff generator.voidsetDiffGenerator(ISVNDiffGenerator diffGenerator)Sets operation's diff generator of type ISVNDiffGenerator.voidsetDiffOptions(SVNDiffOptions diffOptions)Sets the operation's diff options controlling white-spaces and eol-styles.voidsetIgnoreAncestry(boolean ignoreAncestry)Sets whether or not items being diffed should be checked for relatedness first.voidsetIgnoreContentType(boolean ignoreContentType)voidsetNoDiffDeleted(boolean noDiffDeleted)Sets whether to generate differences for deleted files.voidsetOutput(java.io.OutputStream output)Sets output stream where the differences will be written to.voidsetRecurseIntoDeletedDirectories(boolean recurseIntoDeletedDirectories)voidsetRelativeToDirectory(java.io.File relativeToDirectory)voidsetShowCopiesAsAdds(boolean showCopiesAsAdds)Sets whether to report copies and moves as it were adds.voidsetSource(SvnTarget source, SVNRevision start, SVNRevision end)Sets the diff'ssourcewith start and end revisions for one-source type of operation.voidsetSources(SvnTarget source1, SvnTarget source2)Sets both diff'ssources.voidsetUseGitDiffFormat(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, getSqliteJournalMode, getTargets, hasFileTargets, hasLocalTargets, hasRemoteTargets, initDefaults, isCancelled, isSleepForTimestamp, isUseParentWcFormat, needsHomohenousTargets, run, setApplicalbeChangelists, setDepth, setRevision, setSingleTarget, setSleepForTimestamp, setSqliteJournalMode
-
-
-
-
Constructor Detail
-
SvnDiff
protected SvnDiff(SvnOperationFactory factory)
-
-
Method Detail
-
setSource
public void setSource(SvnTarget source, SVNRevision start, SVNRevision end)
Sets the diff'ssourcewith start and end revisions for one-source type of operation.- Parameters:
source- source of the diffstart- start revision of the diffend- end revision of the diff
-
setSources
public void setSources(SvnTarget source1, SvnTarget source2)
Sets both diff'ssources.- Parameters:
source1- first source of the diffsource2- second source of the diff
-
getSource
public SvnTarget getSource()
Gets the diff'ssourcewith 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,DefaultSVNDiffGeneratoris 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:
trueif the paths ancestry should not be noticed while calculating differences, otherwisefalse- 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 isfalse, unrelated items will be diffed as if they were related.- Parameters:
ignoreAncestry-trueif the paths ancestry should not be noticed while calculating differences, otherwisefalse
-
isNoDiffDeleted
public boolean isNoDiffDeleted()
Returns whether to generate differences for deleted files. In 1.6 version it wasISVNDiffGenerator.isDiffDeleted().- Returns:
trueif deleted files should not be diffed, otherwisefalse
-
setNoDiffDeleted
public void setNoDiffDeleted(boolean noDiffDeleted)
Sets whether to generate differences for deleted files. In 1.6 version it wasISVNDiffGenerator.setDiffDeleted(boolean).- Parameters:
noDiffDeleted-trueif deleted files should not be diffed, otherwisefalse
-
isShowCopiesAsAdds
public boolean isShowCopiesAsAdds()
Returns whether to report copies and moves as it were adds.- Returns:
trueif copies and moves should be reported as adds, otherwisefalse- 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-trueif copies and moves should be reported as adds, otherwisefalse- 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:
trueif report should be in report in Git diff format, otherwisefalse- Since:
- 1.7
-
setUseGitDiffFormat
public void setUseGitDiffFormat(boolean useGitDiffFormat)
Sets whether to report in Git diff format.- Parameters:
useGitDiffFormat-trueif report should be in report in Git diff format, otherwisefalse- Since:
- 1.7
-
isRecurseIntoDeletedDirectories
public boolean isRecurseIntoDeletedDirectories()
-
setRecurseIntoDeletedDirectories
public void setRecurseIntoDeletedDirectories(boolean recurseIntoDeletedDirectories)
-
getMinimumTargetsCount
protected int getMinimumTargetsCount()
- Overrides:
getMinimumTargetsCountin classSvnOperation<java.lang.Void>
-
getMaximumTargetsCount
protected int getMaximumTargetsCount()
- Overrides:
getMaximumTargetsCountin classSvnOperation<java.lang.Void>
-
ensureArgumentsAreValid
protected void ensureArgumentsAreValid() throws SVNException- Overrides:
ensureArgumentsAreValidin classSvnOperation<java.lang.Void>- Throws:
SVNException
-
getOperationalWorkingCopy
protected java.io.File getOperationalWorkingCopy()
- Overrides:
getOperationalWorkingCopyin classSvnOperation<java.lang.Void>
-
isChangesWorkingCopy
public boolean isChangesWorkingCopy()
Gets whether the operation changes working copy- Overrides:
isChangesWorkingCopyin classSvnOperation<java.lang.Void>- Returns:
trueif the operation changes the working copy, otherwisefalse
-
-