windows: always work around EINVAL in case of broken pipe for stdout / stderr
In
29a905fe23ae, I missed the fact that the `winstdout` class works around two
unrelated bugs (size limit when writing to consoles and EINVAL in case of
broken pipe) and that the latter bug happens even when no console is involved.
When writing a test for this, I realized that the same problem applies to
stderr, so I applied the workaround for EINVAL to both stdout and stderr.
The size limit is worked around in the same case as before (consoles on Windows
on Python 2). For that, I changed the `winstdout` class.
# Disable the $CAP wire protocol capability.
if test -z "$CAP"
then
echo "CAP environment variable not set."
fi
cat > notcapable-$CAP.py << EOF
from mercurial import extensions, localrepo
from mercurial.interfaces import repository
def extsetup(ui):
extensions.wrapfunction(repository.peer, 'capable', wrapcapable)
extensions.wrapfunction(localrepo.localrepository, 'peer', wrappeer)
def wrapcapable(orig, self, name, *args, **kwargs):
if name in b'$CAP'.split(b' '):
return False
return orig(self, name, *args, **kwargs)
def wrappeer(orig, self):
# Since we're disabling some newer features, we need to make sure local
# repos add in the legacy features again.
return localrepo.locallegacypeer(self)
EOF
echo '[extensions]' >> $HGRCPATH
echo "notcapable-$CAP = `pwd`/notcapable-$CAP.py" >> $HGRCPATH