blame: Allow candidate to manage its setup before output
Pass in the RevWalk and let the candidate decide how to prepare itself for output. This removes the conditional for the missing sourceCommit, as candidates missing a commit can override the method with a no-op. Change-Id: I3fa19b8676dfd3c177583f8f42593b5000b5350d
This commit is contained in:
parent
6afae79901
commit
2ee4d4a2c7
|
@ -519,8 +519,7 @@ private boolean done() {
|
|||
}
|
||||
|
||||
private boolean result(Candidate n) throws IOException {
|
||||
if (n.sourceCommit != null)
|
||||
revPool.parseBody(n.sourceCommit);
|
||||
n.beginResult(revPool);
|
||||
outCandidate = n;
|
||||
outRegion = n.regionList;
|
||||
return true;
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
import org.eclipse.jgit.diff.Edit;
|
||||
import org.eclipse.jgit.diff.EditList;
|
||||
import org.eclipse.jgit.diff.RawText;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectLoader;
|
||||
|
@ -56,6 +57,7 @@
|
|||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevFlag;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.treewalk.filter.PathFilter;
|
||||
|
||||
/**
|
||||
|
@ -114,6 +116,10 @@ class Candidate {
|
|||
recursivePath = path.shouldBeRecursive();
|
||||
}
|
||||
|
||||
void beginResult(RevWalk rw) throws MissingObjectException, IOException {
|
||||
rw.parseBody(sourceCommit);
|
||||
}
|
||||
|
||||
int getParentCount() {
|
||||
return sourceCommit.getParentCount();
|
||||
}
|
||||
|
@ -405,6 +411,11 @@ static final class BlobCandidate extends Candidate {
|
|||
description = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
void beginResult(RevWalk rw) {
|
||||
// Blob candidates have nothing to prepare.
|
||||
}
|
||||
|
||||
@Override
|
||||
int getParentCount() {
|
||||
return parent != null ? 1 : 0;
|
||||
|
|
Loading…
Reference in New Issue