Mercurial > hg > mercurial
view mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java @ 57:99e757f2527b
branches support
author | Pavel.Sher |
---|---|
date | Sun, 26 Oct 2008 16:23:50 +0300 |
parents | 10e774d891b5 |
children | 3cb4f95a4f6f |
line wrap: on
line source
package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; import org.jetbrains.annotations.NotNull; import com.intellij.execution.configurations.GeneralCommandLine; import jetbrains.buildServer.ExecResult; import jetbrains.buildServer.util.StringUtil; import jetbrains.buildServer.vcs.VcsException; /** * @author pavel */ public class BaseCommand { private Settings mySettings; private String myWorkDirectory; public BaseCommand(@NotNull final Settings settings) { mySettings = settings; myWorkDirectory = settings.getLocalRepositoryDir().getAbsolutePath(); } public Settings getSettings() { return mySettings; } /** * Sets new working directory, by default working directory is taken from the Settings#getLocalRepositoryDir * @param workDirectory work dir */ public void setWorkDirectory(final String workDirectory) { myWorkDirectory = workDirectory; } protected GeneralCommandLine createCommandLine() { GeneralCommandLine cli = new GeneralCommandLine(); cli.setExePath(getSettings().getHgCommandPath()); cli.setWorkDirectory(myWorkDirectory); return cli; } protected ExecResult runCommand(@NotNull GeneralCommandLine cli) throws VcsException { return CommandUtil.runCommand(cli); } protected ExecResult runCommand(@NotNull GeneralCommandLine cli, int executionTimeout) throws VcsException { return CommandUtil.runCommand(cli, executionTimeout); } protected void failIfNotEmptyStdErr(@NotNull GeneralCommandLine cli, @NotNull ExecResult res) throws VcsException { if (!StringUtil.isEmpty(res.getStderr())) { CommandUtil.commandFailed(cli.getCommandLineString(), res); } } }