mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] introduce getAllVisibleRoots util method for VcsLogFilterCollection
This commit is contained in:
@@ -122,7 +122,19 @@ public class VcsLogUtil {
|
||||
return selectedRoots;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Set<VirtualFile> getVisibleRoots(@NotNull VcsLogUi logUi) {
|
||||
VcsLogFilterCollection filters = logUi.getFilterUi().getFilters();
|
||||
Set<VirtualFile> roots = logUi.getDataPack().getLogProviders().keySet();
|
||||
return getAllVisibleRoots(roots, filters);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Set<VirtualFile> getAllVisibleRoots(@NotNull Collection<VirtualFile> roots,
|
||||
@NotNull VcsLogFilterCollection collection) {
|
||||
return getAllVisibleRoots(roots, collection.getRootFilter(), collection.getStructureFilter());
|
||||
}
|
||||
|
||||
// collect absolutely all roots that might be visible
|
||||
// if filters unset returns just all roots
|
||||
@NotNull
|
||||
@@ -170,13 +182,6 @@ public class VcsLogUtil {
|
||||
return list.subList(0, Math.min(list.size(), max));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Set<VirtualFile> getVisibleRoots(@NotNull VcsLogUi logUi) {
|
||||
VcsLogFilterCollection filters = logUi.getFilterUi().getFilters();
|
||||
Set<VirtualFile> roots = logUi.getDataPack().getLogProviders().keySet();
|
||||
return getAllVisibleRoots(roots, filters.getRootFilter(), filters.getStructureFilter());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getSingleFilteredBranch(@NotNull VcsLogBranchFilter filter, @NotNull VcsLogRefs refs) {
|
||||
String branchName = null;
|
||||
|
||||
@@ -75,8 +75,7 @@ public class IndexSpeedSearch extends VcsLogSpeedSearch {
|
||||
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());
|
||||
Set<VirtualFile> visibleRoots = VcsLogUtil.getAllVisibleRoots(roots, visiblePack.getFilters());
|
||||
for (VirtualFile root : visibleRoots) {
|
||||
if (!myIndex.isIndexed(root)) return false;
|
||||
}
|
||||
|
||||
@@ -71,8 +71,7 @@ public class VcsLogFilterer {
|
||||
return Pair.create(applyHashFilter(dataPack, hashFilter.getHashes(), sortType), commitCount);
|
||||
}
|
||||
|
||||
Collection<VirtualFile> visibleRoots =
|
||||
VcsLogUtil.getAllVisibleRoots(dataPack.getLogProviders().keySet(), filters.getRootFilter(), filters.getStructureFilter());
|
||||
Collection<VirtualFile> visibleRoots = VcsLogUtil.getAllVisibleRoots(dataPack.getLogProviders().keySet(), filters);
|
||||
Set<Integer> matchingHeads = getMatchingHeads(dataPack.getRefsModel(), visibleRoots, filters);
|
||||
FilterByDetailsResult filterResult = filterByDetails(dataPack, filters, commitCount, visibleRoots, matchingHeads);
|
||||
|
||||
@@ -264,8 +263,7 @@ public class VcsLogFilterer {
|
||||
private static Collection<CommitId> getFilteredDetailsFromTheVcs(@NotNull Map<VirtualFile, VcsLogProvider> providers,
|
||||
@NotNull VcsLogFilterCollection filterCollection,
|
||||
int maxCount) throws VcsException {
|
||||
Set<VirtualFile> visibleRoots =
|
||||
VcsLogUtil.getAllVisibleRoots(providers.keySet(), filterCollection.getRootFilter(), filterCollection.getStructureFilter());
|
||||
Set<VirtualFile> visibleRoots = VcsLogUtil.getAllVisibleRoots(providers.keySet(), filterCollection);
|
||||
|
||||
Collection<CommitId> commits = ContainerUtil.newArrayList();
|
||||
for (Map.Entry<VirtualFile, VcsLogProvider> entry : providers.entrySet()) {
|
||||
@@ -304,7 +302,7 @@ public class VcsLogFilterer {
|
||||
List<VcsLogDetailsFilter> detailsFilters = filters.getDetailsFilters();
|
||||
if (detailsFilters.isEmpty()) return false;
|
||||
|
||||
Set<VirtualFile> affectedRoots = VcsLogUtil.getAllVisibleRoots(roots, filters.getRootFilter(), filters.getStructureFilter());
|
||||
Set<VirtualFile> affectedRoots = VcsLogUtil.getAllVisibleRoots(roots, filters);
|
||||
boolean needsIndex = !affectedRoots.isEmpty();
|
||||
if (needsIndex) {
|
||||
LOG.debug(filters + " are affected by indexing of " + affectedRoots);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class DeepCompareAction extends ToggleAction implements DumbAware {
|
||||
selectBranchAndPerformAction(ui.getDataPack(), e, selectedBranch -> {
|
||||
ui.getFilterUi().setFilter(VcsLogBranchFilterImpl.fromBranch(selectedBranch));
|
||||
dc.highlightInBackground(selectedBranch, dataProvider);
|
||||
}, getAllVisibleRoots(ui));
|
||||
}, VcsLogUtil.getVisibleRoots(ui));
|
||||
return;
|
||||
}
|
||||
dc.highlightInBackground(singleBranchName, dataProvider);
|
||||
@@ -110,17 +110,11 @@ public class DeepCompareAction extends ToggleAction implements DumbAware {
|
||||
Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
VcsLogUi ui = e.getData(VcsLogDataKeys.VCS_LOG_UI);
|
||||
e.getPresentation().setEnabledAndVisible(project != null && ui != null &&
|
||||
hasGitRoots(project, getAllVisibleRoots(ui)));
|
||||
hasGitRoots(project, VcsLogUtil.getVisibleRoots(ui)));
|
||||
}
|
||||
|
||||
private static boolean hasGitRoots(@NotNull Project project, @NotNull Set<VirtualFile> roots) {
|
||||
final GitRepositoryManager manager = GitRepositoryManager.getInstance(project);
|
||||
return ContainerUtil.exists(roots, root -> manager.getRepositoryForRootQuick(root) != null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Set<VirtualFile> getAllVisibleRoots(@NotNull VcsLogUi ui) {
|
||||
return VcsLogUtil.getAllVisibleRoots(ui.getDataPack().getLogProviders().keySet(), ui.getFilterUi().getFilters().getRootFilter(),
|
||||
ui.getFilterUi().getFilters().getStructureFilter());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user