ui: separate option to show prompt echo, enabled only in tests (issue4417) stable
authorYuya Nishihara <yuya@tcha.org>
Tue, 21 Oct 2014 23:16:46 +0900
branchstable
changeset 23053 5ba11ab48fcf
parent 23052 c1ae0b2c1719
child 23054 40c01f95449b
ui: separate option to show prompt echo, enabled only in tests (issue4417) The problem in commandserver was addressed by 524b786bd54f, but it is tricky to reuse ui.nontty option to disable echo back. Instead, this patch introduces new option to enable echoing of prompt response. Prompt echoing is changed to be off by default, which should avoid possible breakage of output parsing in user scripts. For now, this option is undocumented because it exists for internal use.
mercurial/ui.py
tests/run-tests.py
tests/test-basic.t
tests/test-commandserver.t
--- a/mercurial/ui.py	Sat Oct 18 18:14:48 2014 -0500
+++ b/mercurial/ui.py	Tue Oct 21 23:16:46 2014 +0900
@@ -711,11 +711,7 @@
             r = self._readline(self.label(msg, 'ui.prompt'))
             if not r:
                 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')):
+            if self.configbool('ui', 'promptecho'):
                 self.write(r, "\n")
             return r
         except EOFError:
--- a/tests/run-tests.py	Sat Oct 18 18:14:48 2014 -0500
+++ b/tests/run-tests.py	Tue Oct 21 23:16:46 2014 +0900
@@ -681,6 +681,7 @@
         hgrc.write('slash = True\n')
         hgrc.write('interactive = False\n')
         hgrc.write('mergemarkers = detailed\n')
+        hgrc.write('promptecho = True\n')
         hgrc.write('[defaults]\n')
         hgrc.write('backout = -d "0 0"\n')
         hgrc.write('commit = -d "0 0"\n')
--- a/tests/test-basic.t	Sat Oct 18 18:14:48 2014 -0500
+++ b/tests/test-basic.t	Tue Oct 21 23:16:46 2014 +0900
@@ -8,6 +8,7 @@
   ui.slash=True
   ui.interactive=False
   ui.mergemarkers=detailed
+  ui.promptecho=True
   $ hg init t
   $ cd t
 
--- a/tests/test-commandserver.t	Sat Oct 18 18:14:48 2014 -0500
+++ b/tests/test-commandserver.t	Tue Oct 21 23:16:46 2014 +0900
@@ -5,6 +5,11 @@
 #endif
   $ export PYTHONPATH
 
+typical client does not want echo-back messages, so test without it:
+
+  $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new
+  $ mv $HGRCPATH.new $HGRCPATH
+
   $ hg init repo
   $ cd repo