void (@NotNull Project project, @Nullable Listener listener, @NotNull String directoryName, @NotNull String sourceRepositoryURL, @NotNull String parentDirectory) { VirtualFile destinationParent = LocalFileSystem.getInstance().findFileByIoFile(new File(parentDirectory)); if (destinationParent == null) { return; } final String targetDir = destinationParent.getPath() + File.separator + directoryName; String projectPath = FileUtilRt.toSystemIndependentName(targetDir); CloneTask cloneTask = new CloneTask() { @Override public @NotNull CloneTaskInfo taskInfo() { return new CloneTaskInfo(DvcsBundle.message("cloning.repository", sourceRepositoryURL), DvcsBundle.message("cloning.repository.cancel", sourceRepositoryURL), DvcsBundle.message("clone.repository"), DvcsBundle.message("clone.repository.tooltip"), DvcsBundle.message("clone.repository.failed"), DvcsBundle.message("clone.repository.canceled"), DvcsBundle.message("clone.stop.message.title"), DvcsBundle.message("clone.stop.message.description", sourceRepositoryURL)); } @Override public @NotNull CloneStatus run(@NotNull ProgressIndicator indicator) { HgCloneCommand clone = new HgCloneCommand(project); clone.setRepositoryURL(sourceRepositoryURL); clone.setDirectory(targetDir); HgCommandResult commandResult = clone.executeInCurrentThread(); if (commandResult == null || HgErrorUtil.hasErrorsInCommandExecution(commandResult)) { new HgCommandResultNotifier(project).notifyError(CLONE_ERROR, commandResult, DvcsBundle.message("clone.repository.failed"), HgBundle.message("hg4idea.clone.repo.error.msg", sourceRepositoryURL)); return CloneStatus.FAILURE; } else { DvcsUtil.addMappingIfSubRoot(project, targetDir, HgVcs.VCS_NAME); if (listener != null) { listener.directoryCheckedOut(new File(parentDirectory, directoryName), HgVcs.getKey()); listener.checkoutCompleted(); } return CloneStatus.SUCCESS; } } }; CloneableProjectsService.getInstance().runCloneTask(projectPath, cloneTask); }