Search in sources :

Example 1 with HgOutgoingCommand

use of org.zmlx.hg4idea.command.HgOutgoingCommand in project intellij-community by JetBrains.

the class HgOutgoingCommitsProvider method getOutgoingCommits.

@NotNull
@Override
public OutgoingResult getOutgoingCommits(@NotNull final HgRepository repository, @NotNull final PushSpec<HgPushSource, HgTarget> pushSpec, boolean initial) {
    final Project project = repository.getProject();
    HgVcs hgvcs = HgVcs.getInstance(project);
    assert hgvcs != null;
    final HgVersion version = hgvcs.getVersion();
    String[] templates = HgBaseLogParser.constructFullTemplateArgument(true, version);
    HgOutgoingCommand hgOutgoingCommand = new HgOutgoingCommand(project);
    HgTarget hgTarget = pushSpec.getTarget();
    List<VcsError> errors = new ArrayList<>();
    if (StringUtil.isEmptyOrSpaces(hgTarget.myTarget)) {
        errors.add(new VcsError("Hg push path could not be empty."));
        return new OutgoingResult(Collections.<VcsFullCommitDetails>emptyList(), errors);
    }
    HgCommandResult result = hgOutgoingCommand.execute(repository.getRoot(), HgChangesetUtil.makeTemplate(templates), pushSpec.getSource().getPresentation(), hgTarget.myTarget, initial);
    if (result == null) {
        errors.add(new VcsError("Couldn't execute hg outgoing command for " + repository));
        return new OutgoingResult(Collections.<VcsFullCommitDetails>emptyList(), errors);
    }
    List<String> resultErrors = result.getErrorLines();
    if (resultErrors != null && !resultErrors.isEmpty() && result.getExitValue() != 0) {
        for (String error : resultErrors) {
            if (HgErrorUtil.isAbortLine(error)) {
                if (HgErrorUtil.isAuthorizationError(error)) {
                    VcsError authorizationError = new VcsError(error + "<a href='authenticate'>" + LOGIN_AND_REFRESH_LINK + "</a>", new VcsErrorHandler() {

                        public void handleError(@NotNull CommitLoader commitLoader) {
                            commitLoader.reloadCommits();
                        }
                    });
                    errors.add(authorizationError);
                } else {
                    errors.add(new VcsError(error));
                }
            }
        }
        LOG.warn(resultErrors.toString());
    }
    return new OutgoingResult(HgHistoryUtil.createFullCommitsFromResult(project, repository.getRoot(), result, version, true), errors);
}
Also used : HgVcs(org.zmlx.hg4idea.HgVcs) ArrayList(java.util.ArrayList) HgOutgoingCommand(org.zmlx.hg4idea.command.HgOutgoingCommand) HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) Project(com.intellij.openapi.project.Project) HgVersion(org.zmlx.hg4idea.util.HgVersion) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with HgOutgoingCommand

use of org.zmlx.hg4idea.command.HgOutgoingCommand in project intellij-community by JetBrains.

the class HgRemoteStatusUpdater method updateChangesStatusSynchronously.

private void updateChangesStatusSynchronously(Project project, VirtualFile[] roots, HgChangesetStatus status, boolean incoming) {
    if (!myProjectSettings.isCheckIncomingOutgoing())
        return;
    final List<HgRevisionNumber> changesets = new LinkedList<>();
    for (VirtualFile root : roots) {
        if (incoming) {
            changesets.addAll(new HgIncomingCommand(project).executeInCurrentThread(root));
        } else {
            changesets.addAll(new HgOutgoingCommand(project).executeInCurrentThread(root));
        }
    }
    status.setChanges(changesets.size(), new ChangesetFormatter(status, changesets));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgIncomingCommand(org.zmlx.hg4idea.command.HgIncomingCommand) HgOutgoingCommand(org.zmlx.hg4idea.command.HgOutgoingCommand) LinkedList(java.util.LinkedList)

Aggregations

HgOutgoingCommand (org.zmlx.hg4idea.command.HgOutgoingCommand)2 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 NotNull (org.jetbrains.annotations.NotNull)1 HgVcs (org.zmlx.hg4idea.HgVcs)1 HgIncomingCommand (org.zmlx.hg4idea.command.HgIncomingCommand)1 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)1 HgVersion (org.zmlx.hg4idea.util.HgVersion)1