use of jetbrains.buildServer.LineAwareByteArrayOutputStream in project teamcity-git by JetBrains.
the class GitPatchBuilderDispatcher method buildPatchInSeparateProcess.
private void buildPatchInSeparateProcess() throws Exception {
final String rootStr = LogUtil.describe(myGitRoot);
final ProcessXmxProvider xmxProvider = new ProcessXmxProvider(new RepositoryXmxStorage(myContext.getRepository(), "patch"), myConfig, "patch", "(root: " + rootStr + ")");
Integer xmx = xmxProvider.getNextXmx();
while (xmx != null) {
final GeneralCommandLine patchCmd = createPatchCommandLine(xmx);
final File patchFile = FileUtil.createTempFile("git", "patch");
final File internalProperties = getPatchPropertiesFile();
try {
final ByteArrayOutputStream stdout = new LineAwareByteArrayOutputStream(Charset.forName("UTF-8"), new NoOpLineListener(), false);
final ByteArrayOutputStream stderr = new ByteArrayOutputStream();
final GitProcessExecutor.GitExecResult gitResult = new GitProcessExecutor(patchCmd).runProcess(getInput(patchFile, internalProperties), myConfig.getPatchProcessIdleTimeoutSeconds(), stdout, stderr, new GitProcessExecutor.ProcessExecutorAdapter());
VcsException patchError = CommandLineUtil.getCommandLineError("build patch", gitResult.getExecResult());
if (patchError != null) {
if (gitResult.isOutOfMemoryError()) {
final Integer nextXmx = xmxProvider.getNextXmx();
if (nextXmx != null) {
xmx = nextXmx;
FileUtil.delete(patchFile);
continue;
}
throw new VcsException("There is not enough memory for git patch (last attempted -Xmx" + xmx + "M). Please contact your system administrator", patchError);
} else if (gitResult.isTimeout()) {
throw new VcsException("git patch for root " + rootStr + " was idle for more than " + myConfig.getFetchTimeout() + " second(s), try increasing the timeout using the " + PluginConfigImpl.TEAMCITY_GIT_IDLE_TIMEOUT_SECONDS + " property", patchError);
}
throw patchError;
}
new LowLevelPatcher(new FileInputStream(patchFile)).applyPatch(new NoExitLowLevelPatchTranslator(((PatchBuilderEx) myBuilder).getLowLevelBuilder()));
break;
} finally {
FileUtil.delete(patchFile);
FileUtil.delete(internalProperties);
}
}
}
use of jetbrains.buildServer.LineAwareByteArrayOutputStream in project teamcity-git by JetBrains.
the class GitCommandLine method createStderrBuffer.
@NotNull
public ByteArrayOutputStream createStderrBuffer() {
LineAwareByteArrayOutputStream buffer = new LineAwareByteArrayOutputStream(Charset.forName("UTF-8"), new GitProgressListener(myLogger));
buffer.setCREndsLine(true);
return buffer;
}
Aggregations