Search in sources :

Example 6 with ItemLatestState

use of com.intellij.openapi.vcs.diff.ItemLatestState in project intellij-community by JetBrains.

the class HgDiffProvider method getLastRevision.

public ItemLatestState getLastRevision(VirtualFile file) {
    VirtualFile vcsRoot = VcsUtil.getVcsRootFor(project, file);
    if (vcsRoot == null) {
        return null;
    }
    HgRevisionNumber revision = (HgRevisionNumber) getCurrentRevision(file);
    if (revision == null) {
        return null;
    }
    return new ItemLatestState(revision, file.exists(), true);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgRevisionNumber(org.zmlx.hg4idea.HgRevisionNumber) ItemLatestState(com.intellij.openapi.vcs.diff.ItemLatestState)

Example 7 with ItemLatestState

use of com.intellij.openapi.vcs.diff.ItemLatestState in project intellij-community by JetBrains.

the class GitHistoryUtilsTest method testGetLastRevisionForNonExistingFile.

public void testGetLastRevisionForNonExistingFile() throws Exception {
    git("remote add origin git://example.com/repo.git");
    git("config branch.master.remote origin");
    git("config branch.master.merge refs/heads/master");
    git("rm " + bfile.getPath());
    commit("removed bfile");
    String[] hashAndDate = log("--pretty=format:%H#%ct", "-n1").split("#");
    // to avoid pushing to this fake origin
    git("update-ref refs/remotes/origin/master HEAD");
    touch("dir/b.txt", "content");
    addCommit("recreated bfile");
    refresh();
    myRepo.update();
    final ItemLatestState state = GitHistoryUtils.getLastRevision(myProject, toFilePath(bfile));
    assertTrue(!state.isItemExists());
    final GitRevisionNumber revisionNumber = (GitRevisionNumber) state.getNumber();
    assertEquals(revisionNumber.getRev(), hashAndDate[0]);
    assertEquals(revisionNumber.getTimestamp(), GitTestRevision.gitTimeStampToDate(hashAndDate[1]));
}
Also used : GitRevisionNumber(git4idea.GitRevisionNumber) ItemLatestState(com.intellij.openapi.vcs.diff.ItemLatestState)

Aggregations

ItemLatestState (com.intellij.openapi.vcs.diff.ItemLatestState)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 GitRevisionNumber (git4idea.GitRevisionNumber)2 Nullable (org.jetbrains.annotations.Nullable)2 HgRevisionNumber (org.zmlx.hg4idea.HgRevisionNumber)2 CvsRevisionNumber (com.intellij.cvsSupport2.history.CvsRevisionNumber)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Change (com.intellij.openapi.vcs.changes.Change)1 GitSingleRepoTest (git4idea.test.GitSingleRepoTest)1 Entry (org.netbeans.lib.cvsclient.admin.Entry)1 Test (org.testng.annotations.Test)1 HgWorkingCopyRevisionsCommand (org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand)1