changeset 40593:6f0941f4a184

commandserver: make getpass() request distinct from normal prompt Otherwise, GUI clients would have to parse the prompt text.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 04 Nov 2018 12:38:49 +0900
parents 83e571ea06a9
children 234c2d8c9e48
files mercurial/ui.py tests/test-commandserver.t
diffstat 2 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Sun Nov 04 12:17:20 2018 +0900
+++ b/mercurial/ui.py	Sun Nov 04 12:38:49 2018 +0900
@@ -1464,7 +1464,7 @@
             return default
         try:
             self._writemsg(self._fmsgerr, prompt or _('password: '),
-                           type='prompt')
+                           type='prompt', password=True)
             # disable getpass() only if explicitly specified. it's still valid
             # to interact with tty even if fin is not a tty.
             with self.timeblockedsection('stdio'):
--- a/tests/test-commandserver.t	Sun Nov 04 12:17:20 2018 +0900
+++ b/tests/test-commandserver.t	Sun Nov 04 12:38:49 2018 +0900
@@ -762,10 +762,15 @@
   ... def prompt(server):
   ...     readchannel(server)
   ...     interactive = [b'--config', b'ui.interactive=True']
+  ...     runcommand(server, [b'debuggetpass'] + interactive,
+  ...                input=stringio(b'1234\n'))
   ...     runcommand(server, [b'debugprompt'] + interactive,
   ...                input=stringio(b'5678\n'))
   ...     runcommand(server, [b'debugpromptchoice'] + interactive,
   ...                input=stringio(b'n\n'))
+  *** runcommand debuggetpass --config ui.interactive=True
+  message: '\xa3DdataJpassword: Hpassword\xf5DtypeFprompt'
+  1234
   *** runcommand debugprompt --config ui.interactive=True
   message: '\xa3DdataGprompt:GdefaultAyDtypeFprompt'
    5678