void (final @NotNull HgRepository repository, final @NotNull @NonNls String branchName, final @NotNull UpdatedFiles updatedFiles, final @Nullable Runnable onSuccessHandler) { final Project project = repository.getProject(); final VirtualFile repositoryRoot = repository.getRoot(); final HgMergeCommand hgMergeCommand = new HgMergeCommand(project, repository); hgMergeCommand.setRevision(branchName);//there is no difference between branch or revision or bookmark as parameter to merge, // we need just a string new Task.Backgroundable(project, HgBundle.message("action.hg4idea.merge.progress")) { @Override public void run(@NotNull ProgressIndicator indicator) { try { HgCommandResult result = hgMergeCommand.mergeSynchronously(); if (HgErrorUtil.isAncestorMergeError(result)) { //skip and notify VcsNotifier.getInstance(project) .notifyMinorWarning(MERGE_WITH_ANCESTOR_SKIPPED, HgBundle.message("action.hg4idea.merge.skipped.title", repositoryRoot.getPresentableName()), HgBundle.message("action.hg4idea.merge.skipped")); return; } new HgConflictResolver(project, updatedFiles).resolve(repositoryRoot); if (!HgConflictResolver.hasConflicts(project, repositoryRoot) && onSuccessHandler != null) { onSuccessHandler.run(); // for example commit changes } } catch (VcsException exception) { if (exception.isWarning()) { VcsNotifier.getInstance(project).notifyWarning(MERGE_WARNING, HgBundle.message("action.hg4idea.merge.warning"), exception.getMessage()); } else { VcsNotifier.getInstance(project).notifyError(MERGE_EXCEPTION, HgBundle.message("action.hg4idea.merge.exception"), exception.getMessage()); } } } }.queue(); }