Revision: 19482
Author:   [email protected]
Date:     Wed Feb 19 13:40:30 2014 UTC
Log:      Retrieve bleeding edge push revision from trunk commit message.

This is part of moving towards an lkgr-push script and prepares the deprecation of the prepare push commit.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/169843002
http://code.google.com/p/v8/source/detail?r=19482

Modified:
 /branches/bleeding_edge/tools/push-to-trunk/auto_roll.py
 /branches/bleeding_edge/tools/push-to-trunk/common_includes.py
 /branches/bleeding_edge/tools/push-to-trunk/push_to_trunk.py
 /branches/bleeding_edge/tools/push-to-trunk/test_scripts.py

=======================================
--- /branches/bleeding_edge/tools/push-to-trunk/auto_roll.py Wed Feb 19 11:56:48 2014 UTC +++ /branches/bleeding_edge/tools/push-to-trunk/auto_roll.py Wed Feb 19 13:40:30 2014 UTC
@@ -104,17 +104,15 @@
   MESSAGE = "Checking last V8 push to trunk."

   def RunStep(self):
-    log = self.Git("svn log -1 --oneline ChangeLog").strip()
-    match = re.match(r"^r(\d+) \| Prepare push to trunk", log)
-    if match:
-      latest = int(self["latest"])
-      last_push = int(match.group(1))
-      # TODO(machebach): This metric counts all revisions. It could be
-      # improved by counting only the revisions on bleeding_edge.
-      if latest - last_push < 10:
- # This makes sure the script doesn't push twice in a row when the cron
-        # job retries several times.
-        self.Die("Last push too recently: %d" % last_push)
+    last_push_hash = self.FindLastTrunkPush()
+    last_push = int(self.Git("svn find-rev %s" % last_push_hash).strip())
+
+    # TODO(machenbach): This metric counts all revisions. It could be
+    # improved by counting only the revisions on bleeding_edge.
+    if int(self["latest"]) - last_push < 10:
+ # This makes sure the script doesn't push twice in a row when the cron
+      # job retries several times.
+      self.Die("Last push too recently: %d" % last_push)


 class FetchLKGR(Step):
=======================================
--- /branches/bleeding_edge/tools/push-to-trunk/common_includes.py Wed Feb 19 11:56:48 2014 UTC +++ /branches/bleeding_edge/tools/push-to-trunk/common_includes.py Wed Feb 19 13:40:30 2014 UTC
@@ -460,6 +460,11 @@
     if self.Git(args) is None:
       self.WaitForResolvingConflicts(patch_file)

+  def FindLastTrunkPush(self):
+ push_pattern = "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based"
+    args = "log -1 --format=%%H --grep=\"%s\" svn/trunk" % push_pattern
+    return self.Git(args).strip()
+

 class UploadStep(Step):
   MESSAGE = "Upload for code review."
=======================================
--- /branches/bleeding_edge/tools/push-to-trunk/push_to_trunk.py Wed Feb 19 11:56:48 2014 UTC +++ /branches/bleeding_edge/tools/push-to-trunk/push_to_trunk.py Wed Feb 19 13:40:30 2014 UTC
@@ -51,6 +51,9 @@
   DEPS_FILE: "DEPS",
 }

+PUSH_MESSAGE_SUFFIX = " (based on bleeding_edge revision r%d)"
+PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$")
+

 class PushToTrunkOptions(CommonOptions):
   @staticmethod
@@ -61,6 +64,7 @@
     options = Options()
     options.s = 0
     options.l = None
+    options.b = None
     options.f = True
     options.m = False
     options.c = chrome_path
@@ -75,6 +79,7 @@
     self.l = options.l
     self.reviewer = options.reviewer
     self.c = options.c
+    self.b = getattr(options, 'b', None)
     self.author = getattr(options, 'a', None)

 class Preparation(Step):
@@ -100,16 +105,42 @@
   MESSAGE = "Detect commit ID of last push to trunk."

   def RunStep(self):
-    last_push = (self._options.l or
-                 self.Git("log -1 --format=%H ChangeLog").strip())
+    last_push_trunk = self._options.l or self.FindLastTrunkPush()
     while True:
       # Print assumed commit, circumventing git's pager.
-      print self.Git("log -1 %s" % last_push)
+      print self.Git("log -1 %s" % last_push_trunk)
if self.Confirm("Is the commit printed above the last push to trunk?"):
         break
