Reviewers: Jakob,

Message:
PTAL

Description:
Allow to push arbitrary revisions when pushing to trunk.

BUG=

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

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

Affected files (+39, -15 lines):
  M tools/push-to-trunk/push_to_trunk.py
  M tools/push-to-trunk/test_scripts.py


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 f167a8e4f160cd935b5ac0e29edac204c292cd47..6fcc90140ccdbd50f46ebd9b674ae3a7f91e6ea4 100755
--- a/tools/push-to-trunk/push_to_trunk.py
+++ b/tools/push-to-trunk/push_to_trunk.py
@@ -72,6 +72,18 @@ class FreshBranch(Step):
     self.GitCreateBranch(self.Config(BRANCHNAME), "svn/bleeding_edge")


+class PreparePushRevision(Step):
+  MESSAGE = "Check which revision to push."
+
+  def RunStep(self):
+    if self._options.revision:
+      self["push_hash"] = self.GitSVNFindGitHash(self._options.revision)
+    else:
+      self["push_hash"] = self.GitLog(n=1, format="%H", git_hash="HEAD")
+    if not self["push_hash"]:  # pragma: no cover
+      self.Die("Could not determine the git hash for the push.")
+
+
 class DetectLastPush(Step):
   MESSAGE = "Detect commit ID of last push to trunk."

@@ -105,6 +117,9 @@ class DetectLastPush(Step):
     self["last_push_trunk"] = last_push
# This points to the last bleeding_edge revision that went into the last
     # push.
+    # TODO(machenbach): Do we need a check to make sure we're not pushing a
+    # revision older than the last push? If we do this, the output of the
+    # current change log preparation won't make much sense.
     self["last_push_bleeding_edge"] = last_push_bleeding_edge


@@ -161,9 +176,9 @@ class PrepareChangeLog(Step):
     self["date"] = self.GetDate()
     output = "%s: Version %s\n\n" % (self["date"], self["version"])
     TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE))
- # TODO(machenbach): Retrieve the push hash also from a command-line option.
     commits = self.GitLog(format="%H",
-        git_hash="%s..HEAD" % self["last_push_bleeding_edge"])
+        git_hash="%s..%s" % (self["last_push_bleeding_edge"],
+                             self["push_hash"]))

     # Cache raw commit messages.
     commit_messages = [
@@ -219,8 +234,6 @@ class StragglerCommits(Step):
   def RunStep(self):
     self.GitSVNFetch()
     self.GitCheckout("svn/bleeding_edge")
- # TODO(machenbach): Retrieve the push hash also from a command-line option.
-    self["push_hash"] = self.GitLog(n=1, format="%H", git_hash="HEAD")


 class SquashCommits(Step):
@@ -478,6 +491,8 @@ class PushToTrunk(ScriptsBase):
                               "directory to automate the V8 roll."))
     parser.add_argument("-l", "--last-push",
help="The git commit ID of the last push to trunk.")
+    parser.add_argument("-R", "--revision",
+ help="The svn revision to push (defaults to HEAD).")

   def _ProcessOptions(self, options):  # pragma: no cover
     if not options.manual and not options.reviewer:
@@ -489,6 +504,10 @@ class PushToTrunk(ScriptsBase):
     if not options.manual and not options.author:
print "Specify your chromium.org email with -a in (semi-)automatic mode."
       return False
+    if options.revision and not int(options.revision) > 0:
+      print("The --revision flag must be a positiv integer pointing to a "
+            "valid svn revision.")
+      return False

     options.tbr_commit = not options.manual
     return True
@@ -497,6 +516,7 @@ class PushToTrunk(ScriptsBase):
     return [
       Preparation,
       FreshBranch,
+      PreparePushRevision,
       DetectLastPush,
       IncrementVersion,
       PrepareChangeLog,
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 37196de0e324134705737e97f4e21f272903cb6f..34627d9877e0f430663e1fbbb43d17542d847300 100644
--- a/tools/push-to-trunk/test_scripts.py
+++ b/tools/push-to-trunk/test_scripts.py
@@ -469,13 +469,22 @@ class ScriptTest(unittest.TestCase):
                           r"\g<space>3",
                           "//\n#define BUILD_NUMBER  321\n"))

