Mercurial > hg > mercurial
view mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandUtil.java @ 54:10e774d891b5
timeout increased for clone command
author | Pavel.Sher |
---|---|
date | Fri, 24 Oct 2008 13:25:45 +0400 |
parents | cdcf9a82116f |
children | 3cb4f95a4f6f |
line wrap: on
line source
/* * Copyright 2000-2007 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; import com.intellij.execution.configurations.GeneralCommandLine; import jetbrains.buildServer.ExecResult; import jetbrains.buildServer.SimpleCommandLineProcessRunner; import jetbrains.buildServer.log.Loggers; import jetbrains.buildServer.util.StringUtil; import jetbrains.buildServer.vcs.VcsException; import org.jetbrains.annotations.NotNull; public class CommandUtil { private static final int DEFAULT_COMMAND_TIMEOUT_SEC = 3600; public static void checkCommandFailed(@NotNull String cmdName, @NotNull ExecResult res) throws VcsException { if (res.getExitCode() > 0 || res.getException() != null) { commandFailed(cmdName, res); } if (res.getStderr().length() > 0) { Loggers.VCS.warn("Error output produced by: " + cmdName); Loggers.VCS.warn(res.getStderr()); } } public static void commandFailed(final String cmdName, final ExecResult res) throws VcsException { Throwable exception = res.getException(); String stderr = res.getStderr(); String stdout = res.getStdout(); final String message = "'" + cmdName + "' command failed.\n" + (!StringUtil.isEmpty(stderr) ? "stderr: " + stderr + "\n" : "") + (!StringUtil.isEmpty(stdout) ? "stdout: " + stdout + "\n" : "") + (exception != null ? "exception: " + exception.getLocalizedMessage() : ""); Loggers.VCS.warn(message); throw new VcsException(message); } public static ExecResult runCommand(@NotNull GeneralCommandLine cli) throws VcsException { return runCommand(cli, DEFAULT_COMMAND_TIMEOUT_SEC); } public static ExecResult runCommand(@NotNull GeneralCommandLine cli, final int executionTimeout) throws VcsException { String cmdStr = cli.getCommandLineString(); Loggers.VCS.debug("Run command: " + cmdStr); ExecResult res = SimpleCommandLineProcessRunner.runCommand(cli, null, new SimpleCommandLineProcessRunner.RunCommandEventsAdapter() { @Override public Integer getOutputIdleSecondsTimeout() { return executionTimeout; } }); CommandUtil.checkCommandFailed(cmdStr, res); Loggers.VCS.debug(res.getStdout()); return res; } }