Search in sources :

Example 11 with HgCommandResultNotifier

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

the class HgQPushCommand method executeInCurrentThread.

public void executeInCurrentThread(@NotNull final String patchName) {
    final Project project = myRepository.getProject();
    HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(myRepository.getRoot(), "qpush", Arrays.asList("--move", patchName));
    if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
        new HgCommandResultNotifier(project).notifyError(result, "QPush command failed", "Could not apply selected patch " + patchName);
    }
    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 12 with HgCommandResultNotifier

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

the class HgQRenameCommand method performPatchRename.

public static void performPatchRename(@NotNull final HgRepository repository, @NotNull final String oldName, @NotNull final String newName) {
    if (oldName.equals(newName))
        return;
    final Project project = repository.getProject();
    new HgCommandExecutor(project).execute(repository.getRoot(), "qrename", Arrays.asList(oldName, newName), new HgCommandResultHandler() {

        @Override
        public void process(@Nullable HgCommandResult result) {
            if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
                new HgCommandResultNotifier(project).notifyError(result, "Qrename command failed", "Could not rename patch " + oldName + " to " + newName);
            }
            repository.update();
        }
    });
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) Project(com.intellij.openapi.project.Project) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) HgCommandResultHandler(org.zmlx.hg4idea.execution.HgCommandResultHandler) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier)

Example 13 with HgCommandResultNotifier

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

the class HgRegularUpdater method processRebase.

private void processRebase(ProgressIndicator indicator, final UpdatedFiles updatedFiles) throws VcsException {
    indicator.setText2(HgVcsMessages.message("hg4idea.progress.rebase"));
    HgRepository repository = HgUtil.getRepositoryManager(project).getRepositoryForRoot(repoRoot);
    if (repository == null) {
        throw new VcsException("Repository not found for root " + repoRoot);
    }
    HgRebaseCommand rebaseCommand = new HgRebaseCommand(project, repository);
    HgCommandResult result = new HgRebaseCommand(project, repository).startRebase();
    if (HgErrorUtil.isCommandExecutionFailed(result)) {
        new HgCommandResultNotifier(project).notifyError(result, "Hg Error", "Couldn't rebase repository.");
        return;
    }
    //noinspection ConstantConditions
    while (result.getExitValue() == 1) {
        //if result == null isAbort will be true;
        resolvePossibleConflicts(updatedFiles);
        if (HgConflictResolver.hasConflicts(project, repoRoot) || HgErrorUtil.isNothingToRebase(result)) {
            break;
        }
        result = rebaseCommand.continueRebase();
        if (HgErrorUtil.isAbort(result)) {
            new HgCommandResultNotifier(project).notifyError(result, "Hg Error", "Couldn't continue rebasing");
            break;
        }
    }
    repository.update();
    repoRoot.refresh(true, true);
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) VcsException(com.intellij.openapi.vcs.VcsException) HgRepository(org.zmlx.hg4idea.repo.HgRepository) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier)

Example 14 with HgCommandResultNotifier

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

the class HgCheckoutProvider method doCheckout.

public void doCheckout(@NotNull final Project project, @Nullable final Listener listener) {
    FileDocumentManager.getInstance().saveAllDocuments();
    final HgCloneDialog dialog = new HgCloneDialog(project);
    if (!dialog.showAndGet()) {
        return;
    }
    dialog.rememberSettings();
    VirtualFile destinationParent = LocalFileSystem.getInstance().findFileByIoFile(new File(dialog.getParentDirectory()));
    if (destinationParent == null) {
        return;
    }
    final String targetDir = destinationParent.getPath() + File.separator + dialog.getDirectoryName();
    final String sourceRepositoryURL = dialog.getSourceRepositoryURL();
    final AtomicReference<HgCommandResult> cloneResult = new AtomicReference<>();
    new Task.Backgroundable(project, HgVcsMessages.message("hg4idea.clone.progress", sourceRepositoryURL), true) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            HgCloneCommand clone = new HgCloneCommand(project);
            clone.setRepositoryURL(sourceRepositoryURL);
            clone.setDirectory(targetDir);
            cloneResult.set(clone.executeInCurrentThread());
        }

        @Override
        public void onSuccess() {
            if (cloneResult.get() == null || HgErrorUtil.hasErrorsInCommandExecution(cloneResult.get())) {
                new HgCommandResultNotifier(project).notifyError(cloneResult.get(), "Clone failed", "Clone from " + sourceRepositoryURL + " failed.");
            } else {
                DvcsUtil.addMappingIfSubRoot(project, targetDir, HgVcs.VCS_NAME);
                if (listener != null) {
                    listener.directoryCheckedOut(new File(dialog.getParentDirectory(), dialog.getDirectoryName()), HgVcs.getKey());
                    listener.checkoutCompleted();
                }
            }
        }
    }.queue();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Task(com.intellij.openapi.progress.Task) AtomicReference(java.util.concurrent.atomic.AtomicReference) HgCloneCommand(org.zmlx.hg4idea.command.HgCloneCommand) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier) HgCloneDialog(org.zmlx.hg4idea.ui.HgCloneDialog) HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 15 with HgCommandResultNotifier

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

the class HgErrorUtil method handleException.

public static void handleException(@Nullable Project project, @NotNull String title, @NotNull Exception e) {
    LOG.info(e);
    new HgCommandResultNotifier(project).notifyError(null, title, e.getMessage());
}
Also used : 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