Mercurial > public > mercurial-scm > hg
comparison mercurial/commandserver.py @ 27415:f4ca33e33781
commandserver: implement name() to clarify channel is not a plain file
Because unknown attributes are delegated to the underlying file object,
commandserver channels said they were '<stdout>' or '<stdin>' even though
they weren't. This patch makes them say '<X-channel>'.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 13 Dec 2015 19:32:01 +0900 |
parents | 9fd8f1552369 |
children | e7937438e3f7 |
comparison
equal
deleted
inserted
replaced
27414:6602a7b9deec | 27415:f4ca33e33781 |
---|---|
41 """ | 41 """ |
42 def __init__(self, out, channel): | 42 def __init__(self, out, channel): |
43 self.out = out | 43 self.out = out |
44 self.channel = channel | 44 self.channel = channel |
45 | 45 |
46 @property | |
47 def name(self): | |
48 return '<%c-channel>' % self.channel | |
49 | |
46 def write(self, data): | 50 def write(self, data): |
47 if not data: | 51 if not data: |
48 return | 52 return |
49 self.out.write(struct.pack('>cI', self.channel, len(data))) | 53 self.out.write(struct.pack('>cI', self.channel, len(data))) |
50 self.out.write(data) | 54 self.out.write(data) |
72 | 76 |
73 def __init__(self, in_, out, channel): | 77 def __init__(self, in_, out, channel): |
74 self.in_ = in_ | 78 self.in_ = in_ |
75 self.out = out | 79 self.out = out |
76 self.channel = channel | 80 self.channel = channel |
81 | |
82 @property | |
83 def name(self): | |
84 return '<%c-channel>' % self.channel | |
77 | 85 |
78 def read(self, size=-1): | 86 def read(self, size=-1): |
79 if size < 0: | 87 if size < 0: |
80 # if we need to consume all the clients input, ask for 4k chunks | 88 # if we need to consume all the clients input, ask for 4k chunks |
81 # so the pipe doesn't fill up risking a deadlock | 89 # so the pipe doesn't fill up risking a deadlock |