Patchwork [1,of,5] commandserver: implement name() to clarify channel is not a plain file

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 17, 2015, 2:09 p.m.
Message ID <2277a47b0044907d346e.1450361361@mimosa>
Download mbox | patch
Permalink /patch/12096/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 17, 2015, 2:09 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1450002721 -32400
#      Sun Dec 13 19:32:01 2015 +0900
# Node ID 2277a47b0044907d346eefb98891c73aa43db3ba
# Parent  69541cab1dcd4e9f5e8a137bf53b034da825af5c
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>'.

Patch

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -43,6 +43,10 @@  class channeledoutput(object):
         self.out = out
         self.channel = channel
 
+    @property
+    def name(self):
+        return '<%c-channel>' % self.channel
+
     def write(self, data):
         if not data:
             return
@@ -75,6 +79,10 @@  class channeledinput(object):
         self.out = out
         self.channel = channel
 
+    @property
+    def name(self):
+        return '<%c-channel>' % self.channel
+
     def read(self, size=-1):
         if size < 0:
             # if we need to consume all the clients input, ask for 4k chunks