private VcsAbstractHistorySession getHistory(VcsRevisionNumber revision, FilePath filePath, VcsHistoryProvider historyProvider,
                                               @Nullable final VcsRevisionNumber firstRevision) throws VcsException {
    final boolean historyCacheSupported = historyProvider instanceof VcsCacheableHistorySessionFactory;
    if (historyCacheSupported) {
      final VcsCacheableHistorySessionFactory cacheableHistorySessionFactory = (VcsCacheableHistorySessionFactory)historyProvider;
      final VcsAbstractHistorySession cachedSession = myCache.getSession(filePath, myVcs.getKeyInstanceMethod(),
                                                                         cacheableHistorySessionFactory, true);
      if (cachedSession != null && !cachedSession.getRevisionList().isEmpty()) {
        final VcsFileRevision recentRevision = cachedSession.getRevisionList().get(0);
        if (recentRevision.getRevisionNumber().compareTo(revision) >= 0 && (firstRevision == null || cachedSession.getHistoryAsMap().containsKey(firstRevision))) {
          return cachedSession;
        }
      }
    }
    // history may be also cut
    final VcsAbstractHistorySession sessionFor;
    if (firstRevision != null) {
      sessionFor = limitedHistory(filePath, firstRevision);
    }
    else {
      sessionFor = (VcsAbstractHistorySession)historyProvider.createSessionFor(filePath);
    }
    if (sessionFor != null && historyCacheSupported) {
      final VcsCacheableHistorySessionFactory cacheableHistorySessionFactory = (VcsCacheableHistorySessionFactory)historyProvider;
      final FilePath correctedPath = cacheableHistorySessionFactory.getUsedFilePath(sessionFor);
      myCache.putSession(filePath, correctedPath, myVcs.getKeyInstanceMethod(), sessionFor, cacheableHistorySessionFactory, firstRevision == null);
    }
    return sessionFor;
  }
private VcsAbstractHistorySession getHistory(VcsRevisionNumber revision, FilePath filePath, VcsHistoryProvider historyProvider,
                                               @Nullable final VcsRevisionNumber firstRevision)