Show More
@@ -1430,7 +1430,7 b' class ui(object):' | |||
|
1430 | 1430 | |
|
1431 | 1431 | return i |
|
1432 | 1432 | |
|
1433 | def _readline(self): | |
|
1433 | def _readline(self, prompt=' ', promptopts=None): | |
|
1434 | 1434 | # Replacing stdin/stdout temporarily is a hard problem on Python 3 |
|
1435 | 1435 | # because they have to be text streams with *no buffering*. Instead, |
|
1436 | 1436 | # we use rawinput() only if call_readline() will be invoked by |
@@ -1449,17 +1449,27 b' class ui(object):' | |||
|
1449 | 1449 | except Exception: |
|
1450 | 1450 | usereadline = False |
|
1451 | 1451 | |
|
1452 | if self._colormode == 'win32' or not usereadline: | |
|
1453 | if not promptopts: | |
|
1454 | promptopts = {} | |
|
1455 | self._writemsgnobuf(self._fmsgout, prompt, type='prompt', | |
|
1456 | **promptopts) | |
|
1457 | self.flush() | |
|
1458 | prompt = ' ' | |
|
1459 | else: | |
|
1460 | prompt = self.label(prompt, 'ui.prompt') + ' ' | |
|
1461 | ||
|
1452 | 1462 | # prompt ' ' must exist; otherwise readline may delete entire line |
|
1453 | 1463 | # - http://bugs.python.org/issue12833 |
|
1454 | 1464 | with self.timeblockedsection('stdio'): |
|
1455 | 1465 | if usereadline: |
|
1456 |
line = encoding.strtolocal(pycompat.rawinput( |
|
|
1466 | line = encoding.strtolocal(pycompat.rawinput(prompt)) | |
|
1457 | 1467 | # When stdin is in binary mode on Windows, it can cause |
|
1458 | 1468 | # raw_input() to emit an extra trailing carriage return |
|
1459 | 1469 | if pycompat.oslinesep == b'\r\n' and line.endswith(b'\r'): |
|
1460 | 1470 | line = line[:-1] |
|
1461 | 1471 | else: |
|
1462 |
self._fout.write( |
|
|
1472 | self._fout.write(pycompat.bytestr(prompt)) | |
|
1463 | 1473 | self._fout.flush() |
|
1464 | 1474 | line = self._fin.readline() |
|
1465 | 1475 | if not line: |
@@ -1481,10 +1491,8 b' class ui(object):' | |||
|
1481 | 1491 | self._writemsg(self._fmsgout, default or '', "\n", |
|
1482 | 1492 | type='promptecho') |
|
1483 | 1493 | return default |
|
1484 | self._writemsgnobuf(self._fmsgout, msg, type='prompt', **opts) | |
|
1485 | self.flush() | |
|
1486 | 1494 | try: |
|
1487 | r = self._readline() | |
|
1495 | r = self._readline(prompt=msg, promptopts=opts) | |
|
1488 | 1496 | if not r: |
|
1489 | 1497 | r = default |
|
1490 | 1498 | if self.configbool('ui', 'promptecho'): |
General Comments 0
You need to be logged in to leave comments.
Login now