private static Groups prepareGroups(
      @NotNull VcsLogDataPack dataPack,
      @Nullable Collection<VirtualFile> visibleRoots,
      @Nullable List<List<String>> recentItems) {
    Groups filteredGroups = new Groups();
    Collection<VcsRef> allRefs = dataPack.getRefs().getBranches();
    for (Map.Entry<VirtualFile, Set<VcsRef>> entry :
        VcsLogUtil.groupRefsByRoot(allRefs).entrySet()) {
      VirtualFile root = entry.getKey();
      if (visibleRoots != null && !visibleRoots.contains(root)) continue;
      Collection<VcsRef> refs = entry.getValue();
      VcsLogProvider provider = dataPack.getLogProviders().get(root);
      VcsLogRefManager refManager = provider.getReferenceManager();
      List<RefGroup> refGroups = refManager.group(refs);

      putActionsForReferences(refGroups, filteredGroups);
    }

    if (recentItems != null) {
      for (List<String> recentItem : recentItems) {
        if (recentItem.size() == 1) {
          final String item = ContainerUtil.getFirstItem(recentItem);
          if (filteredGroups.singletonGroups.contains(item)
              || ContainerUtil.find(
                      filteredGroups.expandedGroups.values(), strings -> strings.contains(item))
                  != null) {
            continue;
          }
        }
        filteredGroups.recentGroups.add(recentItem);
      }
    }

    return filteredGroups;
  }
 public void onStructureFilterChanged(
     @NotNull Set<VirtualFile> roots, @Nullable VcsLogFileFilter filter) {
   if (filter == null) {
     myVisibleRoots = null;
   } else {
     myVisibleRoots =
         VcsLogUtil.getAllVisibleRoots(
             roots, filter.getRootFilter(), filter.getStructureFilter());
   }
 }
 @Override
 public void performCopy(@NotNull DataContext dataContext) {
   List<VcsFullCommitDetails> details =
       VcsLogUtil.collectFirstPackOfLoadedSelectedDetails(myUI.getVcsLog());
   if (!details.isEmpty()) {
     CopyPasteManager.getInstance()
         .setContents(
             new StringSelection(
                 StringUtil.join(
                     details,
                     new Function<VcsFullCommitDetails, String>() {
                       @Override
                       public String fun(VcsFullCommitDetails details) {
                         return details.getSubject();
                       }
                     },
                     "\n")));
   }
 }