public static @Nullable HgRepository getRepositoryForFile(@NotNull Project project, @Nullable VirtualFile file) {
    if (file == null || project.isDisposed()) return null;

    HgRepositoryManager repositoryManager = getRepositoryManager(project);
    VirtualFile root = getHgRootOrNull(project, file);
    return repositoryManager.getRepositoryForRoot(root);
  }
public static @Nullable HgRepository getRepositoryForFile(@NotNull Project project, @Nullable VirtualFile file)