Patchwork interactive: make sure buffer is flushed before waiting for user input

login
register
mail settings
Submitter Kostia Balytskyi
Date Aug. 5, 2017, 8:20 p.m.
Message ID <6065399003c83344df50.1501964415@devvm1416.lla2.facebook.com>
Download mbox | patch
Permalink /patch/22695/
State Accepted
Headers show

Comments

Kostia Balytskyi - Aug. 5, 2017, 8:20 p.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@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.
Matt Harbison - Aug. 6, 2017, 2:56 a.m.
On Sat, 05 Aug 2017 16:20:15 -0400, Kostia Balytskyi <ikostia@fb.com>  
wrote:

> # HG changeset patch
> # User Kostia Balytskyi <ikostia@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

Needs '(issue5587)' and applied to stable?  I'm not sure if issue5604,  
which was marked as a duplicate, actually is.

> 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.
Yuya Nishihara - Aug. 6, 2017, 3:02 a.m.
On Sat, 5 Aug 2017 13:20:15 -0700, Kostia Balytskyi wrote:
> # HG changeset patch
> # User Kostia Balytskyi <ikostia@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

Marked as (issue5587) and queued for stable, thanks.

> 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'):

I've moved flush() immediately after the write() so it won't break into
backup/restore stdio.
Chuck Kirschman - Aug. 15, 2017, 8:55 p.m.
I filed 5604, and the solution (flushing) was the same. I have verified it in the 4.3.1 build. Thanks for the fix.


-----Original Message-----
From: Matt Harbison [mailto:mharbison72@gmail.com] 
Sent: Saturday, August 5, 2017 10:57 PM
To: Kostia Balytskyi <ikostia@fb.com>
Cc: mercurial-devel@mercurial-scm.org; Chuck Kirschman <Chuck.Kirschman@bentley.com>
Subject: Re: [PATCH] interactive: make sure buffer is flushed before waiting for user input

On Sat, 05 Aug 2017 16:20:15 -0400, Kostia Balytskyi <ikostia@fb.com>
wrote:

> # HG changeset patch
> # User Kostia Balytskyi <ikostia@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

Needs '(issue5587)' and applied to stable?  I'm not sure if issue5604, which was marked as a duplicate, actually is.

> 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.
Augie Fackler - Aug. 16, 2017, 6:32 p.m.
On Tue, Aug 15, 2017 at 08:55:42PM +0000, Chuck Kirschman wrote:
> I filed 5604, and the solution (flushing) was the same. I have verified it in the 4.3.1 build. Thanks for the fix.
>
>
> -----Original Message-----
> From: Matt Harbison [mailto:mharbison72@gmail.com]
> Sent: Saturday, August 5, 2017 10:57 PM
> To: Kostia Balytskyi <ikostia@fb.com>
> Cc: mercurial-devel@mercurial-scm.org; Chuck Kirschman <Chuck.Kirschman@bentley.com>
> Subject: Re: [PATCH] interactive: make sure buffer is flushed before waiting for user input
>
> On Sat, 05 Aug 2017 16:20:15 -0400, Kostia Balytskyi <ikostia@fb.com>
> wrote:
>
> > # HG changeset patch
> > # User Kostia Balytskyi <ikostia@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
>
> Needs '(issue5587)' and applied to stable?  I'm not sure if issue5604, which was marked as a duplicate, actually is.

That's what happened, yeah. This was released as part of 4.3.1.

>
> > 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.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

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