示例#1
0
 @Nullable
 public static <T extends Repository> T guessRepositoryForFile(
     @NotNull Project project,
     @NotNull RepositoryManager<T> manager,
     @Nullable AbstractVcs vcs,
     @Nullable VirtualFile file,
     @Nullable String defaultRootPathValue) {
   T repository = manager.getRepositoryForRoot(guessVcsRoot(project, file));
   return repository != null
       ? repository
       : manager.getRepositoryForRoot(guessRootForVcs(project, vcs, defaultRootPathValue));
 }
示例#2
0
 @NotNull
 public static <R extends Repository> Map<R, List<VcsFullCommitDetails>> groupCommitsByRoots(
     @NotNull RepositoryManager<R> repoManager,
     @NotNull List<? extends VcsFullCommitDetails> commits) {
   Map<R, List<VcsFullCommitDetails>> groupedCommits = ContainerUtil.newHashMap();
   for (VcsFullCommitDetails commit : commits) {
     R repository = repoManager.getRepositoryForRoot(commit.getRoot());
     if (repository == null) {
       LOGGER.info("No repository found for commit " + commit);
       continue;
     }
     List<VcsFullCommitDetails> commitsInRoot = groupedCommits.get(repository);
     if (commitsInRoot == null) {
       commitsInRoot = ContainerUtil.newArrayList();
       groupedCommits.put(repository, commitsInRoot);
     }
     commitsInRoot.add(commit);
   }
   return groupedCommits;
 }