private void updateUI(boolean incomplete) {
    if (trace) GitTraceLocation.getTrace().traceEntry(GitTraceLocation.HISTORYVIEW.getLocation());
    try {
      if (!incomplete && loadedCommits.size() == lastUpdateCnt) return;

      final SWTCommit[] asArray = new SWTCommit[loadedCommits.size()];
      loadedCommits.toArray(asArray);
      page.showCommitList(this, loadedCommits, asArray, commitToShow, incomplete, highlightFlag);
      commitToShow = null;
      lastUpdateCnt = loadedCommits.size();
    } finally {
      if (trace) GitTraceLocation.getTrace().traceExit(GitTraceLocation.HISTORYVIEW.getLocation());
    }
  }
  @Override
  protected IStatus run(final IProgressMonitor monitor) {
    IStatus status = Status.OK_STATUS;
    int maxCommits =
        Activator.getDefault().getPreferenceStore().getInt(UIPreferences.HISTORY_MAX_NUM_COMMITS);
    boolean incomplete = false;
    try {
      if (trace) GitTraceLocation.getTrace().traceEntry(GitTraceLocation.HISTORYVIEW.getLocation());
      try {
        for (; ; ) {
          int oldsz = loadedCommits.size();
          if (trace)
            GitTraceLocation.getTrace()
                .trace(
                    GitTraceLocation.HISTORYVIEW.getLocation(),
                    "Filling commit list"); //$NON-NLS-1$
          // ensure that filling (here) and reading (CommitGraphTable)
          // the commit list is thread safe
          synchronized (loadedCommits) {
            if (commitToLoad != null) {
              loadedCommits.fillTo(commitToLoad, maxCommits);
              commitToShow = commitToLoad;
              commitToLoad = null;
            } else loadedCommits.fillTo(oldsz + BATCH_SIZE - 1);
          }
          if (monitor.isCanceled()) return Status.CANCEL_STATUS;
          final boolean loadIncrementally =
              !Activator.getDefault()
                  .getPreferenceStore()
                  .getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_FINDTOOLBAR);
          if (loadedCommits.size() > itemToLoad + (BATCH_SIZE / 2) + 1 && loadIncrementally) break;
          if (maxCommits > 0 && loadedCommits.size() > maxCommits) incomplete = true;
          if (incomplete || oldsz == loadedCommits.size()) break;

          if (loadedCommits.size() != 1)
            monitor.setTaskName(
                MessageFormat.format(
                    UIText.GenerateHistoryJob_taskFoundMultipleCommits,
                    Integer.valueOf(loadedCommits.size())));
          else monitor.setTaskName(UIText.GenerateHistoryJob_taskFoundSingleCommit);
        }
      } catch (IOException e) {
        status =
            new Status(
                IStatus.ERROR,
                Activator.getPluginId(),
                UIText.GenerateHistoryJob_errorComputingHistory,
                e);
      }
      if (trace)
        GitTraceLocation.getTrace()
            .trace(
                GitTraceLocation.HISTORYVIEW.getLocation(),
                "Loaded " + loadedCommits.size() + " commits"); // $NON-NLS-1$ //$NON-NLS-2$
      updateUI(incomplete);
    } finally {
      monitor.done();
      if (trace) GitTraceLocation.getTrace().traceExit(GitTraceLocation.HISTORYVIEW.getLocation());
    }
    return status;
  }