List<HgRepository> (@NotNull DataContext dataContext) { Project project = dataContext.getData(CommonDataKeys.PROJECT); if (project == null) return Collections.emptyList(); HgRepositoryManager repositoryManager = HgUtil.getRepositoryManager(project); VirtualFile[] files = ObjectUtils.notNull(dataContext.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY), VirtualFile.EMPTY_ARRAY); List<HgRepository> selectedRepositories = ContainerUtil.mapNotNull(files, repositoryManager::getRepositoryForFileQuick); if (!selectedRepositories.isEmpty()) return selectedRepositories; HgRepository repository = HgUtil.guessRepositoryForOperation(project, dataContext); return ContainerUtil.createMaybeSingletonList(repository); }