# HG changeset patch # User Gábor Stefanik # Date 1505236596 14400 # Node ID 5609a21fe39ace1f45e1fbd7ebb8e6ec6d4b03d6 # Parent 9062a6b935ad45a443349cc590f70f2e194ad4c4 client: fail gracefully on unexpected prompts (issue5516) Right now, if hglib encounters an unexpected prompt, it fails with a rather opaque "unexpected data on required channel 'L'" error message. Furthermore, if subsequently another command is called on the same client instance, both the client and server processes lock up hard (at least on Windows), and the server process rapidly leaks ~2GB of memory. Fix this by responding with an empty string to any unexpected prompt. This will trigger an "abort: response expected" exception from the server, which is easily handled as a CommandError, and subsequent commands sent from the same client work as expected. This doesn't completely resolve bug 5516, as unexpected requests on another required channel (e.g. I) can still cause a lockup. However, it does fix the most common case of an unexpected password prompt. diff -r 9062a6b935ad -r 5609a21fe39a hglib/client.py --- a/hglib/client.py Wed Aug 02 23:43:16 2017 +0900 +++ b/hglib/client.py Tue Sep 12 13:16:36 2017 -0400 @@ -235,6 +235,8 @@ reply = prompt(size, out.getvalue()) return reply inchannels[b('L')] = func + else: + inchannels[b('L')] = lambda _: '' if input is not None: inchannels[b('I')] = input