Search in sources :

Example 1 with HgCommandResultHandler

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

the class HgQFinishCommand method execute.

public void execute(@NotNull final String revision) {
    final Project project = myRepository.getProject();
    new HgCommandExecutor(project).execute(myRepository.getRoot(), "qfinish", Collections.singletonList("qbase:" + revision), new HgCommandResultHandler() {

        @Override
        public void process(@Nullable HgCommandResult result) {
            if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
                new HgCommandResultNotifier(project).notifyError(result, "QFinish command failed", "Could not apply patches into repository history.");
            }
            myRepository.update();
        }
    });
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) Project(com.intellij.openapi.project.Project) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) HgCommandResultHandler(org.zmlx.hg4idea.execution.HgCommandResultHandler) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier)

Example 2 with HgCommandResultHandler

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

the class HgInitCommand method executeAsynchronously.

public void executeAsynchronously(@NotNull VirtualFile repositoryRoot, final HgCommandResultHandler resultHandler) {
    final List<String> args = new ArrayList<>(1);
    args.add(repositoryRoot.getPath());
    final HgCommandExecutor executor = new HgCommandExecutor(myProject, repositoryRoot.getPath());
    executor.setShowOutput(true);
    executor.execute(null, "init", args, new HgCommandResultHandler() {

        @Override
        public void process(@Nullable HgCommandResult result) {
            resultHandler.process(result);
        }
    });
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) ArrayList(java.util.ArrayList) HgCommandResultHandler(org.zmlx.hg4idea.execution.HgCommandResultHandler)

Example 3 with HgCommandResultHandler

use of org.zmlx.hg4idea.execution.HgCommandResultHandler 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);
        }
    });
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) HgCommandResultHandler(org.zmlx.hg4idea.execution.HgCommandResultHandler)

Example 4 with HgCommandResultHandler

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

the class HgQRenameCommand method performPatchRename.

public static void performPatchRename(@NotNull final HgRepository repository, @NotNull final String oldName, @NotNull final String newName) {
    if (oldName.equals(newName))
        return;
    final Project project = repository.getProject();
    new HgCommandExecutor(project).execute(repository.getRoot(), "qrename", Arrays.asList(oldName, newName), new HgCommandResultHandler() {

        @Override
        public void process(@Nullable HgCommandResult result) {
            if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
                new HgCommandResultNotifier(project).notifyError(result, "Qrename command failed", "Could not rename patch " + oldName + " to " + newName);
            }
            repository.update();
        }
    });
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) Project(com.intellij.openapi.project.Project) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) HgCommandResultHandler(org.zmlx.hg4idea.execution.HgCommandResultHandler) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier)

Example 5 with HgCommandResultHandler

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

the class HgIntegrationEnabler method initOrNotifyError.

@Override
protected boolean initOrNotifyError(@NotNull final VirtualFile projectDir) {
    final boolean[] success = new boolean[1];
    new HgInitCommand(myProject).executeAsynchronously(projectDir, new HgCommandResultHandler() {

        @Override
        public void process(@Nullable HgCommandResult result) {
            VcsNotifier notifier = VcsNotifier.getInstance(myProject);
            if (!HgErrorUtil.hasErrorsInCommandExecution(result)) {
                success[0] = true;
                refreshVcsDir(projectDir, HgUtil.DOT_HG);
                notifier.notifySuccess(message("hg4idea.init.created.notification.title"), message("hg4idea.init.created.notification.description", projectDir.getPresentableUrl()));
            } else {
                success[0] = false;
                String errors = result != null ? result.getRawError() : "";
                notifier.notifyError(message("hg4idea.init.error.description", projectDir.getPresentableUrl()), errors);
            }
        }
    });
    return success[0];
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCommandResultHandler(org.zmlx.hg4idea.execution.HgCommandResultHandler) HgInitCommand(org.zmlx.hg4idea.command.HgInitCommand) VcsNotifier(com.intellij.openapi.vcs.VcsNotifier)

Aggregations

HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)5 HgCommandResultHandler (org.zmlx.hg4idea.execution.HgCommandResultHandler)5 HgCommandExecutor (org.zmlx.hg4idea.execution.HgCommandExecutor)4 Project (com.intellij.openapi.project.Project)2 HgCommandResultNotifier (org.zmlx.hg4idea.action.HgCommandResultNotifier)2 VcsNotifier (com.intellij.openapi.vcs.VcsNotifier)1 ArrayList (java.util.ArrayList)1 HgInitCommand (org.zmlx.hg4idea.command.HgInitCommand)1