view mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommitCommand.java @ 704:5ee94ee69b29

helper method
author eugene.petrenko@jetbrains.com
date Wed, 08 Jan 2014 17:42:41 +0100
parents 8b09ec36fbef
children 31a1aca3305c
line wrap: on
line source
package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;

import jetbrains.buildServer.vcs.VcsException;
import org.jetbrains.annotations.NotNull;

import java.io.File;

public class CommitCommand extends BaseCommand {

  private String myCommitMessage;
  private String myUser;

  public CommitCommand(@NotNull CommandSettings commandSettings,
                       @NotNull String hgPath,
                       @NotNull File workingDir) {
    super(commandSettings, hgPath, workingDir);
  }

  public CommitCommand message(@NotNull String commitMessage) {
    myCommitMessage = commitMessage;
    return this;
  }

  public CommitCommand by(String user) {
    myUser = user;
    return this;
  }

  public void call() throws VcsException {
    MercurialCommandLine cmd = createCommandLine();
    cmd.addParameter("commit");
    cmd.addParameter("-S");
    if (myCommitMessage != null)
      cmd.addParameters("-m", myCommitMessage);
    if (myUser != null)
      cmd.addParameters("--user", myUser);
    runCommand(cmd);
  }
}