@ -143,7 +143,8 @@ public class BlameGenerator {
private int remaining ;
private int remaining ;
/** Blame is currently assigned to this source. */
/** Blame is currently assigned to this source. */
private Candidate currentSource ;
private Candidate outCandidate ;
private Region outRegion ;
/ * *
/ * *
* Create a blame generator for the repository and path ( relative to
* Create a blame generator for the repository and path ( relative to
@ -466,19 +467,19 @@ public class BlameGenerator {
* /
* /
public boolean next ( ) throws IOException {
public boolean next ( ) throws IOException {
// If there is a source still pending, produce the next region.
// If there is a source still pending, produce the next region.
if ( currentSource ! = null ) {
if ( outRegion ! = null ) {
Region r = currentSource . regionList ;
Region r = outRegion ;
Region n = r . next ;
remaining - = r . length ;
remaining - = r . length ;
if ( n ! = null ) {
if ( r . next ! = null ) {
currentSource . regionList = n ;
outRegion = r . next ;
return true ;
return true ;
}
}
if ( currentSourc e. queueNext ! = null )
if ( outCandidat e. queueNext ! = null )
return result ( currentSourc e. queueNext ) ;
return result ( outCandidat e. queueNext ) ;
currentSource = null ;
outCandidate = null ;
outRegion = null ;
}
}
// If there are no lines remaining, the entire result is done,
// If there are no lines remaining, the entire result is done,
@ -518,9 +519,9 @@ public class BlameGenerator {
}
}
private boolean result ( Candidate n ) throws IOException {
private boolean result ( Candidate n ) throws IOException {
if ( n . sourceCommit ! = null )
n . beginResult ( revPool ) ;
revPool . parseBody ( n . sourceCommit ) ;
outCandidate = n ;
currentSource = n ;
outRegion = n . regionList ;
return true ;
return true ;
}
}
@ -688,9 +689,8 @@ public class BlameGenerator {
revPool . parseHeaders ( parent ) ;
revPool . parseHeaders ( parent ) ;
if ( ! find ( parent , n . sourcePath ) )
if ( ! find ( parent , n . sourcePath ) )
continue ;
continue ;
if ( ! ( n instanceof ReverseCandidate ) & & idBuf . equals ( n . sourceBlob ) ) {
if ( ! ( n instanceof ReverseCandidate ) & & idBuf . equals ( n . sourceBlob ) )
return blameEntireRegionOnParent ( n , parent ) ;
return blameEntireRegionOnParent ( n , parent ) ;
}
if ( ids = = null )
if ( ids = = null )
ids = new ObjectId [ pCnt ] ;
ids = new ObjectId [ pCnt ] ;
ids [ pIdx ] = idBuf . toObjectId ( ) ;
ids [ pIdx ] = idBuf . toObjectId ( ) ;
@ -720,10 +720,8 @@ public class BlameGenerator {
// have an exact content match. For performance reasons
// have an exact content match. For performance reasons
// we choose to follow the one parent over trying to do
// we choose to follow the one parent over trying to do
// possibly both parents.
// possibly both parents.
n . sourceCommit = parent ;
n . setSourcePath ( PathFilter . create ( r . getOldPath ( ) ) ) ;
n . setSourcePath ( PathFilter . create ( r . getOldPath ( ) ) ) ;
push ( n ) ;
return blameEntireRegionOnParent ( n , parent ) ;
return false ;
}
}
renames [ pIdx ] = r ;
renames [ pIdx ] = r ;
@ -847,12 +845,12 @@ public class BlameGenerator {
* @return current revision being blamed .
* @return current revision being blamed .
* /
* /
public RevCommit getSourceCommit ( ) {
public RevCommit getSourceCommit ( ) {
return currentSourc e. sourceCommit ;
return outCandidat e. sourceCommit ;
}
}
/** @return current author being blamed. */
/** @return current author being blamed. */
public PersonIdent getSourceAuthor ( ) {
public PersonIdent getSourceAuthor ( ) {
return currentSourc e. getAuthor ( ) ;
return outCandidat e. getAuthor ( ) ;
}
}
/** @return current committer being blamed. */
/** @return current committer being blamed. */
@ -863,12 +861,12 @@ public class BlameGenerator {
/** @return path of the file being blamed. */
/** @return path of the file being blamed. */
public String getSourcePath ( ) {
public String getSourcePath ( ) {
return currentSourc e. sourcePath . getPath ( ) ;
return outCandidat e. sourcePath . getPath ( ) ;
}
}
/** @return rename score if a rename occurred in {@link #getSourceCommit}. */
/** @return rename score if a rename occurred in {@link #getSourceCommit}. */
public int getRenameScore ( ) {
public int getRenameScore ( ) {
return currentSourc e. renameScore ;
return outCandidat e. renameScore ;
}
}
/ * *
/ * *
@ -878,7 +876,7 @@ public class BlameGenerator {
* { @link # getSourcePath ( ) } .
* { @link # getSourcePath ( ) } .
* /
* /
public int getSourceStart ( ) {
public int getSourceStart ( ) {
return currentSource . regionList . sourceStart ;
return outRegion . sourceStart ;
}
}
/ * *
/ * *
@ -888,7 +886,7 @@ public class BlameGenerator {
* { @link # getSourcePath ( ) } .
* { @link # getSourcePath ( ) } .
* /
* /
public int getSourceEnd ( ) {
public int getSourceEnd ( ) {
Region r = currentSource . regionList ;
Region r = outRegion ;
return r . sourceStart + r . length ;
return r . sourceStart + r . length ;
}
}
@ -897,7 +895,7 @@ public class BlameGenerator {
* blamed for providing . Line numbers use 0 based indexing .
* blamed for providing . Line numbers use 0 based indexing .
* /
* /
public int getResultStart ( ) {
public int getResultStart ( ) {
return currentSource . regionList . resultStart ;
return outRegion . resultStart ;
}
}
/ * *
/ * *
@ -908,7 +906,7 @@ public class BlameGenerator {
* than { @link # getResultStart ( ) } .
* than { @link # getResultStart ( ) } .
* /
* /
public int getResultEnd ( ) {
public int getResultEnd ( ) {
Region r = currentSource . regionList ;
Region r = outRegion ;
return r . resultStart + r . length ;
return r . resultStart + r . length ;
}
}
@ -919,7 +917,7 @@ public class BlameGenerator {
* { @code getSourceEnd ( ) - getSourceStart ( ) } .
* { @code getSourceEnd ( ) - getSourceStart ( ) } .
* /
* /
public int getRegionLength ( ) {
public int getRegionLength ( ) {
return currentSource . regionList . length ;
return outRegion . length ;
}
}
/ * *
/ * *
@ -930,7 +928,7 @@ public class BlameGenerator {
* applications will want the result contents for display to users .
* applications will want the result contents for display to users .
* /
* /
public RawText getSourceContents ( ) {
public RawText getSourceContents ( ) {
return currentSourc e. sourceText ;
return outCandidat e. sourceText ;
}
}
/ * *
/ * *
@ -951,7 +949,8 @@ public class BlameGenerator {
public void release ( ) {
public void release ( ) {
revPool . release ( ) ;
revPool . release ( ) ;
queue = null ;
queue = null ;
currentSource = null ;
outCandidate = null ;
outRegion = null ;
}
}
private boolean find ( RevCommit commit , PathFilter path ) throws IOException {
private boolean find ( RevCommit commit , PathFilter path ) throws IOException {