com.intellij.vcs.log.VcsLog Java Examples

The following examples show how to use com.intellij.vcs.log.VcsLog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VcsLogAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  Project project = e.getProject();
  VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
  if (project == null || log == null) {
    e.getPresentation().setEnabledAndVisible(false);
    return;
  }

  List<VcsFullCommitDetails> details = log.getSelectedDetails();
  MultiMap<Repo, VcsFullCommitDetails> grouped = groupByRootWithCheck(project, details);
  if (grouped == null) {
    e.getPresentation().setEnabledAndVisible(false);
  }
  else {
    e.getPresentation().setVisible(isVisible(project, grouped));
    e.getPresentation().setEnabled(!grouped.isEmpty() && isEnabled(grouped));
  }
}
 
Example #2
Source File: VcsLogAction.java    From GitLink with MIT License 5 votes vote down vote up
@Override
public void actionPerformed(@NotNull final Project project, @NotNull final AnActionEvent event)
{
    VcsLog vcsLog = event.getData(VcsLogDataKeys.VCS_LOG);

    if (vcsLog == null) {
        return;
    }

    VcsFullCommitDetails vcsCommit = vcsLog.getSelectedDetails().get(0);

    Commit commit = new Commit(vcsCommit.getId().toShortString());

    this.perform(project, commit, vcsCommit.getRoot());
}
 
Example #3
Source File: VcsLogAction.java    From GitLink with MIT License 5 votes vote down vote up
@Override
protected boolean shouldActionBeEnabled(@NotNull final AnActionEvent event)
{
    VcsLog log = event.getData(VcsLogDataKeys.VCS_LOG);

    if (log == null) {
        return false;
    }

    List<VcsFullCommitDetails> commits = log.getSelectedDetails();

    return commits.size() == 1;
}
 
Example #4
Source File: OpenCommitInBrowserAction.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@Override
public void update(@NotNull final AnActionEvent anActionEvent) {

    final Presentation presentation = anActionEvent.getPresentation();

    final Project project = anActionEvent.getData(CommonDataKeys.PROJECT);
    final VcsLog log = anActionEvent.getData(VcsLogDataKeys.VCS_LOG);
    if (project == null || project.isDisposed() || log == null) {
        presentation.setEnabledAndVisible(false);
        return;
    }

    final List<VcsFullCommitDetails> commits = log.getSelectedDetails();
    if (commits.size() == 0) {
        presentation.setEnabledAndVisible(false);
        return;
    }

    final VcsFullCommitDetails commit = commits.get(0);

    final GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForRootQuick(commit.getRoot());

    if (repository == null || !TfGitHelper.isTfGitRepository(repository)) {
        presentation.setEnabledAndVisible(false);
        return;
    } else if (commits.size() > 1) {
        // only one for now, leave it visible as a breadcrumb
        presentation.setVisible(true);
        presentation.setEnabled(false);
        return;
    }

    presentation.setEnabledAndVisible(true);
}
 
Example #5
Source File: VcsCherryPickAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #6
Source File: VcsCherryPickAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(@Nonnull 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);
}
 
Example #7
Source File: VcsCherryPickManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void cherryPick(@Nonnull VcsLog log) {
  log.requestSelectedDetails(new Consumer<List<VcsFullCommitDetails>>() {
    @Override
    public void consume(List<VcsFullCommitDetails> details) {
      ProgressManager.getInstance().run(new CherryPickingTask(myProject, ContainerUtil.reverse(details)));
    }
  }, null);
}
 
Example #8
Source File: VcsCherryPicker.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * Return null if all selected commits can be cherry-picked without problems by this cherry-picker or error description otherwise.
 *
 * @param log     additional log information
 * @param commits commits to cherry-pick, grouped by version control root
 * @return
 */
public String getInfo(@Nonnull VcsLog log, @Nonnull Map<VirtualFile, List<Hash>> commits) {
  return null;
}