Patchwork [2,of,3] cmdserver: get file attributes of 'e'-channel from stdout, not from stderr

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

Comments

Yuya Nishihara - Sept. 27, 2014, 4:31 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1411788423 -32400
#      Sat Sep 27 12:27:03 2014 +0900
# Node ID c1ab38c0a930e39eefaf6ffa794e3fa838b46dc5
# Parent  5ee54fd7d942d4d6f6a315c4a6ccdfb6204c5ae4
cmdserver: get file attributes of 'e'-channel from stdout, not from stderr

It seems wrong to get attributes from object different than the underlying
file.  In the following example, it doesn't make sense to flush stderr after
writing to stdout:

    self.ferr.write(str(a))
    if not getattr(self.ferr, 'closed', False):
        self.ferr.flush()
Idan Kamara - Sept. 27, 2014, 7:40 p.m.
On Fri, Sep 26, 2014 at 9:31 PM, Yuya Nishihara <yuya@tcha.org> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1411788423 -32400
> #      Sat Sep 27 12:27:03 2014 +0900
> # Node ID c1ab38c0a930e39eefaf6ffa794e3fa838b46dc5
> # Parent  5ee54fd7d942d4d6f6a315c4a6ccdfb6204c5ae4
> cmdserver: get file attributes of 'e'-channel from stdout, not from stderr
>
> It seems wrong to get attributes from object different than the underlying
> file.  In the following example, it doesn't make sense to flush stderr after
> writing to stdout:
>
>     self.ferr.write(str(a))
>     if not getattr(self.ferr, 'closed', False):
>         self.ferr.flush()

It took me a while to find that we use this pattern in ui.write_err,
but seems like a harmless and correct change.

Patch

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -153,7 +153,7 @@  class server(object):
             self.repo = self.repoui = None
 
         if mode == 'pipe':
-            self.cerr = channeledoutput(sys.stderr, sys.stdout, 'e')
+            self.cerr = channeledoutput(sys.stdout, sys.stdout, 'e')
             self.cout = channeledoutput(sys.stdout, sys.stdout, 'o')
             self.cin = channeledinput(sys.stdin, sys.stdout, 'I')
             self.cresult = channeledoutput(sys.stdout, sys.stdout, 'r')