Search in sources :

Example 11 with IFileHistory

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

the class HistoryTest method queryFile2Targets.

@Test
public void queryFile2Targets() {
    final IFileHistory history = historyProvider.getFileHistoryFor(iFile2, IFileHistoryProvider.NONE, new NullProgressMonitor());
    assertNotNull(history);
    final IFileRevision[] revisions = history.getFileRevisions();
    IFileRevision masterFileRevision3 = null;
    IFileRevision masterFileRevision2 = null;
    IFileRevision branchFileRevision2 = null;
    for (IFileRevision revision : revisions) {
        final String revisionId = revision.getContentIdentifier();
        if (masterCommit3.getName().equals(revisionId))
            masterFileRevision3 = revision;
        else if (masterCommit2.getName().equals(revisionId))
            masterFileRevision2 = revision;
        else if (branchCommit2.getName().equals(revisionId))
            branchFileRevision2 = revision;
    }
    assertNotNull(masterFileRevision3);
    assertNotNull(masterFileRevision2);
    assertNotNull(branchFileRevision2);
    final IFileRevision[] masterCommit2Children = history.getTargets(masterFileRevision2);
    assertEquals(2, masterCommit2Children.length);
    assertTrue(Arrays.asList(masterCommit2Children).contains(masterFileRevision3));
    assertTrue(Arrays.asList(masterCommit2Children).contains(branchFileRevision2));
    final IFileRevision[] masterCommit3Children = history.getTargets(masterFileRevision3);
    assertEquals(0, masterCommit3Children.length);
    final IFileRevision[] branchCommit2Children = history.getTargets(branchFileRevision2);
    assertEquals(0, branchCommit2Children.length);
}
Also used : IFileHistory(org.eclipse.team.core.history.IFileHistory) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileRevision(org.eclipse.team.core.history.IFileRevision) Test(org.junit.Test)

Example 12 with IFileHistory

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

the class HistoryTest method queryFile1Contributors.

@Test
public void queryFile1Contributors() {
    final IFileHistory history = historyProvider.getFileHistoryFor(iFile1, IFileHistoryProvider.NONE, new NullProgressMonitor());
    assertNotNull(history);
    final IFileRevision[] revisions = history.getFileRevisions();
    IFileRevision branchFileRevision1 = null;
    IFileRevision masterFileRevision3 = null;
    IFileRevision masterFileRevision1 = null;
    for (IFileRevision revision : revisions) {
        final String revisionId = revision.getContentIdentifier();
        if (branchCommit1.getName().equals(revisionId))
            branchFileRevision1 = revision;
        else if (masterCommit3.getName().equals(revisionId))
            masterFileRevision3 = revision;
        else if (masterCommit1.getName().equals(revisionId))
            masterFileRevision1 = revision;
    }
    assertNotNull(branchFileRevision1);
    assertNotNull(masterFileRevision3);
    assertNotNull(masterFileRevision1);
    /*
		 * The "direct" parent of branchCommit1 is masterCommit2. However, that
		 * commit did not contain file1. We thus expect the returned contributor
		 * to be masterCommit1.
		 */
    final IFileRevision[] branchCommit1Parents = history.getContributors(branchFileRevision1);
    assertEquals(1, branchCommit1Parents.length);
    assertRevisionMatchCommit(branchCommit1Parents[0], masterCommit1);
    // Likewise for masterCommit3
    final IFileRevision[] masterCommit3Parents = history.getContributors(masterFileRevision3);
    assertEquals(1, masterCommit3Parents.length);
    assertRevisionMatchCommit(masterCommit3Parents[0], masterCommit1);
    // masterCommit1 is our initial commit
    final IFileRevision[] masterCommit1Parents = history.getContributors(masterFileRevision1);
    assertEquals(0, masterCommit1Parents.length);
}
Also used : IFileHistory(org.eclipse.team.core.history.IFileHistory) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileRevision(org.eclipse.team.core.history.IFileRevision) Test(org.junit.Test)

Example 13 with IFileHistory

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

the class HistoryTest method queryHistoryThroughTeam.

/*
	 * This aims at exerting the behavior of the EGit history provider when used
	 * through the Team APIs. This is the behavior extenders will see when
	 * interfacing with EGit through the synchronize view.
	 *
	 * The exact comparison with which we've reached the synchronize perspective
	 * should not be relevant. To keep this test as short as possible, we'll
	 * only test a single comparison.
	 */
@Test
public void queryHistoryThroughTeam() throws IOException, CoreException {
    GitSynchronizeData gsd = new GitSynchronizeData(testRepository.getRepository(), MASTER, BRANCH, false);
    GitSynchronizeDataSet gsds = new GitSynchronizeDataSet(gsd);
    GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsds);
    subscriber.init(new NullProgressMonitor());
    IDiff diff = subscriber.getDiff(iFile2);
    assertTrue(diff instanceof IThreeWayDiff);
    IFileRevision sourceRevision = getSource(diff);
    IFileRevision destinationRevision = getDestination(diff);
    IFileRevision baseRevision = getBase(diff);
    assertRevisionMatchCommit(baseRevision, masterCommit2);
    assertRevisionMatchCommit(destinationRevision, branchCommit2);
    assertRevisionMatchCommit(sourceRevision, masterCommit3);
    final IFileHistory history = historyProvider.getFileHistoryFor(iFile2, IFileHistoryProvider.NONE, new NullProgressMonitor());
    assertNotNull(history);
    // no parent of masterCommit2 in file2's history
    IFileRevision[] parents = history.getContributors(baseRevision);
    assertEquals(0, parents.length);
    /*
		 * branchCommit1 did not contain file2, so the "child" of masterCommit2
		 * (branching point) in file2's history is branchCommit2.
		 */
    IFileRevision[] children = history.getTargets(baseRevision);
    List<RevCommit> expectedChildren = new ArrayList<RevCommit>(Arrays.asList(masterCommit3, branchCommit2));
    assertEquals(expectedChildren.size(), children.length);
    assertMatchingRevisions(Arrays.asList(children), expectedChildren);
}
Also used : GitSynchronizeData(org.eclipse.egit.core.synchronize.dto.GitSynchronizeData) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileHistory(org.eclipse.team.core.history.IFileHistory) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) IThreeWayDiff(org.eclipse.team.core.diff.IThreeWayDiff) IFileRevision(org.eclipse.team.core.history.IFileRevision) ArrayList(java.util.ArrayList) GitResourceVariantTreeSubscriber(org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber) IDiff(org.eclipse.team.core.diff.IDiff) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 14 with IFileHistory

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

the class HistoryTest method testDeepHistory_B.

@Test
public void testDeepHistory_B() {
    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.NONE, new NullProgressMonitor());
    IFileRevision[] fileRevisions = fileHistory.getFileRevisions();
    assertEquals(2, fileRevisions.length);
    assertEquals("fd5a571c8a3a4a152e4c413d09d3ecb7d41e1e5f", fileRevisions[0].getContentIdentifier());
    assertEquals("J. Author", fileRevisions[0].getAuthor());
    assertEquals("60f0d7917fe2aed5c92b5bc35dfb55b9b8ada359", fileRevisions[1].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 15 with IFileHistory

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

the class HistoryTest method testSingleRevision_3.

@Test
public void testSingleRevision_3() {
    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("fd5a571c8a3a4a152e4c413d09d3ecb7d41e1e5f");
    assertEquals("fd5a571c8a3a4a152e4c413d09d3ecb7d41e1e5f", 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)

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