Repository (@NotNull String name) { String tempDirectory = FileUtil.getTempDirectory(); String root = tempDirectory + "/" + name; assertTrue(new File(root).mkdirs()); HgPlatformTest.initRepo(root); touch("a.txt"); hg("add a.txt"); hg("commit -m another -u abc"); hg("up -r 0"); ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl)ProjectLevelVcsManager.getInstance(myProject); HgVcs hgVcs = HgVcs.getInstance(myProject); assert hgVcs != null; vcsManager.setDirectoryMapping(root, HgVcs.VCS_NAME); assertNotNull(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(root, DOT_HG))); HgRepository repository = HgUtil.getRepositoryManager(myProject).getRepositoryForRoot(LocalFileSystem.getInstance().findFileByIoFile(new File(root))); assertNotNull("Couldn't find repository for root " + root, repository); return repository; }