Reviewers: ulan,

Message:
PTAL

Description:
Enable specification of author email in push-to-trunk.

If not specified, depot tools tend to ask for an email on the command line once
in a while, which makes the automated script hang.

BUG=

Please review this at https://codereview.chromium.org/158733002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+31, -11 lines):
  M tools/push-to-trunk/auto_roll.py
  M tools/push-to-trunk/common_includes.py
  M tools/push-to-trunk/push_to_trunk.py
  M tools/push-to-trunk/test_scripts.py


Index: tools/push-to-trunk/auto_roll.py
diff --git a/tools/push-to-trunk/auto_roll.py b/tools/push-to-trunk/auto_roll.py index ac2067c61ecc96111e07e002fdaefd9c29cf96be..63e6cf5a61c09e974c657e2e7489aba36d2878d0 100755
--- a/tools/push-to-trunk/auto_roll.py
+++ b/tools/push-to-trunk/auto_roll.py
@@ -55,6 +55,7 @@ class AutoRollOptions(CommonOptions):
     self.r = options.r
     self.c = options.c
     self.push = getattr(options, 'push', False)
+    self.author = getattr(options, 'a', None)


 class Preparation(Step):
@@ -154,14 +155,14 @@ class PushToTrunk(Step):
       print "ToT (r%d) is clean. Pushing to trunk." % latest
       self.PushTreeStatus("Tree is closed (preparing to push)")

