comparison mercurial/ui.py @ 15053:17ffb30d9174 stable

ui: pass ' ' to raw_input when prompting This is a workaround for calling ui.prompt(...), typing some character then hitting backspace which causes the entire line to delete rather than just the one character. This was seen on Debian using gnome-terminal. (credits to Mads for the idea) Python bug can be found here: http://bugs.python.org/issue12833
author Idan Kamara <idankk86@gmail.com>
date Thu, 25 Aug 2011 22:06:03 +0300
parents 68b5d7005cca
children 7c03e3b1b858 0fc95f5cea57
comparison
equal deleted inserted replaced
15052:06c3667c259c 15053:17ffb30d9174
542 self.write(prompt) 542 self.write(prompt)
543 543
544 # instead of trying to emulate raw_input, swap self.fin with sys.stdin 544 # instead of trying to emulate raw_input, swap self.fin with sys.stdin
545 old = sys.stdin 545 old = sys.stdin
546 sys.stdin = self.fin 546 sys.stdin = self.fin
547 line = raw_input() 547 line = raw_input(' ')
548 sys.stdin = old 548 sys.stdin = old
549 549
550 # When stdin is in binary mode on Windows, it can cause 550 # When stdin is in binary mode on Windows, it can cause
551 # raw_input() to emit an extra trailing carriage return 551 # raw_input() to emit an extra trailing carriage return
552 if os.linesep == '\r\n' and line and line[-1] == '\r': 552 if os.linesep == '\r\n' and line and line[-1] == '\r':
559 """ 559 """
560 if not self.interactive(): 560 if not self.interactive():
561 self.write(msg, ' ', default, "\n") 561 self.write(msg, ' ', default, "\n")
562 return default 562 return default
563 try: 563 try:
564 r = self._readline(self.label(msg, 'ui.prompt') + ' ') 564 r = self._readline(self.label(msg, 'ui.prompt'))
565 if not r: 565 if not r:
566 return default 566 return default
567 return r 567 return r
568 except EOFError: 568 except EOFError:
569 raise util.Abort(_('response expected')) 569 raise util.Abort(_('response expected'))