@Override
  protected void mergeAndClose(final @NotNull String branch, final @NotNull List<? extends HgRepository> repositories) {
    String bookmarkRevisionArg = "bookmark(\"" + branch + "\")";
    FileDocumentManager.getInstance().saveAllDocuments();
    final UpdatedFiles updatedFiles = UpdatedFiles.create();
    for (final HgRepository repository : repositories) {
      HgMergeCommand.mergeWith(repository, bookmarkRevisionArg, updatedFiles, () -> {
        Project project = repository.getProject();
        VirtualFile repositoryRoot = repository.getRoot();
        try {
          new HgCommitCommand(project, repository, "Automated merge with " + branch).executeInCurrentThread(); //NON-NLS
          HgBookmarkCommand.deleteBookmarkSynchronously(project, repositoryRoot, branch);
        }
        catch (HgCommandException e) {
            HgErrorUtil.handleException(project, MERGE_ERROR, e);
        }
        catch (VcsException e) {
          VcsNotifier.getInstance(project)
            .notifyError(EXCEPTION_DURING_MERGE_COMMIT, HgBundle.message("hg4idea.commit.merge.error", branch), e.getMessage());
        }
      });
    }
  }
@Override
  protected void mergeAndClose(final @NotNull String branch, final @NotNull List<? extends HgRepository> repositories)