comparison mercurial/wireprototypes.py @ 36073:cd6ab329c5c7

wireprototypes: move wire protocol response types to new module We'll be introducing more types as part of wire protocol version 2. These types are shared between the command handling code (in wireproto.py) and the protocol/transport code in wireprotoserver.py. So they need to go in a new module to prevent a cycle. The types are aliased into the wireproto module, so API compatibility is preserved. Differential Revision: https://phab.mercurial-scm.org/D2088
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 07 Feb 2018 16:29:05 -0800
parents
children 2f7290555c96
comparison
equal deleted inserted replaced
36072:341c886e411e 36073:cd6ab329c5c7
1 # Copyright 2018 Gregory Szorc <gregory.szorc@gmail.com>
2 #
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.
5
6 from __future__ import absolute_import
7
8 class ooberror(object):
9 """wireproto reply: failure of a batch of operation
10
11 Something failed during a batch call. The error message is stored in
12 `self.message`.
13 """
14 def __init__(self, message):
15 self.message = message
16
17 class pushres(object):
18 """wireproto reply: success with simple integer return
19
20 The call was successful and returned an integer contained in `self.res`.
21 """
22 def __init__(self, res, output):
23 self.res = res
24 self.output = output
25
26 class pusherr(object):
27 """wireproto reply: failure
28
29 The call failed. The `self.res` attribute contains the error message.
30 """
31 def __init__(self, res, output):
32 self.res = res
33 self.output = output
34
35 class streamres(object):
36 """wireproto reply: binary stream
37
38 The call was successful and the result is a stream.
39
40 Accepts a generator containing chunks of data to be sent to the client.
41
42 ``prefer_uncompressed`` indicates that the data is expected to be
43 uncompressable and that the stream should therefore use the ``none``
44 engine.
45 """
46 def __init__(self, gen=None, prefer_uncompressed=False):
47 self.gen = gen
48 self.prefer_uncompressed = prefer_uncompressed
49
50 class streamreslegacy(object):
51 """wireproto reply: uncompressed binary stream
52
53 The call was successful and the result is a stream.
54
55 Accepts a generator containing chunks of data to be sent to the client.
56
57 Like ``streamres``, but sends an uncompressed data for "version 1" clients
58 using the application/mercurial-0.1 media type.
59 """
60 def __init__(self, gen=None):
61 self.gen = gen