use of org.zmlx.hg4idea.command.HgCloneCommand in project intellij-community by JetBrains.
the class HgCheckoutProvider method doCheckout.
public void doCheckout(@NotNull final Project project, @Nullable final Listener listener) {
FileDocumentManager.getInstance().saveAllDocuments();
final HgCloneDialog dialog = new HgCloneDialog(project);
if (!dialog.showAndGet()) {
return;
}
dialog.rememberSettings();
VirtualFile destinationParent = LocalFileSystem.getInstance().findFileByIoFile(new File(dialog.getParentDirectory()));
if (destinationParent == null) {
return;
}
final String targetDir = destinationParent.getPath() + File.separator + dialog.getDirectoryName();
final String sourceRepositoryURL = dialog.getSourceRepositoryURL();
final AtomicReference<HgCommandResult> cloneResult = new AtomicReference<>();
new Task.Backgroundable(project, HgVcsMessages.message("hg4idea.clone.progress", sourceRepositoryURL), true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
HgCloneCommand clone = new HgCloneCommand(project);
clone.setRepositoryURL(sourceRepositoryURL);
clone.setDirectory(targetDir);
cloneResult.set(clone.executeInCurrentThread());
}
@Override
public void onSuccess() {
if (cloneResult.get() == null || HgErrorUtil.hasErrorsInCommandExecution(cloneResult.get())) {
new HgCommandResultNotifier(project).notifyError(cloneResult.get(), "Clone failed", "Clone from " + sourceRepositoryURL + " failed.");
} else {
DvcsUtil.addMappingIfSubRoot(project, targetDir, HgVcs.VCS_NAME);
if (listener != null) {
listener.directoryCheckedOut(new File(dialog.getParentDirectory(), dialog.getDirectoryName()), HgVcs.getKey());
listener.checkoutCompleted();
}
}
}
}.queue();
}
Aggregations