SVNKit Home

org.tmatesoft.svn.core.wc
Class DefaultSVNDiffGenerator

java.lang.Object
  extended by org.tmatesoft.svn.core.wc.DefaultSVNDiffGenerator
All Implemented Interfaces:
ISVNDiffGenerator

public class DefaultSVNDiffGenerator
extends Object
implements 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().

Version:
1.2.0
Author:
TMate Software Ltd.

Field Summary
protected static InputStream EMPTY_FILE_IS
           
protected static byte[] HEADER_SEPARATOR
           
protected static byte[] PROPERTIES_SEPARATOR
           
protected static String WC_REVISION_LABEL
           
 
Constructor Summary
DefaultSVNDiffGenerator()
          Constructs a DefaultSVNDiffGenerator.
 
Method Summary
 File createTempDirectory()
          Creates a temporary directory for diff files.
 void displayAddedDirectory(String path, String rev1, String rev2)
          Does nothing.
protected  void displayBinary(OutputStream os, String mimeType1, String mimeType2)
           
 void displayDeletedDirectory(String path, String rev1, String rev2)
          Does nothing.
 void displayFileDiff(String path, File file1, File file2, String rev1, String rev2, String mimeType1, String mimeType2, OutputStream result)
          Writes the difference between file1 and file2 as they are seen in rev1 and rev2 to result.
protected  boolean displayHeader(OutputStream os, String path, boolean deleted)
           
protected  void displayHeaderFields(OutputStream os, String label1, String label2)
           
 void displayPropDiff(String path, SVNProperties baseProps, SVNProperties diff, OutputStream result)
          Produces properties difference and writes it to result.
protected  File getBasePath()
           
 SVNDiffOptions getDiffOptions()
          Gets the diff options that are used by this generator.
protected  String getDisplayPath(String path)
           
 String getEncoding()
          Returns the encoding used for diff output.
 byte[] getEOL()
          Returns the EOL marker bytes being in use.
protected  String getExternalDiffCommand()
           
protected  String getLabel(String path, String revToken)
           
protected  ISVNOptions getOptions()
           
 void init(String anchorPath1, String anchorPath2)
          Initializes this generator with old and new diff anchor paths.
 boolean isDiffAdded()
          Tells whether added files must be diffed also.
 boolean isDiffCopied()
          Tells whether deleted files must be diffed also.
 boolean isDiffDeleted()
          Tells whether deleted files must be diffed also.
 boolean isDiffUnversioned()
          Says if unversioned files are also diffed or ignored.
 boolean isForcedBinaryDiff()
          Tells if this generator forced binary files diff.
protected  boolean isHeaderForced(File file1, File file2)
           
 void setBasePath(File basePath)
          Sets the base path that must be stripped from the front of the paths of compared files.
 void setDiffAdded(boolean isDiffAdded)
          Enables or disables diffing added files.
 void setDiffCopied(boolean isDiffCopied)
          Enables or disables copied files diffing.
 void setDiffDeleted(boolean isDiffDeleted)
          Enables or disables diffing deleted files.
 void setDiffOptions(SVNDiffOptions options)
          Sets diff options containing diff rules.
 void setDiffUnversioned(boolean diffUnversioned)
          Includes or not unversioned files into diff processing.
 void setEncoding(String encoding)
          Sets the encoding to use for diff output.
 void setEOL(byte[] eol)
          Sets the EOL bytes to use in diff output.
 void setExternalDiffCommand(String command)
          Sets an external diff program for producing the difference between files.
 void setForcedBinaryDiff(boolean forced)
          Sets whether binary files diff must be forced or not.
 void setOptions(ISVNOptions options)
          Sets global run-time options.
 void setRawDiffOptions(Collection options)
          Sets a collection of raw (String) diff options.
protected  boolean useLocalFileSeparatorChar()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTIES_SEPARATOR

protected static final byte[] PROPERTIES_SEPARATOR

HEADER_SEPARATOR

protected static final byte[] HEADER_SEPARATOR

WC_REVISION_LABEL

protected static final String WC_REVISION_LABEL
See Also:
Constant Field Values

EMPTY_FILE_IS

protected static final InputStream EMPTY_FILE_IS
Constructor Detail

DefaultSVNDiffGenerator

public DefaultSVNDiffGenerator()
Constructs a DefaultSVNDiffGenerator.

Method Detail

init

public void init(String anchorPath1,
                 String anchorPath2)
Initializes this generator with old and new diff anchor paths.

Specified by:
init in interface ISVNDiffGenerator
Parameters:
anchorPath1 - an old path/URL
anchorPath2 - a new path/URL

setDiffOptions

public void setDiffOptions(SVNDiffOptions options)
Sets diff options containing diff rules.

Parameters:
options - diff options

setRawDiffOptions

public void setRawDiffOptions(Collection options)
Sets a collection of raw (String) diff options.

Parameters:
options - raw options

setOptions

public void setOptions(ISVNOptions options)
Sets global run-time options.

Parameters:
options - options implementation

setExternalDiffCommand

public void setExternalDiffCommand(String command)
Sets an external diff program for producing the difference between files.

Parameters:
command - external diff program

setBasePath

public void setBasePath(File basePath)
Sets the base path that must be stripped from the front of the paths of compared files. If basePath is not null but is not a parent path of the target, this will lead to an error during diff.

Note: basePath doesn't affect the path index generated by external diff programs.

Specified by:
setBasePath in interface ISVNDiffGenerator
Parameters:
basePath - common parent path to strip off the displayed paths

setDiffDeleted

public void setDiffDeleted(boolean isDiffDeleted)
Enables or disables diffing deleted files.

Specified by:
setDiffDeleted in interface ISVNDiffGenerator
Parameters:
isDiffDeleted -
See Also:
ISVNDiffGenerator.isDiffDeleted()

