Search in sources :

Example 26 with HgCommandExecutor

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

the class HgCopyCommand method executeInCurrentThread.

public void executeInCurrentThread(VirtualFile source, VirtualFile target) {
    VirtualFile sourceRepo = VcsUtil.getVcsRootFor(myProject, source);
    VirtualFile targetRepo = VcsUtil.getVcsRootFor(myProject, target);
    HgCommandExecutor executor = new HgCommandExecutor(myProject, VcsFileUtil.relativeOrFullPath(sourceRepo, source));
    if (sourceRepo != null && targetRepo != null && sourceRepo.equals(targetRepo)) {
        executor.executeInCurrentThread(sourceRepo, "copy", Arrays.asList("--after", VcsFileUtil.relativeOrFullPath(sourceRepo, source), VcsFileUtil.relativeOrFullPath(targetRepo, target)));
    } else {
        // copying from one repository to another => 'hg add' in new repo
        if (targetRepo != null) {
            new HgAddCommand(myProject).executeInCurrentThread(Collections.singleton(target));
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor)

Example 27 with HgCommandExecutor

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

the class HgGraftCommand method graft.

@Nullable
private HgCommandResult graft(@NotNull List<String> params) {
    List<String> args = new ArrayList<>();
    args.add("--log");
    args.addAll(params);
    AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
    try {
        HgCommandResult result = new HgCommandExecutor(myProject).executeInCurrentThread(myRepository.getRoot(), "graft", args);
        myRepository.update();
        return result;
    } finally {
        token.finish();
    }
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) AccessToken(com.intellij.openapi.application.AccessToken) ArrayList(java.util.ArrayList) Nullable(org.jetbrains.annotations.Nullable)

Example 28 with HgCommandExecutor

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

the class HgLogCommand method execute.

@Nullable
public HgCommandResult execute(@NotNull VirtualFile repo, @NotNull String template, int limit, @Nullable HgFile hgFile, @Nullable List<String> argsForCmd) {
    List<String> arguments = new LinkedList<>();
    if (myIncludeRemoved) {
        // for now, preferring to use --follow over --removed.
        if (!(myFollowCopies && myLogFile)) {
            arguments.add("--removed");
        }
    }
    if (myFollowCopies) {
        arguments.add("--follow");
        //see http://selenic.com/pipermail/mercurial-devel/2013-May/051209.html  fixed since 2.7
        if (!myLargeFilesWithFollowSupported) {
            arguments.add("--config");
            arguments.add("extensions.largefiles=!");
        }
    }
    arguments.add("--template");
    arguments.add(template);
    if (limit != -1) {
        arguments.add("--limit");
        arguments.add(String.valueOf(limit));
    }
    if (argsForCmd != null) {
        arguments.addAll(argsForCmd);
    }
    if (myLogFile && hgFile != null) {
        arguments.add(hgFile.getRelativePath());
    }
    HgCommandExecutor commandExecutor = new HgCommandExecutor(myProject);
    commandExecutor.setOutputAlwaysSuppressed(true);
    return commandExecutor.executeInCurrentThread(repo, "log", arguments);
}
Also used : HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) LinkedList(java.util.LinkedList) Nullable(org.jetbrains.annotations.Nullable)

Example 29 with HgCommandExecutor

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

the class HgRebaseCommand method performRebase.

@Nullable
private HgCommandResult performRebase(@NotNull String... args) {
    AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
    try {
        final List<String> list = ContainerUtil.newArrayList(args);
        list.add("--config");
        list.add("extensions.rebase=");
        HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(repo.getRoot(), "rebase", list);
        repo.update();
        return result;
    } finally {
        token.finish();
    }
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) AccessToken(com.intellij.openapi.application.AccessToken) Nullable(org.jetbrains.annotations.Nullable)

Example 30 with HgCommandExecutor

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

the class HgResolveCommand method getListSynchronously.

public Map<HgFile, HgResolveStatusEnum> getListSynchronously(VirtualFile repo) {
    if (repo == null) {
        return Collections.emptyMap();
    }
    final HgCommandExecutor executor = new HgCommandExecutor(myProject);
    executor.setSilent(true);
    final HgCommandResult result = executor.executeInCurrentThread(repo, "resolve", Collections.singletonList("--list"));
    if (result == null) {
        return Collections.emptyMap();
    }
    return handleResult(repo, result);
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) 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