Patchwork [3,of,3] cmdserver: drop useless in_ attribute from channeledoutput

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 27, 2014, 4:31 a.m.
Message ID <e5f8fa91ad36d260cc68.1411792304@mimosa>
Download mbox | patch
Permalink /patch/5991/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 27, 2014, 4:31 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1411789073 -32400
#      Sat Sep 27 12:37:53 2014 +0900
# Node ID e5f8fa91ad36d260cc68e53e71c91883f608bc7a
# Parent  c1ab38c0a930e39eefaf6ffa794e3fa838b46dc5
cmdserver: drop useless in_ attribute from channeledoutput
Pierre-Yves David - Sept. 27, 2014, 10:47 p.m.
On 09/26/2014 09:31 PM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1411789073 -32400
> #      Sat Sep 27 12:37:53 2014 +0900
> # Node ID e5f8fa91ad36d260cc68e53e71c91883f608bc7a
> # Parent  c1ab38c0a930e39eefaf6ffa794e3fa838b46dc5
> cmdserver: drop useless in_ attribute from channeledoutput

Can you elaborate on why it is useless?
Yuya Nishihara - Sept. 28, 2014, 2:33 a.m.
On Sat, 27 Sep 2014 15:47:56 -0700, Pierre-Yves David wrote:
> On 09/26/2014 09:31 PM, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1411789073 -32400
> > #      Sat Sep 27 12:37:53 2014 +0900
> > # Node ID e5f8fa91ad36d260cc68e53e71c91883f608bc7a
> > # Parent  c1ab38c0a930e39eefaf6ffa794e3fa838b46dc5
> > cmdserver: drop useless in_ attribute from channeledoutput
> 
> Can you elaborate on why it is useless?

The previous patch makes sure that in_ == out, so it's no longer needed
to keep in_ for __getattr__.  Also, it seems strange for channeledoutput
to have in_ stream which is actually a writable file object.
Pierre-Yves David - Sept. 28, 2014, 2:59 a.m.
On 09/27/2014 07:33 PM, Yuya Nishihara wrote:
> The previous patch makes sure that in_ == out, so it's no longer needed
> to keep in_ for __getattr__.  Also, it seems strange for channeledoutput
> to have in_ stream which is actually a writable file object.

I augmented patch3 description with this paragraph and pushed the whole 
to clowncopter.
Matt Mackall - Sept. 29, 2014, 7:31 p.m.
On Sat, 2014-09-27 at 19:59 -0700, Pierre-Yves David wrote:
> 
> On 09/27/2014 07:33 PM, Yuya Nishihara wrote:
> > The previous patch makes sure that in_ == out, so it's no longer needed
> > to keep in_ for __getattr__.  Also, it seems strange for channeledoutput
> > to have in_ stream which is actually a writable file object.
> 
> I augmented patch3 description with this paragraph and pushed the whole 
> to clowncopter.

I think something may have broken on the buildbot here:

http://hgbuildbot.kublai.com/builders/python-hglib
Matt Mackall - Sept. 29, 2014, 9:47 p.m.
On Sat, 2014-09-27 at 19:59 -0700, Pierre-Yves David wrote:
> 
> On 09/27/2014 07:33 PM, Yuya Nishihara wrote:
> > The previous patch makes sure that in_ == out, so it's no longer needed
> > to keep in_ for __getattr__.  Also, it seems strange for channeledoutput
> > to have in_ stream which is actually a writable file object.
> 
> I augmented patch3 description with this paragraph and pushed the whole 
> to clowncopter.

I think something may have broken on the buildbot here:

http://hgbuildbot.kublai.com/builders/python-hglib
Yuya Nishihara - Sept. 30, 2014, 1:08 p.m.
On Mon, 29 Sep 2014 14:31:29 -0500, Matt Mackall wrote:
> On Sat, 2014-09-27 at 19:59 -0700, Pierre-Yves David wrote:
> > 
> > On 09/27/2014 07:33 PM, Yuya Nishihara wrote:
> > > The previous patch makes sure that in_ == out, so it's no longer needed
> > > to keep in_ for __getattr__.  Also, it seems strange for channeledoutput
> > > to have in_ stream which is actually a writable file object.
> > 
> > I augmented patch3 description with this paragraph and pushed the whole 
> > to clowncopter.
> 
> I think something may have broken on the buildbot here:
> 
> http://hgbuildbot.kublai.com/builders/python-hglib

Filed bug as
http://bz.selenic.com/show_bug.cgi?id=4396

python-hglib runs "hg log -r 'rev(n)'" to see if the revision exists or not.

Patch

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -28,8 +28,7 @@  class channeledoutput(object):
     data length (unsigned int),
     data
     """
-    def __init__(self, in_, out, channel):
-        self.in_ = in_
+    def __init__(self, out, channel):
         self.out = out
         self.channel = channel
 
@@ -43,7 +42,7 @@  class channeledoutput(object):
     def __getattr__(self, attr):
         if attr in ('isatty', 'fileno'):
             raise AttributeError(attr)
-        return getattr(self.in_, attr)
+        return getattr(self.out, attr)
 
 class channeledinput(object):
     """
@@ -138,7 +137,7 @@  class server(object):
             global logfile
             if logpath == '-':
                 # write log on a special 'd' (debug) channel
-                logfile = channeledoutput(sys.stdout, sys.stdout, 'd')
+                logfile = channeledoutput(sys.stdout, 'd')
             else:
                 logfile = open(logpath, 'a')
 
@@ -153,10 +152,10 @@  class server(object):
             self.repo = self.repoui = None
 
         if mode == 'pipe':
-            self.cerr = channeledoutput(sys.stdout, sys.stdout, 'e')
-            self.cout = channeledoutput(sys.stdout, sys.stdout, 'o')
+            self.cerr = channeledoutput(sys.stdout, 'e')
+            self.cout = channeledoutput(sys.stdout, 'o')
             self.cin = channeledinput(sys.stdin, sys.stdout, 'I')
-            self.cresult = channeledoutput(sys.stdout, sys.stdout, 'r')
+            self.cresult = channeledoutput(sys.stdout, 'r')
 
             self.client = sys.stdin
         else: