Reviewers: jarin,

Message:
PTAL

Description:
Let releases script retrieve information about chromium branches.

BUG=

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

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

Affected files (+74, -3 lines):
  M tools/push-to-trunk/releases.py
  M tools/push-to-trunk/test_scripts.py


Index: tools/push-to-trunk/releases.py
diff --git a/tools/push-to-trunk/releases.py b/tools/push-to-trunk/releases.py index 578a9a139681b88933443db081551d48d7169b59..8b1c99ac14deb6ec07792ab7a0e02b28f441cbb5 100755
--- a/tools/push-to-trunk/releases.py
+++ b/tools/push-to-trunk/releases.py
@@ -6,6 +6,10 @@
# This script retrieves the history of all V8 branches and trunk revisions and
 # their corresponding Chromium revisions.

+# Requires a chromium checkout with branch heads:
+# gclient sync --with_branch_heads
+# gclient fetch
+
 import argparse
 import csv
 import itertools
@@ -87,6 +91,7 @@ def BuildRevisionRanges(cr_releases):
   entry is the only one of the form R1, as there is no end range.

   cr_releases is a list of [cr_rev, v8_rev] reverse-sorted by cr_rev.
+ cr_rev either refers to a chromium svn revision or a chromium branch number.
   """
   range_lists = {}
   cr_releases = FilterDuplicatesAndReverse(cr_releases)
@@ -174,6 +179,8 @@ class RetrieveV8Releases(Step):
       "patches_merged": patches,
       # Default for easier output formatting.
       "chromium_revision": "",
+      # Default for easier output formatting.
+      "chromium_branch": "",
# Link to the CL on code review. Trunk pushes are not uploaded, so this
       # field will be populated below with the recent roll CL link.
       "review_link": MatchSafe(REVIEW_LINK_RE.search(body)),
@@ -326,6 +333,64 @@ class RetrieveChromiumV8Releases(Step):
     for revision, ranges in all_ranges.iteritems():
       trunk_dict.get(revision, {})["chromium_revision"] = ranges

+
+# TODO(machenbach): Unify common code with method above.
+class RietrieveChromiumBranches(Step):
+  MESSAGE = "Retrieve Chromium branch information."
+  REQUIRES = "chrome_path"
+
+  def RunStep(self):
+    os.chdir(self["chrome_path"])
+
+ trunk_releases = filter(lambda r: r["branch"] == "trunk", self["releases"])
+    if not trunk_releases:  # pragma: no cover
+      print "No trunk releases detected. Skipping chromium history."
+      return True
+
+    oldest_v8_rev = int(trunk_releases[-1]["revision"])
+
+    # Filter out irrelevant branches.
+    branches = filter(lambda r: re.match(r"branch-heads/\d+", r),
+                      self.GitRemotes())
+
+    # Transform into pure branch numbers.
+ branches = map(lambda r: int(re.match(r"branch-heads/(\d+)", r).group(1)),
+                   branches)
+
+    branches = sorted(branches, reverse=True)
+
+    cr_branches = []
+    try:
+      for branch in branches:
+        if not self.GitCheckoutFileSafe(self._config[DEPS_FILE],
+                                        "branch-heads/%d" % branch):
+          break  # pragma: no cover
+        deps = FileToText(self.Config(DEPS_FILE))
+        match = DEPS_RE.search(deps)
+        if match:
+          v8_rev = match.group(1)
+          cr_branches.append([str(branch), v8_rev])
+
+ # Stop after reaching beyond the last v8 revision we want to update.
+          # We need a small buffer for possible revert/reland frenzies.
+          # TODO(machenbach): Subtraction is not git friendly.
+          if int(v8_rev) < oldest_v8_rev - 100:
+            break  # pragma: no cover
+
+    # Allow Ctrl-C interrupt.
+    except (KeyboardInterrupt, SystemExit):  # pragma: no cover
+      pass
+
+    # Clean up.
+    self.GitCheckoutFileSafe(self._config[DEPS_FILE], "HEAD")
+
+    # Add the chromium branches to the v8 trunk releases.
+    all_ranges = BuildRevisionRanges(cr_branches)
+    trunk_dict = dict((r["revision"], r) for r in trunk_releases)
+    for revision, ranges in all_ranges.iteritems():
+      trunk_dict.get(revision, {})["chromium_branch"] = ranges
+
+
 class SwitchV8(Step):
   MESSAGE = "Returning to V8 checkout."
   REQUIRES = "chrome_path"
@@ -388,6 +453,7 @@ class Releases(ScriptsBase):
       SwitchChromium,
       UpdateChromiumCheckout,
       RetrieveChromiumV8Releases,
+      RietrieveChromiumBranches,
       SwitchV8,
       CleanUp,
       WriteOutput,
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 108d1519e0ef8b4740a713167b4b81b81eb3ca3b..a55a9bf1afffecd59f3faa41131952bd256e6424 100644
--- a/tools/push-to-trunk/test_scripts.py
+++ b/tools/push-to-trunk/test_scripts.py
@@ -1228,6 +1228,11 @@ LOG=N
       Git("svn find-rev c_hash2", "4567"),
       Git("checkout -f HEAD -- %s" % TEST_CONFIG[DEPS_FILE], "",
           cb=ResetDEPS(567)),
+      Git("branch -r", " weird/123\n  branch-heads/7\n"),
+      Git("checkout -f branch-heads/7 -- %s" % TEST_CONFIG[DEPS_FILE], "",
+          cb=ResetDEPS(345)),
+      Git("checkout -f HEAD -- %s" % TEST_CONFIG[DEPS_FILE], "",
+          cb=ResetDEPS(567)),
       Git("checkout -f master", ""),
       Git("branch -D %s" % TEST_CONFIG[BRANCHNAME], ""),
       Git("checkout -f some_branch", ""),
@@ -1250,15 +1255,15 @@ LOG=N
     expected_json = [
       {"bleeding_edge": "", "patches_merged": "", "version": "3.22.3",
        "chromium_revision": "4567", "branch": "trunk", "revision": "345",
-       "review_link": "", "date": "",
+       "review_link": "", "date": "", "chromium_branch": "7",
        "revision_link": "https://code.google.com/p/v8/source/detail?r=345"},
       {"patches_merged": "", "bleeding_edge": "", "version": "3.21.2",
        "chromium_revision": "", "branch": "3.21", "revision": "123",
-       "review_link": "", "date": "03:15",
+       "review_link": "", "date": "03:15", "chromium_branch": "",
        "revision_link": "https://code.google.com/p/v8/source/detail?r=123"},
       {"patches_merged": "12", "bleeding_edge": "", "version": "3.3.1.1",
        "chromium_revision": "", "branch": "3.3", "revision": "234",
-       "review_link": "fake.com", "date": "18:15",
+       "review_link": "fake.com", "date": "18:15", "chromium_branch": "",
        "revision_link": "https://code.google.com/p/v8/source/detail?r=234"},
     ]
     self.assertEquals(expected_json, json.loads(FileToText(json_output)))


--
--
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/d/optout.

Reply via email to