Browse Source

Fix History rendering

There was the possibility that during history rendering we draw a lane
"trough" a passed commit. Vadim Dmitriev found that out in bug 335818. 
I added the needed check to that block of code where it was missing.

Bug: 335818
Change-Id: Ic944193b2aca55ff3eb0235d46afa60b7896aa0f
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
stable-1.3
Christian Halstrick 13 years ago
parent
commit
df8511eeea
  1. 72
      org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java

72
org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java

@ -141,6 +141,7 @@ public class PlotCommitList<L extends PlotLane> extends
} }
currCommit.lane = c.lane; currCommit.lane = c.lane;
handleBlockedLanes(index, currCommit, nChildren);
} else { } else {
// More than one child, or our child is a merge. // More than one child, or our child is a merge.
// Use a different lane. // Use a different lane.
@ -189,39 +190,50 @@ public class PlotCommitList<L extends PlotLane> extends
currCommit.lane = nextFreeLane(); currCommit.lane = nextFreeLane();
activeLanes.add(currCommit.lane); activeLanes.add(currCommit.lane);
// take care: when connecting yourself to your child make sure that handleBlockedLanes(index, currCommit, nChildren);
// you will not be located on a lane on which a passed commit is }
// located on. Otherwise we would have to draw a line through a }
// commit.
int remaining = nChildren; /**
BitSet blockedPositions = new BitSet(); * when connecting a plotcommit to the child make sure that you will not be
for (int r = index - 1; r >= 0; r--) { * located on a lane on which a passed commit is located on. Otherwise we
final PlotCommit rObj = get(r); * would have to draw a line through a commit.
if (currCommit.isChild(rObj)) { *
if (--remaining == 0) * @param index
break; * @param commit
} * @param nChildren
if (rObj != null) { */
PlotLane lane = rObj.getLane(); private void handleBlockedLanes(final int index,
if (lane != null) final PlotCommit<L> commit, final int nChildren) {
blockedPositions.set(lane.getPosition()); // take care:
rObj.addPassingLane(currCommit.lane); int remaining = nChildren;
} BitSet blockedPositions = new BitSet();
for (int r = index - 1; r >= 0; r--) {
final PlotCommit rObj = get(r);
if (commit.isChild(rObj)) {
if (--remaining == 0)
break;
} }
// Now let's check whether we have to reposition the lane if (rObj != null) {
if (blockedPositions.get(currCommit.lane.getPosition())) { PlotLane lane = rObj.getLane();
int newPos = -1; if (lane != null)
for (Integer pos : freePositions) blockedPositions.set(lane.getPosition());
if (!blockedPositions.get(pos)) { rObj.addPassingLane(commit.lane);
newPos = pos;
break;
}
if (newPos == -1)
newPos = positionsAllocated++;
freePositions.add(currCommit.lane.getPosition());
currCommit.lane.position = newPos;
} }
} }
// Now let's check whether we have to reposition the lane
if (blockedPositions.get(commit.lane.getPosition())) {
int newPos = -1;
for (Integer pos : freePositions)
if (!blockedPositions.get(pos)) {
newPos = pos;
break;
}
if (newPos == -1)
newPos = positionsAllocated++;
freePositions.add(commit.lane.getPosition());
commit.lane.position = newPos;
}
} }
private void closeLane(PlotLane lane) { private void closeLane(PlotLane lane) {

Loading…
Cancel
Save