Chromium Code Reviews| Index: tools/push-to-trunk/common_includes.py |
| diff --git a/tools/push-to-trunk/common_includes.py b/tools/push-to-trunk/common_includes.py |
| index 55182d8019cdce85a29c1aab2e9c070bc8c5cbeb..628a30b311ea2f7cb6833515ffdd54350c3a3b94 100644 |
| --- a/tools/push-to-trunk/common_includes.py |
| +++ b/tools/push-to-trunk/common_includes.py |
| @@ -176,6 +176,7 @@ class Step(object): |
| def __init__(self, text="", requires=None): |
| self._text = text |
| self._number = -1 |
| + self._options = None |
| self._requires = requires |
| self._side_effect_handler = DEFAULT_SIDE_EFFECT_HANDLER |
| @@ -212,8 +213,13 @@ class Step(object): |
| def RunStep(self): |
| raise NotImplementedError |
| - def ReadLine(self): |
| - return self._side_effect_handler.ReadLine() |
| + def ReadLine(self, default=None): |
| + # Don't prompt in forced mode. |
| + if self._options and self._options.f and default is not None: |
| + print "%s (forced)" % default |
| + return default |
| + else: |
| + return self._side_effect_handler.ReadLine() |
| def Git(self, args="", prefix="", pipe=True): |
| return self._side_effect_handler.Command("git", args, prefix, pipe) |
| @@ -228,9 +234,14 @@ class Step(object): |
| print "Exiting" |
| raise Exception(msg) |
| + def DieInFocedMode(self, msg=""): |
|
Jakob Kummerow
2013/11/19 13:46:11
s/Foced/Forced/
Michael Achenbach
2013/11/19 15:09:37
Done.
|
| + if self._options and self._options.f: |
| + msg = msg or "Not implemented in forced mode." |
| + self.Die(msg) |
| + |
| def Confirm(self, msg): |
| print "%s [Y/n] " % msg, |
| - answer = self.ReadLine() |
| + answer = self.ReadLine(default="Y") |
| return answer == "" or answer == "Y" or answer == "y" |
| def DeleteBranch(self, name): |
| @@ -264,6 +275,8 @@ class Step(object): |
| if not os.path.exists(self._config[DOT_GIT_LOCATION]): |
| self.Die("This is not a git checkout, this script won't work for you.") |
| + # TODO(machenbach): Don't use EDITOR in forced mode as soon as script is |
| + # well tested. |
| # Cancel if EDITOR is unset or not executable. |
| if (not os.environ.get("EDITOR") or |
| Command("which", os.environ["EDITOR"]) is None): |
| @@ -335,6 +348,8 @@ class Step(object): |
| answer = "" |
| while answer != "LGTM": |
| print "> ", |
| + # TODO(machenbach): Add default="LGTM" to avoid prompt when script is |
| + # well tested and when prepare push cl has TBR flag. |
| answer = self.ReadLine() |
| if answer != "LGTM": |
| print "That was not 'LGTM'." |
| @@ -343,6 +358,7 @@ class Step(object): |
| print("Applying the patch \"%s\" failed. Either type \"ABORT<Return>\", " |
| "or resolve the conflicts, stage *all* touched files with " |
| "'git add', and type \"RESOLVED<Return>\"") |
| + self.DieInFocedMode() |
| answer = "" |
| while answer != "RESOLVED": |
| if answer == "ABORT": |
| @@ -364,8 +380,13 @@ class UploadStep(Step): |
| Step.__init__(self, "Upload for code review.") |
| def RunStep(self): |
| - print "Please enter the email address of a V8 reviewer for your patch: ", |
| - reviewer = self.ReadLine() |
| + if self._options and self._options.r: |
| + print "Using account %s for review." % self._options.r |
| + reviewer = self._options.r |
| + else: |
| + print "Please enter the email address of a V8 reviewer for your patch: ", |
| + self.DieInFocedMode("A reviewer must be specified in forced mode.") |
| + reviewer = self.ReadLine() |
| args = "cl upload -r \"%s\" --send-mail" % reviewer |
| if self.Git(args,pipe=False) is None: |
| self.Die("'git cl upload' failed, please try again.") |