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

Yuya Nishihara yuya at tcha.org
Tue Oct 21 09:52:42 CDT 2014


# HG changeset patch
# User Yuya Nishihara <yuya at 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.

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
 


More information about the Mercurial-devel mailing list