[PATCH v2 stable] sshpeer: try harder to snag stderr when stdout closes unexpectedly

Matt Harbison mharbison72 at gmail.com
Fri Apr 21 22:55:01 EDT 2017


On Fri, 21 Apr 2017 16:32:32 -0400, Augie Fackler <raf at durin42.com> wrote:

> # HG changeset patch
> # User Augie Fackler <augie at google.com>
> # Date 1492114180 14400
> #      Thu Apr 13 16:09:40 2017 -0400
> # Branch stable
> # Node ID 8862fd11cc7d27512a4b4c2a56c983d68609660b
> # Parent  6e0368b6e0bb2aa5210daec091c0200583553a78
> sshpeer: try harder to snag stderr when stdout closes unexpectedly

This also fixes both flakey tests on Windows for me.  Thanks.

> Resolves test failures on FreeBSD, but I'm not happy about the fix.
>
> A previous version of this also wrapped readline by putting the hack
> in the _call method on doublepipe. That was confusing for readers and
> wasn't necessary - just doing this on read() is sufficient to fix the
> bugs I'm observing. We can always come back and do readline later if
> needed.
>
> diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
> --- a/mercurial/sshpeer.py
> +++ b/mercurial/sshpeer.py
> @@ -91,7 +91,15 @@ class doublepipe(object):
>          return self._call('write', data)
>     def read(self, size):
> -        return self._call('read', size)
> +        r = self._call('read', size)
> +        if size != 0 and not r:
> +            # We've observed a condition that indicates the
> +            # stdout closed unexpectedly. Check stderr one
> +            # more time and snag anything that's there before
> +            # letting anyone know the main part of the pipe
> +            # closed prematurely.
> +            _forwardoutput(self._ui, self._side)
> +        return r
>     def readline(self):
>          return self._call('readline')
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list