Browse Source

Merge "Fix History rendering"

stable-1.3
Shawn Pearce 13 years ago committed by Code Review
parent
commit
9fc04272e6
  1. 32
      org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java

32
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,15 +190,27 @@ 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.
/**
* when connecting a plotcommit to the child make sure that 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.
*
* @param index
* @param commit
* @param nChildren
*/
private void handleBlockedLanes(final int index,
final PlotCommit<L> commit, final int nChildren) {
// take care:
int remaining = nChildren; int remaining = nChildren;
BitSet blockedPositions = new BitSet(); BitSet blockedPositions = new BitSet();
for (int r = index - 1; r >= 0; r--) { for (int r = index - 1; r >= 0; r--) {
final PlotCommit rObj = get(r); final PlotCommit rObj = get(r);
if (currCommit.isChild(rObj)) { if (commit.isChild(rObj)) {
if (--remaining == 0) if (--remaining == 0)
break; break;
} }
@ -205,11 +218,11 @@ public class PlotCommitList<L extends PlotLane> extends
PlotLane lane = rObj.getLane(); PlotLane lane = rObj.getLane();
if (lane != null) if (lane != null)
blockedPositions.set(lane.getPosition()); blockedPositions.set(lane.getPosition());
rObj.addPassingLane(currCommit.lane); rObj.addPassingLane(commit.lane);
} }
} }
// Now let's check whether we have to reposition the lane // Now let's check whether we have to reposition the lane
if (blockedPositions.get(currCommit.lane.getPosition())) { if (blockedPositions.get(commit.lane.getPosition())) {
int newPos = -1; int newPos = -1;
for (Integer pos : freePositions) for (Integer pos : freePositions)
if (!blockedPositions.get(pos)) { if (!blockedPositions.get(pos)) {
@ -218,9 +231,8 @@ public class PlotCommitList<L extends PlotLane> extends
} }
if (newPos == -1) if (newPos == -1)
newPos = positionsAllocated++; newPos = positionsAllocated++;
freePositions.add(currCommit.lane.getPosition()); freePositions.add(commit.lane.getPosition());
currCommit.lane.position = newPos; commit.lane.position = newPos;
}
} }
} }

Loading…
Cancel
Save