Mercurial > hg > mercurial
view mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java @ 65:3cb4f95a4f6f
do not show credentials in the error messages
author | Pavel.Sher |
---|---|
date | Thu, 09 Jul 2009 21:21:36 +0400 |
parents | 99e757f2527b |
children | 6c1cff1f61cc |
line wrap: on
line source
package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; import com.intellij.execution.configurations.GeneralCommandLine; import jetbrains.buildServer.ExecResult; import jetbrains.buildServer.util.StringUtil; import jetbrains.buildServer.vcs.VcsException; import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.Set; /** * @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, getPrivateData()); } protected ExecResult runCommand(@NotNull GeneralCommandLine cli, int executionTimeout) throws VcsException { return CommandUtil.runCommand(cli, executionTimeout, getPrivateData()); } protected void failIfNotEmptyStdErr(@NotNull GeneralCommandLine cli, @NotNull ExecResult res) throws VcsException { if (!StringUtil.isEmpty(res.getStderr())) { CommandUtil.commandFailed(cli.getCommandLineString(), res); } } public Set<String> getPrivateData() { return Collections.singleton(mySettings.getPassword()); } }