Examples of IFileHistory


Examples of org.eclipse.team.core.history.IFileHistory

    RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject());
    if (provider == null) {
      return null;
    }

    IFileHistory history = provider.getFileHistoryProvider().getFileHistoryFor(resource, flags, monitor);
    if (history == null) {
      return new IFileRevision[0];
    }
    return history.getFileRevisions();
  }
View Full Code Here

Examples of org.eclipse.team.core.history.IFileHistory

  private void assertFullHistoryMatches(IFile target,
      List<RevCommit> expectedHistory) throws CoreException {
    // Whatever the position of HEAD, the history should be the same
    for (RevCommit commit : commits) {
      testRepository.checkoutBranch(commit.getName());
      final IFileHistory history = historyProvider.getFileHistoryFor(
          target, IFileHistoryProvider.NONE,
          new NullProgressMonitor());
      assertNotNull(history);

      final IFileRevision[] revisions = history.getFileRevisions();
      assertEquals(expectedHistory.size(), revisions.length);
      final List<RevCommit> commitList = new ArrayList<RevCommit>(
          expectedHistory);
      assertMatchingRevisions(Arrays.asList(revisions), commitList);
    }
View Full Code Here

Examples of org.eclipse.team.core.history.IFileHistory

  @Test
  public void querySingleRevisions() throws CoreException {
    for (RevCommit commit : commits) {
      for (IFile target : Arrays.asList(iFile1, iFile2)) {
        testRepository.checkoutBranch(commit.getName());
        final IFileHistory history = historyProvider.getFileHistoryFor(
            target, IFileHistoryProvider.SINGLE_REVISION,
            new NullProgressMonitor());
        assertNotNull(history);

        final IFileRevision[] revisions = history.getFileRevisions();
        assertEquals(1, revisions.length);
        assertRevisionMatchCommit(revisions[0], commit);
      }
    }
  }
View Full Code Here

Examples of org.eclipse.team.core.history.IFileHistory

    }
  }

  @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);
  }
View Full Code Here

Examples of org.eclipse.team.core.history.IFileHistory

    assertEquals(0, masterCommit1Parents.length);
  }

  @Test
  public void queryFile2Contributors() {
    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[] masterCommit3Parents = history
        .getContributors(masterFileRevision3);
    assertEquals(1, masterCommit3Parents.length);
    assertRevisionMatchCommit(masterCommit3Parents[0], masterCommit2);

    /*
     * The direct parent of masterCommit2 is the initial commit,
     * masterCommit1. However, file2 was not included in that commit. We
     * thus expect no parent.
     */
    final IFileRevision[] masterCommit2Parents = history
        .getContributors(masterFileRevision2);
    assertEquals(0, masterCommit2Parents.length);

    final IFileRevision[] branchCommit2Parents = history
        .getContributors(branchFileRevision2);
    assertEquals(1, branchCommit2Parents.length);
    assertRevisionMatchCommit(branchCommit2Parents[0], masterCommit2);
  }
View Full Code Here

Examples of org.eclipse.team.core.history.IFileHistory

    assertRevisionMatchCommit(branchCommit2Parents[0], masterCommit2);
  }

  @Test
  public void queryFile1Targets() {
    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" child of masterCommit1 is masterCommit2. However, that
     * commit did not contain file1. We thus expect the returned children to
     * be masterCommit3 and branchCommit1, since the ignored masterCommit2
     * is a branching point.
     */
    final IFileRevision[] masterCommit1Children = history
        .getTargets(masterFileRevision1);
    assertEquals(2, masterCommit1Children.length);
    final List<RevCommit> expected = new ArrayList<RevCommit>(
        Arrays.asList(masterCommit3, branchCommit1));
    assertMatchingRevisions(Arrays.asList(masterCommit1Children), expected);

    // masterCommit3 and branchCommit1 are leafs
    final IFileRevision[] masterCommit3Children = history
        .getTargets(masterFileRevision3);
    assertEquals(0, masterCommit3Children.length);

    final IFileRevision[] branchCommit1Children = history
        .getTargets(branchFileRevision1);
    assertEquals(0, branchCommit1Children.length);
  }
View Full Code Here

Examples of org.eclipse.team.core.history.IFileHistory

    assertEquals(0, branchCommit1Children.length);
  }

  @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);
  }
View Full Code Here

Examples of org.eclipse.team.core.history.IFileHistory

    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);
  }
View Full Code Here

Examples of org.eclipse.team.core.history.IFileHistory

      Git git = new Git(singleProjectRepo);
      git.add().addFilepattern(".").call();
      RevCommit commit = git.commit().setAuthor("JUnit", "junit@jgit.org").setAll(true).setMessage("First commit").call();

      GitFileHistoryProvider fhProvider = new GitFileHistoryProvider();
      IFileHistory fh = fhProvider.getFileHistoryFor(singleRepoProject.getProject(), 0, null);
      assertNotNull(fh);
      assertEquals(fh.getFileRevisions().length, 1);
      assertNotNull(fh.getFileRevision(commit.getId().getName()));
    } finally {
      DisconnectProviderOperation disconnectOp = new DisconnectProviderOperation(Collections.singletonList(proj));
      disconnectOp.execute(progress);
      Activator.getDefault().getRepositoryUtil().removeDir(singleProjectGitDir);
      singleProjectRepo.close();
View Full Code Here

Examples of org.eclipse.team.core.history.IFileHistory

  @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());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.