-      # TODO(machenbach): Call push to trunk script.
       # TODO(machenbach): Update the script before calling it.
       try:
         if self._options.push:
           self._side_effect_handler.Call(
               RunPushToTrunk,
               push_to_trunk.CONFIG,
-              PushToTrunkOptions.MakeForcedOptions(self._options.r,
+              PushToTrunkOptions.MakeForcedOptions(self._options.author,
+                                                   self._options.r,
                                                    self._options.c),
               self._side_effect_handler)
       finally:
@@ -188,6 +189,8 @@ def RunAutoRoll(config,

 def BuildOptions():
   result = optparse.OptionParser()
+  result.add_option("-a", "--author", dest="a",
+                    help=("Specify the author email used for rietveld."))
   result.add_option("-c", "--chromium", dest="c",
                     help=("Specify the path to your Chromium src/ "
                           "directory to automate the V8 roll."))
@@ -207,8 +210,8 @@ def BuildOptions():
 def Main():
   parser = BuildOptions()
   (options, args) = parser.parse_args()
-  if not options.c or not options.r:
-    print "You need to specify the chromium src location and a reviewer."
+  if not options.a or not options.c or not options.r:
+    print "You need to specify author, chromium src location and reviewer."
     parser.print_help()
     return 1
   RunAutoRoll(CONFIG, AutoRollOptions(options))
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 410be8bbc529e78d251906a04f2c04dac0f6ecf6..4eb33e92b7a09b28a7cdaa6a5239a5eb4c373063 100644
--- a/tools/push-to-trunk/common_includes.py
+++ b/tools/push-to-trunk/common_includes.py
@@ -227,6 +227,7 @@ class CommonOptions(object):
     self.force_readline_defaults = not manual
     self.force_upload = not manual
     self.manual = manual
+    self.author = getattr(options, 'a', None)


 class Step(object):
@@ -468,8 +469,11 @@ class UploadStep(Step):
print "Please enter the email address of a V8 reviewer for your patch: ",
       self.DieNoManualMode("A reviewer must be specified in forced mode.")
       reviewer = self.ReadLine()
+    author_option = self._options.author
+    author = " --email \"%s\"" % author_option if author_option else ""
     force_flag = " -f" if self._options.force_upload else ""
-    args = "cl upload -r \"%s\" --send-mail%s" % (reviewer, force_flag)
+    args = ("cl upload%s -r \"%s\" --send-mail%s"
+            % (author, reviewer, force_flag))
# TODO(machenbach): Check output in forced mode. Verify that all required
     # base files were uploaded, if not retry.
     if self.Git(args, pipe=False) is None:
Index: tools/push-to-trunk/push_to_trunk.py
diff --git a/tools/push-to-trunk/push_to_trunk.py b/tools/push-to-trunk/push_to_trunk.py index 9c30570f5ebaf690cda4639ac3637fab9bcf6c87..cd7803a95883ce0b76b34c10c896a96274b3f188 100755
--- a/tools/push-to-trunk/push_to_trunk.py
+++ b/tools/push-to-trunk/push_to_trunk.py
@@ -54,7 +54,7 @@ CONFIG = {

 class PushToTrunkOptions(CommonOptions):
   @staticmethod
-  def MakeForcedOptions(reviewer, chrome_path):
+  def MakeForcedOptions(author, reviewer, chrome_path):
     """Convenience wrapper."""
     class Options(object):
       pass
@@ -65,6 +65,7 @@ class PushToTrunkOptions(CommonOptions):
     options.m = False
     options.r = reviewer
     options.c = chrome_path
+    options.a = author
     return PushToTrunkOptions(options)

   def __init__(self, options):
@@ -75,6 +76,7 @@ class PushToTrunkOptions(CommonOptions):
     self.l = options.l
     self.r = options.r
     self.c = options.c
+    self.author = getattr(options, 'a', None)

 class Preparation(Step):
   MESSAGE = "Preparation."
@@ -492,8 +494,11 @@ class UploadCL(Step):
             % (ver, self._state["svn_revision"], rev))
     if self.Git(args) is None:
       self.Die("'git commit' failed.")
+    author_option = self._options.author
+    author = " --email \"%s\"" % author_option if author_option else ""
     force_flag = " -f" if self._options.force_upload else ""
- if self.Git("cl upload --send-mail%s" % force_flag, pipe=False) is None:
+    if self.Git("cl upload%s --send-mail%s" % (author, force_flag),
+                pipe=False) is None:
       self.Die("'git cl upload' failed, please try again.")
     print "CL uploaded."

@@ -568,6 +573,8 @@ def RunPushToTrunk(config,

 def BuildOptions():
   result = optparse.OptionParser()
+  result.add_option("-a", "--author", dest="a",
+                    help=("Specify the author email used for rietveld."))
   result.add_option("-c", "--chromium", dest="c",
                     help=("Specify the path to your Chromium src/ "
                           "directory to automate the V8 roll."))
@@ -601,6 +608,9 @@ def ProcessOptions(options):
   if not options.m and not options.c:
     print "A chromium checkout (-c) is required in (semi-)automatic mode."
     return False
+  if not options.m and not options.a:
+ print "Specify your chromium.org email with -a in (semi-)automatic mode."
+    return False
   return True


Index: tools/push-to-trunk/test_scripts.py
diff --git a/tools/push-to-trunk/test_scripts.py b/tools/push-to-trunk/test_scripts.py index 90f484911d12f64a0078135c31e76e27af900442..d32c4e16c2cc2fb252992ee7c9216144bcb6a457 100644
--- a/tools/push-to-trunk/test_scripts.py
+++ b/tools/push-to-trunk/test_scripts.py
@@ -59,7 +59,7 @@ TEST_CONFIG = {
 }


-def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None,
+def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None, a=None,
                 status_password=None):
   """Convenience wrapper."""
   class Options(object):
@@ -71,6 +71,7 @@ def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None,
   options.m = m
   options.r = r
   options.c = c
+  options.a = a
   options.status_password = status_password
   return options

@@ -673,7 +674,8 @@ Performance and stability improvements on all platforms.""", commit)
         "Now working on version 3.22.6.%s\"" % review_suffix),
        " 2 files changed\n",
         CheckPreparePush],
-      ["cl upload -r \"[email protected]\" --send-mail%s" % force_flag,
+      [("cl upload --email \"[email protected]\" "
+        "-r \"[email protected]\" --send-mail%s" % force_flag),
        "done\n"],
       ["cl presubmit", "Presubmit successfull\n"],
       ["cl dcommit -f --bypass-hooks", "Closing issue\n"],
@@ -698,7 +700,8 @@ Performance and stability improvements on all platforms.""", commit)
         "(based on bleeding_edge revision r123455).\n\n"
         "[email protected]\""),
        ""],
-      ["cl upload --send-mail%s" % force_flag, ""],
+ ["cl upload --email \"[email protected]\" --send-mail%s" % force_flag,
+       ""],
       ["checkout -f some_branch", ""],
       ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""],
       ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""],
@@ -728,7 +731,7 @@ Performance and stability improvements on all platforms.""", commit)
     if force:
       self.ExpectReadline([])

-    options = MakeOptions(f=force, m=manual,
+    options = MakeOptions(f=force, m=manual, a="[email protected]",
r="[email protected]" if not manual else None,
                           c = TEST_CONFIG[CHROMIUM])
     RunPushToTrunk(TEST_CONFIG, PushToTrunkOptions(options), self)


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to