private void continueActiveLanes(PlotCommit currCommit) { for (PlotLane lane : activeLanes) if (lane != currCommit.lane) currCommit.addPassingLane(lane); }
/** {@inheritDoc} */ @Override protected RevCommit createCommit(AnyObjectId id) { return new PlotCommit(id); }
private void setupChildren(PlotCommit<L> currCommit) { final int nParents = currCommit.getParentCount(); for (int i = 0; i < nParents; i++) ((PlotCommit) currCommit.getParent(i)).addChild(currCommit); }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (PlotWalk revWalk = new PlotWalk(repository)) { ObjectId rootId = repository.resolve("refs/heads/master"); RevCommit root = revWalk.parseCommit(rootId); revWalk.markStart(root); PlotCommitList<PlotLane> plotCommitList = new PlotCommitList<>(); plotCommitList.source(revWalk); plotCommitList.fillTo(Integer.MAX_VALUE); System.out.println("Printing children of commit " + root); for (RevCommit com : revWalk) { System.out.println("Child: " + com); } System.out.println("Printing with next()"); System.out.println("next: " + revWalk.next()); } } } }
boolean childIsMerge = child.getParent(0) != currCommit; if (childIsMerge) { PlotLane laneToUse = currCommit.lane; laneToUse = handleMerge(index, currCommit, childOnLane, child, laneToUse); child.addMergingLane(laneToUse); } else { currCommit.addForkingOffLane(laneToUse);
@Override public int compare(Ref o1, Ref o2) { try { RevObject obj1 = parseAny(o1.getObjectId()); RevObject obj2 = parseAny(o2.getObjectId()); long t1 = timeof(obj1); long t2 = timeof(obj2); if (t1 > t2) return -1; if (t1 < t2) return 1; } catch (IOException e) { // ignore } int cmp = kind(o1) - kind(o2); if (cmp == 0) cmp = o1.getName().compareTo(o2.getName()); return cmp; }
/** * Connects the commit at commitIndex to the child, using the given lane. * All blockades on the lane must be resolved before calling this method. * * @param commitIndex * @param child * @param laneToContinue */ private void drawLaneToChild(final int commitIndex, PlotCommit child, PlotLane laneToContinue) { for (int r = commitIndex - 1; r >= 0; r--) { final PlotCommit rObj = get(r); if (rObj == child) break; if (rObj != null) rObj.addPassingLane(laneToContinue); } }
private static void addBlockedPosition(BitSet blockedPositions, final PlotCommit rObj) { if (rObj != null) { PlotLane lane = rObj.getLane(); // Positions may be blocked by a commit on a lane. if (lane != null) blockedPositions.set(lane.getPosition()); // Positions may also be blocked by forking off and merging lanes. // We don't consider passing lanes, because every passing lane forks // off and merges at it ends. for (PlotLane l : rObj.forkingOffLanes) blockedPositions.set(l.getPosition()); for (PlotLane l : rObj.mergingLanes) blockedPositions.set(l.getPosition()); } }
@SuppressWarnings("unchecked") private void closeLane(PlotLane lane) { if (activeLanes.remove(lane)) { recycleLane((L) lane); laneLength.remove(lane); freePositions.add(Integer.valueOf(lane.getPosition())); } }
private PlotLane nextFreeLane(BitSet blockedPositions) { final PlotLane p = createLane(); p.position = getFreePosition(blockedPositions); activeLanes.add(p); laneLength.put(p, Integer.valueOf(1)); return p; }
void addPassingLane(PlotLane c) { passingLanes = addLane(c, passingLanes); }
void addChild(PlotCommit c) { final int cnt = children.length; if (cnt == 0) children = new PlotCommit[] { c }; else if (cnt == 1) { if (!c.getId().equals(children[0].getId())) children = new PlotCommit[] { children[0], c }; } else { for (PlotCommit pc : children) if (c.getId().equals(pc.getId())) return; final PlotCommit[] n = new PlotCommit[cnt + 1]; System.arraycopy(children, 0, n, 0, cnt); n[cnt] = c; children = n; } }
/** * Create a new {@link PlotLane} appropriate for this particular * {@link PlotCommitList}. * * @return a new {@link PlotLane} appropriate for this particular * {@link PlotCommitList}. */ @SuppressWarnings("unchecked") protected L createLane() { return (L) new PlotLane(); }
private static int laneC(PlotLane myLane) { return laneX(myLane) + LANE_WIDTH / 2; } }
private static int laneX(PlotLane myLane) { final int p = myLane != null ? myLane.getPosition() : 0; return LEFT_PAD + LANE_WIDTH * p; }
private PlotLane nextFreeLane() { return nextFreeLane(null); }
/** {@inheritDoc} */ @Override public RevCommit next() throws MissingObjectException, IncorrectObjectTypeException, IOException { PlotCommit<?> pc = (PlotCommit) super.next(); if (pc != null) pc.refs = getRefs(pc); return pc; }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (PlotWalk revWalk = new PlotWalk(repository)) { ObjectId rootId = repository.resolve("refs/heads/master"); RevCommit root = revWalk.parseCommit(rootId); revWalk.markStart(root); PlotCommitList<PlotLane> plotCommitList = new PlotCommitList<>(); plotCommitList.source(revWalk); plotCommitList.fillTo(Integer.MAX_VALUE); System.out.println("Printing children of commit " + root); for (RevCommit com : revWalk) { System.out.println("Child: " + com); } System.out.println("Printing with next()"); System.out.println("next: " + revWalk.next()); } } } }
void addForkingOffLane(PlotLane f) { forkingOffLanes = addLane(f, forkingOffLanes); }
void addMergingLane(PlotLane m) { mergingLanes = addLane(m, mergingLanes); }