Patchwork [1,of,2,STABLE] ui: separate option to disable echo back of prompt response

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 20, 2014, 3:15 p.m.
Message ID <7ce8b804b319af65322c.1413818147@mimosa>
Download mbox | patch
Permalink /patch/6429/
State Accepted
Headers show

Comments

Yuya Nishihara - Oct. 20, 2014, 3:15 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1412769061 -32400
#      Wed Oct 08 20:51:01 2014 +0900
# Branch stable
# Node ID 7ce8b804b319af65322c0ab345f21d289f92c63f
# Parent  c1ae0b2c1719f56b906472efea8b20ca0774c968
ui: separate option to disable echo back of prompt response

The problem in commandserver was addressed by 524b786bd54f, but it is tricky
to reuse ui.nontty option to disable echo back.

The new ui.simulatettyecho option will be disabled globally by next patch.
I agree this option is clumsy, but it can avoid possible breakage of third-
party scripts.

Patch

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -196,6 +196,9 @@  class server(object):
         for ui in uis:
             # any kind of interaction must use server channels
             ui.setconfig('ui', 'nontty', 'true', 'commandserver')
+            # echo-back message shouldn't be written because a client
+            # typically have to parse the output
+            ui.setconfig('ui', 'simulatettyecho', 'false', 'commandserver')
 
         req = dispatch.request(args[:], copiedui, self.repo, self.cin,
                                self.cout, self.cerr)
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -713,9 +713,8 @@  class ui(object):
                 r = default
             # sometimes self.interactive disagrees with isatty,
             # show response provided on stdin when simulating
-            # but commandserver
             if (not util.isatty(self.fin)
-                and not self.configbool('ui', 'nontty')):
+                and self.configbool('ui', 'simulatettyecho', True)):
                 self.write(r, "\n")
             return r
         except EOFError:
diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t
--- a/tests/test-commandserver.t
+++ b/tests/test-commandserver.t
@@ -178,6 +178,7 @@  check that local configs for the cached 
   ui.mergemarkers=detailed
   ui.foo=bar
   ui.nontty=true
+  ui.simulatettyecho=false
   *** runcommand init foo
   *** runcommand -R foo showconfig ui defaults
   defaults.backout=-d "0 0"
@@ -188,6 +189,7 @@  check that local configs for the cached 
   ui.interactive=False
   ui.mergemarkers=detailed
   ui.nontty=true
+  ui.simulatettyecho=false
 
   $ rm -R foo