Search in sources :

Example 1 with VcsLog

use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.

the class VcsCherryPickAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    FileDocumentManager.getInstance().saveAllDocuments();
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    VcsLog log = e.getRequiredData(VcsLogDataKeys.VCS_LOG);
    VcsCherryPickManager.getInstance(project).cherryPick(log);
}
Also used : Project(com.intellij.openapi.project.Project) VcsLog(com.intellij.vcs.log.VcsLog)

Example 2 with VcsLog

use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.

the class VcsCherryPickAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    super.update(e);
    e.getPresentation().setVisible(true);
    final VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
    Project project = e.getProject();
    if (project == null) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    VcsCherryPickManager cherryPickManager = VcsCherryPickManager.getInstance(project);
    List<VcsCherryPicker> cherryPickers = getActiveCherryPickersForProject(project);
    if (log == null || cherryPickers.isEmpty()) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    List<CommitId> commits = VcsLogUtil.collectFirstPack(log.getSelectedCommits(), VcsLogUtil.MAX_SELECTED_COMMITS);
    if (commits.isEmpty() || cherryPickManager.isCherryPickAlreadyStartedFor(commits)) {
        e.getPresentation().setEnabled(false);
        return;
    }
    final Map<VirtualFile, List<Hash>> groupedByRoot = groupByRoot(commits);
    VcsCherryPicker activeCherryPicker = getActiveCherryPicker(cherryPickers, groupedByRoot.keySet());
    String description = activeCherryPicker != null ? activeCherryPicker.getInfo(log, groupedByRoot) : SEVERAL_VCS_DESCRIPTION;
    e.getPresentation().setEnabled(description == null);
    e.getPresentation().setText(activeCherryPicker == null ? concatActionNamesForAllAvailable(cherryPickers) : activeCherryPicker.getActionTitle());
    e.getPresentation().setDescription(description == null ? "" : description);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) CommitId(com.intellij.vcs.log.CommitId) VcsLog(com.intellij.vcs.log.VcsLog) List(java.util.List)

Example 3 with VcsLog

use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.

the class GoToHashOrRefAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    VcsLogUtil.triggerUsage(e);
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    VcsLog log = e.getRequiredData(VcsLogDataKeys.VCS_LOG);
    VcsLogUi ui = e.getRequiredData(VcsLogDataKeys.VCS_LOG_UI);
    assert ui instanceof AbstractVcsLogUi;
    AbstractVcsLogUi logUi = (AbstractVcsLogUi) ui;
    Set<VirtualFile> visibleRoots = VcsLogUtil.getVisibleRoots(logUi);
    GoToHashOrRefPopup popup = new GoToHashOrRefPopup(project, logUi.getDataPack().getRefs(), visibleRoots, log::jumpToReference, vcsRef -> logUi.jumpToCommit(vcsRef.getCommitHash(), vcsRef.getRoot()), logUi.getColorManager(), new VcsGoToRefComparator(logUi.getDataPack().getLogProviders()));
    popup.show(logUi.getTable());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) VcsGoToRefComparator(com.intellij.vcs.log.impl.VcsGoToRefComparator) VcsLog(com.intellij.vcs.log.VcsLog) AbstractVcsLogUi(com.intellij.vcs.log.ui.AbstractVcsLogUi) AbstractVcsLogUi(com.intellij.vcs.log.ui.AbstractVcsLogUi) VcsLogUi(com.intellij.vcs.log.VcsLogUi)

Example 4 with VcsLog

use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.

the class GitShowCommitInLogAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent event) {
    final Project project = event.getRequiredData(CommonDataKeys.PROJECT);
    final VcsRevisionNumber revision = getRevisionNumber(event);
    if (revision == null) {
        return;
    }
    boolean logReady = findLog(project) != null;
    final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
    ContentManager cm = window.getContentManager();
    Content[] contents = cm.getContents();
    for (Content content : contents) {
        if (VcsLogContentProvider.TAB_NAME.equals(content.getDisplayName())) {
            cm.setSelectedContent(content);
            break;
        }
    }
    final VcsLog log = findLog(project);
    if (log == null) {
        showLogNotReadyMessage(project);
        return;
    }
    Runnable selectAndOpenLog = new Runnable() {

        @Override
        public void run() {
            Runnable selectCommit = new Runnable() {

                @Override
                public void run() {
                    jumpToRevisionUnderProgress(project, log, revision);
                }
            };
            if (!window.isVisible()) {
                window.activate(selectCommit, true);
            } else {
                selectCommit.run();
            }
        }
    };
    if (logReady) {
        selectAndOpenLog.run();
        return;
    }
    VcsProjectLog projectLog = VcsProjectLog.getInstance(project);
    if (projectLog == null) {
        showLogNotReadyMessage(project);
        return;
    }
    VcsLogUiImpl logUi = projectLog.getMainLogUi();
    if (logUi == null) {
        showLogNotReadyMessage(project);
        return;
    }
    logUi.invokeOnChange(selectAndOpenLog);
}
Also used : Project(com.intellij.openapi.project.Project) ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) VcsLog(com.intellij.vcs.log.VcsLog) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) ChangesViewContentManager(com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager) ContentManager(com.intellij.ui.content.ContentManager) VcsProjectLog(com.intellij.vcs.log.impl.VcsProjectLog) VcsLogUiImpl(com.intellij.vcs.log.ui.VcsLogUiImpl)

Example 5 with VcsLog

use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.

the class VcsLogSingleCommitAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    VcsLog log = e.getRequiredData(VcsLogDataKeys.VCS_LOG);
    CommitId commit = ContainerUtil.getFirstItem(log.getSelectedCommits());
    assert commit != null;
    Repo repository = getRepositoryForRoot(project, commit.getRoot());
    assert repository != null;
    actionPerformed(repository, commit.getHash());
}
Also used : Project(com.intellij.openapi.project.Project) CommitId(com.intellij.vcs.log.CommitId) VcsLog(com.intellij.vcs.log.VcsLog)

Aggregations

VcsLog (com.intellij.vcs.log.VcsLog)9 Project (com.intellij.openapi.project.Project)8 CommitId (com.intellij.vcs.log.CommitId)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 VcsLogUi (com.intellij.vcs.log.VcsLogUi)2 AbstractVcsLogUi (com.intellij.vcs.log.ui.AbstractVcsLogUi)2 List (java.util.List)2 ChangesViewContentManager (com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager)1 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)1 ToolWindow (com.intellij.openapi.wm.ToolWindow)1 Content (com.intellij.ui.content.Content)1 ContentManager (com.intellij.ui.content.ContentManager)1 VcsFullCommitDetails (com.intellij.vcs.log.VcsFullCommitDetails)1 VcsGoToRefComparator (com.intellij.vcs.log.impl.VcsGoToRefComparator)1 VcsProjectLog (com.intellij.vcs.log.impl.VcsProjectLog)1 VcsLogUiImpl (com.intellij.vcs.log.ui.VcsLogUiImpl)1 GitRepository (git4idea.repo.GitRepository)1 Nullable (org.jetbrains.annotations.Nullable)1 HgRepository (org.zmlx.hg4idea.repo.HgRepository)1