summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2019-11-19 10:40:21 -0800
committerIvan Frade <ifrade@google.com>2019-11-21 09:30:19 -0800
commita0204a4727ce39f3bd1564c445065dce6cefe608 (patch)
tree4f605e9ecc065fe950fbbbddcea81c8e4e42bbf0 /org.eclipse.jgit.test
parent2ff0c0abaaa88f26eda4ae553cbbb954c74642df (diff)
downloadjgit-a0204a4727ce39f3bd1564c445065dce6cefe608.tar.gz
jgit-a0204a4727ce39f3bd1564c445065dce6cefe608.zip
ReachabilityChecker: Receive a Stream instead of a Collection
Preparatory change. Converting ObjectIds to RevCommits is potentially expensive and in the incremental reachability check, it is probably not required for all elements in the collection. Pass a Stream to the reachability checker. In the follow up we make the conversion from ObjectId to RevCommit in the stream (i.e. on demand). This should reduce the latency of reachability checks over big sets of references. Change-Id: I9f310e331de5b0bf8de34143bd7dcd34316d2fba Signed-off-by: Ivan Frade <ifrade@google.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ReachabilityCheckerTestCase.java20
1 files changed, 10 insertions, 10 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ReachabilityCheckerTestCase.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ReachabilityCheckerTestCase.java
index dd73e35727..092033449b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ReachabilityCheckerTestCase.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ReachabilityCheckerTestCase.java
@@ -47,6 +47,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.Optional;
+import java.util.stream.Stream;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
@@ -83,11 +84,11 @@ public abstract class ReachabilityCheckerTestCase
ReachabilityChecker checker = getChecker(repo);
assertReachable("reachable from one tip",
- checker.areAllReachable(Arrays.asList(a), Arrays.asList(c2)));
+ checker.areAllReachable(Arrays.asList(a), Stream.of(c2)));
assertReachable("reachable from another tip",
- checker.areAllReachable(Arrays.asList(a), Arrays.asList(b2)));
+ checker.areAllReachable(Arrays.asList(a), Stream.of(b2)));
assertReachable("reachable from itself",
- checker.areAllReachable(Arrays.asList(a), Arrays.asList(b2)));
+ checker.areAllReachable(Arrays.asList(a), Stream.of(b2)));
}
@Test
@@ -104,13 +105,13 @@ public abstract class ReachabilityCheckerTestCase
assertReachable("reachable through one branch",
checker.areAllReachable(Arrays.asList(b1),
- Arrays.asList(merge)));
+ Stream.of(merge)));
assertReachable("reachable through another branch",
checker.areAllReachable(Arrays.asList(c1),
- Arrays.asList(merge)));
+ Stream.of(merge)));
assertReachable("reachable, before the branching",
checker.areAllReachable(Arrays.asList(a),
- Arrays.asList(merge)));
+ Stream.of(merge)));
}
@Test
@@ -123,7 +124,7 @@ public abstract class ReachabilityCheckerTestCase
ReachabilityChecker checker = getChecker(repo);
assertUnreachable("unreachable from the future",
- checker.areAllReachable(Arrays.asList(b2), Arrays.asList(b1)));
+ checker.areAllReachable(Arrays.asList(b2), Stream.of(b1)));
}
@Test
@@ -137,7 +138,7 @@ public abstract class ReachabilityCheckerTestCase
ReachabilityChecker checker = getChecker(repo);
assertUnreachable("unreachable from different branch",
- checker.areAllReachable(Arrays.asList(c1), Arrays.asList(b2)));
+ checker.areAllReachable(Arrays.asList(c1), Stream.of(b2)));
}
@Test
@@ -152,7 +153,7 @@ public abstract class ReachabilityCheckerTestCase
ReachabilityChecker checker = getChecker(repo);
assertReachable("reachable with long chain in the middle", checker
- .areAllReachable(Arrays.asList(root), Arrays.asList(head)));
+ .areAllReachable(Arrays.asList(root), Stream.of(head)));
}
private static void assertReachable(String msg,
@@ -164,5 +165,4 @@ public abstract class ReachabilityCheckerTestCase
Optional<RevCommit> result) {
assertTrue(msg, result.isPresent());
}
-
}