Search in sources :

Example 1 with IFileHistory

use of org.eclipse.team.core.history.IFileHistory in project egit by eclipse.

the class HistoryTest method testSingleRevision_1.

@Test
public void testSingleRevision_1() {
    GitProvider provider = (GitProvider) RepositoryProvider.getProvider(project.project);
    assertNotNull(provider);
    IFileHistoryProvider fileHistoryProvider = provider.getFileHistoryProvider();
    IFileHistory fileHistory = fileHistoryProvider.getFileHistoryFor(project.getProject().getWorkspace().getRoot().findMember("Project-1/A.txt"), IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, new NullProgressMonitor());
    IFileRevision fileRevision = fileHistory.getFileRevision("60f0d7917fe2aed5c92b5bc35dfb55b9b8ada359");
    assertEquals("60f0d7917fe2aed5c92b5bc35dfb55b9b8ada359", fileRevision.getContentIdentifier());
    assertEquals("J. Author", fileRevision.getAuthor());
}
Also used : IFileHistory(org.eclipse.team.core.history.IFileHistory) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileHistoryProvider(org.eclipse.team.core.history.IFileHistoryProvider) IFileRevision(org.eclipse.team.core.history.IFileRevision) GitProvider(org.eclipse.egit.core.GitProvider) Test(org.junit.Test)

Example 2 with IFileHistory

use of org.eclipse.team.core.history.IFileHistory in project egit by eclipse.

the class HistoryTest method testIndexRevisionSecondCommit.

@Test
public void testIndexRevisionSecondCommit() throws Exception {
    GitProvider provider = (GitProvider) RepositoryProvider.getProvider(project.project);
    assertNotNull(provider);
    IFileHistoryProvider fileHistoryProvider = provider.getFileHistoryProvider();
    IFileHistory fileHistory = fileHistoryProvider.getFileHistoryFor(project.getProject().getWorkspace().getRoot().findMember("Project-1/B.txt"), IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, new NullProgressMonitor());
    IFileRevision fileRevision = fileHistory.getFileRevision(GitFileRevision.INDEX);
    assertEquals(GitFileRevision.INDEX, fileRevision.getContentIdentifier());
    IStorage storage = fileRevision.getStorage(null);
    String content = testUtils.slurpAndClose(storage.getContents());
    assertEquals("B.txt - second version\n", content);
}
Also used : IFileHistory(org.eclipse.team.core.history.IFileHistory) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileHistoryProvider(org.eclipse.team.core.history.IFileHistoryProvider) IFileRevision(org.eclipse.team.core.history.IFileRevision) IStorage(org.eclipse.core.resources.IStorage) GitProvider(org.eclipse.egit.core.GitProvider) Test(org.junit.Test)

Example 3 with IFileHistory

use of org.eclipse.team.core.history.IFileHistory in project egit by eclipse.

the class HistoryTest method testShallowHistory.

@Test
public void testShallowHistory() {
    GitProvider provider = (GitProvider) RepositoryProvider.getProvider(project.project);
    assertNotNull(provider);
    IFileHistoryProvider fileHistoryProvider = provider.getFileHistoryProvider();
    IFileHistory fileHistory = fileHistoryProvider.getFileHistoryFor(project.getProject().getWorkspace().getRoot().findMember("Project-1/A.txt"), IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, new NullProgressMonitor());
    IFileRevision[] fileRevisions = fileHistory.getFileRevisions();
    assertEquals(1, fileRevisions.length);
    assertEquals("60f0d7917fe2aed5c92b5bc35dfb55b9b8ada359", fileRevisions[0].getContentIdentifier());
    assertEquals("J. Author", fileRevisions[0].getAuthor());
}
Also used : IFileHistory(org.eclipse.team.core.history.IFileHistory) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileHistoryProvider(org.eclipse.team.core.history.IFileHistoryProvider) IFileRevision(org.eclipse.team.core.history.IFileRevision) GitProvider(org.eclipse.egit.core.GitProvider) Test(org.junit.Test)

Example 4 with IFileHistory

use of org.eclipse.team.core.history.IFileHistory in project egit by eclipse.

the class HistoryTest method testSingleRevision_2.

@Test
public void testSingleRevision_2() {
    GitProvider provider = (GitProvider) RepositoryProvider.getProvider(project.project);
    assertNotNull(provider);
    IFileHistoryProvider fileHistoryProvider = provider.getFileHistoryProvider();
    IFileHistory fileHistory = fileHistoryProvider.getFileHistoryFor(project.getProject().getWorkspace().getRoot().findMember("Project-1/A.txt"), IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, new NullProgressMonitor());
    IFileRevision fileRevision = fileHistory.getFileRevision("fd5a571c8a3a4a152e4c413d09d3ecb7d41e1e5f");
    // not matched by getFileHistoryFor
    assertNull(fileRevision);
}
Also used : IFileHistory(org.eclipse.team.core.history.IFileHistory) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileHistoryProvider(org.eclipse.team.core.history.IFileHistoryProvider) IFileRevision(org.eclipse.team.core.history.IFileRevision) GitProvider(org.eclipse.egit.core.GitProvider) Test(org.junit.Test)

Example 5 with IFileHistory

use of org.eclipse.team.core.history.IFileHistory in project egit by eclipse.

the class HistoryTest method testIndexRevision.

@Test
public void testIndexRevision() throws Exception {
    GitProvider provider = (GitProvider) RepositoryProvider.getProvider(project.project);
    assertNotNull(provider);
    IFileHistoryProvider fileHistoryProvider = provider.getFileHistoryProvider();
    IFileHistory fileHistory = fileHistoryProvider.getFileHistoryFor(project.getProject().getWorkspace().getRoot().findMember("Project-1/A.txt"), IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, new NullProgressMonitor());
    IFileRevision fileRevision = fileHistory.getFileRevision(GitFileRevision.INDEX);
    assertEquals(GitFileRevision.INDEX, fileRevision.getContentIdentifier());
    IStorage storage = fileRevision.getStorage(null);
    String content = testUtils.slurpAndClose(storage.getContents());
    assertEquals("A.txt - first version\n", content);
}
Also used : IFileHistory(org.eclipse.team.core.history.IFileHistory) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileHistoryProvider(org.eclipse.team.core.history.IFileHistoryProvider) IFileRevision(org.eclipse.team.core.history.IFileRevision) IStorage(org.eclipse.core.resources.IStorage) GitProvider(org.eclipse.egit.core.GitProvider) Test(org.junit.Test)

Aggregations

IFileHistory (org.eclipse.team.core.history.IFileHistory)17 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)16 IFileRevision (org.eclipse.team.core.history.IFileRevision)16 Test (org.junit.Test)15 GitProvider (org.eclipse.egit.core.GitProvider)8 IFileHistoryProvider (org.eclipse.team.core.history.IFileHistoryProvider)8 RevCommit (org.eclipse.jgit.revwalk.RevCommit)5 ArrayList (java.util.ArrayList)3 IFile (org.eclipse.core.resources.IFile)2 IStorage (org.eclipse.core.resources.IStorage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 IProject (org.eclipse.core.resources.IProject)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 GitFileHistoryProvider (org.eclipse.egit.core.internal.storage.GitFileHistoryProvider)1 ConnectProviderOperation (org.eclipse.egit.core.op.ConnectProviderOperation)1 DisconnectProviderOperation (org.eclipse.egit.core.op.DisconnectProviderOperation)1 GitResourceVariantTreeSubscriber (org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber)1 GitSynchronizeData (org.eclipse.egit.core.synchronize.dto.GitSynchronizeData)1 GitSynchronizeDataSet (org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet)1