use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.
the class HgShowConfigCommand method execute.
@NotNull
public Map<String, Map<String, String>> execute(@Nullable VirtualFile repo) {
if (repo == null) {
return Collections.emptyMap();
}
final HgCommandExecutor executor = new HgCommandExecutor(project);
executor.setSilent(true);
//force override debug option while initialize hg configs
HgCommandResult result = executor.executeInCurrentThread(repo, "showconfig", Arrays.asList("--config", "ui.debug=false"));
if (result == null) {
return Collections.emptyMap();
}
Map<String, Map<String, String>> configMap = new HashMap<>();
for (String line : result.getOutputLines()) {
List<String> option = StringUtil.split(line, "=", true, false);
if (option.size() == 2) {
String sectionAndName = option.get(0).trim();
String value = option.get(1).trim();
int dotIndex = sectionAndName.indexOf('.');
if (dotIndex > 0) {
String sectionName = sectionAndName.substring(0, dotIndex);
String optionName = sectionAndName.substring(dotIndex + 1, sectionAndName.length());
if (configMap.containsKey(sectionName)) {
configMap.get(sectionName).put(optionName, value);
} else {
HashMap<String, String> sectionMap = new HashMap<>();
sectionMap.put(optionName, value);
configMap.put(sectionName, sectionMap);
}
}
}
}
return configMap;
}
use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.
the class HgQGotoCommand method executeInCurrentThread.
public HgCommandResult executeInCurrentThread(@NotNull final String name) {
Project project = myRepository.getProject();
HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(myRepository.getRoot(), "qgoto", Collections.singletonList(name));
if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
new HgCommandResultNotifier(project).notifyError(result, "QGoto command failed", "Could not go to patch " + name);
}
myRepository.update();
return result;
}
use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.
the class HgQImportCommand method executeInCurrentThread.
public void executeInCurrentThread(@NotNull final String startRevisionNumber) {
final Project project = myRepository.getProject();
String lastRevisionName = myRepository.getMQAppliedPatches().isEmpty() ? "tip" : "qparent";
List<String> arguments = ContainerUtil.newArrayList("--rev", startRevisionNumber + ":" + lastRevisionName);
HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(myRepository.getRoot(), "qimport", arguments);
if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
new HgCommandResultNotifier(project).notifyError(result, "Import failed", "Import revision from " + startRevisionNumber + " to qparent failed");
}
myRepository.update();
}
use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.
the class HgQNewCommand method executeQRefreshInCurrentThread.
private void executeQRefreshInCurrentThread(@NotNull List<String> chunkFiles) throws VcsException {
List<String> args = ContainerUtil.newArrayList();
args.add("-l");
args.add(saveCommitMessage().getAbsolutePath());
args.add("-s");
args.addAll(chunkFiles);
HgCommandResult result = new HgCommandExecutor(myProject).executeInCurrentThread(myRepository.getRoot(), "qrefresh", args);
if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
new HgCommandResultNotifier(myProject).notifyError(result, "QRefresh Failed", "Could not amend selected changes to newly created patch");
}
}
use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.
the class HgQPushCommand method executeInCurrentThread.
public void executeInCurrentThread(@NotNull final String patchName) {
final Project project = myRepository.getProject();
HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(myRepository.getRoot(), "qpush", Arrays.asList("--move", patchName));
if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
new HgCommandResultNotifier(project).notifyError(result, "QPush command failed", "Could not apply selected patch " + patchName);
}
myRepository.update();
}
Aggregations