Patchwork py3: only flush before prompting during interactive patch filtering

login
register
mail settings
Submitter Denis Laxalde
Date Oct. 10, 2019, 8:27 a.m.
Message ID <c65b8e24c99f989cd774.1570696061@steppe.local>
Download mbox | patch
Permalink /patch/42178/
State Accepted
Headers show

Comments

Denis Laxalde - Oct. 10, 2019, 8:27 a.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1570694581 -7200
#      Thu Oct 10 10:03:01 2019 +0200
# Node ID c65b8e24c99f989cd774997aad3943b97f7cc805
# Parent  52781d57313d512efb7150603104bea3ca11d0eb
py3: only flush before prompting during interactive patch filtering

Follows up on c9093ae8d6c4. It's enough to flush just before each
prompt.
Yuya Nishihara - Oct. 10, 2019, 1:16 p.m.
On Thu, 10 Oct 2019 10:27:41 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1570694581 -7200
> #      Thu Oct 10 10:03:01 2019 +0200
> # Node ID c65b8e24c99f989cd774997aad3943b97f7cc805
> # Parent  52781d57313d512efb7150603104bea3ca11d0eb
> py3: only flush before prompting during interactive patch filtering

Queued, thanks.
Pulkit Goyal - Oct. 10, 2019, 1:18 p.m.
On Thu, Oct 10, 2019 at 11:31 AM Denis Laxalde <denis@laxalde.org> wrote:
>
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1570694581 -7200
> #      Thu Oct 10 10:03:01 2019 +0200
> # Node ID c65b8e24c99f989cd774997aad3943b97f7cc805
> # Parent  52781d57313d512efb7150603104bea3ca11d0eb
> py3: only flush before prompting during interactive patch filtering
>
> Follows up on c9093ae8d6c4. It's enough to flush just before each
> prompt.

Queued this, many thanks!

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
index 927b798..16d8fbd 100644
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1183,16 +1183,15 @@  def filterpatch(ui, headers, match, oper
         if skipfile is not None:
             return skipfile, skipfile, skipall, newpatches
         while True:
+            ui.flush()
             resps = messages[b'help'][operation]
             # IMPORTANT: keep the last line of this prompt short (<40 english
             # chars is a good target) because of issue6158.
             r = ui.promptchoice(b"%s\n(enter ? for help) %s" % (query, resps))
             ui.write(b"\n")
-            ui.flush()
             if r == 8:  # ?
                 for c, t in ui.extractchoices(resps)[1]:
                     ui.write(b'%s - %s\n' % (c, encoding.lower(t)))
-                    ui.flush()
                 continue
             elif r == 0:  # yes
                 ret = True
@@ -1202,12 +1201,10 @@  def filterpatch(ui, headers, match, oper
                 if chunk is None:
                     ui.write(_(b'cannot edit patch for whole file'))
                     ui.write(b"\n")
-                    ui.flush()
                     continue
                 if chunk.header.binary():
                     ui.write(_(b'cannot edit patch for binary file'))
                     ui.write(b"\n")
-                    ui.flush()
                     continue
                 # Patch comment based on the Git one (based on comment at end of
                 # https://mercurial-scm.org/wiki/RecordExtension)
@@ -1308,7 +1305,6 @@  the hunk is left unchanged.
         for i, chunk in enumerate(h.hunks):
             if skipfile is None and skipall is None:
                 chunk.pretty(ui)
-                ui.flush()
             if total == 1:
                 msg = messages[b'single'][operation] % chunk.filename()
             else: