Search in sources :

Example 1 with VcsFullCommitDetails

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

the class DvcsUtil method groupCommitsByRoots.

@NotNull
public static <R extends Repository> Map<R, List<VcsFullCommitDetails>> groupCommitsByRoots(@NotNull RepositoryManager<R> repoManager, @NotNull List<? extends VcsFullCommitDetails> commits) {
    Map<R, List<VcsFullCommitDetails>> groupedCommits = ContainerUtil.newHashMap();
    for (VcsFullCommitDetails commit : commits) {
        R repository = repoManager.getRepositoryForRoot(commit.getRoot());
        if (repository == null) {
            LOGGER.info("No repository found for commit " + commit);
            continue;
        }
        List<VcsFullCommitDetails> commitsInRoot = groupedCommits.get(repository);
        if (commitsInRoot == null) {
            commitsInRoot = ContainerUtil.newArrayList();
            groupedCommits.put(repository, commitsInRoot);
        }
        commitsInRoot.add(commit);
    }
    return groupedCommits;
}
Also used : VcsFullCommitDetails(com.intellij.vcs.log.VcsFullCommitDetails) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with VcsFullCommitDetails

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

the class FileHistoryUi method collectChanges.

@NotNull
public List<Change> collectChanges(@NotNull List<VcsFullCommitDetails> detailsList, boolean onlyRelevant) {
    List<Change> changes = ContainerUtil.newArrayList();
    List<VcsFullCommitDetails> detailsListReversed = ContainerUtil.reverse(detailsList);
    for (VcsFullCommitDetails details : detailsListReversed) {
        changes.addAll(onlyRelevant ? collectRelevantChanges(details) : details.getChanges());
    }
    return CommittedChangesTreeBrowser.zipChanges(changes);
}
Also used : Change(com.intellij.openapi.vcs.changes.Change) VcsFullCommitDetails(com.intellij.vcs.log.VcsFullCommitDetails) ObjectUtils.chooseNotNull(com.intellij.util.ObjectUtils.chooseNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with VcsFullCommitDetails

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

the class CompareRevisionsFromHistoryAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    FileHistoryUi ui = e.getRequiredData(VcsLogInternalDataKeys.FILE_HISTORY_UI);
    FilePath filePath = e.getRequiredData(VcsDataKeys.FILE_PATH);
    if (e.getInputEvent() instanceof MouseEvent && ui.getTable().isResizingColumns()) {
        // disable action during columns resize
        return;
    }
    VcsLogUtil.triggerUsage(e);
    List<CommitId> commits = ui.getVcsLog().getSelectedCommits();
    if (commits.size() != 1 && commits.size() != 2)
        return;
    List<Integer> commitIds = ContainerUtil.map(commits, c -> ui.getLogData().getCommitIndex(c.getHash(), c.getRoot()));
    ui.getLogData().getCommitDetailsGetter().loadCommitsData(commitIds, details -> {
        if (details.size() == 2) {
            VcsFileRevision newestRevision = ui.createRevision(details.get(0));
            VcsFileRevision olderRevision = ui.createRevision(details.get(1));
            if (olderRevision != null && newestRevision != null) {
                myDiffHandler.showDiffForTwo(project, filePath, olderRevision, newestRevision);
            }
        } else if (details.size() == 1) {
            VcsFullCommitDetails detail = ObjectUtils.notNull(ContainerUtil.getFirstItem(details));
            List<Change> changes = ui.collectRelevantChanges(detail);
            if (filePath.isDirectory()) {
                VcsDiffUtil.showChangesDialog(project, "Changes in " + detail.getId().toShortString() + " for " + filePath.getName(), ContainerUtil.newArrayList(changes));
            } else {
                ShowDiffAction.showDiffForChange(project, changes, 0, new ShowDiffContext());
            }
        }
    }, null);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) Project(com.intellij.openapi.project.Project) MouseEvent(java.awt.event.MouseEvent) CommitId(com.intellij.vcs.log.CommitId) ShowDiffContext(com.intellij.openapi.vcs.changes.actions.diff.ShowDiffContext) List(java.util.List) FileHistoryUi(com.intellij.vcs.log.history.FileHistoryUi) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) VcsFullCommitDetails(com.intellij.vcs.log.VcsFullCommitDetails)

