[PATCH] interactive: make sure buffer is flushed before waiting for user input

Kostia Balytskyi ikostia at fb.com
Sat Aug 5 20:20:15 UTC 2017


# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1501964349 25200
#      Sat Aug 05 13:19:09 2017 -0700
# Node ID 6065399003c83344df50209068ea85d82b3382d7
# Parent  609606d217659e0a6c1cf6f907b6512be5340e57
interactive: make sure buffer is flushed before waiting for user input

Without this patch on Windows 'hg ci -i' hangs waiting for user input
and "examine changes to 'file'? [Ynesfdaq?]" is never displayed (at least
if the diff is sufficiently small). When Ctrl+C is pressed, this prompt
becomes visible, which suggests that the buffer just wasn't flushed.
I've never seen this happening on Linux, but this looks harmless enought
to not platform-gate it.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1218,6 +1218,7 @@ class ui(object):
         sys.stdout = self.fout
         # prompt ' ' must exist; otherwise readline may delete entire line
         # - http://bugs.python.org/issue12833
+        self.flush()
         with self.timeblockedsection('stdio'):
             line = raw_input(' ')
         sys.stdin = oldin


More information about the Mercurial-devel mailing list