Skip to content

Commit 6b602a2

Browse files
seraphiregitster
authored andcommitted
git-p4: rewrite prompt to be Windows compatible
The existing function prompt(prompt_text) does not work correctly when run on Windows 10 bash terminal when launched from the sourcetree GUI application. The stdout is not flushed properly so the prompt text is not displayed to the user until the next flush of stdout, which is quite confusing. Change this method by: * Adding flush to stderr, stdout, and stdin * Use readline from sys.stdin instead of raw_input. The existing strip().lower() are retained. Signed-off-by: Ben Keene <seraphire@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent d0654dc commit 6b602a2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

git-p4.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ def prompt(prompt_text):
175175
"""
176176
choices = set(m.group(1) for m in re.finditer(r"\[(.)\]", prompt_text))
177177
while True:
178-
response = raw_input(prompt_text).strip().lower()
178+
sys.stderr.flush()
179+
sys.stdout.write(prompt_text)
180+
sys.stdout.flush()
181+
response=sys.stdin.readline().strip().lower()
179182
if not response:
180183
continue
181184
response = response[0]

0 commit comments

Comments
 (0)