Search in sources :

Example 6 with HgCommandExecutor

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

the class HgCommitCommand method commitChunkFiles.

private void commitChunkFiles(@NotNull List<String> chunk, boolean amendCommit, boolean withSubrepos, boolean closeBranch) throws VcsException {
    List<String> parameters = new LinkedList<>();
    parameters.add("--logfile");
    parameters.add(saveCommitMessage().getAbsolutePath());
    // note: for now mercurial could not perform amend commit with -S option
    if (withSubrepos) {
        parameters.add("-S");
        parameters.addAll(mySubrepos);
    } else if (amendCommit) {
        parameters.add("--amend");
    }
    if (closeBranch) {
        if (chunk.isEmpty() && myRepository.getState() != Repository.State.MERGING) {
            //if there are changed files but nothing selected -> need to exclude all; if merge commit then nothing excluded
            parameters.add("-X");
            parameters.add("\"**\"");
        }
        parameters.add("--close-branch");
    }
    parameters.addAll(chunk);
    HgCommandExecutor executor = new HgCommandExecutor(myProject);
    ensureSuccess(executor.executeInCurrentThread(myRepository.getRoot(), "commit", parameters));
}
Also used : HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) LinkedList(java.util.LinkedList)

Example 7 with HgCommandExecutor

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

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

the class HgCatCommand method execute.

@Nullable
public HgCommandResult execute(@NotNull HgFile hgFile, @Nullable HgRevisionNumber vcsRevisionNumber, @Nullable Charset charset) {
    final List<String> arguments = createArguments(vcsRevisionNumber, hgFile.getRelativePath());
    final HgCommandExecutor executor = new HgCommandExecutor(myProject);
    executor.setSilent(true);
    executor.setOutputAlwaysSuppressed(true);
    executor.setCharset(charset);
    executor.setBinary(true);
    return executor.executeInCurrentThread(hgFile.getRepo(), "cat", arguments);
}
Also used : HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) Nullable(org.jetbrains.annotations.Nullable)

Example 9 with HgCommandExecutor

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

the class HgChangesetsCommand method executeCommandInCurrentThread.

@Nullable
protected HgCommandResult executeCommandInCurrentThread(VirtualFile repo, List<String> args) {
    final HgCommandExecutor executor = new HgCommandExecutor(project);
    executor.setSilent(isSilentCommand());
    return executor.executeInCurrentThread(repo, command, args);
}
Also used : HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) Nullable(org.jetbrains.annotations.Nullable)

Example 10 with HgCommandExecutor

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

the class HgRemoveCommand method executeInCurrentThread.

/**
   * Removes given files from their Mercurial repositories.
   * @param hgFiles files to be removed.
   */
public void executeInCurrentThread(@NotNull Collection<HgFile> hgFiles) {
    for (Map.Entry<VirtualFile, List<String>> entry : HgUtil.getRelativePathsByRepository(hgFiles).entrySet()) {
        List<String> filePaths = entry.getValue();
        for (List<String> chunkFiles : VcsFileUtil.chunkArguments(filePaths)) {
            List<String> parameters = new LinkedList<>();
            parameters.addAll(chunkFiles);
            parameters.add(0, "--after");
            new HgCommandExecutor(myProject).executeInCurrentThread(entry.getKey(), "remove", parameters);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor)

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