Search in sources :

Example 1 with HgRemoteCommandExecutor

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

the class HgCloneCommand method executeInCurrentThread.

@Nullable
public HgCommandResult executeInCurrentThread() {
    final List<String> arguments = new ArrayList<>(2);
    arguments.add(repositoryURL);
    arguments.add(directory);
    final HgRemoteCommandExecutor executor = new HgRemoteCommandExecutor(project, repositoryURL);
    executor.setShowOutput(true);
    return executor.executeInCurrentThread(null, "clone", arguments);
}
Also used : ArrayList(java.util.ArrayList) HgRemoteCommandExecutor(org.zmlx.hg4idea.execution.HgRemoteCommandExecutor) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with HgRemoteCommandExecutor

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

the class HgIdentifyCommand method execute.

@Nullable
public HgCommandResult execute(@NotNull ModalityState state) {
    final List<String> arguments = new LinkedList<>();
    arguments.add(source);
    final HgRemoteCommandExecutor executor = new HgRemoteCommandExecutor(project, source, state, false);
    executor.setSilent(true);
    return executor.executeInCurrentThread(null, "identify", arguments);
}
Also used : HgRemoteCommandExecutor(org.zmlx.hg4idea.execution.HgRemoteCommandExecutor) LinkedList(java.util.LinkedList) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with HgRemoteCommandExecutor

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

the class HgOutgoingCommand method execute.

@Nullable
public HgCommandResult execute(@NotNull VirtualFile repo, @NotNull String template, @NotNull String source, @NotNull String destination, boolean doNotShowAuthorizationRequest) {
    List<String> arguments = new LinkedList<>();
    arguments.add("-n");
    arguments.add("--template");
    arguments.add(template);
    arguments.add(HgHistoryUtil.prepareParameter("rev", source));
    arguments.add(destination);
    HgRemoteCommandExecutor commandExecutor = new HgRemoteCommandExecutor(project, destination, ModalityState.any(), doNotShowAuthorizationRequest);
    commandExecutor.setOutputAlwaysSuppressed(true);
    return commandExecutor.executeInCurrentThread(repo, "outgoing", arguments);
}
Also used : HgRemoteCommandExecutor(org.zmlx.hg4idea.execution.HgRemoteCommandExecutor) LinkedList(java.util.LinkedList) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with HgRemoteCommandExecutor

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

the class HgPullCommand method executeInCurrentThread.

public HgCommandExitCode executeInCurrentThread() {
    List<String> arguments = new LinkedList<>();
    if (update) {
        arguments.add("--update");
    } else if (rebase) {
        arguments.add("--rebase");
    }
    if (!StringUtil.isEmptyOrSpaces(revision)) {
        arguments.add("--rev");
        arguments.add(revision);
    }
    arguments.add(source);
    final HgRemoteCommandExecutor executor = new HgRemoteCommandExecutor(project, source);
    executor.setShowOutput(true);
    HgCommandResult result = executor.executeInCurrentThread(repo, "pull", arguments);
    if (HgErrorUtil.isAuthorizationError(result)) {
        new HgCommandResultNotifier(project).notifyError(result, "Authorization required", "http authorization required for <code>" + source + "</code>");
        return ERROR;
    } else if (HgErrorUtil.isAbort(result) || result.getExitValue() > 1) {
        //if result == null - > isAbort returns true
        new HgCommandResultNotifier(project).notifyError(result, "", "Pull failed");
        return ERROR;
    } else if (result.getExitValue() == 1) {
        return UNRESOLVED;
    } else {
        project.getMessageBus().syncPublisher(HgVcs.REMOTE_TOPIC).update(project, null);
        return SUCCESS;
    }
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgRemoteCommandExecutor(org.zmlx.hg4idea.execution.HgRemoteCommandExecutor) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier) LinkedList(java.util.LinkedList)

Example 5 with HgRemoteCommandExecutor

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

the class HgRemoteChangesetsCommand method executeCommandInCurrentThread.

@Override
protected HgCommandResult executeCommandInCurrentThread(VirtualFile repo, List<String> args) {
    String repositoryURL = getRepositoryUrl(repo);
    if (repositoryURL == null) {
        LOG.info("executeCommand no default path configured");
        return null;
    }
    HgRemoteCommandExecutor executor = new HgRemoteCommandExecutor(project, repositoryURL);
    HgCommandResult result = executor.executeInCurrentThread(repo, command, args);
    if (result == HgCommandResult.CANCELLED || HgErrorUtil.isAuthorizationError(result)) {
        final HgVcs vcs = HgVcs.getInstance(project);
        if (vcs == null) {
            return result;
        }
        new HgCommandResultNotifier(project).notifyError(result, "Checking for incoming/outgoing changes disabled", "Authentication is required to check incoming/outgoing changes in " + repositoryURL + "<br/>You may enable checking for changes <a href='#'>in the Settings</a>.", new NotificationListener() {

            @Override
            public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                ShowSettingsUtil.getInstance().showSettingsDialog(project, vcs.getConfigurable().getDisplayName());
            }
        });
        final HgProjectSettings projectSettings = vcs.getProjectSettings();
        projectSettings.setCheckIncomingOutgoing(false);
        project.getMessageBus().syncPublisher(HgVcs.INCOMING_OUTGOING_CHECK_TOPIC).hide();
    }
    return result;
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgVcs(org.zmlx.hg4idea.HgVcs) HyperlinkEvent(javax.swing.event.HyperlinkEvent) HgProjectSettings(org.zmlx.hg4idea.HgProjectSettings) HgRemoteCommandExecutor(org.zmlx.hg4idea.execution.HgRemoteCommandExecutor) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Aggregations

HgRemoteCommandExecutor (org.zmlx.hg4idea.execution.HgRemoteCommandExecutor)6 LinkedList (java.util.LinkedList)4 Nullable (org.jetbrains.annotations.Nullable)3 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)3 HgCommandResultNotifier (org.zmlx.hg4idea.action.HgCommandResultNotifier)2 Notification (com.intellij.notification.Notification)1 NotificationListener (com.intellij.notification.NotificationListener)1 ArrayList (java.util.ArrayList)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1 HgProjectSettings (org.zmlx.hg4idea.HgProjectSettings)1 HgVcs (org.zmlx.hg4idea.HgVcs)1