Search in sources :

Example 6 with CommitId

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

the class FileHistorySingleCommitAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    VcsLogUtil.triggerUsage(e);
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    FileHistoryUi ui = e.getRequiredData(VcsLogInternalDataKeys.FILE_HISTORY_UI);
    List<CommitId> commits = ui.getVcsLog().getSelectedCommits();
    if (commits.size() != 1)
        return;
    CommitId commit = notNull(getFirstItem(commits));
    List<Integer> commitIndex = Ints.asList(ui.getLogData().getCommitIndex(commit.getHash(), commit.getRoot()));
    ui.getLogData().getCommitDetailsGetter().loadCommitsData(commitIndex, details -> {
        if (!details.isEmpty()) {
            performAction(project, ui, notNull(getFirstItem(details)), e);
        }
    }, null);
}
Also used : Project(com.intellij.openapi.project.Project) CommitId(com.intellij.vcs.log.CommitId) FileHistoryUi(com.intellij.vcs.log.history.FileHistoryUi)

Example 7 with CommitId

use of com.intellij.vcs.log.CommitId 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)

Example 8 with CommitId

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

the class VcsLogSingleCommitAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
    if (project == null || log == null) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    List<CommitId> commits = log.getSelectedCommits();
    if (commits.isEmpty()) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    CommitId commit = ContainerUtil.getFirstItem(commits);
    assert commit != null;
    Repo repository = getRepositoryForRoot(project, commit.getRoot());
    if (repository == null) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    e.getPresentation().setVisible(isVisible(project, repository, commit.getHash()));
    e.getPresentation().setEnabled(commits.size() == 1 && isEnabled(repository, commit.getHash()));
}
Also used : Project(com.intellij.openapi.project.Project) CommitId(com.intellij.vcs.log.CommitId) VcsLog(com.intellij.vcs.log.VcsLog)

Example 9 with CommitId

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

the class RefsModel method refsToCommit.

public Collection<VcsRef> refsToCommit(int index) {
    CommitId id = myStorage.getCommitId(index);
    if (id == null)
        return Collections.emptyList();
    VirtualFile root = id.getRoot();
    return myRefs.get(root).refsToCommit(index);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CommitId(com.intellij.vcs.log.CommitId)

Example 10 with CommitId

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

the class CreatePatchFromHistoryAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    FileHistoryUi ui = e.getData(VcsLogInternalDataKeys.FILE_HISTORY_UI);
    if (project == null || ui == null) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    e.getPresentation().setVisible(true);
    List<CommitId> selectedCommits = ui.getVcsLog().getSelectedCommits();
    String commitMessage = e.getData(VcsDataKeys.PRESET_COMMIT_MESSAGE);
    e.getPresentation().setEnabled(!selectedCommits.isEmpty() && commitMessage != null);
}
Also used : Project(com.intellij.openapi.project.Project) CommitId(com.intellij.vcs.log.CommitId) FileHistoryUi(com.intellij.vcs.log.history.FileHistoryUi)

Aggregations

CommitId (com.intellij.vcs.log.CommitId)11 Project (com.intellij.openapi.project.Project)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 VcsLog (com.intellij.vcs.log.VcsLog)4 FileHistoryUi (com.intellij.vcs.log.history.FileHistoryUi)3 List (java.util.List)3 NotNull (org.jetbrains.annotations.NotNull)3 FilePath (com.intellij.openapi.vcs.FilePath)1 ShowDiffContext (com.intellij.openapi.vcs.changes.actions.diff.ShowDiffContext)1 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)1 MultiMap (com.intellij.util.containers.MultiMap)1 Hash (com.intellij.vcs.log.Hash)1 VcsFullCommitDetails (com.intellij.vcs.log.VcsFullCommitDetails)1 VcsLogProvider (com.intellij.vcs.log.VcsLogProvider)1 VcsShortCommitDetails (com.intellij.vcs.log.VcsShortCommitDetails)1 LoadingDetails (com.intellij.vcs.log.data.LoadingDetails)1 GitRepository (git4idea.repo.GitRepository)1 TIntIntHashMap (gnu.trove.TIntIntHashMap)1 TIntObjectHashMap (gnu.trove.TIntObjectHashMap)1 MouseEvent (java.awt.event.MouseEvent)1