Show More
@@ -381,6 +381,10 b' def getfstype(dirpath):' | |||
|
381 | 381 | return getattr(osutil, 'getfstype', lambda x: None)(dirpath) |
|
382 | 382 | |
|
383 | 383 | |
|
384 | def get_password(): | |
|
385 | return encoding.strtolocal(getpass.getpass('')) | |
|
386 | ||
|
387 | ||
|
384 | 388 | def setbinary(fd): |
|
385 | 389 | pass |
|
386 | 390 |
@@ -11,7 +11,6 b' import collections' | |||
|
11 | 11 | import contextlib |
|
12 | 12 | import datetime |
|
13 | 13 | import errno |
|
14 | import getpass | |
|
15 | 14 | import inspect |
|
16 | 15 | import os |
|
17 | 16 | import re |
@@ -1779,7 +1778,7 b' class ui(object):' | |||
|
1779 | 1778 | raise EOFError |
|
1780 | 1779 | return l.rstrip(b'\n') |
|
1781 | 1780 | else: |
|
1782 |
return |
|
|
1781 | return util.get_password() | |
|
1783 | 1782 | except EOFError: |
|
1784 | 1783 | raise error.ResponseExpected() |
|
1785 | 1784 |
@@ -106,6 +106,7 b' copymode = platform.copymode' | |||
|
106 | 106 | expandglobs = platform.expandglobs |
|
107 | 107 | getfsmountpoint = platform.getfsmountpoint |
|
108 | 108 | getfstype = platform.getfstype |
|
109 | get_password = platform.get_password | |
|
109 | 110 | groupmembers = platform.groupmembers |
|
110 | 111 | groupname = platform.groupname |
|
111 | 112 | isexec = platform.isexec |
@@ -194,6 +194,28 b' def _isatty(fp):' | |||
|
194 | 194 | return False |
|
195 | 195 | |
|
196 | 196 | |
|
197 | def get_password(): | |
|
198 | """Prompt for password with echo off, using Windows getch(). | |
|
199 | ||
|
200 | This shouldn't be called directly- use ``ui.getpass()`` instead, which | |
|
201 | checks if the session is interactive first. | |
|
202 | """ | |
|
203 | pw = "" | |
|
204 | while True: | |
|
205 | c = msvcrt.getwch() | |
|
206 | if c == '\r' or c == '\n': | |
|
207 | break | |
|
208 | if c == '\003': | |
|
209 | raise KeyboardInterrupt | |
|
210 | if c == '\b': | |
|
211 | pw = pw[:-1] | |
|
212 | else: | |
|
213 | pw = pw + c | |
|
214 | msvcrt.putwch('\r') | |
|
215 | msvcrt.putwch('\n') | |
|
216 | return encoding.strtolocal(pw) | |
|
217 | ||
|
218 | ||
|
197 | 219 | class winstdout(object): |
|
198 | 220 | """Some files on Windows misbehave. |
|
199 | 221 |
General Comments 0
You need to be logged in to leave comments.
Login now