Can't Redirect Mercurial stdout/stderr Under Windows 2012 R2 Noninteractive Session
Steve Barnes
gadgetsteve at hotmail.com
Tue Sep 23 20:41:18 UTC 2014
On 22/09/14 23:38, Mads Kiilerich wrote:
> On 09/20/2014 06:07 AM, Jensen, Aaron wrote:
>> We have several automated build jobs that check changes into
>> Mercurial. If they encounter unmerged heads on the outgoing server,
>> the scripts will pull down those changes, merge them, then push
>> everything back out (repeated until the push succeeds). In some
>> cases, Mercurial would ask for input from the user, which caused our
>> automated jobs to timeout. We can't use the --interactive flag
>> because there are occasions we *didn't* want to choose `y` to
>> Mercurial's questions.
>>
>> So, we wrote a wrapper script in PowerShell which starts a Mercurial
>> as a background process and monitors it. If the script detects
>> Merurial is asking a question, it will abort Mercurial, and fail the
>> build with a friendly error message. This script also redirects
>> Mercurial's stdout/stderr streams, reads them in, writes the errors
>> to PowerShell's error stream, and converts Mercurial's output to
>> objects, which consumers of our script use to perform additional
>> processing.
>>
>> Unfortunately, beginning with Windows 2012 R2 (we were using Windows
>> 2008 R2 previously), the background Mercurial process started hanging
>> when run by our build server (CruiseControl.NET running as an
>> Administrator). It does not happen when I'm running at an interactive
>> console. After several hours of research, it looks like redirecting
>> Mercurial's stdout/stderr streams causes Mercurial to freeze and not
>> output anything. Even running `hg help` hangs.
>>
>> Here's how you can reproduce. Under CruiseControl.NET, or some other
>> non-interactive process/service, run the following PowerShell code
>> [1]. I'm pretty sure this is something in Mercurial because I
>> switched the background process to `cmd.exe` with arguments of `@(
>> '/c', 'echo fubar' )` and that process completes successfully.
>
> It sounds like a blocking buffer. Obviously 'hg status' without output
> passes? How about short output like 'hg id'?
>
>> Any ideas what would be causing this? How can I troubleshoot further?
>
> Unless you or some other windows expert can figure out how to debug
> it, I would suggest replacing your complex wrapper script with a small
> extension that just modify merges. Or perhaps even simpler: let it run
> non-interactively and merge as it wants and then check the output
> whether it did some of the forbidden actions.
>
> /Mads
>
> _______________________________________________
> Mercurial mailing list
> Mercurial at selenic.com
> http://selenic.com/mailman/listinfo/mercurial
>
>
I would also suggest that this might be the sort of job that would be
better written as a (wx)python script - using hglib
<http://mercurial.selenic.com/wiki/PythonHglib> or the command server
<http://mercurial.selenic.com/wiki/CommandServer#Example_client> in
python you can control mercurial quite thoroughly and if you use
wxPython you can even have a GUI to show the progress, number of errors,
etc.
Gadget/Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20140923/5b159f25/attachment-0002.html>
More information about the Mercurial
mailing list