Przeglądaj źródła

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
tags/v3.4.0.201405051725-m7
Shawn Pearce 10 lat temu
rodzic
commit
2ee4d4a2c7

+ 1
- 2
org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java Wyświetl plik

@@ -519,8 +519,7 @@ public class BlameGenerator {
}

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;

+ 11
- 0
org.eclipse.jgit/src/org/eclipse/jgit/blame/Candidate.java Wyświetl plik

@@ -49,6 +49,7 @@ import org.eclipse.jgit.blame.ReverseWalk.ReverseCommit;
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.ObjectReader;
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 @@ class Candidate {
description = name;
}

@Override
void beginResult(RevWalk rw) {
// Blob candidates have nothing to prepare.
}

@Override
int getParentCount() {
return parent != null ? 1 : 0;

Ładowanie…
Anuluj
Zapisz