# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1433050828 -32400
#      Sun May 31 14:40:28 2015 +0900
# Node ID 3ff4b07412ad709d57e304c139d05469fede8fce
# Parent  20ad936ac5d2a58877ad2ed8ca389b246f9b1802
ui: flush stdout before writing traceback to stderr

Sometimes a traceback message is paired with ui.debug(). This patch makes sure
that these messages are displayed in the right order.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -867,6 +867,7 @@
                                ''.join(causetb),
                                ''.join(exconly))
             else:
+                self.flush()  # flush debug or status message
                 traceback.print_exception(exc[0], exc[1], exc[2],
                                           file=self.ferr)
         return self.tracebackflag or force