From 9ac59efbbd17bcc41fa82e2ead3b2a0a73206dce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Konrad=20K=C3=BCgler?= Date: Mon, 1 Sep 2014 21:09:59 +0200 Subject: [PATCH] PlotCommitList: Close plot lanes at root commits MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Bug: 443006 Change-Id: I40b1eb044fa2d9e6c5d4b956c17e32ca6c1bd39f Signed-off-by: Konrad Kügler --- .../jgit/revplot/PlotCommitListTest.java | 38 +++++++++++++++++++ .../eclipse/jgit/revplot/PlotCommitList.java | 10 ++--- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/PlotCommitListTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/PlotCommitListTest.java index 0f582c4001..ecc119b29a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/PlotCommitListTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/PlotCommitListTest.java @@ -668,4 +668,42 @@ public class PlotCommitListTest extends RevWalkTestCase { new PlotLane[] { laneB }, test.current.passingLanes); test.noMoreCommits(); } + + @Test + public void testTwoRoots1() throws Exception { + final RevCommit a = commit(); + final RevCommit b = commit(); + + PlotWalk pw = new PlotWalk(db); + pw.markStart(pw.lookupCommit(a)); + pw.markStart(pw.lookupCommit(b)); + PlotCommitList pcl = new PlotCommitList(); + pcl.source(pw); + pcl.fillTo(Integer.MAX_VALUE); + + CommitListAssert test = new CommitListAssert(pcl); + test.commit(b).lanePos(0); + test.commit(a).lanePos(0); + test.noMoreCommits(); + } + + @Test + public void testTwoRoots2() throws Exception { + final RevCommit a = commit(); + final RevCommit b1 = commit(); + final RevCommit b2 = commit(b1); + + PlotWalk pw = new PlotWalk(db); + pw.markStart(pw.lookupCommit(a)); + pw.markStart(pw.lookupCommit(b2)); + PlotCommitList pcl = new PlotCommitList(); + pcl.source(pw); + pcl.fillTo(Integer.MAX_VALUE); + + CommitListAssert test = new CommitListAssert(pcl); + test.commit(b2).lanePos(0); + test.commit(b1).lanePos(0); + test.commit(a).lanePos(0); + test.noMoreCommits(); + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java index 36e4b4b3fa..3444c8df1c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java @@ -128,11 +128,8 @@ public class PlotCommitList extends final int nChildren = currCommit.getChildCount(); if (nChildren == 0) { currCommit.lane = nextFreeLane(); - continueActiveLanes(currCommit); - return; - } - - if (nChildren == 1 && currCommit.children[0].getParentCount() < 2) { + } else if (nChildren == 1 + && currCommit.children[0].getParentCount() < 2) { // Only one child, child has only us as their parent. // Stay in the same lane as the child. @@ -195,7 +192,10 @@ public class PlotCommitList extends closeLane(c.lane); } } + continueActiveLanes(currCommit); + if (currCommit.getParentCount() == 0) + closeLane(currCommit.lane); } private void continueActiveLanes(final PlotCommit currCommit) { -- 2.39.5