diff -r ef68493d652b -r 9c636ec1ef37 mercurial/hook.py --- a/mercurial/hook.py Sat Mar 10 10:27:56 2018 -0800 +++ b/mercurial/hook.py Sat Mar 10 22:02:58 2018 -0500 @@ -265,12 +265,12 @@ raised = False res[hname] = r, raised + finally: + # The stderr is fully buffered on Windows when connected to a pipe. + # A forcible flush is required to make small stderr data in the + # remote side available to the client immediately. + util.stderr.flush() - # The stderr is fully buffered on Windows when connected to a pipe. - # A forcible flush is required to make small stderr data in the - # remote side available to the client immediately. - util.stderr.flush() - finally: if _redirect and oldstdout >= 0: util.stdout.flush() # write hook output to stderr fd os.dup2(oldstdout, stdoutno)