Search in sources :

Example 1 with HgCatCommand

use of org.zmlx.hg4idea.command.HgCatCommand in project intellij-community by JetBrains.

the class HgRevertTest method testRevertToCurrentRevision.

@Test
public void testRevertToCurrentRevision() throws Exception {
    fillFile(myProjectDir, new String[] { "file.txt" }, "initial contents");
    runHgOnProjectRepo("add", ".");
    runHgOnProjectRepo("commit", "-m", "initial contents");
    fillFile(myProjectDir, new String[] { "file.txt" }, "new contents");
    HgRevertCommand revertCommand = new HgRevertCommand(myProject);
    revertCommand.execute(myRepo.getDir(), Collections.singleton(new File(myProjectDir, "file.txt").getPath()), null, false);
    HgCatCommand catCommand = new HgCatCommand(myProject);
    HgCommandResult result = catCommand.execute(getHgFile("file.txt"), null, Charset.defaultCharset());
    assertNotNull(result);
    assertEquals(result.getRawOutput(), "initial contents");
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCatCommand(org.zmlx.hg4idea.command.HgCatCommand) HgRevertCommand(org.zmlx.hg4idea.command.HgRevertCommand) File(java.io.File) Test(org.testng.annotations.Test)

Example 2 with HgCatCommand

use of org.zmlx.hg4idea.command.HgCatCommand in project intellij-community by JetBrains.

the class HgRevertTest method testRevertToGivenRevision.

@Test
public void testRevertToGivenRevision() throws Exception {
    fillFile(myProjectDir, new String[] { "file.txt" }, "initial contents");
    runHgOnProjectRepo("add", ".");
    runHgOnProjectRepo("commit", "-m", "initial contents");
    fillFile(myProjectDir, new String[] { "file.txt" }, "new contents");
    runHgOnProjectRepo("commit", "-m", "new contents");
    HgRevertCommand revertCommand = new HgRevertCommand(myProject);
    revertCommand.execute(myRepo.getDir(), Collections.singleton(new File(myProjectDir, "file.txt").getPath()), HgRevisionNumber.getLocalInstance("0"), false);
    HgCatCommand catCommand = new HgCatCommand(myProject);
    HgCommandResult result = catCommand.execute(getHgFile("file.txt"), HgRevisionNumber.getLocalInstance("0"), Charset.defaultCharset());
    assertNotNull(result);
    assertEquals(result.getRawOutput(), "initial contents");
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCatCommand(org.zmlx.hg4idea.command.HgCatCommand) HgRevertCommand(org.zmlx.hg4idea.command.HgRevertCommand) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

File (java.io.File)2 Test (org.testng.annotations.Test)2 HgCatCommand (org.zmlx.hg4idea.command.HgCatCommand)2 HgRevertCommand (org.zmlx.hg4idea.command.HgRevertCommand)2 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)2