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();
}
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));
}
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)));
}
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");
}
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");
}
Aggregations