Browse Source

Merge "RevWalk: Avoid unnecessary re-parsing of commit bodies"

stable-0.12
Chris Aniszczyk 14 years ago committed by Code Review
parent
commit
cb2a22a9a5
  1. 5
      org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkFilterTest.java
  2. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkResetTest.java
  3. 1
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/PendingGenerator.java
  4. 5
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteTreeFilter.java
  5. 21
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/AndRevFilter.java
  6. 5
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/CommitTimeRevFilter.java
  7. 5
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/NotRevFilter.java
  8. 21
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/OrRevFilter.java
  9. 5
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/PatternMatchRevFilter.java
  10. 29
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/RevFilter.java
  11. 10
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/RevFlagFilter.java
  12. 5
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/SubStringRevFilter.java
  13. 5
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java

5
org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkFilterTest.java

@ -312,5 +312,10 @@ public class RevWalkFilterTest extends RevWalkTestCase {
IncorrectObjectTypeException, IOException { IncorrectObjectTypeException, IOException {
return true; return true;
} }
@Override
public boolean requiresCommitBody() {
return false;
}
} }
} }

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkResetTest.java

@ -81,6 +81,10 @@ public class RevWalkResetTest extends RevWalkTestCase {
return this; return this;
} }
@Override
public boolean requiresCommitBody() {
return true;
}
}; };
// Do an initial run through the walk // Do an initial run through the walk

1
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/PendingGenerator.java

