@Nullable private byte[] loadFromVersionControl(long date, VirtualFile f) { try { final AbstractVcs vcs = VcsUtil.getVcsFor(myProject, f); if (vcs == null) return null; final VcsHistoryProvider historyProvider = vcs.getVcsHistoryProvider(); if (historyProvider == null) return null; final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(f); final VcsHistorySession session = historyProvider.createSessionFor(filePath); if (session == null) return null; final List<VcsFileRevision> list = session.getRevisionList(); if (list != null) { for (VcsFileRevision revision : list) { final Date revisionDate = revision.getRevisionDate(); if (revisionDate == null) { return null; } if (revisionDate.getTime() < date) { return revision.loadContent(); } } } } catch (Exception e) { LOG.info(e); return null; } return null; }
private static boolean isEnabled( @NotNull Project project, @NotNull FilePath path, @NotNull VirtualFile fileOrParent) { boolean result = false; AbstractVcs vcs = ChangesUtil.getVcsForFile(fileOrParent, project); if (vcs != null) { VcsHistoryProvider provider = vcs.getVcsHistoryProvider(); result = provider != null && (provider.supportsHistoryForDirectories() || !path.isDirectory()) && AbstractVcs.fileInVcsByFileStatus(project, fileOrParent) && provider.canShowHistoryFor(fileOrParent); } return result; }