Search in sources :

Example 6 with IThreeWayDiff

use of org.eclipse.team.core.diff.IThreeWayDiff 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)

Aggregations

IDiff (org.eclipse.team.core.diff.IDiff)6 IThreeWayDiff (org.eclipse.team.core.diff.IThreeWayDiff)6 IResourceDiff (org.eclipse.team.core.mapping.IResourceDiff)5 IFileRevision (org.eclipse.team.core.history.IFileRevision)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 RangeDifference (org.eclipse.compare.rangedifferencer.RangeDifference)2 IFile (org.eclipse.core.resources.IFile)2 IResource (org.eclipse.core.resources.IResource)2 IStorage (org.eclipse.core.resources.IStorage)2 CoreException (org.eclipse.core.runtime.CoreException)2 LineComparator (org.eclipse.linuxtools.internal.changelog.core.LineComparator)2 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 LineNumberReader (java.io.LineNumberReader)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 IProject (org.eclipse.core.resources.IProject)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 GitResourceVariantTreeSubscriber (org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber)1 GitSynchronizeData (org.eclipse.egit.core.synchronize.dto.GitSynchronizeData)1