comparison mercurial/wireprototypes.py @ 36112:2f7290555c96

wireproto: introduce type for raw byte responses (API) Right now we simply return a str/bytes instance for simple responses. I want all wire protocol response types to be strongly typed. So let's invent and use a type for raw bytes responses. .. api:: Wire protocol command handlers now return a wireprototypes.bytesresponse instead of a raw bytes instance. Protocol handlers will continue handling bytes instances. However, any extensions wrapping wire protocol commands will need to handle the new type. Differential Revision: https://phab.mercurial-scm.org/D2089
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 07 Feb 2018 20:27:36 -0800
parents cd6ab329c5c7
children 0c231df1ffdc
comparison
equal deleted inserted replaced
36111:cd6ab329c5c7 36112:2f7290555c96
2 # 2 #
3 # This software may be used and distributed according to the terms of the 3 # This software may be used and distributed according to the terms of the
4 # GNU General Public License version 2 or any later version. 4 # GNU General Public License version 2 or any later version.
5 5
6 from __future__ import absolute_import 6 from __future__ import absolute_import
7
8 class bytesresponse(object):
9 """A wire protocol response consisting of raw bytes."""
10 def __init__(self, data):
11 self.data = data
7 12
8 class ooberror(object): 13 class ooberror(object):
9 """wireproto reply: failure of a batch of operation 14 """wireproto reply: failure of a batch of operation
10 15
11 Something failed during a batch call. The error message is stored in 16 Something failed during a batch call. The error message is stored in