private void commitChunkFiles(@NotNull List<String> chunk, boolean amendCommit, boolean withSubrepos, boolean closeBranch)
    throws VcsException {
    List<String> parameters = new LinkedList<>();
    parameters.add("--logfile");
    parameters.add(saveCommitMessage().getAbsolutePath());
    // note: for now mercurial could not perform amend commit with -S option
    if (withSubrepos) {
      parameters.add("-S");
      parameters.addAll(mySubrepos);
    }
    else if (amendCommit) {
      parameters.add("--amend");
    }
    if (closeBranch) {
      if (chunk.isEmpty() && myRepository.getState() != Repository.State.MERGING) {
        //if there are changed files but nothing selected -> need to exclude all; if merge commit then nothing excluded
        parameters.add("-X");
        parameters.add("\"**\"");
      }
      parameters.add("--close-branch");
    }
    parameters.addAll(chunk);
    HgCommandExecutor executor = new HgCommandExecutor(myProject);
    ensureSuccess(executor.executeInCurrentThread(myRepository.getRoot(), "commit", parameters));
  }
private void commitChunkFiles(@NotNull List<String> chunk, boolean amendCommit, boolean withSubrepos, boolean closeBranch)