Close RevWalks in tests
Change-Id: Id28804ace2572e8f659271660e78454a0d6ccc49 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
This commit is contained in:
parent
88bd901492
commit
762f6212b4
|
@ -2136,10 +2136,12 @@ public void testFastForwardRebaseWithAutoStash() throws Exception {
|
||||||
private List<DiffEntry> getStashedDiff() throws AmbiguousObjectException,
|
private List<DiffEntry> getStashedDiff() throws AmbiguousObjectException,
|
||||||
IncorrectObjectTypeException, IOException, MissingObjectException {
|
IncorrectObjectTypeException, IOException, MissingObjectException {
|
||||||
ObjectId stashId = db.resolve("stash@{0}");
|
ObjectId stashId = db.resolve("stash@{0}");
|
||||||
RevWalk revWalk = new RevWalk(db);
|
try (RevWalk revWalk = new RevWalk(db)) {
|
||||||
RevCommit stashCommit = revWalk.parseCommit(stashId);
|
RevCommit stashCommit = revWalk.parseCommit(stashId);
|
||||||
List<DiffEntry> diffs = diffWorkingAgainstHead(stashCommit, revWalk);
|
List<DiffEntry> diffs = diffWorkingAgainstHead(stashCommit,
|
||||||
return diffs;
|
revWalk);
|
||||||
|
return diffs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TreeWalk createTreeWalk() {
|
private TreeWalk createTreeWalk() {
|
||||||
|
|
|
@ -680,8 +680,9 @@ private FileRepository setupRepoForShallowFetch() throws Exception {
|
||||||
private static PackIndex writePack(FileRepository repo,
|
private static PackIndex writePack(FileRepository repo,
|
||||||
Set<? extends ObjectId> want, Set<ObjectIdSet> excludeObjects)
|
Set<? extends ObjectId> want, Set<ObjectIdSet> excludeObjects)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
RevWalk walk = new RevWalk(repo);
|
try (RevWalk walk = new RevWalk(repo)) {
|
||||||
return writePack(repo, walk, 0, want, NONE, excludeObjects);
|
return writePack(repo, walk, 0, want, NONE, excludeObjects);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PackIndex writeShallowPack(FileRepository repo, int depth,
|
private static PackIndex writeShallowPack(FileRepository repo, int depth,
|
||||||
|
@ -689,9 +690,10 @@ private static PackIndex writeShallowPack(FileRepository repo, int depth,
|
||||||
Set<? extends ObjectId> shallow) throws IOException {
|
Set<? extends ObjectId> shallow) throws IOException {
|
||||||
// During negotiation, UploadPack would have set up a DepthWalk and
|
// During negotiation, UploadPack would have set up a DepthWalk and
|
||||||
// marked the client's "shallow" commits. Emulate that here.
|
// marked the client's "shallow" commits. Emulate that here.
|
||||||
DepthWalk.RevWalk walk = new DepthWalk.RevWalk(repo, depth - 1);
|
try (DepthWalk.RevWalk walk = new DepthWalk.RevWalk(repo, depth - 1)) {
|
||||||
walk.assumeShallow(shallow);
|
walk.assumeShallow(shallow);
|
||||||
return writePack(repo, walk, depth, want, have, EMPTY_ID_SET);
|
return writePack(repo, walk, depth, want, have, EMPTY_ID_SET);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PackIndex writePack(FileRepository repo, RevWalk walk,
|
private static PackIndex writePack(FileRepository repo, RevWalk walk,
|
||||||
|
@ -707,6 +709,7 @@ private static PackIndex writePack(FileRepository repo, RevWalk walk,
|
||||||
if (depth > 0) {
|
if (depth > 0) {
|
||||||
pw.setShallowPack(depth, null);
|
pw.setShallowPack(depth, null);
|
||||||
}
|
}
|
||||||
|
// ow doesn't need to be closed; caller closes walk.
|
||||||
ObjectWalk ow = walk.toObjectWalkWithSameObjects();
|
ObjectWalk ow = walk.toObjectWalkWithSameObjects();
|
||||||
|
|
||||||
pw.preparePack(NullProgressMonitor.INSTANCE, ow, want, have, NONE);
|
pw.preparePack(NullProgressMonitor.INSTANCE, ow, want, have, NONE);
|
||||||
|
|
|
@ -441,8 +441,9 @@ public void testUpdate_RefusesRefsTxnNamespace() throws IOException {
|
||||||
ReceiveCommand cmd = command(null, B, "refs/txn/tmp");
|
ReceiveCommand cmd = command(null, B, "refs/txn/tmp");
|
||||||
BatchRefUpdate batch = refdb.newBatchUpdate();
|
BatchRefUpdate batch = refdb.newBatchUpdate();
|
||||||
batch.addCommand(cmd);
|
batch.addCommand(cmd);
|
||||||
batch.execute(new RevWalk(repo), NullProgressMonitor.INSTANCE);
|
try (RevWalk rw = new RevWalk(repo)) {
|
||||||
|
batch.execute(rw, NullProgressMonitor.INSTANCE);
|
||||||
|
}
|
||||||
assertEquals(REJECTED_OTHER_REASON, cmd.getResult());
|
assertEquals(REJECTED_OTHER_REASON, cmd.getResult());
|
||||||
assertEquals(MessageFormat.format(JGitText.get().invalidRefName,
|
assertEquals(MessageFormat.format(JGitText.get().invalidRefName,
|
||||||
"refs/txn/tmp"), cmd.getMessage());
|
"refs/txn/tmp"), cmd.getMessage());
|
||||||
|
@ -461,8 +462,9 @@ public void testUpdate_RefusesDotLockInRefName() throws IOException {
|
||||||
ReceiveCommand cmd = command(null, B, "refs/heads/pu.lock");
|
ReceiveCommand cmd = command(null, B, "refs/heads/pu.lock");
|
||||||
BatchRefUpdate batch = refdb.newBatchUpdate();
|
BatchRefUpdate batch = refdb.newBatchUpdate();
|
||||||
batch.addCommand(cmd);
|
batch.addCommand(cmd);
|
||||||
batch.execute(new RevWalk(repo), NullProgressMonitor.INSTANCE);
|
try (RevWalk rw = new RevWalk(repo)) {
|
||||||
|
batch.execute(rw, NullProgressMonitor.INSTANCE);
|
||||||
|
}
|
||||||
assertEquals(REJECTED_OTHER_REASON, cmd.getResult());
|
assertEquals(REJECTED_OTHER_REASON, cmd.getResult());
|
||||||
assertEquals(JGitText.get().funnyRefname, cmd.getMessage());
|
assertEquals(JGitText.get().funnyRefname, cmd.getMessage());
|
||||||
assertEquals(txnId, getTxnCommitted());
|
assertEquals(txnId, getTxnCommitted());
|
||||||
|
@ -481,7 +483,9 @@ public void testUpdate_RefusesOrigHeadOnBare() throws IOException {
|
||||||
ReceiveCommand cmd = command(null, B, ORIG_HEAD);
|
ReceiveCommand cmd = command(null, B, ORIG_HEAD);
|
||||||
BatchRefUpdate batch = refdb.newBatchUpdate();
|
BatchRefUpdate batch = refdb.newBatchUpdate();
|
||||||
batch.addCommand(cmd);
|
batch.addCommand(cmd);
|
||||||
batch.execute(new RevWalk(repo), NullProgressMonitor.INSTANCE);
|
try (RevWalk rw = new RevWalk(repo)) {
|
||||||
|
batch.execute(rw, NullProgressMonitor.INSTANCE);
|
||||||
|
}
|
||||||
assertEquals(REJECTED_OTHER_REASON, cmd.getResult());
|
assertEquals(REJECTED_OTHER_REASON, cmd.getResult());
|
||||||
assertEquals(
|
assertEquals(
|
||||||
MessageFormat.format(JGitText.get().invalidRefName, ORIG_HEAD),
|
MessageFormat.format(JGitText.get().invalidRefName, ORIG_HEAD),
|
||||||
|
@ -500,7 +504,9 @@ public void testBatchRefUpdate_NonFastForwardAborts() throws IOException {
|
||||||
command(B, A, "refs/heads/masters"));
|
command(B, A, "refs/heads/masters"));
|
||||||
BatchRefUpdate batchUpdate = refdb.newBatchUpdate();
|
BatchRefUpdate batchUpdate = refdb.newBatchUpdate();
|
||||||
batchUpdate.addCommand(commands);
|
batchUpdate.addCommand(commands);
|
||||||
batchUpdate.execute(new RevWalk(repo), NullProgressMonitor.INSTANCE);
|
try (RevWalk rw = new RevWalk(repo)) {
|
||||||
|
batchUpdate.execute(rw, NullProgressMonitor.INSTANCE);
|
||||||
|
}
|
||||||
assertEquals(txnId, getTxnCommitted());
|
assertEquals(txnId, getTxnCommitted());
|
||||||
|
|
||||||
assertEquals(REJECTED_NONFASTFORWARD,
|
assertEquals(REJECTED_NONFASTFORWARD,
|
||||||
|
@ -523,7 +529,9 @@ public void testBatchRefUpdate_ForceUpdate() throws IOException {
|
||||||
BatchRefUpdate batchUpdate = refdb.newBatchUpdate();
|
BatchRefUpdate batchUpdate = refdb.newBatchUpdate();
|
||||||
batchUpdate.setAllowNonFastForwards(true);
|
batchUpdate.setAllowNonFastForwards(true);
|
||||||
batchUpdate.addCommand(commands);
|
batchUpdate.addCommand(commands);
|
||||||
batchUpdate.execute(new RevWalk(repo), NullProgressMonitor.INSTANCE);
|
try (RevWalk rw = new RevWalk(repo)) {
|
||||||
|
batchUpdate.execute(rw, NullProgressMonitor.INSTANCE);
|
||||||
|
}
|
||||||
assertNotEquals(txnId, getTxnCommitted());
|
assertNotEquals(txnId, getTxnCommitted());
|
||||||
|
|
||||||
Map<String, Ref> refs = refdb.getRefs(ALL);
|
Map<String, Ref> refs = refdb.getRefs(ALL);
|
||||||
|
@ -547,13 +555,15 @@ public void testBatchRefUpdate_NonFastForwardDoesNotDoExpensiveMergeCheck()
|
||||||
BatchRefUpdate batchUpdate = refdb.newBatchUpdate();
|
BatchRefUpdate batchUpdate = refdb.newBatchUpdate();
|
||||||
batchUpdate.setAllowNonFastForwards(true);
|
batchUpdate.setAllowNonFastForwards(true);
|
||||||
batchUpdate.addCommand(commands);
|
batchUpdate.addCommand(commands);
|
||||||
batchUpdate.execute(new RevWalk(repo) {
|
try (RevWalk rw = new RevWalk(repo) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isMergedInto(RevCommit base, RevCommit tip) {
|
public boolean isMergedInto(RevCommit base, RevCommit tip) {
|
||||||
fail("isMergedInto() should not be called");
|
fail("isMergedInto() should not be called");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, NullProgressMonitor.INSTANCE);
|
}) {
|
||||||
|
batchUpdate.execute(rw, NullProgressMonitor.INSTANCE);
|
||||||
|
}
|
||||||
assertNotEquals(txnId, getTxnCommitted());
|
assertNotEquals(txnId, getTxnCommitted());
|
||||||
|
|
||||||
Map<String, Ref> refs = refdb.getRefs(ALL);
|
Map<String, Ref> refs = refdb.getRefs(ALL);
|
||||||
|
@ -574,7 +584,9 @@ public void testBatchRefUpdate_ConflictCausesAbort() throws IOException {
|
||||||
BatchRefUpdate batchUpdate = refdb.newBatchUpdate();
|
BatchRefUpdate batchUpdate = refdb.newBatchUpdate();
|
||||||
batchUpdate.setAllowNonFastForwards(true);
|
batchUpdate.setAllowNonFastForwards(true);
|
||||||
batchUpdate.addCommand(commands);
|
batchUpdate.addCommand(commands);
|
||||||
batchUpdate.execute(new RevWalk(repo), NullProgressMonitor.INSTANCE);
|
try (RevWalk rw = new RevWalk(repo)) {
|
||||||
|
batchUpdate.execute(rw, NullProgressMonitor.INSTANCE);
|
||||||
|
}
|
||||||
assertEquals(txnId, getTxnCommitted());
|
assertEquals(txnId, getTxnCommitted());
|
||||||
|
|
||||||
assertEquals(LOCK_FAILURE, commands.get(0).getResult());
|
assertEquals(LOCK_FAILURE, commands.get(0).getResult());
|
||||||
|
@ -601,7 +613,9 @@ public void testBatchRefUpdate_NoConflictIfDeleted() throws IOException {
|
||||||
BatchRefUpdate batchUpdate = refdb.newBatchUpdate();
|
BatchRefUpdate batchUpdate = refdb.newBatchUpdate();
|
||||||
batchUpdate.setAllowNonFastForwards(true);
|
batchUpdate.setAllowNonFastForwards(true);
|
||||||
batchUpdate.addCommand(commands);
|
batchUpdate.addCommand(commands);
|
||||||
batchUpdate.execute(new RevWalk(repo), NullProgressMonitor.INSTANCE);
|
try (RevWalk rw = new RevWalk(repo)) {
|
||||||
|
batchUpdate.execute(rw, NullProgressMonitor.INSTANCE);
|
||||||
|
}
|
||||||
assertNotEquals(txnId, getTxnCommitted());
|
assertNotEquals(txnId, getTxnCommitted());
|
||||||
|
|
||||||
assertEquals(OK, commands.get(0).getResult());
|
assertEquals(OK, commands.get(0).getResult());
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -55,7 +54,6 @@
|
||||||
import org.eclipse.jgit.junit.RepositoryTestCase;
|
import org.eclipse.jgit.junit.RepositoryTestCase;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
import org.eclipse.jgit.lib.Ref;
|
import org.eclipse.jgit.lib.Ref;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -83,23 +81,18 @@ public void testDrawTextAlignment() throws Exception {
|
||||||
git.commit().setMessage("commit on master").call();
|
git.commit().setMessage("commit on master").call();
|
||||||
MergeResult mergeCall = merge(db.resolve("topic"));
|
MergeResult mergeCall = merge(db.resolve("topic"));
|
||||||
ObjectId start = mergeCall.getNewHead();
|
ObjectId start = mergeCall.getNewHead();
|
||||||
PlotCommitList<PlotLane> commitList = createCommitList(start);
|
try (PlotWalk walk = new PlotWalk(db)) {
|
||||||
|
walk.markStart(walk.parseCommit(start));
|
||||||
|
PlotCommitList<PlotLane> commitList = new PlotCommitList<>();
|
||||||
|
commitList.source(walk);
|
||||||
|
commitList.fillTo(1000);
|
||||||
|
|
||||||
for (int i = 0; i < commitList.size(); i++)
|
for (int i = 0; i < commitList.size(); i++)
|
||||||
plotRenderer.paintCommit(commitList.get(i), 30);
|
plotRenderer.paintCommit(commitList.get(i), 30);
|
||||||
|
|
||||||
List<Integer> indentations = plotRenderer.indentations;
|
List<Integer> indentations = plotRenderer.indentations;
|
||||||
assertEquals(indentations.get(2), indentations.get(3));
|
assertEquals(indentations.get(2), indentations.get(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlotCommitList<PlotLane> createCommitList(ObjectId start)
|
|
||||||
throws IOException {
|
|
||||||
TestPlotWalk walk = new TestPlotWalk(db);
|
|
||||||
walk.markStart(walk.parseCommit(start));
|
|
||||||
PlotCommitList<PlotLane> commitList = new PlotCommitList<>();
|
|
||||||
commitList.source(walk);
|
|
||||||
commitList.fillTo(1000);
|
|
||||||
return commitList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private MergeResult merge(ObjectId includeId) throws GitAPIException {
|
private MergeResult merge(ObjectId includeId) throws GitAPIException {
|
||||||
|
@ -107,12 +100,6 @@ private MergeResult merge(ObjectId includeId) throws GitAPIException {
|
||||||
.include(includeId).call();
|
.include(includeId).call();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TestPlotWalk extends PlotWalk {
|
|
||||||
public TestPlotWalk(Repository repo) {
|
|
||||||
super(repo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class TestPlotRenderer extends
|
private static class TestPlotRenderer extends
|
||||||
AbstractPlotRenderer<PlotLane, Object> {
|
AbstractPlotRenderer<PlotLane, Object> {
|
||||||
|
|
||||||
|
|
|
@ -135,18 +135,19 @@ public void testLinear() throws Exception {
|
||||||
final RevCommit b = commit(a);
|
final RevCommit b = commit(a);
|
||||||
final RevCommit c = commit(b);
|
final RevCommit c = commit(b);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(c.getId()));
|
pw.markStart(pw.lookupCommit(c.getId()));
|
||||||
|
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
|
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
test.commit(c).lanePos(0).parents(b);
|
test.commit(c).lanePos(0).parents(b);
|
||||||
test.commit(b).lanePos(0).parents(a);
|
test.commit(b).lanePos(0).parents(a);
|
||||||
test.commit(a).lanePos(0).parents();
|
test.commit(a).lanePos(0).parents();
|
||||||
test.noMoreCommits();
|
test.noMoreCommits();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -156,19 +157,20 @@ public void testMerged() throws Exception {
|
||||||
final RevCommit c = commit(a);
|
final RevCommit c = commit(a);
|
||||||
final RevCommit d = commit(b, c);
|
final RevCommit d = commit(b, c);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(d.getId()));
|
pw.markStart(pw.lookupCommit(d.getId()));
|
||||||
|
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
|
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
test.commit(d).lanePos(0).parents(b, c);
|
test.commit(d).lanePos(0).parents(b, c);
|
||||||
test.commit(c).lanePos(1).parents(a);
|
test.commit(c).lanePos(1).parents(a);
|
||||||
test.commit(b).lanePos(0).parents(a);
|
test.commit(b).lanePos(0).parents(a);
|
||||||
test.commit(a).lanePos(0).parents();
|
test.commit(a).lanePos(0).parents();
|
||||||
test.noMoreCommits();
|
test.noMoreCommits();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -177,20 +179,21 @@ public void testSideBranch() throws Exception {
|
||||||
final RevCommit b = commit(a);
|
final RevCommit b = commit(a);
|
||||||
final RevCommit c = commit(a);
|
final RevCommit c = commit(a);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(b.getId()));
|
pw.markStart(pw.lookupCommit(b.getId()));
|
||||||
pw.markStart(pw.lookupCommit(c.getId()));
|
pw.markStart(pw.lookupCommit(c.getId()));
|
||||||
|
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
|
|
||||||
Set<Integer> childPositions = asSet(0, 1);
|
Set<Integer> childPositions = asSet(0, 1);
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
test.commit(c).lanePos(childPositions).parents(a);
|
test.commit(c).lanePos(childPositions).parents(a);
|
||||||
test.commit(b).lanePos(childPositions).parents(a);
|
test.commit(b).lanePos(childPositions).parents(a);
|
||||||
test.commit(a).lanePos(0).parents();
|
test.commit(a).lanePos(0).parents();
|
||||||
test.noMoreCommits();
|
test.noMoreCommits();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -200,22 +203,23 @@ public void test2SideBranches() throws Exception {
|
||||||
final RevCommit c = commit(a);
|
final RevCommit c = commit(a);
|
||||||
final RevCommit d = commit(a);
|
final RevCommit d = commit(a);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(b.getId()));
|
pw.markStart(pw.lookupCommit(b.getId()));
|
||||||
pw.markStart(pw.lookupCommit(c.getId()));
|
pw.markStart(pw.lookupCommit(c.getId()));
|
||||||
pw.markStart(pw.lookupCommit(d.getId()));
|
pw.markStart(pw.lookupCommit(d.getId()));
|
||||||
|
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
|
|
||||||
Set<Integer> childPositions = asSet(0, 1, 2);
|
Set<Integer> childPositions = asSet(0, 1, 2);
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
test.commit(d).lanePos(childPositions).parents(a);
|
test.commit(d).lanePos(childPositions).parents(a);
|
||||||
test.commit(c).lanePos(childPositions).parents(a);
|
test.commit(c).lanePos(childPositions).parents(a);
|
||||||
test.commit(b).lanePos(childPositions).parents(a);
|
test.commit(b).lanePos(childPositions).parents(a);
|
||||||
test.commit(a).lanePos(0).parents();
|
test.commit(a).lanePos(0).parents();
|
||||||
test.noMoreCommits();
|
test.noMoreCommits();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -228,34 +232,35 @@ public void testBug300282_1() throws Exception {
|
||||||
final RevCommit f = commit(a);
|
final RevCommit f = commit(a);
|
||||||
final RevCommit g = commit(f);
|
final RevCommit g = commit(f);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
// TODO: when we add unnecessary commit's as tips (e.g. a commit which
|
// TODO: when we add unnecessary commit's as tips (e.g. a commit
|
||||||
// is a parent of another tip) the walk will return those commits twice.
|
// which is a parent of another tip) the walk will return those
|
||||||
// Find out why!
|
// commits twice. Find out why!
|
||||||
// pw.markStart(pw.lookupCommit(a.getId()));
|
// pw.markStart(pw.lookupCommit(a.getId()));
|
||||||
pw.markStart(pw.lookupCommit(b.getId()));
|
pw.markStart(pw.lookupCommit(b.getId()));
|
||||||
pw.markStart(pw.lookupCommit(c.getId()));
|
pw.markStart(pw.lookupCommit(c.getId()));
|
||||||
pw.markStart(pw.lookupCommit(d.getId()));
|
pw.markStart(pw.lookupCommit(d.getId()));
|
||||||
pw.markStart(pw.lookupCommit(e.getId()));
|
pw.markStart(pw.lookupCommit(e.getId()));
|
||||||
// pw.markStart(pw.lookupCommit(f.getId()));
|
// pw.markStart(pw.lookupCommit(f.getId()));
|
||||||
pw.markStart(pw.lookupCommit(g.getId()));
|
pw.markStart(pw.lookupCommit(g.getId()));
|
||||||
|
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
|
|
||||||
Set<Integer> childPositions = asSet(0, 1, 2, 3, 4);
|
Set<Integer> childPositions = asSet(0, 1, 2, 3, 4);
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
int posG = test.commit(g).lanePos(childPositions).parents(f)
|
int posG = test.commit(g).lanePos(childPositions).parents(f)
|
||||||
.getLanePos();
|
.getLanePos();
|
||||||
test.commit(f).lanePos(posG).parents(a);
|
test.commit(f).lanePos(posG).parents(a);
|
||||||
|
|
||||||
test.commit(e).lanePos(childPositions).parents(a);
|
test.commit(e).lanePos(childPositions).parents(a);
|
||||||
test.commit(d).lanePos(childPositions).parents(a);
|
test.commit(d).lanePos(childPositions).parents(a);
|
||||||
test.commit(c).lanePos(childPositions).parents(a);
|
test.commit(c).lanePos(childPositions).parents(a);
|
||||||
test.commit(b).lanePos(childPositions).parents(a);
|
test.commit(b).lanePos(childPositions).parents(a);
|
||||||
test.commit(a).lanePos(0).parents();
|
test.commit(a).lanePos(0).parents();
|
||||||
test.noMoreCommits();
|
test.noMoreCommits();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -270,25 +275,26 @@ public void testBug368927() throws Exception {
|
||||||
final RevCommit h = commit(f);
|
final RevCommit h = commit(f);
|
||||||
final RevCommit i = commit(h);
|
final RevCommit i = commit(h);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(i.getId()));
|
pw.markStart(pw.lookupCommit(i.getId()));
|
||||||
pw.markStart(pw.lookupCommit(g.getId()));
|
pw.markStart(pw.lookupCommit(g.getId()));
|
||||||
|
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
Set<Integer> childPositions = asSet(0, 1);
|
Set<Integer> childPositions = asSet(0, 1);
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
int posI = test.commit(i).lanePos(childPositions).parents(h)
|
int posI = test.commit(i).lanePos(childPositions).parents(h)
|
||||||
.getLanePos();
|
.getLanePos();
|
||||||
test.commit(h).lanePos(posI).parents(f);
|
test.commit(h).lanePos(posI).parents(f);
|
||||||
test.commit(g).lanePos(childPositions).parents(a);
|
test.commit(g).lanePos(childPositions).parents(a);
|
||||||
test.commit(f).lanePos(posI).parents(e, d);
|
test.commit(f).lanePos(posI).parents(e, d);
|
||||||
test.commit(e).lanePos(posI).parents(c);
|
test.commit(e).lanePos(posI).parents(c);
|
||||||
test.commit(d).lanePos(2).parents(b);
|
test.commit(d).lanePos(2).parents(b);
|
||||||
test.commit(c).lanePos(posI).parents(b);
|
test.commit(c).lanePos(posI).parents(b);
|
||||||
test.commit(b).lanePos(posI).parents(a);
|
test.commit(b).lanePos(posI).parents(a);
|
||||||
test.commit(a).lanePos(0).parents();
|
test.commit(a).lanePos(0).parents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the history of the egit project between 9fdaf3c1 and e76ad9170f
|
// test the history of the egit project between 9fdaf3c1 and e76ad9170f
|
||||||
|
@ -330,67 +336,71 @@ public void testEgitHistory() throws Exception {
|
||||||
final RevCommit merge_fixed_logged_npe = commit(sort_roots,
|
final RevCommit merge_fixed_logged_npe = commit(sort_roots,
|
||||||
fix_logged_npe);
|
fix_logged_npe);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(merge_fixed_logged_npe.getId()));
|
pw.markStart(pw.lookupCommit(merge_fixed_logged_npe.getId()));
|
||||||
|
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
|
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
|
|
||||||
// Note: all positions of side branches are rather arbitrary, but some
|
// Note: all positions of side branches are rather arbitrary, but
|
||||||
// may not overlap. Testing for the positions yielded by the current
|
// some
|
||||||
// implementation, which was manually checked to not overlap.
|
// may not overlap. Testing for the positions yielded by the current
|
||||||
final int mainPos = 0;
|
// implementation, which was manually checked to not overlap.
|
||||||
test.commit(merge_fixed_logged_npe).parents(sort_roots, fix_logged_npe)
|
final int mainPos = 0;
|
||||||
.lanePos(mainPos);
|
test.commit(merge_fixed_logged_npe)
|
||||||
test.commit(fix_logged_npe).parents(merge_changeset_implementation)
|
.parents(sort_roots, fix_logged_npe).lanePos(mainPos);
|
||||||
.lanePos(1);
|
test.commit(fix_logged_npe).parents(merge_changeset_implementation)
|
||||||
test.commit(sort_roots).parents(merge_update_eclipse).lanePos(mainPos);
|
.lanePos(1);
|
||||||
test.commit(merge_update_eclipse).parents(add_a_clear, update_eclipse)
|
test.commit(sort_roots).parents(merge_update_eclipse)
|
||||||
.lanePos(mainPos);
|
.lanePos(mainPos);
|
||||||
test.commit(add_a_clear).parents(fix_broken).lanePos(mainPos);
|
test.commit(merge_update_eclipse)
|
||||||
test.commit(fix_broken).parents(merge_disable_comment).lanePos(mainPos);
|
.parents(add_a_clear, update_eclipse).lanePos(mainPos);
|
||||||
test.commit(merge_disable_comment)
|
test.commit(add_a_clear).parents(fix_broken).lanePos(mainPos);
|
||||||
.parents(merge_resolve_handler, disable_comment)
|
test.commit(fix_broken).parents(merge_disable_comment)
|
||||||
.lanePos(mainPos);
|
.lanePos(mainPos);
|
||||||
test.commit(disable_comment).parents(clone_operation).lanePos(2);
|
test.commit(merge_disable_comment)
|
||||||
test.commit(merge_resolve_handler)
|
.parents(merge_resolve_handler, disable_comment)
|
||||||
.parents(clone_operation, resolve_handler).lanePos(mainPos);
|
.lanePos(mainPos);
|
||||||
test.commit(update_eclipse).parents(add_Maven).lanePos(3);
|
test.commit(disable_comment).parents(clone_operation).lanePos(2);
|
||||||
test.commit(clone_operation).parents(merge_changeset_implementation)
|
test.commit(merge_resolve_handler)
|
||||||
.lanePos(mainPos);
|
.parents(clone_operation, resolve_handler).lanePos(mainPos);
|
||||||
test.commit(merge_changeset_implementation)
|
test.commit(update_eclipse).parents(add_Maven).lanePos(3);
|
||||||
.parents(merge_disable_source, changeset_implementation)
|
test.commit(clone_operation).parents(merge_changeset_implementation)
|
||||||
.lanePos(mainPos);
|
.lanePos(mainPos);
|
||||||
test.commit(merge_disable_source)
|
test.commit(merge_changeset_implementation)
|
||||||
.parents(update_eclipse_iplog2, disable_source)
|
.parents(merge_disable_source, changeset_implementation)
|
||||||
.lanePos(mainPos);
|
.lanePos(mainPos);
|
||||||
test.commit(update_eclipse_iplog2).parents(merge_use_remote)
|
test.commit(merge_disable_source)
|
||||||
.lanePos(mainPos);
|
.parents(update_eclipse_iplog2, disable_source)
|
||||||
test.commit(disable_source).parents(merge_use_remote).lanePos(1);
|
.lanePos(mainPos);
|
||||||
test.commit(merge_use_remote).parents(update_eclipse_iplog, use_remote)
|
test.commit(update_eclipse_iplog2).parents(merge_use_remote)
|
||||||
.lanePos(mainPos);
|
.lanePos(mainPos);
|
||||||
test.commit(changeset_implementation).parents(clear_repositorycache)
|
test.commit(disable_source).parents(merge_use_remote).lanePos(1);
|
||||||
.lanePos(2);
|
test.commit(merge_use_remote)
|
||||||
test.commit(update_eclipse_iplog).parents(merge_add_Maven)
|
.parents(update_eclipse_iplog, use_remote).lanePos(mainPos);
|
||||||
.lanePos(mainPos);
|
test.commit(changeset_implementation).parents(clear_repositorycache)
|
||||||
test.commit(merge_add_Maven).parents(findToolBar_layout, add_Maven)
|
.lanePos(2);
|
||||||
.lanePos(mainPos);
|
test.commit(update_eclipse_iplog).parents(merge_add_Maven)
|
||||||
test.commit(findToolBar_layout).parents(clear_repositorycache)
|
.lanePos(mainPos);
|
||||||
.lanePos(mainPos);
|
test.commit(merge_add_Maven).parents(findToolBar_layout, add_Maven)
|
||||||
test.commit(use_remote).parents(clear_repositorycache).lanePos(1);
|
.lanePos(mainPos);
|
||||||
test.commit(add_Maven).parents(clear_repositorycache).lanePos(3);
|
test.commit(findToolBar_layout).parents(clear_repositorycache)
|
||||||
test.commit(clear_repositorycache).parents(merge_remove)
|
.lanePos(mainPos);
|
||||||
.lanePos(mainPos);
|
test.commit(use_remote).parents(clear_repositorycache).lanePos(1);
|
||||||
test.commit(resolve_handler).parents(merge_fix).lanePos(4);
|
test.commit(add_Maven).parents(clear_repositorycache).lanePos(3);
|
||||||
test.commit(merge_remove).parents(add_simple, remove_unused)
|
test.commit(clear_repositorycache).parents(merge_remove)
|
||||||
.lanePos(mainPos);
|
.lanePos(mainPos);
|
||||||
test.commit(remove_unused).parents(merge_fix).lanePos(1);
|
test.commit(resolve_handler).parents(merge_fix).lanePos(4);
|
||||||
test.commit(add_simple).parents(merge_fix).lanePos(mainPos);
|
test.commit(merge_remove).parents(add_simple, remove_unused)
|
||||||
test.commit(merge_fix).parents().lanePos(mainPos);
|
.lanePos(mainPos);
|
||||||
test.noMoreCommits();
|
test.commit(remove_unused).parents(merge_fix).lanePos(1);
|
||||||
|
test.commit(add_simple).parents(merge_fix).lanePos(mainPos);
|
||||||
|
test.commit(merge_fix).parents().lanePos(mainPos);
|
||||||
|
test.noMoreCommits();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a history where a merge commit has two time the same parent
|
// test a history where a merge commit has two time the same parent
|
||||||
|
@ -403,20 +413,21 @@ public void testDuplicateParents() throws Exception {
|
||||||
final RevCommit s1 = commit(m2);
|
final RevCommit s1 = commit(m2);
|
||||||
final RevCommit s2 = commit(s1);
|
final RevCommit s2 = commit(s1);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(m3));
|
pw.markStart(pw.lookupCommit(m3));
|
||||||
pw.markStart(pw.lookupCommit(s2));
|
pw.markStart(pw.lookupCommit(s2));
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
|
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
test.commit(s2).nrOfPassingLanes(0);
|
test.commit(s2).nrOfPassingLanes(0);
|
||||||
test.commit(s1).nrOfPassingLanes(0);
|
test.commit(s1).nrOfPassingLanes(0);
|
||||||
test.commit(m3).nrOfPassingLanes(1);
|
test.commit(m3).nrOfPassingLanes(1);
|
||||||
test.commit(m2).nrOfPassingLanes(0);
|
test.commit(m2).nrOfPassingLanes(0);
|
||||||
test.commit(m1).nrOfPassingLanes(0);
|
test.commit(m1).nrOfPassingLanes(0);
|
||||||
test.noMoreCommits();
|
test.noMoreCommits();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -465,30 +476,31 @@ public void testBug419359() throws Exception {
|
||||||
final RevCommit a4 = commit(a3);
|
final RevCommit a4 = commit(a3);
|
||||||
final RevCommit a5 = commit(a3, a4);
|
final RevCommit a5 = commit(a3, a4);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(b3.getId()));
|
pw.markStart(pw.lookupCommit(b3.getId()));
|
||||||
pw.markStart(pw.lookupCommit(c.getId()));
|
pw.markStart(pw.lookupCommit(c.getId()));
|
||||||
pw.markStart(pw.lookupCommit(e.getId()));
|
pw.markStart(pw.lookupCommit(e.getId()));
|
||||||
pw.markStart(pw.lookupCommit(a5.getId()));
|
pw.markStart(pw.lookupCommit(a5.getId()));
|
||||||
|
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
|
|
||||||
// test that the commits b1, b2 and b3 are on the same position
|
// test that the commits b1, b2 and b3 are on the same position
|
||||||
int bPos = pcl.get(9).lane.position; // b1
|
int bPos = pcl.get(9).lane.position; // b1
|
||||||
assertEquals("b2 is an a different position", bPos,
|
assertEquals("b2 is an a different position", bPos,
|
||||||
pcl.get(7).lane.position);
|
pcl.get(7).lane.position);
|
||||||
assertEquals("b3 is on a different position", bPos,
|
assertEquals("b3 is on a different position", bPos,
|
||||||
pcl.get(4).lane.position);
|
pcl.get(4).lane.position);
|
||||||
|
|
||||||
// test that nothing blocks the connections between b1, b2 and b3
|
// test that nothing blocks the connections between b1, b2 and b3
|
||||||
assertNotEquals("b lane is blocked by c", bPos,
|
assertNotEquals("b lane is blocked by c", bPos,
|
||||||
pcl.get(8).lane.position);
|
pcl.get(8).lane.position);
|
||||||
assertNotEquals("b lane is blocked by a2", bPos,
|
assertNotEquals("b lane is blocked by a2", bPos,
|
||||||
pcl.get(6).lane.position);
|
pcl.get(6).lane.position);
|
||||||
assertNotEquals("b lane is blocked by d", bPos,
|
assertNotEquals("b lane is blocked by d", bPos,
|
||||||
pcl.get(5).lane.position);
|
pcl.get(5).lane.position);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -517,23 +529,24 @@ public void testMultipleMerges() throws Exception {
|
||||||
final RevCommit a4 = commit(a3, b2);
|
final RevCommit a4 = commit(a3, b2);
|
||||||
final RevCommit b3 = commit(b2);
|
final RevCommit b3 = commit(b2);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(a4));
|
pw.markStart(pw.lookupCommit(a4));
|
||||||
pw.markStart(pw.lookupCommit(b3));
|
pw.markStart(pw.lookupCommit(b3));
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
|
|
||||||
Set<Integer> positions = asSet(0, 1);
|
Set<Integer> positions = asSet(0, 1);
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
int posB = test.commit(b3).lanePos(positions).getLanePos();
|
int posB = test.commit(b3).lanePos(positions).getLanePos();
|
||||||
int posA = test.commit(a4).lanePos(positions).getLanePos();
|
int posA = test.commit(a4).lanePos(positions).getLanePos();
|
||||||
test.commit(b2).lanePos(posB);
|
test.commit(b2).lanePos(posB);
|
||||||
test.commit(a3).lanePos(posA);
|
test.commit(a3).lanePos(posA);
|
||||||
test.commit(a2).lanePos(posA);
|
test.commit(a2).lanePos(posA);
|
||||||
test.commit(b1).lanePos(posB);
|
test.commit(b1).lanePos(posB);
|
||||||
test.commit(a1).lanePos(posA);
|
test.commit(a1).lanePos(posA);
|
||||||
test.noMoreCommits();
|
test.noMoreCommits();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -562,25 +575,26 @@ public void testMergeBlockedBySelf() throws Exception {
|
||||||
final RevCommit b3 = commit(b2);
|
final RevCommit b3 = commit(b2);
|
||||||
final RevCommit a4 = commit(a3);
|
final RevCommit a4 = commit(a3);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(a4));
|
pw.markStart(pw.lookupCommit(a4));
|
||||||
pw.markStart(pw.lookupCommit(b3));
|
pw.markStart(pw.lookupCommit(b3));
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
|
|
||||||
Set<Integer> positions = asSet(0, 1);
|
Set<Integer> positions = asSet(0, 1);
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
int posA = test.commit(a4).lanePos(positions).getLanePos();
|
int posA = test.commit(a4).lanePos(positions).getLanePos();
|
||||||
int posB = test.commit(b3).lanePos(positions).getLanePos();
|
int posB = test.commit(b3).lanePos(positions).getLanePos();
|
||||||
test.commit(a3).lanePos(posA);
|
test.commit(a3).lanePos(posA);
|
||||||
test.commit(b2).lanePos(posB);
|
test.commit(b2).lanePos(posB);
|
||||||
test.commit(a2).lanePos(posA);
|
test.commit(a2).lanePos(posA);
|
||||||
// b1 is not repositioned, uses "detour lane"
|
// b1 is not repositioned, uses "detour lane"
|
||||||
// (drawn as a double arc in the ascii graph above)
|
// (drawn as a double arc in the ascii graph above)
|
||||||
test.commit(b1).lanePos(posB);
|
test.commit(b1).lanePos(posB);
|
||||||
test.commit(a1).lanePos(posA);
|
test.commit(a1).lanePos(posA);
|
||||||
test.noMoreCommits();
|
test.noMoreCommits();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -611,24 +625,25 @@ public void testMergeBlockedByOther() throws Exception {
|
||||||
final RevCommit a4 = commit(a3, b1);
|
final RevCommit a4 = commit(a3, b1);
|
||||||
final RevCommit b2 = commit(b1);
|
final RevCommit b2 = commit(b1);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(a4));
|
pw.markStart(pw.lookupCommit(a4));
|
||||||
pw.markStart(pw.lookupCommit(b2));
|
pw.markStart(pw.lookupCommit(b2));
|
||||||
pw.markStart(pw.lookupCommit(c));
|
pw.markStart(pw.lookupCommit(c));
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
|
|
||||||
Set<Integer> positions = asSet(0, 1, 2);
|
Set<Integer> positions = asSet(0, 1, 2);
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
int posB = test.commit(b2).lanePos(positions).getLanePos();
|
int posB = test.commit(b2).lanePos(positions).getLanePos();
|
||||||
int posA = test.commit(a4).lanePos(positions).getLanePos();
|
int posA = test.commit(a4).lanePos(positions).getLanePos();
|
||||||
test.commit(a3).lanePos(posA);
|
test.commit(a3).lanePos(posA);
|
||||||
test.commit(c).lanePos(positions);
|
test.commit(c).lanePos(positions);
|
||||||
test.commit(a2).lanePos(posA);
|
test.commit(a2).lanePos(posA);
|
||||||
test.commit(b1).lanePos(posB); // repositioned to go around c
|
test.commit(b1).lanePos(posB); // repositioned to go around c
|
||||||
test.commit(a1).lanePos(posA);
|
test.commit(a1).lanePos(posA);
|
||||||
test.noMoreCommits();
|
test.noMoreCommits();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -651,22 +666,24 @@ public void testDanglingCommitShouldContinueLane() throws Exception {
|
||||||
final RevCommit a3 = commit(a2);
|
final RevCommit a3 = commit(a2);
|
||||||
final RevCommit b1 = commit(a1);
|
final RevCommit b1 = commit(a1);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(a3));
|
pw.markStart(pw.lookupCommit(a3));
|
||||||
pw.markStart(pw.lookupCommit(b1));
|
pw.markStart(pw.lookupCommit(b1));
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(2); // don't process a1
|
pcl.fillTo(2); // don't process a1
|
||||||
|
|
||||||
Set<Integer> positions = asSet(0, 1);
|
Set<Integer> positions = asSet(0, 1);
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
PlotLane laneB = test.commit(b1).lanePos(positions).current.getLane();
|
PlotLane laneB = test.commit(b1).lanePos(positions).current
|
||||||
int posA = test.commit(a3).lanePos(positions).getLanePos();
|
.getLane();
|
||||||
test.commit(a2).lanePos(posA);
|
int posA = test.commit(a3).lanePos(positions).getLanePos();
|
||||||
assertArrayEquals(
|
test.commit(a2).lanePos(posA);
|
||||||
"Although the parent of b1, a1, is not processed yet, the b lane should still be drawn",
|
assertArrayEquals(
|
||||||
new PlotLane[] { laneB }, test.current.passingLanes);
|
"Although the parent of b1, a1, is not processed yet, the b lane should still be drawn",
|
||||||
test.noMoreCommits();
|
new PlotLane[] { laneB }, test.current.passingLanes);
|
||||||
|
test.noMoreCommits();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -674,17 +691,18 @@ public void testTwoRoots1() throws Exception {
|
||||||
final RevCommit a = commit();
|
final RevCommit a = commit();
|
||||||
final RevCommit b = commit();
|
final RevCommit b = commit();
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(a));
|
pw.markStart(pw.lookupCommit(a));
|
||||||
pw.markStart(pw.lookupCommit(b));
|
pw.markStart(pw.lookupCommit(b));
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
|
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
test.commit(b).lanePos(0);
|
test.commit(b).lanePos(0);
|
||||||
test.commit(a).lanePos(0);
|
test.commit(a).lanePos(0);
|
||||||
test.noMoreCommits();
|
test.noMoreCommits();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -693,17 +711,18 @@ public void testTwoRoots2() throws Exception {
|
||||||
final RevCommit b1 = commit();
|
final RevCommit b1 = commit();
|
||||||
final RevCommit b2 = commit(b1);
|
final RevCommit b2 = commit(b1);
|
||||||
|
|
||||||
PlotWalk pw = new PlotWalk(db);
|
try (PlotWalk pw = new PlotWalk(db)) {
|
||||||
pw.markStart(pw.lookupCommit(a));
|
pw.markStart(pw.lookupCommit(a));
|
||||||
pw.markStart(pw.lookupCommit(b2));
|
pw.markStart(pw.lookupCommit(b2));
|
||||||
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
PlotCommitList<PlotLane> pcl = new PlotCommitList<>();
|
||||||
pcl.source(pw);
|
pcl.source(pw);
|
||||||
pcl.fillTo(Integer.MAX_VALUE);
|
pcl.fillTo(Integer.MAX_VALUE);
|
||||||
|
|
||||||
CommitListAssert test = new CommitListAssert(pcl);
|
CommitListAssert test = new CommitListAssert(pcl);
|
||||||
test.commit(b2).lanePos(0);
|
test.commit(b2).lanePos(0);
|
||||||
test.commit(b1).lanePos(0);
|
test.commit(b1).lanePos(0);
|
||||||
test.commit(a).lanePos(0);
|
test.commit(a).lanePos(0);
|
||||||
test.noMoreCommits();
|
test.noMoreCommits();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,18 +107,18 @@ public void testParse_NoParents() throws Exception {
|
||||||
|
|
||||||
body.append("\n");
|
body.append("\n");
|
||||||
|
|
||||||
final RevWalk rw = new RevWalk(db);
|
|
||||||
final RevCommit c;
|
final RevCommit c;
|
||||||
|
|
||||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
assertNull(c.getTree());
|
assertNull(c.getTree());
|
||||||
assertNull(c.parents);
|
assertNull(c.parents);
|
||||||
|
|
||||||
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
assertNotNull(c.getTree());
|
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
|
||||||
assertEquals(treeId, c.getTree().getId());
|
assertNotNull(c.getTree());
|
||||||
assertSame(rw.lookupTree(treeId), c.getTree());
|
assertEquals(treeId, c.getTree().getId());
|
||||||
|
assertSame(rw.lookupTree(treeId), c.getTree());
|
||||||
|
}
|
||||||
assertNotNull(c.parents);
|
assertNotNull(c.parents);
|
||||||
assertEquals(0, c.parents.length);
|
assertEquals(0, c.parents.length);
|
||||||
assertEquals("", c.getFullMessage());
|
assertEquals("", c.getFullMessage());
|
||||||
|
@ -148,8 +148,10 @@ private RevCommit create(String msg) throws Exception {
|
||||||
|
|
||||||
final RevCommit c;
|
final RevCommit c;
|
||||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
return c;
|
c.parseCanonical(rw, b.toString().getBytes(UTF_8));
|
||||||
|
return c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -161,8 +163,9 @@ public void testParse_WeirdHeaderOnlyCommit() throws Exception {
|
||||||
|
|
||||||
final RevCommit c;
|
final RevCommit c;
|
||||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toString().getBytes(UTF_8));
|
||||||
|
}
|
||||||
assertEquals("", c.getFullMessage());
|
assertEquals("", c.getFullMessage());
|
||||||
assertEquals("", c.getShortMessage());
|
assertEquals("", c.getShortMessage());
|
||||||
}
|
}
|
||||||
|
@ -176,8 +179,9 @@ public void testParse_incompleteAuthorAndCommitter() throws Exception {
|
||||||
|
|
||||||
final RevCommit c;
|
final RevCommit c;
|
||||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toString().getBytes(UTF_8));
|
||||||
|
}
|
||||||
assertEquals(new PersonIdent("", "a_u_thor@example.com", 1218123387000l, 7), c.getAuthorIdent());
|
assertEquals(new PersonIdent("", "a_u_thor@example.com", 1218123387000l, 7), c.getAuthorIdent());
|
||||||
assertEquals(new PersonIdent("", "", 1218123390000l, -5), c.getCommitterIdent());
|
assertEquals(new PersonIdent("", "", 1218123390000l, -5), c.getCommitterIdent());
|
||||||
}
|
}
|
||||||
|
@ -194,8 +198,9 @@ public void testParse_implicit_UTF8_encoded() throws Exception {
|
||||||
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
||||||
final RevCommit c;
|
final RevCommit c;
|
||||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
||||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
assertSame(UTF_8, c.getEncoding());
|
assertSame(UTF_8, c.getEncoding());
|
||||||
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
|
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
|
||||||
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
|
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
|
||||||
|
@ -214,8 +219,9 @@ public void testParse_implicit_mixed_encoded() throws Exception {
|
||||||
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
||||||
final RevCommit c;
|
final RevCommit c;
|
||||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
||||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
assertSame(UTF_8, c.getEncoding());
|
assertSame(UTF_8, c.getEncoding());
|
||||||
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
|
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
|
||||||
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
|
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
|
||||||
|
@ -240,7 +246,9 @@ public void testParse_explicit_encoded() throws Exception {
|
||||||
b.write("Hi\n".getBytes("EUC-JP"));
|
b.write("Hi\n".getBytes("EUC-JP"));
|
||||||
final RevCommit c;
|
final RevCommit c;
|
||||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
||||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals("EUC-JP", c.getEncoding().name());
|
assertEquals("EUC-JP", c.getEncoding().name());
|
||||||
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
|
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
|
||||||
|
@ -270,7 +278,9 @@ public void testParse_explicit_bad_encoded() throws Exception {
|
||||||
b.write("Hi\n".getBytes(UTF_8));
|
b.write("Hi\n".getBytes(UTF_8));
|
||||||
final RevCommit c;
|
final RevCommit c;
|
||||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
||||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals("EUC-JP", c.getEncoding().name());
|
assertEquals("EUC-JP", c.getEncoding().name());
|
||||||
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
|
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
|
||||||
|
@ -301,7 +311,9 @@ public void testParse_explicit_bad_encoded2() throws Exception {
|
||||||
b.write("Hi\n".getBytes(UTF_8));
|
b.write("Hi\n".getBytes(UTF_8));
|
||||||
final RevCommit c;
|
final RevCommit c;
|
||||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
||||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals("ISO-8859-1", c.getEncoding().name());
|
assertEquals("ISO-8859-1", c.getEncoding().name());
|
||||||
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
|
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
|
||||||
|
@ -323,7 +335,9 @@ public void testParse_incorrectUtf8Name() throws Exception {
|
||||||
|
|
||||||
RevCommit c = new RevCommit(
|
RevCommit c = new RevCommit(
|
||||||
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
assertEquals("'utf8'", c.getEncodingName());
|
assertEquals("'utf8'", c.getEncodingName());
|
||||||
assertEquals("Sm\u00f6rg\u00e5sbord\n", c.getFullMessage());
|
assertEquals("Sm\u00f6rg\u00e5sbord\n", c.getFullMessage());
|
||||||
|
|
||||||
|
@ -347,7 +361,9 @@ public void testParse_illegalEncoding() throws Exception {
|
||||||
|
|
||||||
RevCommit c = new RevCommit(
|
RevCommit c = new RevCommit(
|
||||||
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
assertEquals("utf-8logoutputencoding=gbk", c.getEncodingName());
|
assertEquals("utf-8logoutputencoding=gbk", c.getEncodingName());
|
||||||
assertEquals("message\n", c.getFullMessage());
|
assertEquals("message\n", c.getFullMessage());
|
||||||
assertEquals("message", c.getShortMessage());
|
assertEquals("message", c.getShortMessage());
|
||||||
|
@ -374,7 +390,9 @@ public void testParse_unsupportedEncoding() throws Exception {
|
||||||
|
|
||||||
RevCommit c = new RevCommit(
|
RevCommit c = new RevCommit(
|
||||||
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
assertEquals("it_IT.UTF8", c.getEncodingName());
|
assertEquals("it_IT.UTF8", c.getEncodingName());
|
||||||
assertEquals("message\n", c.getFullMessage());
|
assertEquals("message\n", c.getFullMessage());
|
||||||
assertEquals("message", c.getShortMessage());
|
assertEquals("message", c.getShortMessage());
|
||||||
|
@ -507,7 +525,9 @@ public void testParse_gpgSig() throws Exception {
|
||||||
|
|
||||||
final RevCommit c;
|
final RevCommit c;
|
||||||
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
c.parseCanonical(new RevWalk(db), commit.getBytes(UTF_8));
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, commit.getBytes(UTF_8));
|
||||||
|
}
|
||||||
String gpgSig = new String(c.getRawGpgSignature(), UTF_8);
|
String gpgSig = new String(c.getRawGpgSignature(), UTF_8);
|
||||||
assertTrue(gpgSig.startsWith("-----BEGIN"));
|
assertTrue(gpgSig.startsWith("-----BEGIN"));
|
||||||
assertTrue(gpgSig.endsWith("END PGP SIGNATURE-----"));
|
assertTrue(gpgSig.endsWith("END PGP SIGNATURE-----"));
|
||||||
|
|
|
@ -91,17 +91,18 @@ private void testOneType(int typeCode) throws Exception {
|
||||||
b.append("tagger A U. Thor <a_u_thor@example.com> 1218123387 +0700\n");
|
b.append("tagger A U. Thor <a_u_thor@example.com> 1218123387 +0700\n");
|
||||||
b.append("\n");
|
b.append("\n");
|
||||||
|
|
||||||
final RevWalk rw = new RevWalk(db);
|
|
||||||
final RevTag c;
|
final RevTag c;
|
||||||
|
|
||||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
assertNull(c.getObject());
|
assertNull(c.getObject());
|
||||||
assertNull(c.getTagName());
|
assertNull(c.getTagName());
|
||||||
|
|
||||||
c.parseCanonical(rw, b.toString().getBytes(UTF_8));
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
assertNotNull(c.getObject());
|
c.parseCanonical(rw, b.toString().getBytes(UTF_8));
|
||||||
assertEquals(id, c.getObject().getId());
|
assertNotNull(c.getObject());
|
||||||
assertSame(rw.lookupAny(id, typeCode), c.getObject());
|
assertEquals(id, c.getObject().getId());
|
||||||
|
assertSame(rw.lookupAny(id, typeCode), c.getObject());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -134,18 +135,18 @@ public void testParseAllFields() throws Exception {
|
||||||
|
|
||||||
body.append("\n");
|
body.append("\n");
|
||||||
|
|
||||||
final RevWalk rw = new RevWalk(db);
|
|
||||||
final RevTag c;
|
final RevTag c;
|
||||||
|
|
||||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
assertNull(c.getObject());
|
assertNull(c.getObject());
|
||||||
assertNull(c.getTagName());
|
assertNull(c.getTagName());
|
||||||
|
|
||||||
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
assertNotNull(c.getObject());
|
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
|
||||||
assertEquals(treeId, c.getObject().getId());
|
assertNotNull(c.getObject());
|
||||||
assertSame(rw.lookupTree(treeId), c.getObject());
|
assertEquals(treeId, c.getObject().getId());
|
||||||
|
assertSame(rw.lookupTree(treeId), c.getObject());
|
||||||
|
}
|
||||||
assertNotNull(c.getTagName());
|
assertNotNull(c.getTagName());
|
||||||
assertEquals(name, c.getTagName());
|
assertEquals(name, c.getTagName());
|
||||||
assertEquals("", c.getFullMessage());
|
assertEquals("", c.getFullMessage());
|
||||||
|
@ -182,17 +183,18 @@ public void testParseOldStyleNoTagger() throws Exception {
|
||||||
body.append("\n");
|
body.append("\n");
|
||||||
body.append(message);
|
body.append(message);
|
||||||
|
|
||||||
final RevWalk rw = new RevWalk(db);
|
|
||||||
final RevTag c;
|
final RevTag c;
|
||||||
|
|
||||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
assertNull(c.getObject());
|
assertNull(c.getObject());
|
||||||
assertNull(c.getTagName());
|
assertNull(c.getTagName());
|
||||||
|
|
||||||
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
assertNotNull(c.getObject());
|
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
|
||||||
assertEquals(treeId, c.getObject().getId());
|
assertNotNull(c.getObject());
|
||||||
assertSame(rw.lookupTree(treeId), c.getObject());
|
assertEquals(treeId, c.getObject().getId());
|
||||||
|
assertSame(rw.lookupTree(treeId), c.getObject());
|
||||||
|
}
|
||||||
|
|
||||||
assertNotNull(c.getTagName());
|
assertNotNull(c.getTagName());
|
||||||
assertEquals(name, c.getTagName());
|
assertEquals(name, c.getTagName());
|
||||||
|
@ -213,7 +215,9 @@ private RevTag create(String msg) throws Exception {
|
||||||
|
|
||||||
final RevTag c;
|
final RevTag c;
|
||||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toString().getBytes(UTF_8));
|
||||||
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +238,9 @@ public void testParse_implicit_UTF8_encoded() throws Exception {
|
||||||
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
||||||
final RevTag c;
|
final RevTag c;
|
||||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals("F\u00f6r fattare", c.getTaggerIdent().getName());
|
assertEquals("F\u00f6r fattare", c.getTaggerIdent().getName());
|
||||||
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
|
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
|
||||||
|
@ -257,7 +263,9 @@ public void testParse_implicit_mixed_encoded() throws Exception {
|
||||||
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
|
||||||
final RevTag c;
|
final RevTag c;
|
||||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals("F\u00f6r fattare", c.getTaggerIdent().getName());
|
assertEquals("F\u00f6r fattare", c.getTaggerIdent().getName());
|
||||||
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
|
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
|
||||||
|
@ -287,7 +295,9 @@ public void testParse_explicit_encoded() throws Exception {
|
||||||
b.write("Hi\n".getBytes("EUC-JP"));
|
b.write("Hi\n".getBytes("EUC-JP"));
|
||||||
final RevTag c;
|
final RevTag c;
|
||||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals("F\u00f6r fattare", c.getTaggerIdent().getName());
|
assertEquals("F\u00f6r fattare", c.getTaggerIdent().getName());
|
||||||
assertEquals("\u304d\u308c\u3044", c.getShortMessage());
|
assertEquals("\u304d\u308c\u3044", c.getShortMessage());
|
||||||
|
@ -320,7 +330,9 @@ public void testParse_explicit_bad_encoded() throws Exception {
|
||||||
b.write("Hi\n".getBytes(UTF_8));
|
b.write("Hi\n".getBytes(UTF_8));
|
||||||
final RevTag c;
|
final RevTag c;
|
||||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals("F\u00f6r fattare", c.getTaggerIdent().getName());
|
assertEquals("F\u00f6r fattare", c.getTaggerIdent().getName());
|
||||||
assertEquals("\u304d\u308c\u3044", c.getShortMessage());
|
assertEquals("\u304d\u308c\u3044", c.getShortMessage());
|
||||||
|
@ -355,7 +367,9 @@ public void testParse_explicit_bad_encoded2() throws Exception {
|
||||||
b.write("Hi\n".getBytes(UTF_8));
|
b.write("Hi\n".getBytes(UTF_8));
|
||||||
final RevTag c;
|
final RevTag c;
|
||||||
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
c.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
c.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals("F\u00f6r fattare", c.getTaggerIdent().getName());
|
assertEquals("F\u00f6r fattare", c.getTaggerIdent().getName());
|
||||||
assertEquals("\u304d\u308c\u3044", c.getShortMessage());
|
assertEquals("\u304d\u308c\u3044", c.getShortMessage());
|
||||||
|
@ -374,7 +388,9 @@ public void testParse_illegalEncoding() throws Exception {
|
||||||
b.write("message\n".getBytes(UTF_8));
|
b.write("message\n".getBytes(UTF_8));
|
||||||
|
|
||||||
RevTag t = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
RevTag t = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
t.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
t.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals("t", t.getTaggerIdent().getName());
|
assertEquals("t", t.getTaggerIdent().getName());
|
||||||
assertEquals("message", t.getShortMessage());
|
assertEquals("message", t.getShortMessage());
|
||||||
|
@ -393,7 +409,9 @@ public void testParse_unsupportedEncoding() throws Exception {
|
||||||
b.write("message\n".getBytes(UTF_8));
|
b.write("message\n".getBytes(UTF_8));
|
||||||
|
|
||||||
RevTag t = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
RevTag t = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
|
||||||
t.parseCanonical(new RevWalk(db), b.toByteArray());
|
try (RevWalk rw = new RevWalk(db)) {
|
||||||
|
t.parseCanonical(rw, b.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals("t", t.getTaggerIdent().getName());
|
assertEquals("t", t.getTaggerIdent().getName());
|
||||||
assertEquals("message", t.getShortMessage());
|
assertEquals("message", t.getShortMessage());
|
||||||
|
|
Loading…
Reference in New Issue