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=
R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/169843002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19482 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1342cb8b
...@@ -104,17 +104,15 @@ class CheckLastPush(Step): ...@@ -104,17 +104,15 @@ class CheckLastPush(Step):
MESSAGE = "Checking last V8 push to trunk." MESSAGE = "Checking last V8 push to trunk."
def RunStep(self): def RunStep(self):
log = self.Git("svn log -1 --oneline ChangeLog").strip() last_push_hash = self.FindLastTrunkPush()
match = re.match(r"^r(\d+) \| Prepare push to trunk", log) last_push = int(self.Git("svn find-rev %s" % last_push_hash).strip())
if match:
latest = int(self["latest"]) # TODO(machenbach): This metric counts all revisions. It could be
last_push = int(match.group(1)) # improved by counting only the revisions on bleeding_edge.
# TODO(machebach): This metric counts all revisions. It could be if int(self["latest"]) - last_push < 10:
# improved by counting only the revisions on bleeding_edge. # This makes sure the script doesn't push twice in a row when the cron
if latest - last_push < 10: # job retries several times.
# This makes sure the script doesn't push twice in a row when the cron self.Die("Last push too recently: %d" % last_push)
# job retries several times.
self.Die("Last push too recently: %d" % last_push)
class FetchLKGR(Step): class FetchLKGR(Step):
......
...@@ -460,6 +460,11 @@ class Step(object): ...@@ -460,6 +460,11 @@ class Step(object):
if self.Git(args) is None: if self.Git(args) is None:
self.WaitForResolvingConflicts(patch_file) 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): class UploadStep(Step):
MESSAGE = "Upload for code review." MESSAGE = "Upload for code review."
......
...@@ -51,6 +51,9 @@ CONFIG = { ...@@ -51,6 +51,9 @@ CONFIG = {
DEPS_FILE: "DEPS", 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): class PushToTrunkOptions(CommonOptions):
@staticmethod @staticmethod
...@@ -61,6 +64,7 @@ class PushToTrunkOptions(CommonOptions): ...@@ -61,6 +64,7 @@ class PushToTrunkOptions(CommonOptions):
options = Options() options = Options()
options.s = 0 options.s = 0
options.l = None options.l = None
options.b = None
options.f = True options.f = True
options.m = False options.m = False
options.c = chrome_path options.c = chrome_path
...@@ -75,6 +79,7 @@ class PushToTrunkOptions(CommonOptions): ...@@ -75,6 +79,7 @@ class PushToTrunkOptions(CommonOptions):
self.l = options.l self.l = options.l
self.reviewer = options.reviewer self.reviewer = options.reviewer
self.c = options.c self.c = options.c
self.b = getattr(options, 'b', None)
self.author = getattr(options, 'a', None) self.author = getattr(options, 'a', None)
class Preparation(Step): class Preparation(Step):
...@@ -100,16 +105,42 @@ class DetectLastPush(Step): ...@@ -100,16 +105,42 @@ class DetectLastPush(Step):
MESSAGE = "Detect commit ID of last push to trunk." MESSAGE = "Detect commit ID of last push to trunk."
def RunStep(self): def RunStep(self):
last_push = (self._options.l or last_push_trunk = self._options.l or self.FindLastTrunkPush()
self.Git("log -1 --format=%H ChangeLog").strip())
while True: while True:
# Print assumed commit, circumventing git's pager. # 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?"): if self.Confirm("Is the commit printed above the last push to trunk?"):
break break
args = "log -1 --format=%H %s^ ChangeLog" % last_push args = ("log -1 --format=%%H %s^ --grep=\"%s\""
last_push = self.Git(args).strip() % (last_push_trunk, push_pattern))
self["last_push"] = last_push 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): class PrepareChangeLog(Step):
...@@ -144,7 +175,7 @@ class PrepareChangeLog(Step): ...@@ -144,7 +175,7 @@ class PrepareChangeLog(Step):
self["version"]) self["version"])
TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) 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() commits = self.Git(args).strip()
# Cache raw commit messages. # Cache raw commit messages.
...@@ -291,10 +322,8 @@ class SquashCommits(Step): ...@@ -291,10 +322,8 @@ class SquashCommits(Step):
# commit message. # commit message.
args = "svn find-rev %s" % self["prepare_commit_hash"] args = "svn find-rev %s" % self["prepare_commit_hash"]
self["svn_revision"] = self.Git(args).strip() self["svn_revision"] = self.Git(args).strip()
text = MSub(r"^(Version \d+\.\d+\.\d+)$", suffix = PUSH_MESSAGE_SUFFIX % int(self["svn_revision"])
("\\1 (based on bleeding_edge revision r%s)" text = MSub(r"^(Version \d+\.\d+\.\d+)$", "\\1%s" % suffix, text)
% self["svn_revision"]),
text)
# Remove indentation and merge paragraphs into single long lines, keeping # Remove indentation and merge paragraphs into single long lines, keeping
# empty lines between them. # empty lines between them.
...@@ -548,6 +577,11 @@ def BuildOptions(): ...@@ -548,6 +577,11 @@ def BuildOptions():
result = optparse.OptionParser() result = optparse.OptionParser()
result.add_option("-a", "--author", dest="a", result.add_option("-a", "--author", dest="a",
help=("Specify the author email used for rietveld.")) 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", result.add_option("-c", "--chromium", dest="c",
help=("Specify the path to your Chromium src/ " help=("Specify the path to your Chromium src/ "
"directory to automate the V8 roll.")) "directory to automate the V8 roll."))
......
...@@ -482,7 +482,7 @@ class ScriptTest(unittest.TestCase): ...@@ -482,7 +482,7 @@ class ScriptTest(unittest.TestCase):
"Title\n\nBUG=456\nLOG=N\n\n"], "Title\n\nBUG=456\nLOG=N\n\n"],
]) ])
self._state["last_push"] = "1234" self._state["last_push_bleeding_edge"] = "1234"
self.MakeStep(PrepareChangeLog).Run() self.MakeStep(PrepareChangeLog).Run()
actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])
...@@ -668,9 +668,14 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -668,9 +668,14 @@ Performance and stability improvements on all platforms.""", commit)
["branch", " branch1\n* branch2\n"], ["branch", " branch1\n* branch2\n"],
["branch", " branch1\n* branch2\n"], ["branch", " branch1\n* branch2\n"],
["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""],
["log -1 --format=%H ChangeLog", "1234\n"], [("log -1 --format=%H --grep="
["log -1 1234", "Last push ouput\n"], "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" "
["log 1234..HEAD --format=%H", "rev1\n"], "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=\"%s\"", "Log text 1.\n"],
["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"], ["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"],
["log -1 rev1 --format=\"%an\"", "author1@chromium.org\n"], ["log -1 rev1 --format=\"%an\"", "author1@chromium.org\n"],
...@@ -796,7 +801,10 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -796,7 +801,10 @@ Performance and stability improvements on all platforms.""", commit)
["status -s -b -uno", "## some_branch\n"], ["status -s -b -uno", "## some_branch\n"],
["svn fetch", ""], ["svn fetch", ""],
["svn log -1 --oneline", "r100 | Text"], ["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( auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment