changeset 22783:524b786bd54f

ui: disable echo back of prompt input if ui is set to non-tty purposely 9ab18a912c44 is nice for test output, but it also affects command-server channel. Command-server client shouldn't receive echo-back message, which makes it harder to parse the output.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 08 Oct 2014 20:51:01 +0900
parents a1eb21f5caea
children 0f4e655136ef
files mercurial/ui.py tests/test-commandserver.t
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Fri Oct 03 18:48:09 2014 -0700
+++ b/mercurial/ui.py	Wed Oct 08 20:51:01 2014 +0900
@@ -684,7 +684,9 @@
                 r = default
             # sometimes self.interactive disagrees with isatty,
             # show response provided on stdin when simulating
-            if not util.isatty(self.fin):
+            # but commandserver
+            if (not util.isatty(self.fin)
+                and not self.configbool('ui', 'nontty')):
                 self.write(r, "\n")
             return r
         except EOFError:
--- a/tests/test-commandserver.t	Fri Oct 03 18:48:09 2014 -0700
+++ b/tests/test-commandserver.t	Wed Oct 08 20:51:01 2014 +0900
@@ -497,6 +497,9 @@
   > @command("debuggetpass", norepo=True)
   > def debuggetpass(ui):
   >     ui.write("%s\\n" % ui.getpass())
+  > @command("debugprompt", norepo=True)
+  > def debugprompt(ui):
+  >     ui.write("%s\\n" % ui.prompt("prompt:"))
   > EOF
   $ cat <<EOF >> .hg/hgrc
   > [extensions]
@@ -511,8 +514,13 @@
   ...     runcommand(server, ['debuggetpass', '--config',
   ...                         'ui.interactive=True'],
   ...                input=cStringIO.StringIO('1234\n'))
+  ...     runcommand(server, ['debugprompt', '--config',
+  ...                         'ui.interactive=True'],
+  ...                input=cStringIO.StringIO('5678\n'))
   *** runcommand debuggetpass --config ui.interactive=True
   password: 1234
+  *** runcommand debugprompt --config ui.interactive=True
+  prompt: 5678
 
 
 start without repository: