[PATCH 7 of 8] commandserver: make getpass() request distinct from normal prompt

Yuya Nishihara yuya at tcha.org
Thu Nov 8 09:24:45 EST 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1541302729 -32400
#      Sun Nov 04 12:38:49 2018 +0900
# Node ID b7781ccecdcdf9021ea3e6cadf6039be2f8c613e
# Parent  ae086b413ab2bdf76d3207d9b6250f145a65eaf3
commandserver: make getpass() request distinct from normal prompt

Otherwise, GUI clients would have to parse the prompt text.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1467,7 +1467,7 @@ class ui(object):
             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'):
diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t
--- a/tests/test-commandserver.t
+++ b/tests/test-commandserver.t
@@ -762,10 +762,15 @@ structured message channel:
   ... 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


More information about the Mercurial-devel mailing list