Search in sources :

Example 21 with HgCommandExecutor

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

the class HgQDeleteCommand method executeInCurrentThread.

public void executeInCurrentThread(@NotNull final List<String> patchNames) {
    final Project project = myRepository.getProject();
    HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(myRepository.getRoot(), "qdelete", patchNames);
    if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
        new HgCommandResultNotifier(project).notifyError(result, "QDelete command failed", "Could not delete selected " + StringUtil.pluralize("patch", patchNames.size()));
    }
    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 22 with HgCommandExecutor

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

the class HgQFoldCommand method executeInCurrentThread.

public void executeInCurrentThread(@NotNull final List<String> patchNames) {
    final Project project = myRepository.getProject();
    HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(myRepository.getRoot(), "qfold", patchNames);
    if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
        new HgCommandResultNotifier(project).notifyError(result, "QFold command failed", "Could not fold patches into the current patch");
    }
    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 23 with HgCommandExecutor

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

the class HgAddCommand method addFilesSynchronously.

private void addFilesSynchronously(VirtualFile repo, Collection<VirtualFile> files, @Nullable ProgressIndicator indicator) {
    final List<List<String>> chunks = VcsFileUtil.chunkFiles(repo, files);
    int currentChunk = 0;
    for (List<String> paths : chunks) {
        if (indicator != null) {
            if (indicator.isCanceled())
                return;
            indicator.setFraction((double) currentChunk / chunks.size());
            currentChunk++;
        }
        new HgCommandExecutor(myProject).executeInCurrentThread(repo, "add", paths);
    }
}
Also used : HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) List(java.util.List)

Example 24 with HgCommandExecutor

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

the class HgAnnotateCommand method execute.

public List<HgAnnotationLine> execute(@NotNull HgFile hgFile, @Nullable HgRevisionNumber revision) {
    final List<String> arguments = new ArrayList<>();
    arguments.add("-cvnudl");
    HgVcs vcs = HgVcs.getInstance(myProject);
    if (vcs != null && vcs.getProjectSettings().isWhitespacesIgnoredInAnnotations() && vcs.getVersion().isIgnoreWhitespaceDiffInAnnotationsSupported()) {
        arguments.add("-w");
    }
    if (revision != null) {
        arguments.add("-r");
        arguments.add(revision.getChangeset());
    }
    arguments.add(hgFile.getRelativePath());
    final HgCommandResult result = new HgCommandExecutor(myProject).executeInCurrentThread(hgFile.getRepo(), "annotate", arguments);
    if (result == null) {
        return Collections.emptyList();
    }
    List<String> outputLines = result.getOutputLines();
    return parse(outputLines);
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgVcs(org.zmlx.hg4idea.HgVcs) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) ArrayList(java.util.ArrayList)

Example 25 with HgCommandExecutor

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

the class HgBookmarkCommand method executeBookmarkCommandSynchronously.

private static void executeBookmarkCommandSynchronously(@NotNull Project project, @NotNull VirtualFile repositoryRoot, @NotNull String name, @NotNull List<String> args) {
    ArrayList<String> arguments = ContainerUtil.newArrayList(args);
    arguments.add(name);
    HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(repositoryRoot, "bookmark", arguments);
    getRepositoryManager(project).updateRepository(repositoryRoot);
    if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
        new HgCommandResultNotifier(project).notifyError(result, "Hg Error", String.format("Hg bookmark command failed for repository %s with name %s ", repositoryRoot.getName(), name));
    }
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) 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