-      args = "log -1 --format=%H %s^ ChangeLog" % last_push
-      last_push = self.Git(args).strip()
-    self["last_push"] = last_push
+      args = ("log -1 --format=%%H %s^ --grep=\"%s\""
+              % (last_push_trunk, push_pattern))
+      last_push_trunk = self.Git(args).strip()
+
+    if self._options.b:
+ # Read the bleeding edge revision of the last push from a command-line
+      # option.
+      last_push_bleeding_edge = self._options.b
+    else:
+ # Retrieve the bleeding edge revision of the last push from the text in
+      # the push commit message.
+      args = "log -1 --format=%%s %s" % last_push_trunk
+      last_push_trunk_title = self.Git(args).strip()
+ last_push_be_svn = PUSH_MESSAGE_RE.match(last_push_trunk_title).group(1)
+      if not last_push_be_svn:
+ self.Die("Could not retrieve bleeding edge revision for trunk push %s"
+                 % last_push_trunk)
+      args = "svn find-rev r%s" % last_push_be_svn
+      last_push_bleeding_edge = self.Git(args).strip()
+      if not last_push_bleeding_edge:
+ self.Die("Could not retrieve bleeding edge git hash for trunk push %s"
+                 % last_push_trunk)
+
+ # TODO(machenbach): last_push_trunk points to the svn revision on trunk. + # It is not used yet but we'll need it for retrieving the current version.
+    self["last_push_trunk"] = last_push_trunk
+ # TODO(machenbach): This currently points to the prepare push revision that + # will be deprecated soon. After the deprecation it will point to the last
+    # bleeding_edge revision that went into the last push.
+    self["last_push_bleeding_edge"] = last_push_bleeding_edge


 class PrepareChangeLog(Step):
@@ -144,7 +175,7 @@
                                      self["version"])
     TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE))

-    args = "log %s..HEAD --format=%%H" % self["last_push"]
+    args = "log %s..HEAD --format=%%H" % self["last_push_bleeding_edge"]
     commits = self.Git(args).strip()

     # Cache raw commit messages.
@@ -291,10 +322,8 @@
     # commit message.
     args = "svn find-rev %s" % self["prepare_commit_hash"]
     self["svn_revision"] = self.Git(args).strip()
-    text = MSub(r"^(Version \d+\.\d+\.\d+)$",
-                ("\\1 (based on bleeding_edge revision r%s)"
-                 % self["svn_revision"]),
-                text)
+    suffix = PUSH_MESSAGE_SUFFIX % int(self["svn_revision"])
+    text = MSub(r"^(Version \d+\.\d+\.\d+)$", "\\1%s" % suffix, text)

# Remove indentation and merge paragraphs into single long lines, keeping
     # empty lines between them.
@@ -548,6 +577,11 @@
   result = optparse.OptionParser()
   result.add_option("-a", "--author", dest="a",
                     help=("Specify the author email used for rietveld."))
+  result.add_option("-b", "--last-bleeding-edge", dest="b",
+                    help=("Manually specify the git commit ID of the last "
+ "bleeding edge revision that was pushed to trunk. "
+                          "This is used for the auto-generated ChangeLog "
+                          "entry."))
   result.add_option("-c", "--chromium", dest="c",
                     help=("Specify the path to your Chromium src/ "
                           "directory to automate the V8 roll."))
=======================================
--- /branches/bleeding_edge/tools/push-to-trunk/test_scripts.py Wed Feb 19 11:56:48 2014 UTC +++ /branches/bleeding_edge/tools/push-to-trunk/test_scripts.py Wed Feb 19 13:40:30 2014 UTC
@@ -482,7 +482,7 @@
        "Title\n\nBUG=456\nLOG=N\n\n"],
     ])

-    self._state["last_push"] = "1234"
+    self._state["last_push_bleeding_edge"] = "1234"
     self.MakeStep(PrepareChangeLog).Run()

     actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])
@@ -668,9 +668,14 @@
       ["branch", "  branch1\n* branch2\n"],
       ["branch", "  branch1\n* branch2\n"],
       ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""],
-      ["log -1 --format=%H ChangeLog", "1234\n"],
-      ["log -1 1234", "Last push ouput\n"],
-      ["log 1234..HEAD --format=%H", "rev1\n"],
+      [("log -1 --format=%H --grep="
+        "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" "
+        "svn/trunk"), "hash2\n"],
+      ["log -1 hash2", "Log message\n"],
+      ["log -1 --format=%s hash2",
+       "Version 3.4.5 (based on bleeding_edge revision r1234)\n"],
+      ["svn find-rev r1234", "hash3\n"],
+      ["log hash3..HEAD --format=%H", "rev1\n"],
       ["log -1 rev1 --format=\"%s\"", "Log text 1.\n"],
       ["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"],
       ["log -1 rev1 --format=\"%an\"", "[email protected]\n"],
@@ -796,7 +801,10 @@
       ["status -s -b -uno", "## some_branch\n"],
       ["svn fetch", ""],
       ["svn log -1 --oneline", "r100 | Text"],
-      ["svn log -1 --oneline ChangeLog", "r65 | Prepare push to trunk..."],
+      [("log -1 --format=%H --grep=\""
+        "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\""
+        " svn/trunk"), "push_hash\n"],
+      ["svn find-rev push_hash", "65"],
     ])

     auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(

--
--
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