Search in sources :

Example 1 with HgDiffProvider

use of org.zmlx.hg4idea.provider.HgDiffProvider in project intellij-community by JetBrains.

the class HgDiffProviderTest method shouldFindCurrentRevisionForRenamedFile.

@Test
public void shouldFindCurrentRevisionForRenamedFile() throws Exception {
    fillFile(myProjectDir, new String[] { AFILE }, INITIAL_FILE_CONTENT);
    addAll();
    commitAll("initial content");
    fillFile(myProjectDir, new String[] { AFILE }, UPDATED_FILE_CONTENT);
    commitAll("updated content");
    runHgOnProjectRepo("rename", AFILE, BFILE);
    //don't commit 
    refreshVfs();
    ChangeListManager.getInstance(myProject).ensureUpToDate(false);
    HgDiffProvider diffProvider = new HgDiffProvider(myProject);
    VirtualFile child = myWorkingCopyDir.findChild(BFILE);
    ContentRevision fileContent = diffProvider.createFileContent(diffProvider.getCurrentRevision(child), child);
    assertNotNull(fileContent);
    assertEquals(fileContent.getContent(), UPDATED_FILE_CONTENT);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) HgDiffProvider(org.zmlx.hg4idea.provider.HgDiffProvider) Test(org.testng.annotations.Test)

Example 2 with HgDiffProvider

use of org.zmlx.hg4idea.provider.HgDiffProvider in project intellij-community by JetBrains.

the class HgDiffProviderTest method currentRevisionShouldBeTheRevisionInWhichTheFileLastChanged.

@Test
public void currentRevisionShouldBeTheRevisionInWhichTheFileLastChanged() throws Exception {
    fillFile(myProjectDir, new String[] { AFILE }, INITIAL_FILE_CONTENT);
    addAll();
    commitAll("initial content");
    fillFile(myProjectDir, new String[] { AFILE }, UPDATED_FILE_CONTENT);
    commitAll("updated content");
    fillFile(myProjectDir, new String[] { BFILE }, INITIAL_FILE_CONTENT);
    commitAll("added new file");
    refreshVfs();
    HgDiffProvider diffProvider = new HgDiffProvider(myProject);
    HgRevisionNumber currentRevision = (HgRevisionNumber) diffProvider.getCurrentRevision(myWorkingCopyDir.findChild(AFILE));
    assertNotNull(currentRevision, "The current revision for AFILE should be found");
    assertEquals(currentRevision.getRevision(), "1", "The diff provider should return the revision in which AFILE was last changed");
}
Also used : HgRevisionNumber(org.zmlx.hg4idea.HgRevisionNumber) HgDiffProvider(org.zmlx.hg4idea.provider.HgDiffProvider) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)2 HgDiffProvider (org.zmlx.hg4idea.provider.HgDiffProvider)2 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 HgRevisionNumber (org.zmlx.hg4idea.HgRevisionNumber)1