Search in sources :

Example 46 with HgCommandResult

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

the class HgIntegrationEnabler method initOrNotifyError.

@Override
protected boolean initOrNotifyError(@NotNull final VirtualFile projectDir) {
    final boolean[] success = new boolean[1];
    new HgInitCommand(myProject).executeAsynchronously(projectDir, new HgCommandResultHandler() {

        @Override
        public void process(@Nullable HgCommandResult result) {
            VcsNotifier notifier = VcsNotifier.getInstance(myProject);
            if (!HgErrorUtil.hasErrorsInCommandExecution(result)) {
                success[0] = true;
                refreshVcsDir(projectDir, HgUtil.DOT_HG);
                notifier.notifySuccess(message("hg4idea.init.created.notification.title"), message("hg4idea.init.created.notification.description", projectDir.getPresentableUrl()));
            } else {
                success[0] = false;
                String errors = result != null ? result.getRawError() : "";
                notifier.notifyError(message("hg4idea.init.error.description", projectDir.getPresentableUrl()), errors);
            }
        }
    });
    return success[0];
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCommandResultHandler(org.zmlx.hg4idea.execution.HgCommandResultHandler) HgInitCommand(org.zmlx.hg4idea.command.HgInitCommand) VcsNotifier(com.intellij.openapi.vcs.VcsNotifier)

Example 47 with HgCommandResult

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

the class HgCloneDialog method test.

@NotNull
@Override
protected TestResult test(@NotNull final String url) {
    HgIdentifyCommand identifyCommand = new HgIdentifyCommand(myProject);
    identifyCommand.setSource(url);
    HgCommandResult result = identifyCommand.execute(ModalityState.stateForComponent(getRootPane()));
    return result != null && result.getExitValue() == 0 ? TestResult.SUCCESS : new TestResult(result.getRawError());
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgIdentifyCommand(org.zmlx.hg4idea.command.HgIdentifyCommand) NotNull(org.jetbrains.annotations.NotNull)

Example 48 with HgCommandResult

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

the class HgQNewCommand method executeQNewInCurrentThread.

private void executeQNewInCurrentThread(@NotNull List<String> chunkFiles) throws VcsException {
    List<String> args = ContainerUtil.newArrayList();
    args.add("-l");
    args.add(saveCommitMessage().getAbsolutePath());
    args.add("-UD");
    String patchName = DATE_FORMAT.format(new Date()).concat(".diff");
    args.add(patchName);
    args.addAll(chunkFiles);
    HgCommandExecutor executor = new HgCommandExecutor(myProject);
    HgCommandResult result = executor.executeInCurrentThread(myRepository.getRoot(), "qnew", args);
    if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
        new HgCommandResultNotifier(myProject).notifyError(result, "Qnew Failed", "Could not create mq patch for selected changes");
    }
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgCommandExecutor(org.zmlx.hg4idea.execution.HgCommandExecutor) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier) Date(java.util.Date)

Example 49 with HgCommandResult

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

the class HgQPopCommand method executeInCurrentThread.

public HgCommandResult executeInCurrentThread() {
    final Project project = myRepository.getProject();
    HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(myRepository.getRoot(), "qpop", Collections.singletonList("--all"));
    if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
        new HgCommandResultNotifier(project).notifyError(result, "QPop command failed", "Could not make all patches unapplied");
    } else {
        assert result != null;
        if (!result.getErrorLines().isEmpty()) {
            VcsNotifier.getInstance(project).notifyWarning("QPop completed with errors", result.getRawError());
        }
    }
    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 50 with HgCommandResult

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

the class HgHistoryUtil method readAllHashes.

@NotNull
public static List<TimedVcsCommit> readAllHashes(@NotNull Project project, @NotNull VirtualFile root, @NotNull final Consumer<VcsUser> userRegistry, @NotNull List<String> params) throws VcsException {
    final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project);
    if (factory == null) {
        return Collections.emptyList();
    }
    HgVcs hgvcs = HgVcs.getInstance(project);
    assert hgvcs != null;
    HgVersion version = hgvcs.getVersion();
    String[] templates = ArrayUtil.toStringArray(HgBaseLogParser.constructDefaultTemplate(version));
    HgCommandResult result = getLogResult(project, root, version, -1, params, HgChangesetUtil.makeTemplate(templates));
    return getCommitRecords(project, result, new HgBaseLogParser<TimedVcsCommit>() {

        @Override
        protected TimedVcsCommit convertDetails(@NotNull String rev, @NotNull String changeset, @NotNull SmartList<HgRevisionNumber> parents, @NotNull Date revisionDate, @NotNull String author, @NotNull String email, @NotNull List<String> attributes) {
            List<Hash> parentsHash = new SmartList<>();
            for (HgRevisionNumber parent : parents) {
                parentsHash.add(factory.createHash(parent.getChangeset()));
            }
            userRegistry.consume(factory.createUser(author, email));
            return factory.createTimedCommit(factory.createHash(changeset), parentsHash, revisionDate.getTime());
        }
    });
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) SmartList(com.intellij.util.SmartList) HgVersion(org.zmlx.hg4idea.util.HgVersion) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)54 HgCommandExecutor (org.zmlx.hg4idea.execution.HgCommandExecutor)21 HgCommandResultNotifier (org.zmlx.hg4idea.action.HgCommandResultNotifier)19 Project (com.intellij.openapi.project.Project)12 NotNull (org.jetbrains.annotations.NotNull)11 ArrayList (java.util.ArrayList)7 HgVersion (org.zmlx.hg4idea.util.HgVersion)7 VcsException (com.intellij.openapi.vcs.VcsException)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 File (java.io.File)5 LinkedList (java.util.LinkedList)5 HgCommandResultHandler (org.zmlx.hg4idea.execution.HgCommandResultHandler)5 AccessToken (com.intellij.openapi.application.AccessToken)4 Nullable (org.jetbrains.annotations.Nullable)4 HgRevisionNumber (org.zmlx.hg4idea.HgRevisionNumber)4 HgVcs (org.zmlx.hg4idea.HgVcs)4 HgRevertCommand (org.zmlx.hg4idea.command.HgRevertCommand)4 SmartList (com.intellij.util.SmartList)3 HgFile (org.zmlx.hg4idea.HgFile)3 HgRemoteCommandExecutor (org.zmlx.hg4idea.execution.HgRemoteCommandExecutor)3