summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2014-04-19 19:59:21 -0700
committerShawn Pearce <spearce@spearce.org>2014-04-21 11:43:02 -0700
commit6afae79901f7d3fe7598c81f7474bc98c29909b9 (patch)
tree52db1eda5db12eb12c38250bbe2b17d445a29c89
parent4db7e8f94d3764e4ebdb51fb6f22b75d701bb248 (diff)
downloadjgit-6afae79901f7d3fe7598c81f7474bc98c29909b9.tar.gz
jgit-6afae79901f7d3fe7598c81f7474bc98c29909b9.zip
blame: Do not update candidate regionList during output
Instead of updating the candidate's regionList field to iterate through the linked list of regions, use a special purpose field in the BlameGenerator. This allows the candidate to be unmodified. Change-Id: I2cda031b59220ab603ef82050e741ecbbaa1953f
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java45
1 files changed, 24 insertions, 21 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
index 5b02ce6c92..d90d59824d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
@@ -143,7 +143,8 @@ public class BlameGenerator {
private int remaining;
/** 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
@@ -466,19 +467,19 @@ public class BlameGenerator {
*/
public boolean next() throws IOException {
// If there is a source still pending, produce the next region.
- if (currentSource != null) {
- Region r = currentSource.regionList;
- Region n = r.next;
+ if (outRegion != null) {
+ Region r = outRegion;
remaining -= r.length;
- if (n != null) {
- currentSource.regionList = n;
+ if (r.next != null) {
+ outRegion = r.next;
return true;
}
- if (currentSource.queueNext != null)
- return result(currentSource.queueNext);
+ if (outCandidate.queueNext != null)
+ return result(outCandidate.queueNext);
- currentSource = null;
+ outCandidate = null;
+ outRegion = null;
}
// If there are no lines remaining, the entire result is done,
@@ -520,7 +521,8 @@ public class BlameGenerator {
private boolean result(Candidate n) throws IOException {
if (n.sourceCommit != null)
revPool.parseBody(n.sourceCommit);
- currentSource = n;
+ outCandidate = n;
+ outRegion = n.regionList;
return true;
}
@@ -847,12 +849,12 @@ public class BlameGenerator {
* @return current revision being blamed.
*/
public RevCommit getSourceCommit() {
- return currentSource.sourceCommit;
+ return outCandidate.sourceCommit;
}
/** @return current author being blamed. */
public PersonIdent getSourceAuthor() {
- return currentSource.getAuthor();
+ return outCandidate.getAuthor();
}
/** @return current committer being blamed. */
@@ -863,12 +865,12 @@ public class BlameGenerator {
/** @return path of the file being blamed. */
public String getSourcePath() {
- return currentSource.sourcePath.getPath();
+ return outCandidate.sourcePath.getPath();
}
/** @return rename score if a rename occurred in {@link #getSourceCommit}. */
public int getRenameScore() {
- return currentSource.renameScore;
+ return outCandidate.renameScore;
}
/**
@@ -878,7 +880,7 @@ public class BlameGenerator {
* {@link #getSourcePath()}.
*/
public int getSourceStart() {
- return currentSource.regionList.sourceStart;
+ return outRegion.sourceStart;
}
/**
@@ -888,7 +890,7 @@ public class BlameGenerator {
* {@link #getSourcePath()}.
*/
public int getSourceEnd() {
- Region r = currentSource.regionList;
+ Region r = outRegion;
return r.sourceStart + r.length;
}
@@ -897,7 +899,7 @@ public class BlameGenerator {
* blamed for providing. Line numbers use 0 based indexing.
*/
public int getResultStart() {
- return currentSource.regionList.resultStart;
+ return outRegion.resultStart;
}
/**
@@ -908,7 +910,7 @@ public class BlameGenerator {
* than {@link #getResultStart()}.
*/
public int getResultEnd() {
- Region r = currentSource.regionList;
+ Region r = outRegion;
return r.resultStart + r.length;
}
@@ -919,7 +921,7 @@ public class BlameGenerator {
* {@code getSourceEnd() - getSourceStart()}.
*/
public int getRegionLength() {
- return currentSource.regionList.length;
+ return outRegion.length;
}
/**
@@ -930,7 +932,7 @@ public class BlameGenerator {
* applications will want the result contents for display to users.
*/
public RawText getSourceContents() {
- return currentSource.sourceText;
+ return outCandidate.sourceText;
}
/**
@@ -951,7 +953,8 @@ public class BlameGenerator {
public void release() {
revPool.release();
queue = null;
- currentSource = null;
+ outCandidate = null;
+ outRegion = null;
}
private boolean find(RevCommit commit, PathFilter path) throws IOException {