public IHgResult Execute(HgArguments hgArguments) { var startInfo = new ProcessStartInfo(_executableName, hgArguments.ToString()) { CreateNoWindow = true, ErrorDialog = false, RedirectStandardError = true, RedirectStandardOutput = true, UseShellExecute = false, }; using (var process = new Process { StartInfo = startInfo, }) { var errorBuilder = new StringBuilder(); var outBuilder = new StringBuilder(); process.ErrorDataReceived += (sender, e) => errorBuilder.AppendLine(e.Data); process.OutputDataReceived += (sender, e) => outBuilder.AppendLine(e.Data); process.Start(); process.BeginErrorReadLine(); process.BeginOutputReadLine(); process.WaitForExit(); return new HgResult(process.ExitCode != 0, outBuilder.ToString().Trim(), errorBuilder.ToString().Trim()); } }
public IHgResult Execute(HgArguments hgArguments) { if (hgArguments == null) { throw new ArgumentNullException("hgArguments"); } _processExecutor.ProcessOutput += HandleProcessOutput; try { var processInfo = new ProcessInfo("hg", hgArguments.ToString()); var result = _processExecutor.Execute(processInfo); return new CruiseControlHgResult(result); } finally { _processExecutor.ProcessOutput -= HandleProcessOutput; } }