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);
}
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);
}
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);
}
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());
}
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());
}
Aggregations