Search in sources :

Example 1 with ShellCommand

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

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

the class HgUtil method getVersionOutput.

@NotNull
public static HgCommandResult getVersionOutput(@NotNull String executable) throws ShellCommandException, InterruptedException {
    String hgExecutable = executable.trim();
    List<String> cmdArgs = new ArrayList<>();
    cmdArgs.add(hgExecutable);
    cmdArgs.add("version");
    cmdArgs.add("-q");
    ShellCommand shellCommand = new ShellCommand(cmdArgs, null, CharsetToolkit.getDefaultSystemCharset());
    return shellCommand.execute(false, false);
}
Also used : ShellCommand(org.zmlx.hg4idea.execution.ShellCommand) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ShellCommand (org.zmlx.hg4idea.execution.ShellCommand)2 NotNull (org.jetbrains.annotations.NotNull)1 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)1