Search in sources :

Example 6 with HgCommandResult

use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.

the class HgExecutor method hg.

public static String hg(@NotNull String command, boolean ignoreNonZeroExitCode) {
    List<String> split = splitCommandInParameters(command);
    split.add(0, HG_EXECUTABLE);
    debug("hg " + command);
    HgCommandResult result;
    try {
        result = new ShellCommand(split, pwd(), null).execute(false, false);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    int exitValue = result.getExitValue();
    if (!ignoreNonZeroExitCode && exitValue != 0) {
        throw new RuntimeException(result.getRawError());
    }
    return result.getRawOutput();
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) ShellCommand(org.zmlx.hg4idea.execution.ShellCommand)

Example 7 with HgCommandResult

use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.

the class HgRevertUncommittedMergeTest method testRevertAfterMerge.

public void testRevertAfterMerge() throws VcsException {
    cd(myRepository);
    hg("branch branchA");
    String aFile = "A.txt";
    touch(aFile, "a");
    hg("add " + aFile);
    hg("commit -m 'create file in branchA' ");
    hg("up default");
    touch(aFile, "default");
    hg("add " + aFile);
    hg("commit -m 'create file in default branch'");
    hgMergeWith("branchA");
    HgCommandResult revertResult = new HgRevertCommand(myProject).execute(myRepository, Collections.singleton(new File(myRepository.getPath(), aFile).getAbsolutePath()), null, false);
    assertTrue(HgErrorUtil.hasUncommittedChangesConflict(revertResult));
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgRevertCommand(org.zmlx.hg4idea.command.HgRevertCommand) File(java.io.File)

Example 8 with HgCommandResult

use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.

the class HgPushParseTest method testValid.

@Test
public void testValid() {
    ProcessOutput processOutput = new ProcessOutput(0);
    processOutput.appendStdout(myOutput);
    assertEquals(" Wrong commits number for " + myOutput, myExpected, HgPusher.getNumberOfPushedCommits(new HgCommandResult(processOutput)));
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) ProcessOutput(com.intellij.execution.process.ProcessOutput) Test(org.junit.Test)

Example 9 with HgCommandResult

use of org.zmlx.hg4idea.execution.HgCommandResult 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 10 with HgCommandResult

use of org.zmlx.hg4idea.execution.HgCommandResult 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

HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)54 HgCommandExecutor (org.zmlx.hg4idea.execution.HgCommandExecutor)21 HgCommandResultNotifier (org.zmlx.hg4idea.action.HgCommandResultNotifier)19 Project (com.intellij.openapi.project.Project)12 NotNull (org.jetbrains.annotations.NotNull)11 ArrayList (java.util.ArrayList)7 HgVersion (org.zmlx.hg4idea.util.HgVersion)7 VcsException (com.intellij.openapi.vcs.VcsException)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 File (java.io.File)5 LinkedList (java.util.LinkedList)5 HgCommandResultHandler (org.zmlx.hg4idea.execution.HgCommandResultHandler)5 AccessToken (com.intellij.openapi.application.AccessToken)4 Nullable (org.jetbrains.annotations.Nullable)4 HgRevisionNumber (org.zmlx.hg4idea.HgRevisionNumber)4 HgVcs (org.zmlx.hg4idea.HgVcs)4 HgRevertCommand (org.zmlx.hg4idea.command.HgRevertCommand)4 SmartList (com.intellij.util.SmartList)3 HgFile (org.zmlx.hg4idea.HgFile)3 HgRemoteCommandExecutor (org.zmlx.hg4idea.execution.HgRemoteCommandExecutor)3