use of com.intellij.openapi.vcs.history.VcsFileRevision in project intellij-community by JetBrains.
the class ShowAllAffectedGenericAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null)
return;
final VcsKey vcsKey = e.getData(VcsDataKeys.VCS);
if (vcsKey == null)
return;
final VcsFileRevision revision = e.getData(VcsDataKeys.VCS_FILE_REVISION);
VirtualFile revisionVirtualFile = e.getData(VcsDataKeys.VCS_VIRTUAL_FILE);
final Boolean isNonLocal = e.getData(VcsDataKeys.VCS_NON_LOCAL_HISTORY_SESSION);
if ((revision != null) && (revisionVirtualFile != null)) {
showSubmittedFiles(project, revision.getRevisionNumber(), revisionVirtualFile, vcsKey, revision.getChangedRepositoryPath(), Boolean.TRUE.equals(isNonLocal));
}
}
use of com.intellij.openapi.vcs.history.VcsFileRevision in project intellij-community by JetBrains.
the class HgHistoryTest method locallyRenamedFileShouldGetHistory.
@Test
public void locallyRenamedFileShouldGetHistory() throws Exception {
int versions = 0;
fillFile(myProjectDir, new String[] { AFILE }, INITIAL_FILE_CONTENT);
addAll();
commitAll("initial content");
versions++;
fillFile(myProjectDir, new String[] { AFILE }, UPDATED_FILE_CONTENT);
commitAll("updated content");
versions++;
runHgOnProjectRepo("rename", AFILE, BFILE);
//don't commit
refreshVfs();
ChangeListManager.getInstance(myProject).ensureUpToDate(false);
final VcsHistorySession session = getHistorySession(BFILE);
final List<VcsFileRevision> revisions = session.getRevisionList();
for (VcsFileRevision rev : revisions) {
rev.loadContent();
}
assertEquals(revisions.size(), versions);
assertTrue(session.isCurrentRevision(revisions.get(0).getRevisionNumber()));
assertEquals(revisions.get(0).getContent(), UPDATED_FILE_CONTENT.getBytes());
assertEquals(revisions.get(1).getContent(), INITIAL_FILE_CONTENT.getBytes());
}
use of com.intellij.openapi.vcs.history.VcsFileRevision 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.VcsFileRevision in project intellij-community by JetBrains.
the class SvnHistoryTest method testLocallyMovedToRenamedDirectory.
@Test
public void testLocallyMovedToRenamedDirectory() throws Exception {
enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
enableSilentOperation(VcsConfiguration.StandardConfirmation.REMOVE);
myCnt = 0;
final VcsHistoryProvider provider = SvnVcs.getInstance(myProject).getVcsHistoryProvider();
final SubTree tree = new SubTree(myWorkingCopyDir);
checkin();
for (int i = 0; i < 10; i++) {
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3\n4\n" + i);
checkin();
}
VcsTestUtil.renameFileInCommand(myProject, tree.myTargetDir, "renamedTarget");
VcsTestUtil.moveFileInCommand(myProject, tree.myS1File, tree.myTargetDir);
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
ChangeListManager.getInstance(myProject).ensureUpToDate(false);
final Semaphore semaphore = new Semaphore();
semaphore.down();
provider.reportAppendableHistory(VcsUtil.getFilePath(tree.myS1File), new VcsAppendableHistorySessionPartner() {
@Override
public void reportCreatedEmptySession(VcsAbstractHistorySession session) {
}
@Override
public void acceptRevision(VcsFileRevision revision) {
++myCnt;
}
@Override
public void reportException(VcsException exception) {
throw new RuntimeException(exception);
}
@Override
public void finished() {
semaphore.up();
}
@Override
public void beforeRefresh() {
}
@Override
public void forceRefresh() {
}
});
semaphore.waitFor(1000);
Assert.assertEquals(11, myCnt);
myCnt = 0;
semaphore.down();
provider.reportAppendableHistory(VcsUtil.getFilePath(tree.myTargetDir), new VcsAppendableHistorySessionPartner() {
@Override
public void reportCreatedEmptySession(VcsAbstractHistorySession session) {
}
@Override
public void acceptRevision(VcsFileRevision revision) {
++myCnt;
}
@Override
public void reportException(VcsException exception) {
throw new RuntimeException(exception);
}
@Override
public void finished() {
semaphore.up();
}
@Override
public void beforeRefresh() {
}
@Override
public void forceRefresh() {
}
});
semaphore.waitFor(1000);
Assert.assertEquals(1, myCnt);
myCnt = 0;
semaphore.down();
provider.reportAppendableHistory(VcsUtil.getFilePath(tree.myTargetFiles.get(0)), new VcsAppendableHistorySessionPartner() {
@Override
public void reportCreatedEmptySession(VcsAbstractHistorySession session) {
}
@Override
public void acceptRevision(VcsFileRevision revision) {
++myCnt;
}
@Override
public void reportException(VcsException exception) {
throw new RuntimeException(exception);
}
@Override
public void finished() {
semaphore.up();
}
@Override
public void beforeRefresh() {
}
@Override
public void forceRefresh() {
}
});
semaphore.waitFor(1000);
Assert.assertEquals(1, myCnt);
}
use of com.intellij.openapi.vcs.history.VcsFileRevision in project intellij-community by JetBrains.
the class GitAnnotationProvider method loadFileHistoryInBackground.
private void loadFileHistoryInBackground(@NotNull GitFileAnnotation fileAnnotation) {
List<VcsFileRevision> fileRevisions = BackgroundTaskUtil.computeInBackgroundAndTryWait(() -> {
try {
VirtualFile file = fileAnnotation.getFile();
FilePath filePath = VcsUtil.getFilePath(file);
VcsRevisionNumber currentRevision = fileAnnotation.getCurrentRevision();
if (file.isInLocalFileSystem() || currentRevision == null) {
return loadFileHistory(filePath);
} else {
return GitHistoryUtils.history(myProject, filePath, null, currentRevision);
}
} catch (VcsException e) {
LOG.error(e);
return null;
}
}, (revisions) -> {
if (revisions == null)
return;
ApplicationManager.getApplication().invokeLater(() -> {
GitFileAnnotation newFileAnnotation = new GitFileAnnotation(fileAnnotation);
newFileAnnotation.setRevisions(revisions);
fileAnnotation.reload(newFileAnnotation);
}, myProject.getDisposed());
}, ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS);
if (fileRevisions != null) {
fileAnnotation.setRevisions(fileRevisions);
}
}
Aggregations