Block (int revisionIndex, int totalRevisions, Progress p) { Block cached = myCache.get(revisionIndex); if (cached != null) return cached; String content = getRevisionContent(myRevisions.get(revisionIndex)); p.processed(((totalRevisions - revisionIndex) * 100) / totalRevisions); Block result; if (content == null) { result = EMPTY_BLOCK; } else if (revisionIndex == 0) { result = new Block(content, myFromLine, myToLine + 1); } else { Block prev = EMPTY_BLOCK; int i = revisionIndex; while(prev == EMPTY_BLOCK && i > 0) { i--; prev = getSelectionFor(i, totalRevisions, p); } result = prev.createPreviousBlock(content); } myCache.put(revisionIndex, result); return result; }