Package org.tmatesoft.svn.core
Class SVNAnnotationGenerator
- java.lang.Object
-
- org.tmatesoft.svn.core.SVNAnnotationGenerator
-
- All Implemented Interfaces:
ISVNDeltaConsumer
,ISVNFileRevisionHandler
public class SVNAnnotationGenerator extends java.lang.Object implements ISVNFileRevisionHandler
The SVNAnnotationGenerator class is used to annotate files - that is to place author and revision information in-line for the specified file.Since SVNAnnotationGenerator implements ISVNFileRevisionHandler, it is merely passed to a
getFileRevisions()
method of SVNRepository. After that you handle the resultant annotated file line-by-line providing an ISVNAnnotateHandler implementation to thereportAnnotations()
method:import org.tmatesoft.svn.core.SVNAnnotationGenerator; import org.tmatesoft.svn.core.io.SVNRepositoryFactory; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.wc.SVNAnnotateHandler; ... File tmpFile; SVNRepository repos; ISVNAnnotateHandler annotateHandler; ISVNEventHandler cancelHandler; long startRev = 0; long endRev = 150; ... SVNAnnotationGenerator generator = new SVNAnnotationGenerator(path, tmpFile, cancelHandler); try { repos.getFileRevisions("", startRev, endRev, generator); generator.reportAnnotations(annotateHandler, null); } finally { generator.dispose(); } ...
- Since:
- 1.2
- Version:
- 1.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
SVNAnnotationGenerator.BlameChunk
-
Field Summary
Fields Modifier and Type Field Description private java.util.List
myBlameChunks
private ISVNEventHandler
myCancelBaton
private java.lang.String
myCurrentAuthor
private java.util.Date
myCurrentDate
private java.io.File
myCurrentFile
private java.lang.String
myCurrentPath
private long
myCurrentRevision
private SVNDeltaProcessor
myDeltaProcessor
private SVNDiffOptions
myDiffOptions
private java.lang.String
myEncoding
private ISVNAnnotateHandler
myFileHandler
private boolean
myIncludeMergedRevisions
private boolean
myIsCurrentResultOfMerge
private boolean
myIsForce
private boolean
myIsLastRevisionReported
private boolean
myIsTmpDirCreated
private java.util.List
myMergeBlameChunks
private java.lang.String
myPath
private java.io.File
myPreviousFile
private java.io.File
myPreviousOriginalFile
private de.regnis.q.sequence.line.simplifier.QSequenceLineSimplifier
mySimplifier
private long
myStartRevision
private java.io.File
myTmpDirectory
-
Constructor Summary
Constructors Constructor Description SVNAnnotationGenerator(java.lang.String path, java.io.File tmpDirectory, long startRevision, boolean force, boolean includeMergedRevisions, SVNDiffOptions diffOptions, java.lang.String encoding, ISVNAnnotateHandler handler, ISVNEventHandler cancelBaton)
Constructs an annotation generator object.SVNAnnotationGenerator(java.lang.String path, java.io.File tmpDirectory, long startRevision, boolean force, ISVNEventHandler cancelBaton)
Constructs an annotation generator object.SVNAnnotationGenerator(java.lang.String path, java.io.File tmpDirectory, long startRevision, boolean force, SVNDiffOptions diffOptions, ISVNEventHandler cancelBaton)
Constructs an annotation generator object.SVNAnnotationGenerator(java.lang.String path, java.io.File tmpDirectory, long startRevision, ISVNEventHandler cancelBaton)
Constructs an annotation generator object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.List
addFileBlame(java.io.File previousFile, java.io.File currentFile, java.util.List chain)
void
addFileBlame(java.io.InputStream contents)
private void
adjustBlameChunks(java.util.List chain, int startIndex, int adjust)
void
applyTextDelta(java.lang.String token, java.lang.String baseChecksum)
Creates a temporary file for delta application.void
closeRevision(java.lang.String token)
Does nothing.private de.regnis.q.sequence.line.simplifier.QSequenceLineSimplifier
createSimplifier()
private void
deleteBlameChunk(int start, int length, java.util.List chain)
void
dispose()
Finalizes an annotation operation releasing resources involved by this generator.private SVNAnnotationGenerator.BlameChunk
findBlameChunk(java.util.List chain, int offset, int[] index)
private void
insertBlameChunk(long revision, java.lang.String author, java.util.Date date, java.lang.String path, int start, int length, java.util.List chain)
boolean
isLastRevisionReported()
This method is used bySVNKit
internals and is not intended for API users.private void
normalizeBlames(java.util.List chain, java.util.List mergedChain)
void
openRevision(SVNFileRevision fileRevision)
Handles a next revision.void
reportAnnotations(ISVNAnnotateHandler handler, java.lang.String inputEncoding)
Dispatches file lines along with author & revision info to the provided annotation handler.java.io.OutputStream
textDeltaChunk(java.lang.String token, SVNDiffWindow diffWindow)
Applies a next text delta chunk.void
textDeltaEnd(java.lang.String token)
Marks the end of the text delta series.
-
-
-
Field Detail
-
myTmpDirectory
private java.io.File myTmpDirectory
-
myIsTmpDirCreated
private boolean myIsTmpDirCreated
-
myPath
private java.lang.String myPath
-
myCurrentRevision
private long myCurrentRevision
-
myCurrentAuthor
private java.lang.String myCurrentAuthor
-
myCurrentDate
private java.util.Date myCurrentDate
-
myIsCurrentResultOfMerge
private boolean myIsCurrentResultOfMerge
-
myCurrentPath
private java.lang.String myCurrentPath
-
myPreviousFile
private java.io.File myPreviousFile
-
myPreviousOriginalFile
private java.io.File myPreviousOriginalFile
-
myCurrentFile
private java.io.File myCurrentFile
-
myMergeBlameChunks
private java.util.List myMergeBlameChunks
-
myBlameChunks
private java.util.List myBlameChunks
-
myDeltaProcessor
private SVNDeltaProcessor myDeltaProcessor
-
myCancelBaton
private ISVNEventHandler myCancelBaton
-
myStartRevision
private long myStartRevision
-
myIsForce
private boolean myIsForce
-
myIncludeMergedRevisions
private boolean myIncludeMergedRevisions
-
myDiffOptions
private SVNDiffOptions myDiffOptions
-
mySimplifier
private de.regnis.q.sequence.line.simplifier.QSequenceLineSimplifier mySimplifier
-
myFileHandler
private ISVNAnnotateHandler myFileHandler
-
myEncoding
private java.lang.String myEncoding
-
myIsLastRevisionReported
private boolean myIsLastRevisionReported
-
-
Constructor Detail
-
SVNAnnotationGenerator
public SVNAnnotationGenerator(java.lang.String path, java.io.File tmpDirectory, long startRevision, ISVNEventHandler cancelBaton)
Constructs an annotation generator object.This constructor is equivalent to
SVNAnnotationGenerator(path, tmpDirectory, startRevision, false, cancelBaton)
.- Parameters:
path
- a file path (relative to a repository location)tmpDirectory
- a revision to stop atstartRevision
- a start revision to begin annotation withcancelBaton
- a baton which is used to check if an operation is cancelled
-
SVNAnnotationGenerator
public SVNAnnotationGenerator(java.lang.String path, java.io.File tmpDirectory, long startRevision, boolean force, ISVNEventHandler cancelBaton)
Constructs an annotation generator object. This constructor is identical toSVNAnnotationGenerator(path, tmpDirectory, startRevision, force, new SVNDiffOptions(), cancelBaton)
.- Parameters:
path
- a file path (relative to a repository location)tmpDirectory
- a revision to stop atstartRevision
- a start revision to begin annotation withforce
- forces binary files processingcancelBaton
- a baton which is used to check if an operation is cancelled
-
SVNAnnotationGenerator
public SVNAnnotationGenerator(java.lang.String path, java.io.File tmpDirectory, long startRevision, boolean force, SVNDiffOptions diffOptions, ISVNEventHandler cancelBaton)
Constructs an annotation generator object. This constructor is identical toSVNAnnotationGenerator(path, tmpDirectory, startRevision, force, false, diffOptions, null, null, cancelBaton)
.- Parameters:
path
- a file path (relative to a repository location)tmpDirectory
- a revision to stop atstartRevision
- a start revision to begin annotation withforce
- forces binary files processingdiffOptions
- diff optionscancelBaton
- a baton which is used to check if an operation is cancelled
-
SVNAnnotationGenerator
public SVNAnnotationGenerator(java.lang.String path, java.io.File tmpDirectory, long startRevision, boolean force, boolean includeMergedRevisions, SVNDiffOptions diffOptions, java.lang.String encoding, ISVNAnnotateHandler handler, ISVNEventHandler cancelBaton)
Constructs an annotation generator object.- Parameters:
path
- a file path (relative to a repository location) or URL-encoded URLtmpDirectory
- a revision to stop atstartRevision
- a start revision to begin annotation withforce
- forces binary files processingincludeMergedRevisions
- whether to include merged revisions or notdiffOptions
- diff optionsencoding
- charset name to use to encode annotation resulthandler
- caller's annotation handler implementationcancelBaton
- a baton which is used to check if an operation is cancelled- Since:
- 1.2.0
-
-
Method Detail
-
openRevision
public void openRevision(SVNFileRevision fileRevision) throws SVNException
Handles a next revision.- Specified by:
openRevision
in interfaceISVNFileRevisionHandler
- Parameters:
fileRevision
-- Throws:
SVNException
- if one of the following occurs:- exception with
SVNErrorCode.CLIENT_IS_BINARY_FILE
error code - if the file is binary and no forcing is specified - operation is cancelled
- exception with
- See Also:
SVNFileRevision
-
closeRevision
public void closeRevision(java.lang.String token) throws SVNException
Does nothing.- Specified by:
closeRevision
in interfaceISVNFileRevisionHandler
- Parameters:
token
-- Throws:
SVNException
-
applyTextDelta
public void applyTextDelta(java.lang.String token, java.lang.String baseChecksum) throws SVNException
Creates a temporary file for delta application.- Specified by:
applyTextDelta
in interfaceISVNDeltaConsumer
- Parameters:
token
- not used in this methodbaseChecksum
- not used in this method- Throws:
SVNException
-
textDeltaChunk
public java.io.OutputStream textDeltaChunk(java.lang.String token, SVNDiffWindow diffWindow) throws SVNException
Applies a next text delta chunk.- Specified by:
textDeltaChunk
in interfaceISVNDeltaConsumer
- Parameters:
token
- not used in this methoddiffWindow
- next diff window- Returns:
- dummy output stream
- Throws:
SVNException
-
textDeltaEnd
public void textDeltaEnd(java.lang.String token) throws SVNException
Marks the end of the text delta series.- Specified by:
textDeltaEnd
in interfaceISVNDeltaConsumer
- Parameters:
token
- not used in this method- Throws:
SVNException
-
addFileBlame
public void addFileBlame(java.io.InputStream contents) throws SVNException
- Throws:
SVNException
-
isLastRevisionReported
public boolean isLastRevisionReported()
This method is used bySVNKit
internals and is not intended for API users.- Returns:
- whether the last revision was reported or not yet
- Since:
- 1.2.0
-
reportAnnotations
public void reportAnnotations(ISVNAnnotateHandler handler, java.lang.String inputEncoding) throws SVNException
Dispatches file lines along with author & revision info to the provided annotation handler.If
inputEncoding
is null then "file.encoding" system property is used.- Parameters:
handler
- an annotation handler that processes file lines with author & revision infoinputEncoding
- a desired character set (encoding) of text lines- Throws:
SVNException
-
dispose
public void dispose()
Finalizes an annotation operation releasing resources involved by this generator. Should be called afterreportAnnotations()
.
-
addFileBlame
private java.util.List addFileBlame(java.io.File previousFile, java.io.File currentFile, java.util.List chain) throws SVNException
- Throws:
SVNException
-
insertBlameChunk
private void insertBlameChunk(long revision, java.lang.String author, java.util.Date date, java.lang.String path, int start, int length, java.util.List chain)
-
deleteBlameChunk
private void deleteBlameChunk(int start, int length, java.util.List chain)
-
adjustBlameChunks
private void adjustBlameChunks(java.util.List chain, int startIndex, int adjust)
-
findBlameChunk
private SVNAnnotationGenerator.BlameChunk findBlameChunk(java.util.List chain, int offset, int[] index)
-
normalizeBlames
private void normalizeBlames(java.util.List chain, java.util.List mergedChain) throws SVNException
- Throws:
SVNException
-
createSimplifier
private de.regnis.q.sequence.line.simplifier.QSequenceLineSimplifier createSimplifier()
-
-