use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.
the class HgResolveCommand method getListSynchronously.
public Map<HgFile, HgResolveStatusEnum> getListSynchronously(VirtualFile repo) {
if (repo == null) {
return Collections.emptyMap();
}
final HgCommandExecutor executor = new HgCommandExecutor(myProject);
executor.setSilent(true);
final HgCommandResult result = executor.executeInCurrentThread(repo, "resolve", Collections.singletonList("--list"));
if (result == null) {
return Collections.emptyMap();
}
return handleResult(repo, result);
}
use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.
the class HgRollbackEnvironment method revert.
private void revert(@NotNull List<FilePath> filePaths) {
for (Map.Entry<VirtualFile, Collection<FilePath>> entry : HgUtil.groupFilePathsByHgRoots(project, filePaths).entrySet()) {
final VirtualFile repo = entry.getKey();
final Collection<FilePath> files = entry.getValue();
HgRevisionNumber revisionNumber = new HgWorkingCopyRevisionsCommand(project).firstParent(repo);
for (List<String> chunk : VcsFileUtil.chunkPaths(repo, files)) {
HgCommandResult revertResult = new HgRevertCommand(project).execute(repo, chunk, revisionNumber, false);
if (HgErrorUtil.hasUncommittedChangesConflict(revertResult)) {
String message = String.format("<html>Revert failed due to uncommitted merge.<br>" + "Would you like to discard all changes for repository <it><b>%s</b></it>?</html>", repo.getPresentableName());
int exitCode = HgUpdateCommand.showDiscardChangesConfirmation(project, message);
if (exitCode == Messages.OK) {
//discard all changes for this repository//
HgUpdateCommand updateCommand = new HgUpdateCommand(project, repo);
updateCommand.setClean(true);
updateCommand.setRevision(".");
updateCommand.execute();
}
break;
}
new HgResolveCommand(project).markResolved(repo, files);
}
}
}
use of org.zmlx.hg4idea.execution.HgCommandResult in project intellij-community by JetBrains.
the class HgRegularUpdater method processRebase.
private void processRebase(ProgressIndicator indicator, final UpdatedFiles updatedFiles) throws VcsException {
indicator.setText2(HgVcsMessages.message("hg4idea.progress.rebase"));
HgRepository repository = HgUtil.getRepositoryManager(project).getRepositoryForRoot(repoRoot);
if (repository == null) {
throw new VcsException("Repository not found for root " + repoRoot);
}
HgRebaseCommand rebaseCommand = new HgRebaseCommand(project, repository);
HgCommandResult result = new HgRebaseCommand(project, repository).startRebase();
if (HgErrorUtil.isCommandExecutionFailed(result)) {
new HgCommandResultNotifier(project).notifyError(result, "Hg Error", "Couldn't rebase repository.");
return;
}
//noinspection ConstantConditions
while (result.getExitValue() == 1) {
//if result == null isAbort will be true;
resolvePossibleConflicts(updatedFiles);
if (HgConflictResolver.hasConflicts(project, repoRoot) || HgErrorUtil.isNothingToRebase(result)) {
break;
}
result = rebaseCommand.continueRebase();
if (HgErrorUtil.isAbort(result)) {
new HgCommandResultNotifier(project).notifyError(result, "Hg Error", "Couldn't continue rebasing");
break;
}
}
repository.update();
repoRoot.refresh(true, true);
}
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));
}
Aggregations