@ -136,6 +136,7 @@ class PendingGenerator extends Generator {
if ((c.flags & UNINTERESTING) != 0) if ((c.flags & UNINTERESTING) != 0)
produce = false; produce = false;
else { else {
if (filter.requiresCommitBody())
c.parseBody(walker); c.parseBody(walker);
produce = filter.include(walker, c); produce = filter.include(walker, c);
} }

5
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteTreeFilter.java

@ -230,6 +230,11 @@ class RewriteTreeFilter extends RevFilter {
return false; return false;
} }
@Override
public boolean requiresCommitBody() {
return false;
}
private void updateFollowFilter(ObjectId[] trees) private void updateFollowFilter(ObjectId[] trees)
throws MissingObjectException, IncorrectObjectTypeException, throws MissingObjectException, IncorrectObjectTypeException,
CorruptObjectException, IOException { CorruptObjectException, IOException {

21
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/AndRevFilter.java

@ -120,9 +120,13 @@ public abstract class AndRevFilter extends RevFilter {
private final RevFilter b; private final RevFilter b;
private final boolean requiresCommitBody;
Binary(final RevFilter one, final RevFilter two) { Binary(final RevFilter one, final RevFilter two) {
a = one; a = one;
b = two; b = two;
requiresCommitBody = a.requiresCommitBody()
|| b.requiresCommitBody();
} }
@Override @Override
@ -132,6 +136,11 @@ public abstract class AndRevFilter extends RevFilter {
return a.include(walker, c) && b.include(walker, c); return a.include(walker, c) && b.include(walker, c);
} }
@Override
public boolean requiresCommitBody() {
return requiresCommitBody;
}
@Override @Override
public RevFilter clone() { public RevFilter clone() {
return new Binary(a.clone(), b.clone()); return new Binary(a.clone(), b.clone());
@ -146,8 +155,15 @@ public abstract class AndRevFilter extends RevFilter {
private static class List extends AndRevFilter { private static class List extends AndRevFilter {
private final RevFilter[] subfilters; private final RevFilter[] subfilters;
private final boolean requiresCommitBody;
List(final RevFilter[] list) { List(final RevFilter[] list) {
subfilters = list; subfilters = list;
boolean rcb = false;
for (RevFilter filter : subfilters)
rcb |= filter.requiresCommitBody();
requiresCommitBody = rcb;
} }
@Override @Override
@ -161,6 +177,11 @@ public abstract class AndRevFilter extends RevFilter {
return true; return true;
} }
@Override
public boolean requiresCommitBody() {
return requiresCommitBody;
}
@Override @Override
public RevFilter clone() { public RevFilter clone() {
final RevFilter[] s = new RevFilter[subfilters.length]; final RevFilter[] s = new RevFilter[subfilters.length];

5
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/CommitTimeRevFilter.java

@ -134,6 +134,11 @@ public abstract class CommitTimeRevFilter extends RevFilter {
return this; return this;
} }
@Override
public boolean requiresCommitBody() {
return false;
}
private static class Before extends CommitTimeRevFilter { private static class Before extends CommitTimeRevFilter {
Before(final long ts) { Before(final long ts) {
super(ts); super(ts);

5
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/NotRevFilter.java

@ -81,6 +81,11 @@ public class NotRevFilter extends RevFilter {
return !a.include(walker, c); return !a.include(walker, c);
} }
@Override
public boolean requiresCommitBody() {
return a.requiresCommitBody();
}
@Override @Override
public RevFilter clone() { public RevFilter clone() {
return new NotRevFilter(a.clone()); return new NotRevFilter(a.clone());

21
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/OrRevFilter.java

@ -118,9 +118,13 @@ public abstract class OrRevFilter extends RevFilter {
private final RevFilter b; private final RevFilter b;
private final boolean requiresCommitBody;
Binary(final RevFilter one, final RevFilter two) { Binary(final RevFilter one, final RevFilter two) {
a = one; a = one;
b = two; b = two;
requiresCommitBody = a.requiresCommitBody()
|| b.requiresCommitBody();
} }
@Override @Override
@ -130,6 +134,11 @@ public abstract class OrRevFilter extends RevFilter {
return a.include(walker, c) || b.include(walker, c); return a.include(walker, c) || b.include(walker, c);
} }
@Override
public boolean requiresCommitBody() {
return requiresCommitBody;
}
@Override @Override
public RevFilter clone() { public RevFilter clone() {
return new Binary(a.clone(), b.clone()); return new Binary(a.clone(), b.clone());
@ -144,8 +153,15 @@ public abstract class OrRevFilter extends RevFilter {
private static class List extends OrRevFilter { private static class List extends OrRevFilter {
private final RevFilter[] subfilters; private final RevFilter[] subfilters;
private final boolean requiresCommitBody;
List(final RevFilter[] list) { List(final RevFilter[] list) {
subfilters = list; subfilters = list;
boolean rcb = false;
for (RevFilter filter : subfilters)
rcb |= filter.requiresCommitBody();
requiresCommitBody = rcb;
} }
@Override @Override
@ -159,6 +175,11 @@ public abstract class OrRevFilter extends RevFilter {
return false; return false;
} }
@Override
public boolean requiresCommitBody() {
return requiresCommitBody;
}
@Override @Override
public RevFilter clone() { public RevFilter clone() {
final RevFilter[] s = new RevFilter[subfilters.length]; final RevFilter[] s = new RevFilter[subfilters.length];

5
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/PatternMatchRevFilter.java

@ -131,6 +131,11 @@ public abstract class PatternMatchRevFilter extends RevFilter {
return compiledPattern.reset(text(cmit)).matches(); return compiledPattern.reset(text(cmit)).matches();
} }
@Override
public boolean requiresCommitBody() {
return true;
}
/** /**
* Obtain the raw text to match against. * Obtain the raw text to match against.
* *

29
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/RevFilter.java

@ -107,6 +107,11 @@ public abstract class RevFilter {
return this; return this;
} }
@Override
public boolean requiresCommitBody() {
return false;
}
@Override @Override
public String toString() { public String toString() {
return "ALL"; return "ALL";
@ -127,6 +132,11 @@ public abstract class RevFilter {
return this; return this;
} }
@Override
public boolean requiresCommitBody() {
return false;
}
@Override @Override
public String toString() { public String toString() {
return "NONE"; return "NONE";
@ -147,6 +157,11 @@ public abstract class RevFilter {
return this; return this;
} }
@Override
public boolean requiresCommitBody() {
return false;
}
@Override @Override
public String toString() { public String toString() {
return "NO_MERGES"; return "NO_MERGES";
@ -174,6 +189,11 @@ public abstract class RevFilter {
return this; return this;
} }
@Override
public boolean requiresCommitBody() {
return false;
}
@Override @Override
public String toString() { public String toString() {
return "MERGE_BASE"; return "MERGE_BASE";
@ -189,6 +209,12 @@ public abstract class RevFilter {
return NotRevFilter.create(this); 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. * Determine if the supplied commit should be included in results.
* *
@ -196,7 +222,8 @@ public abstract class RevFilter {
* the active walker this filter is being invoked from within. * the active walker this filter is being invoked from within.
* @param cmit * @param cmit
* the commit currently being tested. The commit has been parsed * 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 * @return true to include this commit in the results; false to have this
* commit be omitted entirely from the results. * commit be omitted entirely from the results.
* @throws StopWalkException * @throws StopWalkException

10
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/RevFlagFilter.java

@ -144,6 +144,11 @@ public abstract class RevFlagFilter extends RevFilter {
IOException { IOException {
return c.hasAll(flags); return c.hasAll(flags);
} }
@Override
public boolean requiresCommitBody() {
return false;
}
} }
private static class HasAny extends RevFlagFilter { private static class HasAny extends RevFlagFilter {
@ -157,5 +162,10 @@ public abstract class RevFlagFilter extends RevFilter {
IOException { IOException {
return c.hasAny(flags); return c.hasAny(flags);
} }
@Override
public boolean requiresCommitBody() {
return false;
}
} }
} }

5
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/SubStringRevFilter.java

@ -104,6 +104,11 @@ public abstract class SubStringRevFilter extends RevFilter {
return pattern.match(text(cmit)) >= 0; return pattern.match(text(cmit)) >= 0;
} }
@Override
public boolean requiresCommitBody() {
return true;
}
/** /**
* Obtain the raw text to match against. * Obtain the raw text to match against.
* *

5
org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java

@ -599,6 +599,11 @@ public abstract class BasePackFetchConnection extends BasePackConnection
} }
return !remoteKnowsIsCommon; return !remoteKnowsIsCommon;
} }
@Override
public boolean requiresCommitBody() {
return false;
}
}); });
} }

Loading…
Cancel
Save