diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py --- a/mercurial/commandserver.py +++ b/mercurial/commandserver.py @@ -160,7 +160,7 @@ class channeledinput(object): buf = s # keep asking for more until there's either no more or # we got a full line - while s and s[-1] != b'\n': + while s and not s.endswith(b'\n'): s = self._read(size, b'L') buf += s diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t --- a/tests/test-commandserver.t +++ b/tests/test-commandserver.t @@ -654,6 +654,9 @@ changelog and manifest would have invali ... runcommand(server, [b'debugprompt', b'--config', ... b'ui.interactive=True'], ... input=stringio(b'5678\n')) + ... runcommand(server, [b'debugprompt', b'--config', + ... b'ui.interactive=True'], + ... input=stringio(b'\nremainder\nshould\nnot\nbe\nread\n')) ... runcommand(server, [b'debugreadstdin']) ... runcommand(server, [b'debugwritestdout']) *** runcommand debuggetpass --config ui.interactive=True @@ -665,6 +668,8 @@ changelog and manifest would have invali [255] *** runcommand debugprompt --config ui.interactive=True prompt: 5678 + *** runcommand debugprompt --config ui.interactive=True + prompt: y *** runcommand debugreadstdin read: '' *** runcommand debugwritestdout