@Override public int compareTo(Commit o) { if (o.equals(this)) return 0; if (findInPredecessors(o)) return 1; if (findInSuccessors(o)) return -1; return time.compareTo(o.getTime()); }
private boolean findInPredecessors(Commit o) { if (this.predecessor.contains(o)) return true; for (Commit c : predecessor) if (c.findInPredecessors(o)) return true; return false; }
private boolean findInSuccessors(Commit o) { if (this.successors.contains(o)) return true; for (Commit c : successors) if (c.findInSuccessors(o)) return true; return false; }