Wrap raw_input() around a try/except to reduce the number of false-positive in breakpad
R=dpranke@chromium.org
BUG=
TEST=
Review URL: http://codereview.chromium.org/6706007
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@80182 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_scm.py b/gclient_scm.py
index 3865643..30e604d 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -8,6 +8,7 @@
import os
import posixpath
import re
+import sys
import time
import scm
@@ -49,6 +50,14 @@
print(line)
+def ask_for_data(prompt):
+ try:
+ return raw_input(prompt)
+ except KeyboardInterrupt:
+ # Hide the exception.
+ sys.exit(1)
+
+
### SCM abstraction layer
# Factory Method for SCM wrapper creation
@@ -353,11 +362,11 @@
while True:
try:
# TODO(maruel): That can't work with --jobs.
- action = str(raw_input("Cannot fast-forward merge, attempt to "
- "rebase? (y)es / (q)uit / (s)kip : "))
+ action = ask_for_data(
+ 'Cannot fast-forward merge, attempt to rebase? '
+ '(y)es / (q)uit / (s)kip : ')
except ValueError:
- gclient_utils.Error('Invalid Character')
- continue
+ raise gclient_utils.Error('Invalid Character')
if re.match(r'yes|y', action, re.I):
self._AttemptRebase(upstream_branch, files, options,
printed_path=printed_path)
@@ -540,11 +549,11 @@
re.match(r'cannot rebase: your index contains uncommitted changes',
e.stderr)):
while True:
- rebase_action = str(raw_input("Cannot rebase because of unstaged "
- "changes.\n'git reset --hard HEAD' ?\n"
- "WARNING: destroys any uncommitted "
- "work in your current branch!"
- " (y)es / (q)uit / (s)how : "))
+ rebase_action = ask_for_data(
+ 'Cannot rebase because of unstaged changes.\n'
+ '\'git reset --hard HEAD\' ?\n'
+ 'WARNING: destroys any uncommitted work in your current branch!'
+ ' (y)es / (q)uit / (s)how : ')
if re.match(r'yes|y', rebase_action, re.I):
self._Run(['reset', '--hard', 'HEAD'], options)
# Should this be recursive?