Search in sources :

Example 16 with HgCommandExecutor

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

Example 17 with HgCommandExecutor

use of org.zmlx.hg4idea.execution.HgCommandExecutor 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();
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) Project(com.intellij.openapi.project.Project) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier)

Example 18 with HgCommandExecutor

use of org.zmlx.hg4idea.execution.HgCommandExecutor 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 19 with HgCommandExecutor

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

the class HgQNewCommand method executeQNewInCurrentThread.

private void executeQNewInCurrentThread(@NotNull List<String> chunkFiles) throws VcsException {
    List<String> args = ContainerUtil.newArrayList();
    args.add("-l");
    args.add(saveCommitMessage().getAbsolutePath());
    args.add("-UD");
    String patchName = DATE_FORMAT.format(new Date()).concat(".diff");
    args.add(patchName);
    args.addAll(chunkFiles);
    HgCommandExecutor executor = new HgCommandExecutor(myProject);
    HgCommandResult result = executor.executeInCurrentThread(myRepository.getRoot(), "qnew", args);
    if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
        new HgCommandResultNotifier(myProject).notifyError(result, "Qnew Failed", "Could not create mq patch for selected changes");
    }
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier) Date(java.util.Date)

Example 20 with HgCommandExecutor

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

the class HgQPopCommand method executeInCurrentThread.

public HgCommandResult executeInCurrentThread() {
    final Project project = myRepository.getProject();
    HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(myRepository.getRoot(), "qpop", Collections.singletonList("--all"));
    if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
        new HgCommandResultNotifier(project).notifyError(result, "QPop command failed", "Could not make all patches unapplied");
    } else {
        assert result != null;
        if (!result.getErrorLines().isEmpty()) {
            VcsNotifier.getInstance(project).notifyWarning("QPop completed with errors", result.getRawError());
        }
    }
    myRepository.update();
    return result;
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) Project(com.intellij.openapi.project.Project) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier)

Aggregations

HgCommandExecutor (org.zmlx.hg4idea.execution.HgCommandExecutor)31 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)21 HgCommandResultNotifier (org.zmlx.hg4idea.action.HgCommandResultNotifier)11 Project (com.intellij.openapi.project.Project)8 Nullable (org.jetbrains.annotations.Nullable)6 ArrayList (java.util.ArrayList)5 LinkedList (java.util.LinkedList)4 HgCommandResultHandler (org.zmlx.hg4idea.execution.HgCommandResultHandler)4 NotNull (org.jetbrains.annotations.NotNull)3 AccessToken (com.intellij.openapi.application.AccessToken)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Date (java.util.Date)1 List (java.util.List)1 HgChange (org.zmlx.hg4idea.HgChange)1 HgRevisionNumber (org.zmlx.hg4idea.HgRevisionNumber)1 HgVcs (org.zmlx.hg4idea.HgVcs)1 HgCommandException (org.zmlx.hg4idea.execution.HgCommandException)1 HgRepositoryManager (org.zmlx.hg4idea.repo.HgRepositoryManager)1