+  def testPreparePushRevision(self):
+ # Tests the default push hash used when the --revision option is not set.
+    self.ExpectGit([
+      Git("log -1 --format=%H HEAD", "push_hash")
+    ])
+
+    self.RunStep(PushToTrunk, PreparePushRevision)
+    self.assertEquals("push_hash", self._state["push_hash"])
+
   def testPrepareChangeLog(self):
     TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile()
     self.WriteFakeVersionFile()
     TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()

     self.ExpectGit([
-      Git("log --format=%H 1234..HEAD", "rev1\nrev2\nrev3\nrev4"),
+      Git("log --format=%H 1234..push_hash", "rev1\nrev2\nrev3\nrev4"),
       Git("log -1 --format=%s rev1", "Title text 1"),
       Git("log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"),
       Git("log -1 --format=%an rev1", "auth...@chromium.org"),
@@ -499,6 +508,7 @@ class ScriptTest(unittest.TestCase):
     ])

     self._state["last_push_bleeding_edge"] = "1234"
+    self._state["push_hash"] = "push_hash"
     self._state["version"] = "3.22.5"
     self.RunStep(PushToTrunk, PrepareChangeLog)

@@ -636,13 +646,6 @@ Performance and stability improvements on all platforms."""
                  TEST_CONFIG[DEPS_FILE])
     os.environ["EDITOR"] = "vi"

-    def CheckPreparePush():
-      self.assertEquals(bleeding_edge_change_log,
-                        FileToText(TEST_CONFIG[CHANGELOG_FILE]))
-
-      version = FileToText(TEST_CONFIG[VERSION_FILE])
-      self.assertTrue(re.search(r"#define BUILD_NUMBER\s+6", version))
-
     def ResetChangeLog():
"""On 'git co -b new_branch svn/trunk', and 'git checkout -- ChangeLog',
       the ChangLog will be reset to its content on trunk."""
@@ -696,6 +699,7 @@ Performance and stability improvements on all platforms.""", commit)
       Git("branch", "  branch1\n* branch2\n"),
       Git("branch", "  branch1\n* branch2\n"),
Git("checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""),
+      Git("svn find-rev r123455", "push_hash\n"),
       Git(("log -1 --format=%H --grep="
            "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" "
            "svn/trunk"), "hash2\n"),
@@ -705,13 +709,12 @@ Performance and stability improvements on all platforms.""", commit)
       Git("svn find-rev r1234", "hash3\n"),
       Git("checkout -f hash2 -- %s" % TEST_CONFIG[VERSION_FILE], "",
           cb=self.WriteFakeVersionFile),
-      Git("log --format=%H hash3..HEAD", "rev1\n"),
+      Git("log --format=%H hash3..push_hash", "rev1\n"),
       Git("log -1 --format=%s rev1", "Log text 1.\n"),
       Git("log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"),
       Git("log -1 --format=%an rev1", "auth...@chromium.org\n"),
       Git("svn fetch", "fetch result\n"),
       Git("checkout -f svn/bleeding_edge", ""),
-      Git("log -1 --format=%H HEAD", "push_hash\n"),
       Git("diff svn/trunk push_hash", "patch content\n"),
       Git("svn find-rev push_hash", "123455\n"),
       Git("checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], "",
@@ -755,7 +758,8 @@ Performance and stability improvements on all platforms.""", commit)
     if not manual:
       self.ExpectReadline([])

-    args = ["-a", "aut...@chromium.org", "-c", TEST_CONFIG[CHROMIUM]]
+    args = ["-a", "aut...@chromium.org", "-c", TEST_CONFIG[CHROMIUM],
+            "--revision", "123455"]
     if force: args.append("-f")
     if manual: args.append("-m")
     else: args += ["-r", "revie...@chromium.org"]


--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to