use of org.zmlx.hg4idea.execution.HgCommandResult 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();
}
use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.
the class HgHistoryProvider method getHistoryForUncommittedRenamed.
/**
* Workaround for getting follow file history in case of uncommitted move/rename change
*/
private static List<HgFileRevision> getHistoryForUncommittedRenamed(@NotNull FilePath originalHgFilePath, @NotNull VirtualFile vcsRoot, @NotNull Project project, int limit) {
HgFile originalHgFile = new HgFile(vcsRoot, originalHgFilePath);
final HgLogCommand logCommand = new HgLogCommand(project);
logCommand.setIncludeRemoved(true);
final HgVersion version = logCommand.getVersion();
String[] templates = HgBaseLogParser.constructFullTemplateArgument(false, version);
String template = HgChangesetUtil.makeTemplate(templates);
List<String> argsForCmd = ContainerUtil.newArrayList();
String relativePath = originalHgFile.getRelativePath();
argsForCmd.add("--rev");
argsForCmd.add(String.format("reverse(follow(%s))", relativePath != null ? "'" + FileUtil.toSystemIndependentName(relativePath) + "'" : ""));
HgCommandResult result = logCommand.execute(vcsRoot, template, limit, relativePath != null ? null : originalHgFile, argsForCmd);
return HgHistoryUtil.getCommitRecords(project, result, new HgFileRevisionLogParser(project, originalHgFile, version));
}
use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.
the class HgIntegrationEnabler method initOrNotifyError.
@Override
protected boolean initOrNotifyError(@NotNull final VirtualFile projectDir) {
final boolean[] success = new boolean[1];
new HgInitCommand(myProject).executeAsynchronously(projectDir, new HgCommandResultHandler() {
@Override
public void process(@Nullable HgCommandResult result) {
VcsNotifier notifier = VcsNotifier.getInstance(myProject);
if (!HgErrorUtil.hasErrorsInCommandExecution(result)) {
success[0] = true;
refreshVcsDir(projectDir, HgUtil.DOT_HG);
notifier.notifySuccess(message("hg4idea.init.created.notification.title"), message("hg4idea.init.created.notification.description", projectDir.getPresentableUrl()));
} else {
success[0] = false;
String errors = result != null ? result.getRawError() : "";
notifier.notifyError(message("hg4idea.init.error.description", projectDir.getPresentableUrl()), errors);
}
}
});
return success[0];
}
use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.
the class HgCloneDialog method test.
@NotNull
@Override
protected TestResult test(@NotNull final String url) {
HgIdentifyCommand identifyCommand = new HgIdentifyCommand(myProject);
identifyCommand.setSource(url);
HgCommandResult result = identifyCommand.execute(ModalityState.stateForComponent(getRootPane()));
return result != null && result.getExitValue() == 0 ? TestResult.SUCCESS : new TestResult(result.getRawError());
}
use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.
the class HgQNewCommand method executeQNewInCurrentThread.
private void executeQNewInCurrentThread(@NotNull List<String> chunkFiles) throws VcsException {
List<String> args = ContainerUtil.newArrayList();
args.add("-l");
args.add(saveCommitMessage().getAbsolutePath());
args.add("-UD");
String patchName = DATE_FORMAT.format(new Date()).concat(".diff");
args.add(patchName);
args.addAll(chunkFiles);
HgCommandExecutor executor = new HgCommandExecutor(myProject);
HgCommandResult result = executor.executeInCurrentThread(myRepository.getRoot(), "qnew", args);
if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
new HgCommandResultNotifier(myProject).notifyError(result, "Qnew Failed", "Could not create mq patch for selected changes");
}
}
Aggregations