Search in sources :

Example 6 with HgCommandResultNotifier

use of org.zmlx.hg4idea.action.HgCommandResultNotifier 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 7 with HgCommandResultNotifier

use of org.zmlx.hg4idea.action.HgCommandResultNotifier 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)

Example 8 with HgCommandResultNotifier

use of org.zmlx.hg4idea.action.HgCommandResultNotifier in project intellij-community by JetBrains.

the class HgQGotoCommand method executeInCurrentThread.

public HgCommandResult executeInCurrentThread(@NotNull final String name) {
    Project project = myRepository.getProject();
    HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(myRepository.getRoot(), "qgoto", Collections.singletonList(name));
    if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
        new HgCommandResultNotifier(project).notifyError(result, "QGoto command failed", "Could not go to patch " + name);
    }
    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)

Example 9 with HgCommandResultNotifier

use of org.zmlx.hg4idea.action.HgCommandResultNotifier in project intellij-community by JetBrains.

the class HgQImportCommand method executeInCurrentThread.

public void executeInCurrentThread(@NotNull final String startRevisionNumber) {
    final Project project = myRepository.getProject();
    String lastRevisionName = myRepository.getMQAppliedPatches().isEmpty() ? "tip" : "qparent";
    List<String> arguments = ContainerUtil.newArrayList("--rev", startRevisionNumber + ":" + lastRevisionName);
    HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(myRepository.getRoot(), "qimport", arguments);
    if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
        new HgCommandResultNotifier(project).notifyError(result, "Import failed", "Import revision from " + startRevisionNumber + " to qparent failed");
    }
    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 10 with HgCommandResultNotifier

use of org.zmlx.hg4idea.action.HgCommandResultNotifier 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)

Aggregations

HgCommandResultNotifier (org.zmlx.hg4idea.action.HgCommandResultNotifier)20 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)19 HgCommandExecutor (org.zmlx.hg4idea.execution.HgCommandExecutor)11 Project (com.intellij.openapi.project.Project)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 File (java.io.File)2 HgCommandResultHandler (org.zmlx.hg4idea.execution.HgCommandResultHandler)2 HgRemoteCommandExecutor (org.zmlx.hg4idea.execution.HgRemoteCommandExecutor)2 HgConflictResolver (org.zmlx.hg4idea.provider.update.HgConflictResolver)2 Notification (com.intellij.notification.Notification)1 NotificationListener (com.intellij.notification.NotificationListener)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 VcsException (com.intellij.openapi.vcs.VcsException)1 VcsNotifier (com.intellij.openapi.vcs.VcsNotifier)1 MergeData (com.intellij.openapi.vcs.merge.MergeData)1 UpdatedFiles (com.intellij.openapi.vcs.update.UpdatedFiles)1 VcsRunnable (com.intellij.vcsUtil.VcsRunnable)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1