use of org.zmlx.hg4idea.execution.HgCommandExecutor in project intellij-community by JetBrains.
the class HgResolveCommand method getListAsynchronously.
public void getListAsynchronously(final VirtualFile repo, final Consumer<Map<HgFile, HgResolveStatusEnum>> resultHandler) {
if (repo == null) {
resultHandler.consume(Collections.emptyMap());
}
final HgCommandExecutor executor = new HgCommandExecutor(myProject);
executor.setSilent(true);
executor.execute(repo, "resolve", Collections.singletonList("--list"), new HgCommandResultHandler() {
@Override
public void process(@Nullable HgCommandResult result) {
if (result == null) {
resultHandler.consume(Collections.emptyMap());
}
final Map<HgFile, HgResolveStatusEnum> resolveStatus = handleResult(repo, result);
resultHandler.consume(resolveStatus);
}
});
}
use of org.zmlx.hg4idea.execution.HgCommandExecutor in project intellij-community by JetBrains.
the class HgRevertCommand method execute.
//all files should be already chunked
@Nullable
public HgCommandResult execute(@NotNull VirtualFile repo, @NotNull Collection<String> files, @Nullable HgRevisionNumber vcsRevisionNumber, boolean backupFile) {
final List<String> options = new LinkedList<>();
if (vcsRevisionNumber != null && !HgRevisionNumber.NULL_REVISION_NUMBER.equals(vcsRevisionNumber)) {
options.add("--rev");
if (!StringUtil.isEmptyOrSpaces(vcsRevisionNumber.getChangeset())) {
options.add(vcsRevisionNumber.getChangeset());
} else {
options.add(vcsRevisionNumber.getRevision());
}
}
if (!backupFile) {
options.add("--no-backup");
}
options.addAll(files);
return new HgCommandExecutor(project).executeInCurrentThread(repo, "revert", options);
}
use of org.zmlx.hg4idea.execution.HgCommandExecutor 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.HgCommandExecutor 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.HgCommandExecutor 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();
}
Aggregations