Search in sources :

Example 1 with HgVcs

use of org.zmlx.hg4idea.HgVcs 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 HgVcs

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

the class HgRepositoryImpl method getInstance.

@NotNull
public static HgRepository getInstance(@NotNull VirtualFile root, @NotNull Project project, @NotNull Disposable parentDisposable) {
    HgVcs vcs = HgVcs.getInstance(project);
    if (vcs == null) {
        throw new IllegalArgumentException("Vcs not found for project " + project);
    }
    HgRepositoryImpl repository = new HgRepositoryImpl(root, vcs, parentDisposable);
    repository.setupUpdater();
    return repository;
}
Also used : HgVcs(org.zmlx.hg4idea.HgVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with HgVcs

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

the class HgMergeProviderTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    HgVcs vcs = HgVcs.getInstance(myProject);
    assertNotNull(vcs);
    myMergeProvider = vcs.getMergeProvider();
    assertNotNull(myMergeProvider);
}
Also used : HgVcs(org.zmlx.hg4idea.HgVcs)

Example 4 with HgVcs

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

the class HgAbstractFilesAction method update.

public final void update(AnActionEvent e) {
    super.update(e);
    Presentation presentation = e.getPresentation();
    final DataContext dataContext = e.getDataContext();
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project == null) {
        presentation.setEnabled(false);
        return;
    }
    VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
    if (files == null || files.length == 0) {
        presentation.setEnabled(false);
        return;
    }
    final HgVcs vcs = HgVcs.getInstance(project);
    if ((vcs == null)) {
        presentation.setEnabled(false);
        return;
    }
    if (!ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, files)) {
        presentation.setEnabled(false);
        return;
    }
    boolean enabled = false;
    for (VirtualFile file : files) {
        boolean fileEnabled = isEnabled(project, vcs, file);
        if (fileEnabled) {
            enabled = true;
            break;
        }
    }
    presentation.setEnabled(enabled);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) HgVcs(org.zmlx.hg4idea.HgVcs)

Example 5 with HgVcs

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

the class HgAbstractGlobalAction method isEnabled.

public boolean isEnabled(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null) {
        return false;
    }
    HgVcs vcs = ObjectUtils.assertNotNull(HgVcs.getInstance(project));
    final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(vcs);
    if (roots == null || roots.length == 0) {
        return false;
    }
    return true;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) HgVcs(org.zmlx.hg4idea.HgVcs)

Aggregations

HgVcs (org.zmlx.hg4idea.HgVcs)14 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 Project (com.intellij.openapi.project.Project)4 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)4 ArrayList (java.util.ArrayList)3 NotNull (org.jetbrains.annotations.NotNull)3 VcsException (com.intellij.openapi.vcs.VcsException)2 File (java.io.File)2 HgVersion (org.zmlx.hg4idea.util.HgVersion)2 Notification (com.intellij.notification.Notification)1 NotificationListener (com.intellij.notification.NotificationListener)1 AbstractVcsHelper (com.intellij.openapi.vcs.AbstractVcsHelper)1 TransactionRunnable (com.intellij.openapi.vcs.TransactionRunnable)1 ProjectLevelVcsManagerImpl (com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1 HgFile (org.zmlx.hg4idea.HgFile)1 HgProjectSettings (org.zmlx.hg4idea.HgProjectSettings)1 HgCommandResultNotifier (org.zmlx.hg4idea.action.HgCommandResultNotifier)1 HgOutgoingCommand (org.zmlx.hg4idea.command.HgOutgoingCommand)1 HgResolveCommand (org.zmlx.hg4idea.command.HgResolveCommand)1