Package org.tmatesoft.svn.core.wc
Class DefaultSVNDiffGenerator
java.lang.Object
org.tmatesoft.svn.core.wc.DefaultSVNDiffGenerator
- All Implemented Interfaces:
ISVNDiffGenerator
DefaultSVNDiffGenerator is a default implementation of
ISVNDiffGenerator.
By default, if there's no any specified implementation of the diff generator's
interface, SVNKit uses this default implementation. To set a custom
diff driver use setDiffGenerator().
- Since:
- 1.2
- Version:
- 1.3
- Author:
- TMate Software Ltd.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final InputStreamprotected static final Stringprotected static final Stringprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a temporary directory for diff files.voiddisplayAddedDirectory(String path, String rev1, String rev2) Does nothing.protected voiddisplayBinary(OutputStream os, String mimeType1, String mimeType2) voiddisplayDeletedDirectory(String path, String rev1, String rev2) Does nothing.voiddisplayFileDiff(String path, File file1, File file2, String rev1, String rev2, String mimeType1, String mimeType2, OutputStream result) Writes the difference betweenfile1andfile2as they are seen inrev1andrev2toresult.protected booleandisplayHeader(OutputStream os, String path, boolean deleted) protected voiddisplayHeaderFields(OutputStream os, String label1, String label2) voiddisplayPropDiff(String path, SVNProperties baseProps, SVNProperties diff, OutputStream result) Produces properties difference and writes it toresult.protected FileGets the diff options that are used by this generator.protected StringgetDisplayPath(String path) Returns the encoding used for diff output.byte[]getEOL()Returns the EOL marker bytes being in use.protected StringReturns the encoding specified by svnkit.global-charset option of the global configuration.protected Stringprotected ISVNOptionsbooleanSays whether this generator is using any special (non-native) charset for outputting diffs.booleanhasEOL()Says whether this generator is using any special (non-native) EOL bytes for outputting diffs.voidInitializes this generator with old and new diff anchor paths.booleanTells whether added files must be diffed also.booleanTells whether deleted files must be diffed also.booleanTells whether deleted files must be diffed also.booleanSays if unversioned files are also diffed or ignored.booleanTells if this generator forced binary files diff.protected booleanisHeaderForced(File file1, File file2) voidsetBasePath(File basePath) Sets the base path that must be stripped from the front of the paths of compared files.voidsetDiffAdded(boolean isDiffAdded) Enables or disables diffing added files.voidsetDiffCopied(boolean isDiffCopied) Enables or disables copied files diffing.voidsetDiffDeleted(boolean isDiffDeleted) Enables or disables diffing deleted files.voidsetDiffOptions(SVNDiffOptions options) Sets diff options containing diff rules.voidsetDiffUnversioned(boolean diffUnversioned) Includes or not unversioned files into diff processing.voidsetEncoding(String encoding) Sets the encoding to use for diff output.voidsetEOL(byte[] eol) Sets the EOL bytes to use in diff output.voidsetExternalDiffCommand(String command) Sets an external diff program for producing the difference between files.voidsetFallbackToAbsolutePath(boolean fallback) Controls whether error is reported on failure to compute relative display path, or absolute path is used instead.voidsetForcedBinaryDiff(boolean forced) Sets whether binary files diff must be forced or not.voidsetOptions(ISVNOptions options) Sets global run-time options.voidsetRawDiffOptions(Collection options) Sets a collection of raw (String) diff options.protected boolean
-
Field Details
-
PROPERTIES_SEPARATOR
- See Also:
-
HEADER_SEPARATOR
- See Also:
-
WC_REVISION_LABEL
- See Also:
-
EMPTY_FILE_IS
-
-
Constructor Details
-
DefaultSVNDiffGenerator
public DefaultSVNDiffGenerator()Constructs a DefaultSVNDiffGenerator.
-
-
Method Details
-
init
Initializes this generator with old and new diff anchor paths.- Specified by:
initin interfaceISVNDiffGenerator- Parameters:
anchorPath1- an old path/URLanchorPath2- a new path/URL
-
setDiffOptions
Sets diff options containing diff rules.- Parameters:
options- diff options
-
setRawDiffOptions
Sets a collection of raw (String) diff options.- Parameters:
options- raw options
-
setOptions
Sets global run-time options.- Parameters:
options- options implementation
-
setExternalDiffCommand
Sets an external diff program for producing the difference between files.- Parameters:
command- external diff program
-
setBasePath
Sets the base path that must be stripped from the front of the paths of compared files. IfbasePathis not null but is not a parent path of the target, this will lead to an error during diff. Note:basePathdoesn't affect the path index generated by external diff programs.- Specified by:
setBasePathin interfaceISVNDiffGenerator- Parameters:
basePath- common parent path to strip off the displayed paths
-
setFallbackToAbsolutePath
public void setFallbackToAbsolutePath(boolean fallback) Controls whether error is reported on failure to compute relative display path, or absolute path is used instead.- Parameters:
fallback- true to make generator use absolute path when relative path could not be computed.
-
setDiffDeleted
public void setDiffDeleted(boolean isDiffDeleted) Enables or disables diffing deleted files.- Specified by:
setDiffDeletedin interfaceISVNDiffGenerator- Parameters:
isDiffDeleted-- See Also:
-
isDiffDeleted
public boolean isDiffDeleted()Tells whether deleted files must be diffed also.- Specified by:
isDiffDeletedin interfaceISVNDiffGenerator- Returns:
- true if deleted files must be diffed also
- See Also:
-
setDiffAdded
public void setDiffAdded(boolean isDiffAdded) Enables or disables diffing added files.- Specified by:
setDiffAddedin interfaceISVNDiffGenerator- Parameters:
isDiffAdded-- See Also:
-
isDiffAdded
public boolean isDiffAdded()Tells whether added files must be diffed also.- Specified by:
isDiffAddedin interfaceISVNDiffGenerator- Returns:
- true if added files must be diffed also
- See Also:
-
setDiffCopied
public void setDiffCopied(boolean isDiffCopied) Enables or disables copied files diffing.- Specified by:
setDiffCopiedin interfaceISVNDiffGenerator- Parameters:
isDiffCopied-- See Also:
-
isDiffCopied
public boolean isDiffCopied()Tells whether deleted files must be diffed also.- Specified by:
isDiffCopiedin interfaceISVNDiffGenerator- Returns:
- true if copied files must be diffed also
- See Also:
-
getDiffOptions
Gets the diff options that are used by this generator. Creates a new one if none was used before.- Returns:
- diff options
-
getDisplayPath
- Throws:
SVNException
-
setForcedBinaryDiff
public void setForcedBinaryDiff(boolean forced) Sets whether binary files diff must be forced or not.- Specified by:
setForcedBinaryDiffin interfaceISVNDiffGenerator- Parameters:
forced- whether to force binary diff or not
-
isForcedBinaryDiff
public boolean isForcedBinaryDiff()Tells if this generator forced binary files diff.- Specified by:
isForcedBinaryDiffin interfaceISVNDiffGenerator- Returns:
- true if forces; otherwise false
-
displayPropDiff
public void displayPropDiff(String path, SVNProperties baseProps, SVNProperties diff, OutputStream result) throws SVNException Produces properties difference and writes it toresult.- Specified by:
displayPropDiffin interfaceISVNDiffGenerator- Parameters:
path-baseProps-diff-result-- Throws:
SVNException- in the following cases:-
exception with
SVNErrorCode.IO_ERRORerror code - if an I\O error occurred
-
getBasePath
-
displayFileDiff
public void displayFileDiff(String path, File file1, File file2, String rev1, String rev2, String mimeType1, String mimeType2, OutputStream result) throws SVNException Writes the difference betweenfile1andfile2as they are seen inrev1andrev2toresult.- Specified by:
displayFileDiffin interfaceISVNDiffGenerator- Parameters:
path-file1-file2-rev1-rev2-mimeType1-mimeType2-result-- Throws:
SVNException- in the following cases:-
exception with
SVNErrorCode.EXTERNAL_PROGRAMerror code - if an external diff program exited with an error code value different from0and1exception withSVNErrorCode.IO_ERRORerror code - if an I\O error occurred
-
setEncoding
Sets the encoding to use for diff output.- Specified by:
setEncodingin interfaceISVNDiffGenerator- Parameters:
encoding- charset name
-
getEncoding
Returns the encoding used for diff output.- Specified by:
getEncodingin interfaceISVNDiffGenerator- Returns:
- charset name
-
hasEncoding
public boolean hasEncoding()Says whether this generator is using any special (non-native) charset for outputting diffs.- Returns:
- true if yes; otherwise false
-
hasEOL
public boolean hasEOL()Says whether this generator is using any special (non-native) EOL bytes for outputting diffs.- Returns:
- true if yes; otherwise false
-
getGlobalEncoding
Returns the encoding specified by svnkit.global-charset option of the global configuration.- Returns:
- global charset name
-
setEOL
public void setEOL(byte[] eol) Sets the EOL bytes to use in diff output.- Specified by:
setEOLin interfaceISVNDiffGenerator- Parameters:
eol- EOL bytes
-
getEOL
public byte[] getEOL()Returns the EOL marker bytes being in use. If no EOL bytes were provided, usesnative EOLfetched from the options.- Specified by:
getEOLin interfaceISVNDiffGenerator- Returns:
- EOL bytes
-
createTempDirectory
Creates a temporary directory for diff files.- Specified by:
createTempDirectoryin interfaceISVNDiffGenerator- Returns:
- returns the temp directory
- Throws:
SVNException
-
isDiffUnversioned
public boolean isDiffUnversioned()Says if unversioned files are also diffed or ignored.By default unversioned files are ignored.
- Specified by:
isDiffUnversionedin interfaceISVNDiffGenerator- Returns:
- true if diffed, false if ignored
- See Also:
-
setDiffUnversioned
public void setDiffUnversioned(boolean diffUnversioned) Includes or not unversioned files into diff processing.If a diff operation is invoked on a versioned directory and
diffUnversionedis true then all unversioned files that may be met in the directory will be processed as added. Otherwise ifdiffUnversionedis false such files are ignored.By default unversioned files are ignored.
- Specified by:
setDiffUnversionedin interfaceISVNDiffGenerator- Parameters:
diffUnversioned- controls whether to diff unversioned files or not- See Also:
-
displayDeletedDirectory
Does nothing.- Specified by:
displayDeletedDirectoryin interfaceISVNDiffGenerator- Parameters:
path- a directory pathrev1- the first diff revisionrev2- the second diff revision- Throws:
SVNException
-
displayAddedDirectory
Does nothing.- Specified by:
displayAddedDirectoryin interfaceISVNDiffGenerator- Parameters:
path- a directory pathrev1- the first diff revisionrev2- the second diff revision- Throws:
SVNException
-
getExternalDiffCommand
-
getOptions
-
displayBinary
protected void displayBinary(OutputStream os, String mimeType1, String mimeType2) throws IOException - Throws:
IOException
-
displayHeader
- Throws:
IOException
-
displayHeaderFields
protected void displayHeaderFields(OutputStream os, String label1, String label2) throws IOException - Throws:
IOException
-
isHeaderForced
-
useLocalFileSeparatorChar
protected boolean useLocalFileSeparatorChar() -
getLabel
-