isDiffDeleted

public boolean isDiffDeleted()
Tells whether deleted files must be diffed also.

Specified by:
isDiffDeleted in interface ISVNDiffGenerator
Returns:
true if deleted files must be diffed also
See Also:
ISVNDiffGenerator.setDiffDeleted(boolean)

setDiffAdded

public void setDiffAdded(boolean isDiffAdded)
Enables or disables diffing added files.

Specified by:
setDiffAdded in interface ISVNDiffGenerator
Parameters:
isDiffAdded -
See Also:
ISVNDiffGenerator.isDiffAdded()

isDiffAdded

public boolean isDiffAdded()
Tells whether added files must be diffed also.

Specified by:
isDiffAdded in interface ISVNDiffGenerator
Returns:
true if added files must be diffed also
See Also:
ISVNDiffGenerator.setDiffAdded(boolean)

setDiffCopied

public void setDiffCopied(boolean isDiffCopied)
Enables or disables copied files diffing.

Specified by:
setDiffCopied in interface ISVNDiffGenerator
Parameters:
isDiffCopied -
See Also:
ISVNDiffGenerator.isDiffCopied()

isDiffCopied

public boolean isDiffCopied()
Tells whether deleted files must be diffed also.

Specified by:
isDiffCopied in interface ISVNDiffGenerator
Returns:
true if copied files must be diffed also
See Also:
ISVNDiffGenerator.setDiffCopied(boolean)

getDiffOptions

public SVNDiffOptions getDiffOptions()
Gets the diff options that are used by this generator. Creates a new one if none was used before.

Returns:
diff options

getDisplayPath

protected String getDisplayPath(String path)
                         throws SVNException
Throws:
SVNException

setForcedBinaryDiff

public void setForcedBinaryDiff(boolean forced)
Sets whether binary files diff must be forced or not.

Specified by:
setForcedBinaryDiff in interface ISVNDiffGenerator
Parameters:
forced - whether to force binary diff or not

isForcedBinaryDiff

public boolean isForcedBinaryDiff()
Tells if this generator forced binary files diff.

Specified by:
isForcedBinaryDiff in interface ISVNDiffGenerator
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 to result.

Specified by:
displayPropDiff in interface ISVNDiffGenerator
Parameters:
path -
baseProps -
diff -
result -
Throws:
SVNException - in the following cases:

getBasePath

protected File 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 between file1 and file2 as they are seen in rev1 and rev2 to result.

Specified by:
displayFileDiff in interface ISVNDiffGenerator
Parameters:
path -
file1 -
file2 -
rev1 -
rev2 -
mimeType1 -
mimeType2 -
result -
Throws:
SVNException - in the following cases:

setEncoding

public void setEncoding(String encoding)
Sets the encoding to use for diff output.

Specified by:
setEncoding in interface ISVNDiffGenerator
Parameters:
encoding - charset name

getEncoding

public String getEncoding()
Returns the encoding used for diff output.

Specified by:
getEncoding in interface ISVNDiffGenerator
Returns:
charset name

setEOL

public void setEOL(byte[] eol)
Sets the EOL bytes to use in diff output.

Specified by:
setEOL in interface ISVNDiffGenerator
Parameters:
eol - EOL bytes

getEOL

public byte[] getEOL()
Returns the EOL marker bytes being in use. If no EOL bytes were provided, uses native EOL fetched from the options.

Specified by:
getEOL in interface ISVNDiffGenerator
Returns:
EOL bytes

createTempDirectory

public File createTempDirectory()
                         throws SVNException
Creates a temporary directory for diff files.

Specified by:
createTempDirectory in interface ISVNDiffGenerator
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:
isDiffUnversioned in interface ISVNDiffGenerator
Returns:
true if diffed, false if ignored
See Also:
setDiffUnversioned(boolean)

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 diffUnversioned is true then all unversioned files that may be met in the directory will be processed as added. Otherwise if diffUnversioned is false such files are ignored.

By default unversioned files are ignored.

Specified by:
setDiffUnversioned in interface ISVNDiffGenerator
Parameters:
diffUnversioned - controls whether to diff unversioned files or not
See Also:
isDiffUnversioned()

displayDeletedDirectory

public void displayDeletedDirectory(String path,
                                    String rev1,
                                    String rev2)
                             throws SVNException
Does nothing.

Specified by:
displayDeletedDirectory in interface ISVNDiffGenerator
Parameters:
path - a directory path
rev1 - the first diff revision
rev2 - the second diff revision
Throws:
SVNException

displayAddedDirectory

public void displayAddedDirectory(String path,
                                  String rev1,
                                  String rev2)
                           throws SVNException
Does nothing.

Specified by:
displayAddedDirectory in interface ISVNDiffGenerator
Parameters:
path - a directory path
rev1 - the first diff revision
rev2 - the second diff revision
Throws:
SVNException

getExternalDiffCommand

protected String getExternalDiffCommand()

getOptions

protected ISVNOptions getOptions()

displayBinary

protected void displayBinary(OutputStream os,
                             String mimeType1,
                             String mimeType2)
                      throws IOException
Throws:
IOException

displayHeader

protected boolean displayHeader(OutputStream os,
                                String path,
                                boolean deleted)
                         throws IOException
Throws:
IOException

displayHeaderFields

protected void displayHeaderFields(OutputStream os,
                                   String label1,
                                   String label2)
                            throws IOException
Throws:
IOException

isHeaderForced

protected boolean isHeaderForced(File file1,
                                 File file2)

useLocalFileSeparatorChar

protected boolean useLocalFileSeparatorChar()

getLabel

protected String getLabel(String path,
                          String revToken)

SVNKit Home

Copyright © 2004-2008 TMate Software Ltd. All Rights Reserved.