Patchwork [STABLE,V2] ui: separate option to show prompt echo, enabled only in tests (issue4417)

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 21, 2014, 2:52 p.m.
Message ID <b62f0b5f6914af1d125c.1413903162@mimosa>
Download mbox | patch
Permalink /patch/6433/
State Accepted
Headers show

Comments

Yuya Nishihara - Oct. 21, 2014, 2:52 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1413901006 -32400
#      Tue Oct 21 23:16:46 2014 +0900
# Branch stable
# Node ID b62f0b5f6914af1d125cd2d713f1e2024171dda5
# Parent  c1ae0b2c1719f56b906472efea8b20ca0774c968
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.
Matt Mackall - Oct. 21, 2014, 7:04 p.m.
On Tue, 2014-10-21 at 23:52 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1413901006 -32400
> #      Tue Oct 21 23:16:46 2014 +0900
> # Branch stable
> # Node ID b62f0b5f6914af1d125cd2d713f1e2024171dda5
> # Parent  c1ae0b2c1719f56b906472efea8b20ca0774c968
> ui: separate option to show prompt echo, enabled only in tests (issue4417)

Queued for stable, thanks.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -711,11 +711,7 @@  class ui(object):
             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:
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -681,6 +681,7 @@  class Test(unittest.TestCase):
         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')
diff --git a/tests/test-basic.t b/tests/test-basic.t
--- a/tests/test-basic.t
+++ b/tests/test-basic.t
@@ -8,6 +8,7 @@  Create a repository:
   ui.slash=True
   ui.interactive=False
   ui.mergemarkers=detailed
+  ui.promptecho=True
   $ hg init t
   $ cd t
 
diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t
--- a/tests/test-commandserver.t
+++ b/tests/test-commandserver.t
@@ -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