in org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GenerateHistoryJob.java [97:198]
protected IStatus run(final IProgressMonitor monitor) {
synchronized (lock) {
nextLoadHint = -1;
}
IStatus status = Status.OK_STATUS;
int maxCommits = Activator.getDefault().getPreferenceStore()
.getInt(UIPreferences.HISTORY_MAX_NUM_COMMITS);
int chunk = maxCommits;
boolean incomplete = false;
boolean commitNotFound = false;
try {
if (trace)
GitTraceLocation.getTrace().traceEntry(
GitTraceLocation.HISTORYVIEW.getLocation());
final boolean loadIncrementally = !Activator.getDefault()
.getPreferenceStore()
.getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_FINDTOOLBAR);
int initialSize = loadedCommits.size();
try {
for (int oldsz = initialSize;;) {
if (trace)
GitTraceLocation.getTrace().trace(
GitTraceLocation.HISTORYVIEW.getLocation(),
"Filling commit list"); //$NON-NLS-1$
if (commitToLoad != null) {
if (maxCommits > 0
&& loadedCommits.size() >= maxCommits) {
// We're still looking for a commit
maxCommits = loadedCommits.size() + Math
.min(Math.max(chunk, 1000), 10000);
}
loadedCommits.fillTo(commitToLoad, maxCommits);
commitToShow = commitToLoad;
boolean commitFound = wantedIndex >= 0;
if (commitFound) {
commitToLoad = null;
}
commitNotFound = !commitFound;
} else {
loadedCommits.fillTo(oldsz + BATCH_SIZE - 1);
if (oldsz == loadedCommits.size()) {
forcedRedrawsAfterListIsCompleted++;
break;
}
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (loadedCommits.size() > itemToLoad + (BATCH_SIZE / 2) + 1
&& loadIncrementally && !commitNotFound) {
break;
}
if (maxCommits > 0 && loadedCommits.size() > maxCommits) {
if (!loadIncrementally) {
incomplete = true;
}
if (commitToLoad == null) {
break;
}
}
if (oldsz == loadedCommits.size()) {
break;
}
oldsz = loadedCommits.size();
monitor.setTaskName(MessageFormat.format(
UIText.GenerateHistoryJob_taskFoundCommits,
Integer.valueOf(oldsz)));
}
} catch (IOException e) {
status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
UIText.GenerateHistoryJob_errorComputingHistory, e);
}
synchronized (lock) {
hasMore = loadedCommits.isPending();
size = loadedCommits.size();
if (!hasMore) {
incomplete = false;
}
}
if (trace)
GitTraceLocation.getTrace().trace(
GitTraceLocation.HISTORYVIEW.getLocation(),
"Loaded " + loadedCommits.size() + " commits"); //$NON-NLS-1$ //$NON-NLS-2$
if (commitNotFound && !loadedCommits.isEmpty()) {
if (forcedRedrawsAfterListIsCompleted < 1
&& !loadIncrementally && hasMore) {
page.setWarningTextInUIThread(this);
}
if (initialSize != loadedCommits.size()) {
updateUI(incomplete);
}
}
else
updateUI(incomplete);
} finally {
monitor.done();
if (trace)
GitTraceLocation.getTrace().traceExit(
GitTraceLocation.HISTORYVIEW.getLocation());
}
return status;
}