use of com.intellij.vcs.log.visible.VisiblePack in project intellij-community by JetBrains.
the class IndexSpeedSearch method isSpeedSearchEnabled.
@Override
protected boolean isSpeedSearchEnabled() {
if (super.isSpeedSearchEnabled()) {
VisiblePack visiblePack = myComponent.getModel().getVisiblePack();
Set<VirtualFile> roots = visiblePack.getLogProviders().keySet();
Set<VirtualFile> visibleRoots = VcsLogUtil.getAllVisibleRoots(roots, visiblePack.getFilters().getRootFilter(), visiblePack.getFilters().getStructureFilter());
for (VirtualFile root : visibleRoots) {
if (!myIndex.isIndexed(root))
return false;
}
return true;
}
return false;
}
use of com.intellij.vcs.log.visible.VisiblePack in project intellij-community by JetBrains.
the class GitUncommitAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
super.update(e);
Project project = e.getProject();
VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
VcsLogData data = (VcsLogData) e.getData(VcsLogDataKeys.VCS_LOG_DATA_PROVIDER);
VcsLogUi ui = e.getData(VcsLogDataKeys.VCS_LOG_UI);
if (project == null || log == null || data == null || ui == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
int selectedCommits = log.getSelectedShortDetails().size();
if (selectedCommits != 1) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
VcsShortCommitDetails commit = log.getSelectedShortDetails().get(0);
Hash hash = commit.getId();
VirtualFile root = commit.getRoot();
GitRepository repository = getRepositoryManager(project).getRepositoryForRootQuick(commit.getRoot());
if (repository == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
DataPackBase dataPackBase = ((VisiblePack) ui.getDataPack()).getDataPack();
if (!(dataPackBase instanceof DataPack)) {
e.getPresentation().setVisible(true);
e.getPresentation().setEnabled(false);
return;
}
// support undo only for the last commit in the branch
DataPack dataPack = (DataPack) dataPackBase;
List<Integer> children = dataPack.getPermanentGraph().getChildren(data.getCommitIndex(hash, root));
if (!children.isEmpty()) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
// undoing merge commit is not allowed
int parents = commit.getParents().size();
if (parents != 1) {
e.getPresentation().setEnabled(false);
e.getPresentation().setDescription("Selected commit has " + parents + " parents");
return;
}
// allow reset only in current branch
List<String> branches = data.getContainingBranchesGetter().getContainingBranchesFromCache(root, hash);
if (branches != null) {
// otherwise the information is not available yet, and we'll recheck harder in actionPerformed
if (!branches.contains(HEAD)) {
e.getPresentation().setEnabled(false);
e.getPresentation().setDescription(COMMIT_NOT_IN_HEAD);
return;
}
// and not if pushed to a protected branch
String protectedBranch = findProtectedRemoteBranch(repository, branches);
if (protectedBranch != null) {
e.getPresentation().setEnabled(false);
e.getPresentation().setDescription(COMMIT_PUSHED_TO_PROTECTED + protectedBranch);
return;
}
}
e.getPresentation().setEnabledAndVisible(true);
}
Aggregations