dispatch: adjust ui.flush() timing to stabilize test-blackbox.t stable
authorYuya Nishihara <yuya@tcha.org>
Sat, 25 Jul 2020 22:51:26 +0900
branchstable
changeset 45253 9b5723784aac
parent 45252 20d110e6eea6
child 45271 7fc3c5fbc65f
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]
mercurial/dispatch.py
--- a/mercurial/dispatch.py	Sun Jul 26 12:46:04 2020 -0700
+++ b/mercurial/dispatch.py	Sat Jul 25 22:51:26 2020 +0900
@@ -323,7 +323,7 @@
             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 @@
                 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