Example 4 with VcsFullCommitDetails

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

the class FileHistorySingleCommitAction 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<VcsFullCommitDetails> details = ui.getVcsLog().getSelectedDetails();
    if (details.isEmpty()) {
        e.getPresentation().setEnabled(false);
        return;
    }
    VcsFullCommitDetails detail = getFirstItem(details);
    if (detail instanceof LoadingDetails)
        detail = null;
    e.getPresentation().setEnabled(details.size() == 1 && isEnabled(ui, detail, e));
}
Also used : Project(com.intellij.openapi.project.Project) LoadingDetails(com.intellij.vcs.log.data.LoadingDetails) FileHistoryUi(com.intellij.vcs.log.history.FileHistoryUi) VcsFullCommitDetails(com.intellij.vcs.log.VcsFullCommitDetails)

Example 5 with VcsFullCommitDetails

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

the class GitOutgoingCommitsProvider method getOutgoingCommits.

@NotNull
@Override
public OutgoingResult getOutgoingCommits(@NotNull GitRepository repository, @NotNull PushSpec<GitPushSource, GitPushTarget> pushSpec, boolean initial) {
    GitLocalBranch branch = pushSpec.getSource().getBranch();
    String source = branch.equals(repository.getCurrentBranch()) ? HEAD : branch.getFullName();
    GitPushTarget target = pushSpec.getTarget();
    String destination = target.getBranch().getFullName();
    try {
        List<GitCommit> commits;
        if (!target.isNewBranchCreated()) {
            commits = GitHistoryUtils.history(myProject, repository.getRoot(), destination + ".." + source);
        } else {
            commits = GitHistoryUtils.history(myProject, repository.getRoot(), source, "--not", "--remotes=" + target.getBranch().getRemote().getName(), "--max-count=" + 1000);
        }
        return new OutgoingResult(commits, Collections.<VcsError>emptyList());
    } catch (VcsException e) {
        return new OutgoingResult(Collections.<VcsFullCommitDetails>emptyList(), Collections.singletonList(new VcsError(GitUtil.cleanupErrorPrefixes(e.getMessage()))));
    }
}
Also used : GitLocalBranch(git4idea.GitLocalBranch) GitCommit(git4idea.GitCommit) VcsException(com.intellij.openapi.vcs.VcsException) OutgoingResult(com.intellij.dvcs.push.OutgoingResult) VcsFullCommitDetails(com.intellij.vcs.log.VcsFullCommitDetails) VcsError(com.intellij.dvcs.push.VcsError) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

VcsFullCommitDetails (com.intellij.vcs.log.VcsFullCommitDetails)12 Project (com.intellij.openapi.project.Project)4 NotNull (org.jetbrains.annotations.NotNull)4 Change (com.intellij.openapi.vcs.changes.Change)3 FileHistoryUi (com.intellij.vcs.log.history.FileHistoryUi)3 FilePath (com.intellij.openapi.vcs.FilePath)2 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)2 LoadingDetails (com.intellij.vcs.log.data.LoadingDetails)2 List (java.util.List)2 OutgoingResult (com.intellij.dvcs.push.OutgoingResult)1 VcsError (com.intellij.dvcs.push.VcsError)1 VcsException (com.intellij.openapi.vcs.VcsException)1 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)1 ShowDiffContext (com.intellij.openapi.vcs.changes.actions.diff.ShowDiffContext)1 ObjectUtils.chooseNotNull (com.intellij.util.ObjectUtils.chooseNotNull)1 CommitId (com.intellij.vcs.log.CommitId)1 VcsLog (com.intellij.vcs.log.VcsLog)1 GitCommit (git4idea.GitCommit)1 GitLocalBranch (git4idea.GitLocalBranch)1 GitCommandResult (git4idea.commands.GitCommandResult)1