# HG changeset patch # User Yuya Nishihara # Date 2020-07-25 13:51:26 # Node ID 9b5723784aac9013471ca273ebdfa401e8bb443e # Parent 20d110e6eea6f37f83c873ec97e0fb5c9fa109ef dispatch: adjust ui.flush() timing to stabilize test-blackbox.t Without this change, dispatch.dispatch() could return before flushing all stdio data. This means chg stdio would print data after receiving the result code. --- tests/test-blackbox.t +++ tests/test-blackbox.t.err @@ -354,13 +354,13 @@ > EOF $ hg log --debug removing $TESTTMP/gone/.hg - warning: cannot write to blackbox.log: $ENOENT$ (no-windows !) warning: cannot write to blackbox.log: $TESTTMP/gone/.hg/blackbox.log: $ENOTDIR$ (windows !) $ cd .. blackbox should disable itself if track is empty $ hg --config blackbox.track= init nothing_tracked + warning: cannot write to blackbox.log: $ENOENT$ $ cd nothing_tracked $ cat >> .hg/hgrc << EOF > [blackbox] diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -323,7 +323,7 @@ def dispatch(req): ret = -1 finally: duration = util.timer() - starttime - req.ui.flush() + req.ui.flush() # record blocked times if req.ui.logblockedtimes: req.ui._blockedtimes[b'command_duration'] = duration * 1000 req.ui.log( @@ -346,6 +346,8 @@ def dispatch(req): req._runexithandlers() except: # exiting, so no re-raises ret = ret or -1 + # do flush again since ui.log() and exit handlers may write to ui + req.ui.flush() return ret