From patchwork Tue Mar 20 00:01:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D2902: wireproto: define frame to represent progress updates From: phabricator X-Patchwork-Id: 29660 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Tue, 20 Mar 2018 00:01:17 +0000 indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Today, a long-running operation on a server may run without any sign of progress on the client. This can lead to the conclusion that the server has hung or the connection has dropped. In fact, connections can and do time out due to inactivity. And a long-running server operation can result in the connection dropping prematurely because no data is being sent! While we're inventing the new wire protocol, let's provide a mechanism for communicating progress on potentially expensive server-side events. We introduce a new frame type that conveys "progress" updates. This frame type essentially holds the data required to formulate a ``ui.progress()`` call. We only define the frame right now. Implementing it will be a bit of work since there is no analog to progress frames in the existing wire protocol. We'll need to teach the ui object to write to the wire protocol, etc. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2902 AFFECTED FILES mercurial/help/internals/wireprotocol.txt mercurial/wireprotoframing.py CHANGE DETAILS To: indygreg, #hg-reviewers Cc: mercurial-devel diff --git a/mercurial/wireprotoframing.py b/mercurial/wireprotoframing.py --- a/mercurial/wireprotoframing.py +++ b/mercurial/wireprotoframing.py @@ -31,14 +31,16 @@ FRAME_TYPE_BYTES_RESPONSE = 0x04 FRAME_TYPE_ERROR_RESPONSE = 0x05 FRAME_TYPE_TEXT_OUTPUT = 0x06 +FRAME_TYPE_PROGRESS = 0x07 FRAME_TYPES = { b'command-name': FRAME_TYPE_COMMAND_NAME, b'command-argument': FRAME_TYPE_COMMAND_ARGUMENT, b'command-data': FRAME_TYPE_COMMAND_DATA, b'bytes-response': FRAME_TYPE_BYTES_RESPONSE, b'error-response': FRAME_TYPE_ERROR_RESPONSE, b'text-output': FRAME_TYPE_TEXT_OUTPUT, + b'progress': FRAME_TYPE_PROGRESS, } FLAG_COMMAND_NAME_EOS = 0x01 @@ -91,6 +93,7 @@ FRAME_TYPE_BYTES_RESPONSE: FLAGS_BYTES_RESPONSE, FRAME_TYPE_ERROR_RESPONSE: FLAGS_ERROR_RESPONSE, FRAME_TYPE_TEXT_OUTPUT: {}, + FRAME_TYPE_PROGRESS: {}, } ARGUMENT_FRAME_HEADER = struct.Struct(r'