Mercurial > hg
comparison hgext/largefiles/proto.py @ 36074: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 | 90ca4986616c |
children | 3ac8b5c1c36c |
comparison
equal
deleted
inserted
replaced
36073:cd6ab329c5c7 | 36074:2f7290555c96 |
---|---|
12 from mercurial import ( | 12 from mercurial import ( |
13 error, | 13 error, |
14 httppeer, | 14 httppeer, |
15 util, | 15 util, |
16 wireproto, | 16 wireproto, |
17 wireprototypes, | |
17 ) | 18 ) |
18 | 19 |
19 from . import ( | 20 from . import ( |
20 lfutil, | 21 lfutil, |
21 ) | 22 ) |
83 The value 1 is reserved for mismatched checksum, but that is too expensive | 84 The value 1 is reserved for mismatched checksum, but that is too expensive |
84 to be verified on every stat and must be caught be running 'hg verify' | 85 to be verified on every stat and must be caught be running 'hg verify' |
85 server side.''' | 86 server side.''' |
86 filename = lfutil.findfile(repo, sha) | 87 filename = lfutil.findfile(repo, sha) |
87 if not filename: | 88 if not filename: |
88 return '2\n' | 89 return wireprototypes.bytesresponse('2\n') |
89 return '0\n' | 90 return wireprototypes.bytesresponse('0\n') |
90 | 91 |
91 def wirereposetup(ui, repo): | 92 def wirereposetup(ui, repo): |
92 class lfileswirerepository(repo.__class__): | 93 class lfileswirerepository(repo.__class__): |
93 def putlfile(self, sha, fd): | 94 def putlfile(self, sha, fd): |
94 # unfortunately, httprepository._callpush tries to convert its | 95 # unfortunately, httprepository._callpush tries to convert its |