Merge "RevWalk: Avoid unnecessary re-parsing of commit bodies"
This commit is contained in:
commit
cb2a22a9a5
|
@ -312,5 +312,10 @@ public boolean include(RevWalk walker, RevCommit cmit)
|
|||
IncorrectObjectTypeException, IOException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,6 +81,10 @@ public RevFilter clone() {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// Do an initial run through the walk
|
||||
|
|
|
@ -136,7 +136,8 @@ RevCommit next() throws MissingObjectException,
|
|||
if ((c.flags & UNINTERESTING) != 0)
|
||||
produce = false;
|
||||
else {
|
||||
c.parseBody(walker);
|
||||
if (filter.requiresCommitBody())
|
||||
c.parseBody(walker);
|
||||
produce = filter.include(walker, c);
|
||||
}
|
||||
|
||||
|
|
|
@ -230,6 +230,11 @@ public boolean include(final RevWalk walker, final RevCommit c)
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateFollowFilter(ObjectId[] trees)
|
||||
throws MissingObjectException, IncorrectObjectTypeException,
|
||||
CorruptObjectException, IOException {
|
||||
|
|
|
@ -120,9 +120,13 @@ private static class Binary extends AndRevFilter {
|
|||
|
||||
private final RevFilter b;
|
||||
|
||||
private final boolean requiresCommitBody;
|
||||
|
||||
Binary(final RevFilter one, final RevFilter two) {
|
||||
a = one;
|
||||
b = two;
|
||||
requiresCommitBody = a.requiresCommitBody()
|
||||
|| b.requiresCommitBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -132,6 +136,11 @@ public boolean include(final RevWalk walker, final RevCommit c)
|
|||
return a.include(walker, c) && b.include(walker, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return requiresCommitBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevFilter clone() {
|
||||
return new Binary(a.clone(), b.clone());
|
||||
|
@ -146,8 +155,15 @@ public String toString() {
|
|||
private static class List extends AndRevFilter {
|
||||
private final RevFilter[] subfilters;
|
||||
|
||||
private final boolean requiresCommitBody;
|
||||
|
||||
List(final RevFilter[] list) {
|
||||
subfilters = list;
|
||||
|
||||
boolean rcb = false;
|
||||
for (RevFilter filter : subfilters)
|
||||
rcb |= filter.requiresCommitBody();
|
||||
requiresCommitBody = rcb;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -161,6 +177,11 @@ public boolean include(final RevWalk walker, final RevCommit c)
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return requiresCommitBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevFilter clone() {
|
||||
final RevFilter[] s = new RevFilter[subfilters.length];
|
||||
|
|
|
@ -134,6 +134,11 @@ public RevFilter clone() {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class Before extends CommitTimeRevFilter {
|
||||
Before(final long ts) {
|
||||
super(ts);
|
||||
|
|
|
@ -81,6 +81,11 @@ public boolean include(final RevWalk walker, final RevCommit c)
|
|||
return !a.include(walker, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return a.requiresCommitBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevFilter clone() {
|
||||
return new NotRevFilter(a.clone());
|
||||
|
|
|
@ -118,9 +118,13 @@ private static class Binary extends OrRevFilter {
|
|||
|
||||
private final RevFilter b;
|
||||
|
||||
private final boolean requiresCommitBody;
|
||||
|
||||
Binary(final RevFilter one, final RevFilter two) {
|
||||
a = one;
|
||||
b = two;
|
||||
requiresCommitBody = a.requiresCommitBody()
|
||||
|| b.requiresCommitBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -130,6 +134,11 @@ public boolean include(final RevWalk walker, final RevCommit c)
|
|||
return a.include(walker, c) || b.include(walker, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return requiresCommitBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevFilter clone() {
|
||||
return new Binary(a.clone(), b.clone());
|
||||
|
@ -144,8 +153,15 @@ public String toString() {
|
|||
private static class List extends OrRevFilter {
|
||||
private final RevFilter[] subfilters;
|
||||
|
||||
private final boolean requiresCommitBody;
|
||||
|
||||
List(final RevFilter[] list) {
|
||||
subfilters = list;
|
||||
|
||||
boolean rcb = false;
|
||||
for (RevFilter filter : subfilters)
|
||||
rcb |= filter.requiresCommitBody();
|
||||
requiresCommitBody = rcb;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -159,6 +175,11 @@ public boolean include(final RevWalk walker, final RevCommit c)
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return requiresCommitBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevFilter clone() {
|
||||
final RevFilter[] s = new RevFilter[subfilters.length];
|
||||
|
|
|
@ -131,6 +131,11 @@ public boolean include(final RevWalk walker, final RevCommit cmit)
|
|||
return compiledPattern.reset(text(cmit)).matches();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the raw text to match against.
|
||||
*
|
||||
|
|
|
@ -107,6 +107,11 @@ public RevFilter clone() {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ALL";
|
||||
|
@ -127,6 +132,11 @@ public RevFilter clone() {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NONE";
|
||||
|
@ -147,6 +157,11 @@ public RevFilter clone() {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NO_MERGES";
|
||||
|
@ -174,6 +189,11 @@ public RevFilter clone() {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MERGE_BASE";
|
||||
|
@ -189,6 +209,12 @@ public RevFilter negate() {
|
|||
return NotRevFilter.create(this);
|
||||
}
|
||||
|
||||
/** @return true if the filter needs the commit body to be parsed. */
|
||||
public boolean requiresCommitBody() {
|
||||
// Assume true to be backward compatible with prior behavior.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the supplied commit should be included in results.
|
||||
*
|
||||
|
@ -196,7 +222,8 @@ public RevFilter negate() {
|
|||
* the active walker this filter is being invoked from within.
|
||||
* @param cmit
|
||||
* the commit currently being tested. The commit has been parsed
|
||||
* and its body is available for inspection.
|
||||
* and its body is available for inspection only if the filter
|
||||
* returns true from {@link #requiresCommitBody()}.
|
||||
* @return true to include this commit in the results; false to have this
|
||||
* commit be omitted entirely from the results.
|
||||
* @throws StopWalkException
|
||||
|
|
|
@ -144,6 +144,11 @@ public boolean include(final RevWalk walker, final RevCommit c)
|
|||
IOException {
|
||||
return c.hasAll(flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class HasAny extends RevFlagFilter {
|
||||
|
@ -157,5 +162,10 @@ public boolean include(final RevWalk walker, final RevCommit c)
|
|||
IOException {
|
||||
return c.hasAny(flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,6 +104,11 @@ public boolean include(final RevWalk walker, final RevCommit cmit)
|
|||
return pattern.match(text(cmit)) >= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the raw text to match against.
|
||||
*
|
||||
|
|
|
@ -599,6 +599,11 @@ public boolean include(final RevWalk walker, final RevCommit c) {
|
|||
}
|
||||
return !remoteKnowsIsCommon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresCommitBody() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue