String (@NotNull String command, boolean ignoreNonZeroExitCode) { List<String> split = new ArrayList<>(); ContainerUtil.addAll(split, HG_EXECUTABLE, "--config", "ui.timeout=10"); split.addAll(splitCommandInParameters(command)); debug("hg " + command); HgCommandResult result; try { int attempt = 0; do { result = new ShellCommand(split, pwd(), null).execute(false, false); } while ((HgErrorUtil.isWLockError(result) || isUsedByAnotherProcess(result)) && attempt++ < 2); } catch (Exception e) { throw new RuntimeException(e); } int exitValue = result.getExitValue(); if (!ignoreNonZeroExitCode && exitValue != 0) { debug("exit code: " + exitValue + " " + result.getRawOutput()); throw new HgCommandFailedException(exitValue, result.getRawOutput(), result.getRawError()); } return result.getRawOutput(); }