use of org.zmlx.hg4idea.execution.HgCommandException in project intellij-community by JetBrains.
the class HgTagCreateCommand method executeAsynchronously.
public void executeAsynchronously(HgCommandResultHandler resultHandler) throws HgCommandException {
if (StringUtil.isEmptyOrSpaces(tagName)) {
throw new HgCommandException("tag name is empty");
}
List<String> arguments = new ArrayList<>();
arguments.add(tagName);
if (!StringUtil.isEmptyOrSpaces(revisionNumberOrHash)) {
arguments.add("--rev");
arguments.add(revisionNumberOrHash);
}
new HgCommandExecutor(project).execute(repo, "tag", arguments, resultHandler);
if (!project.isDisposed()) {
HgRepositoryManager manager = HgUtil.getRepositoryManager(project);
manager.updateRepository(repo);
}
}
use of org.zmlx.hg4idea.execution.HgCommandException in project intellij-community by JetBrains.
the class HgCommitTypeCommand method executeInCurrentThread.
public void executeInCurrentThread() throws HgCommandException, VcsException {
if (StringUtil.isEmptyOrSpaces(myMessage)) {
throw new HgCommandException(HgVcsMessages.message("hg4idea.commit.error.messageEmpty"));
}
if (myFiles.isEmpty()) {
executeChunked(Collections.<List<String>>emptyList());
} else {
List<String> relativePaths = ContainerUtil.map2List(myFiles, new Function<HgFile, String>() {
@Override
public String fun(HgFile file) {
return file.getRelativePath();
}
});
List<List<String>> chunkedCommits = VcsFileUtil.chunkArguments(relativePaths);
executeChunked(chunkedCommits);
}
myRepository.update();
final MessageBus messageBus = myProject.getMessageBus();
messageBus.syncPublisher(HgVcs.REMOTE_TOPIC).update(myProject, null);
}
use of org.zmlx.hg4idea.execution.HgCommandException in project intellij-community by JetBrains.
the class HgTaskHandler method mergeAndClose.
@Override
protected void mergeAndClose(@NotNull final String branch, @NotNull final List<HgRepository> repositories) {
String bookmarkRevisionArg = "bookmark(\"" + branch + "\")";
FileDocumentManager.getInstance().saveAllDocuments();
final UpdatedFiles updatedFiles = UpdatedFiles.create();
for (final HgRepository repository : repositories) {
HgMergeCommand.mergeWith(repository, bookmarkRevisionArg, updatedFiles, new Runnable() {
@Override
public void run() {
Project project = repository.getProject();
VirtualFile repositoryRoot = repository.getRoot();
try {
new HgCommitCommand(project, repository, "Automated merge with " + branch).executeInCurrentThread();
HgBookmarkCommand.deleteBookmarkSynchronously(project, repositoryRoot, branch);
} catch (HgCommandException e) {
HgErrorUtil.handleException(project, e);
} catch (VcsException e) {
VcsNotifier.getInstance(project).notifyError("Exception during merge commit with " + branch, e.getMessage());
}
}
});
}
}
use of org.zmlx.hg4idea.execution.HgCommandException in project intellij-community by JetBrains.
the class HgCheckinEnvironment method commit.
public List<VcsException> commit(List<Change> changes, String preparedComment, @NotNull NullableFunction<Object, Object> parametersHolder, Set<String> feedback) {
List<VcsException> exceptions = new LinkedList<>();
Map<HgRepository, Set<HgFile>> repositoriesMap = getFilesByRepository(changes);
addRepositoriesWithoutChanges(repositoriesMap);
for (Map.Entry<HgRepository, Set<HgFile>> entry : repositoriesMap.entrySet()) {
HgRepository repo = entry.getKey();
Set<HgFile> selectedFiles = entry.getValue();
HgCommitTypeCommand command = myMqNewPatch ? new HgQNewCommand(myProject, repo, preparedComment, myNextCommitAmend) : new HgCommitCommand(myProject, repo, preparedComment, myNextCommitAmend, myCloseBranch, myShouldCommitSubrepos && !selectedFiles.isEmpty());
if (isMergeCommit(repo.getRoot())) {
//partial commits are not allowed during merges
//verifyResult that all changed files in the repo are selected
//If so, commit the entire repository
//If not, abort
Set<HgFile> changedFilesNotInCommit = getChangedFilesNotInCommit(repo.getRoot(), selectedFiles);
boolean partial = !changedFilesNotInCommit.isEmpty();
if (partial) {
final StringBuilder filesNotIncludedString = new StringBuilder();
for (HgFile hgFile : changedFilesNotInCommit) {
filesNotIncludedString.append("<li>");
filesNotIncludedString.append(hgFile.getRelativePath());
filesNotIncludedString.append("</li>");
}
if (!mayCommitEverything(filesNotIncludedString.toString())) {
//abort
return exceptions;
}
//firstly selected changes marked dirty in CommitHelper -> postRefresh, so we need to mark others
VcsDirtyScopeManager dirtyManager = VcsDirtyScopeManager.getInstance(myProject);
for (HgFile hgFile : changedFilesNotInCommit) {
dirtyManager.fileDirty(hgFile.toFilePath());
}
}
// else : all was included, or it was OK to commit everything,
// so no need to set the files on the command, because then mercurial will complain
} else {
command.setFiles(selectedFiles);
}
try {
command.executeInCurrentThread();
} catch (HgCommandException e) {
exceptions.add(new VcsException(e));
} catch (VcsException e) {
exceptions.add(e);
}
}
// push if needed
if (myNextCommitIsPushed && exceptions.isEmpty()) {
final List<HgRepository> preselectedRepositories = ContainerUtil.newArrayList(repositoriesMap.keySet());
GuiUtils.invokeLaterIfNeeded(() -> new VcsPushDialog(myProject, preselectedRepositories, HgUtil.getCurrentRepository(myProject)).show(), ModalityState.defaultModalityState());
}
return exceptions;
}
use of org.zmlx.hg4idea.execution.HgCommandException in project intellij-community by JetBrains.
the class HgRegularUpdater method commitOrWarnAboutConflicts.
private void commitOrWarnAboutConflicts(List<VcsException> exceptions, HgCommandResult mergeResult) throws VcsException {
if (mergeResult.getExitValue() == 0) {
//operation successful and no conflicts
try {
HgRepository hgRepository = HgUtil.getRepositoryForFile(project, repoRoot);
if (hgRepository == null) {
LOG.warn("Couldn't find repository info for " + repoRoot.getName());
return;
}
new HgCommitCommand(project, hgRepository, "Automated merge").executeInCurrentThread();
} catch (HgCommandException e) {
throw new VcsException(e);
}
} else {
reportWarning(exceptions, HgVcsMessages.message("hg4idea.update.warning.merge.conflicts", repoRoot.getPath()));
}
}
Aggregations