use of com.intellij.openapi.vcs.history.VcsHistorySession in project intellij-community by JetBrains.
the class HgHistoryTest method renameShouldPreserveFileHistory.
/**
* 1. Make initial version of a file (create, add, commit).
* 2. Rename file (rename, commit).
* 3. Update file (modify, commit).
* 4. Get the file history.
* 5. Verify revision contents and the current revision.
*/
@Test
public void renameShouldPreserveFileHistory() throws Exception {
int versions = 0;
fillFile(myProjectDir, new String[] { AFILE }, INITIAL_FILE_CONTENT);
addAll();
commitAll("initial content");
versions++;
runHgOnProjectRepo("rename", AFILE, BFILE);
commitAll("file renamed");
versions++;
fillFile(myProjectDir, new String[] { BFILE }, UPDATED_FILE_CONTENT);
commitAll("updated content");
versions++;
final VcsHistorySession session = getHistorySession(BFILE);
final List<VcsFileRevision> revisions = session.getRevisionList();
loadAllRevisions(revisions);
assertEquals(revisions.size(), versions);
assertTrue(session.isCurrentRevision(revisions.get(0).getRevisionNumber()));
assertEquals(revisions.get(0).getContent(), UPDATED_FILE_CONTENT.getBytes());
assertEquals(revisions.get(2).getContent(), INITIAL_FILE_CONTENT.getBytes());
}
use of com.intellij.openapi.vcs.history.VcsHistorySession in project intellij-community by JetBrains.
the class SrcFileAnnotator method loadFromVersionControl.
@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;
}
use of com.intellij.openapi.vcs.history.VcsHistorySession in project intellij-community by JetBrains.
the class GitDiffFromHistoryHandler method showDiffForMergeCommit.
private void showDiffForMergeCommit(@NotNull final AnActionEvent event, @NotNull final FilePath filePath, @NotNull final GitFileRevision rev, @NotNull final Collection<String> parents) {
VcsHistorySession session = event.getData(VcsDataKeys.HISTORY_SESSION);
List<VcsFileRevision> revisions = session != null ? session.getRevisionList() : null;
checkIfFileWasTouchedAndFindParentsInBackground(filePath, rev, parents, revisions, new Consumer<MergeCommitPreCheckInfo>() {
@Override
public void consume(MergeCommitPreCheckInfo info) {
if (!info.wasFileTouched()) {
String message = String.format("There were no changes in %s in this merge commit, besides those which were made in both branches", filePath.getName());
VcsBalloonProblemNotifier.showOverVersionControlView(GitDiffFromHistoryHandler.this.myProject, message, MessageType.INFO);
}
showPopup(event, rev, filePath, info.getParents());
}
});
}
Aggregations