Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hook.py @ 45737:b3e8d8e4a40d
hook: ignore EPIPE when flushing stdout/stderr
This fixes the bug described in the parent commit.
test-transaction-rollback-on-sigpipe.t is updated to show the new
behavior.
Differential Revision: https://phab.mercurial-scm.org/D9152
author | Mitchell Plamann <mplamann@janestreet.com> |
---|---|
date | Mon, 05 Oct 2020 17:18:39 -0400 |
parents | fd3b94f1712d |
children | 89a2afe31e82 |
comparison
equal
deleted
inserted
replaced
45736:2c6b054e22d0 | 45737:b3e8d8e4a40d |
---|---|
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 import contextlib | 10 import contextlib |
11 import errno | |
11 import os | 12 import os |
12 import sys | 13 import sys |
13 | 14 |
14 from .i18n import _ | 15 from .i18n import _ |
15 from .pycompat import getattr | 16 from .pycompat import getattr |
287 | 288 |
288 finally: | 289 finally: |
289 # The stderr is fully buffered on Windows when connected to a pipe. | 290 # The stderr is fully buffered on Windows when connected to a pipe. |
290 # A forcible flush is required to make small stderr data in the | 291 # A forcible flush is required to make small stderr data in the |
291 # remote side available to the client immediately. | 292 # remote side available to the client immediately. |
292 procutil.stderr.flush() | 293 try: |
294 procutil.stderr.flush() | |
295 except IOError as err: | |
296 if err.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): | |
297 raise error.StdioError(err) | |
293 | 298 |
294 if _redirect and oldstdout >= 0: | 299 if _redirect and oldstdout >= 0: |
295 procutil.stdout.flush() # write hook output to stderr fd | 300 try: |
301 procutil.stdout.flush() # write hook output to stderr fd | |
302 except IOError as err: | |
303 if err.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): | |
304 raise error.StdioError(err) | |
296 os.dup2(oldstdout, stdoutno) | 305 os.dup2(oldstdout, stdoutno) |
297 os.close(oldstdout) | 306 os.close(oldstdout) |
298 | 307 |
299 | 308 |
300 def runhooks(ui, repo, htype, hooks, throw=False, **args): | 309 def runhooks(ui, repo, htype, hooks, throw=False, **args): |