Patchwork ui: remove any combinations of CR|LF from prompt response

login
register
mail settings
Submitter Yuya Nishihara
Date March 10, 2018, 7:52 a.m.
Message ID <c38b2b364df79a9defc3.1520668320@mimosa>
Download mbox | patch
Permalink /patch/29240/
State Accepted
Headers show

Comments

Yuya Nishihara - March 10, 2018, 7:52 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1520664609 -32400
#      Sat Mar 10 15:50:09 2018 +0900
# Node ID c38b2b364df79a9defc3520f19207ce47abcc7d8
# Parent  9ddc9aa26801bac571bd3413a8aed900c2d2efb8
ui: remove any combinations of CR|LF from prompt response

On Windows, we have to accept both CR+LF and LF. This patch simply makes
any trailing CRs and LFs removed from a user input instead of doing stricter
parsing, as an input must be a readable text.
Matt Harbison - March 10, 2018, 5:07 p.m.
On Sat, 10 Mar 2018 02:52:00 -0500, Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1520664609 -32400
> #      Sat Mar 10 15:50:09 2018 +0900
> # Node ID c38b2b364df79a9defc3520f19207ce47abcc7d8
> # Parent  9ddc9aa26801bac571bd3413a8aed900c2d2efb8
> ui: remove any combinations of CR|LF from prompt response

I didn't run the whole test suite, but this fixes the ones that broke.   
Thanks.
Pulkit Goyal - March 11, 2018, 6:39 a.m.
On Sat, Mar 10, 2018 at 10:37 PM, Matt Harbison <mharbison72@gmail.com> wrote:
> On Sat, 10 Mar 2018 02:52:00 -0500, Yuya Nishihara <yuya@tcha.org> wrote:
>
>> # HG changeset patch
>> # User Yuya Nishihara <yuya@tcha.org>
>> # Date 1520664609 -32400
>> #      Sat Mar 10 15:50:09 2018 +0900
>> # Node ID c38b2b364df79a9defc3520f19207ce47abcc7d8
>> # Parent  9ddc9aa26801bac571bd3413a8aed900c2d2efb8
>> ui: remove any combinations of CR|LF from prompt response
>
>
> I didn't run the whole test suite, but this fixes the ones that broke.
> Thanks.

Queued as per Matt review. Thanks.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1296,8 +1296,7 @@  class ui(object):
                 line = self.fin.readline()
                 if not line:
                     raise EOFError
-                if line.endswith(pycompat.oslinesep):
-                    line = line[:-len(pycompat.oslinesep)]
+                line = line.rstrip(pycompat.oslinesep)
 
         return line