Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(611)

Unified Diff: gclient_scm.py

Issue 6706007: Wrap raw_input() around a try/except to reduce the number of false-positive in breakpad (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | git_cl.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_scm.py
diff --git a/gclient_scm.py b/gclient_scm.py
index 38656431a5072ecff2a54fe4ff33583b423cd4b2..30e604dd7ebca84fef94e0d12f45ff2c19b0152d 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -8,6 +8,7 @@ import logging
import os
import posixpath
import re
+import sys
import time
import scm
@@ -49,6 +50,14 @@ class DiffFilterer(object):
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 @@ class GitWrapper(SCMWrapper):
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 @@ class GitWrapper(SCMWrapper):
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?
« no previous file with comments | « no previous file | git_cl.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698