Patchwork [1,of,2,chg-port] commandserver: do not set nontty flag if channel is replaced by a real file

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 23, 2015, 2:09 p.m.
Message ID <38feb09b6b71681c7d14.1450879764@mimosa>
Download mbox | patch
Permalink /patch/12292/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 23, 2015, 2:09 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1450102422 -32400
#      Mon Dec 14 23:13:42 2015 +0900
# Node ID 38feb09b6b71681c7d141db4e013652fc2fe2c46
# Parent  e2aa9c4030c4109e5efa50462ffc6048ca30106f
commandserver: do not set nontty flag if channel is replaced by a real file

This prepares for porting the chg server. In chg, a server receives client's
stdio over a UNIX domain socket to override server channels. This is because
chg should behave as if it is a normal hg command attached to tty. "nontty"
is not wanted.

This patch is corresponding to the following change. This doesn't test the
identity of "cin" object because the current version of chg reopens stdio
to apply buffering mode.

https://bitbucket.org/yuja/chg/commits/c48c7aed5fc0

Patch

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -215,8 +215,11 @@  class server(object):
             self.repo.invalidateall()
 
         for ui in uis:
-            # any kind of interaction must use server channels
-            ui.setconfig('ui', 'nontty', 'true', 'commandserver')
+            # any kind of interaction must use server channels, but chg may
+            # replace channels by fully functional tty files. so nontty is
+            # enforced only if cin is a channel.
+            if not util.safehasattr(self.cin, 'fileno'):
+                ui.setconfig('ui', 'nontty', 'true', 'commandserver')
 
         req = dispatch.request(args[:], copiedui, self.repo, self.cin,
                                self.cout, self.cerr)