use of com.intellij.openapi.vcs.history.VcsHistoryProvider 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.VcsHistoryProvider 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);
}
Aggregations