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;
}
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);
}
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);
}
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));
}
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()))));
}
}
Aggregations