aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/blame
diff options
context:
space:
mode:
authorRonald Bhuleskar <funronald@google.com>2022-08-02 17:17:46 -0700
committerTerry Parker <tparker@google.com>2022-08-02 21:02:33 -0400
commit59e8bec6e7705a89b5d0b9c6ac004b323ffa16b0 (patch)
tree58e826198a411c1b2ac37013c9793fd872cefeea /org.eclipse.jgit/src/org/eclipse/jgit/blame
parentceb51a5e0e9db166e572ea7cd362795b4662b0cd (diff)
downloadjgit-59e8bec6e7705a89b5d0b9c6ac004b323ffa16b0.tar.gz
jgit-59e8bec6e7705a89b5d0b9c6ac004b323ffa16b0.zip
Option to pass start RevCommit to be blamed on to the BlameGenerator.
This can allow passing a FilteredRevCommit which is the filtered list of commit graph making it easier for Blame to work on. This can significantly improve blame performance since blame can skip expensive RevWalk. Change-Id: I5dab25301d6aef7df6a0bc25a4c553c730199272
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/blame')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java47
1 files changed, 34 insertions, 13 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 77967df2e5..93ddfc6607 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
@@ -129,6 +129,7 @@ public class BlameGenerator implements AutoCloseable {
/** Blame is currently assigned to this source. */
private Candidate outCandidate;
+
private Region outRegion;
/**
@@ -403,6 +404,35 @@ public class BlameGenerator implements AutoCloseable {
* revision (if the index is interesting), and finally the working tree copy
* (if the working tree is interesting).
*
+ * @param blameCommit
+ * ordered commits to use instead of RevWalk.
+ * @return {@code this}
+ * @throws java.io.IOException
+ * the repository cannot be read.
+ * @since 6.3
+ */
+ public BlameGenerator push(RevCommit blameCommit) throws IOException {
+ if (!find(blameCommit, resultPath)) {
+ return this;
+ }
+
+ Candidate c = new Candidate(getRepository(), blameCommit, resultPath);
+ c.sourceBlob = idBuf.toObjectId();
+ c.loadText(reader);
+ c.regionList = new Region(0, 0, c.sourceText.size());
+ remaining = c.sourceText.size();
+ push(c);
+ return this;
+ }
+
+ /**
+ * Push a candidate object onto the generator's traversal stack.
+ * <p>
+ * Candidates should be pushed in history order from oldest-to-newest.
+ * Applications should push the starting commit first, then the index
+ * revision (if the index is interesting), and finally the working tree copy
+ * (if the working tree is interesting).
+ *
* @param description
* description of the blob revision, such as "Working Tree".
* @param id
@@ -428,16 +458,7 @@ public class BlameGenerator implements AutoCloseable {
}
RevCommit commit = revPool.parseCommit(id);
- if (!find(commit, resultPath))
- return this;
-
- Candidate c = new Candidate(getRepository(), commit, resultPath);
- c.sourceBlob = idBuf.toObjectId();
- c.loadText(reader);
- c.regionList = new Region(0, 0, c.sourceText.size());
- remaining = c.sourceText.size();
- push(c);
- return this;
+ return push(commit);
}
/**
@@ -605,7 +626,7 @@ public class BlameGenerator implements AutoCloseable {
// Do not generate a tip of a reverse. The region
// survives and should not appear to be deleted.
- } else /* if (pCnt == 0) */{
+ } else /* if (pCnt == 0) */ {
// Root commit, with at least one surviving region.
// Assign the remaining blame here.
return result(n);
@@ -846,8 +867,8 @@ public class BlameGenerator implements AutoCloseable {
editList = new EditList(0);
} else {
p.loadText(reader);
- editList = diffAlgorithm.diff(textComparator,
- p.sourceText, n.sourceText);
+ editList = diffAlgorithm.diff(textComparator, p.sourceText,
+ n.sourceText);
}
if (editList.isEmpty()) {