RefsModel (@NotNull RefsModel refsModel, @NotNull Set<Integer> heads, @NotNull VisibleGraphImpl<Integer> visibleGraph, @NotNull Map<VirtualFile, VcsLogProvider> providers, int visibleRow, int visibleRange) { Set<VcsRef> branchesAndHeads = new HashSet<>(); for (int row = Math.max(0, visibleRow - visibleRange); row < Math.min(visibleGraph.getLinearGraph().nodesCount(), visibleRow + visibleRange); row++) { Integer commit = visibleGraph.getRowInfo(row).getCommit(); refsModel.refsToCommit(commit).forEach(ref -> { if (ref.getType().isBranch() || heads.contains(commit)) { branchesAndHeads.add(ref); } }); } Map<VirtualFile, Set<VcsRef>> map = VcsLogUtil.groupRefsByRoot(branchesAndHeads); Map<VirtualFile, CompressedRefs> refs = new HashMap<>(); for (VirtualFile root : providers.keySet()) { Set<VcsRef> refsForRoot = map.get(root); refs.put(root, new CompressedRefs(refsForRoot == null ? new HashSet<>() : refsForRoot, myStorage)); } return new RefsModel(refs, heads, myStorage, providers); }