Reviewers: Jakob,
Message:
PTAL
Description:
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=
Please review this at https://codereview.chromium.org/169843002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+57, -16 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
cd7803a95883ce0b76b34c10c896a96274b3f188..9e1ef5fcb2a08b7d2847763f6d7542760ddbc9f8
100755
--- a/tools/push-to-trunk/push_to_trunk.py
+++ b/tools/push-to-trunk/push_to_trunk.py
@@ -51,6 +51,9 @@ CONFIG = {
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 @@ class PushToTrunkOptions(CommonOptions):
options = Options()
options.s = 0
options.l = None
+ options.b = None
options.f = True
options.m = False
options.r = reviewer
@@ -76,6 +80,7 @@ class PushToTrunkOptions(CommonOptions):
self.l = options.l
self.r = options.r
self.c = options.c
+ self.b = getattr(options, 'b', None)
self.author = getattr(options, 'a', None)
class Preparation(Step):
@@ -101,17 +106,46 @@ class DetectLastPush(Step):
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())
+ push_pattern = "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*
(based"
+ args = "log -1 --format=%%H --grep=\"%s\" svn/trunk" % push_pattern
+ last_push_trunk = self._options.l or self.Git(args).strip()
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.Persist("last_push", last_push)
- self._state["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%d" % int(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.Persist("last_push_trunk", last_push_trunk)
+ self._state["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.Persist("last_push_bleeding_edge", last_push_bleeding_edge)
+ self._state["last_push_bleeding_edge"] = last_push_bleeding_edge
class PrepareChangeLog(Step):
@@ -135,7 +169,7 @@ class PrepareChangeLog(Step):
return body
def RunStep(self):
- self.RestoreIfUnset("last_push")
+ self.RestoreIfUnset("last_push_bleeding_edge")
# These version numbers are used again later for the trunk commit.
self.ReadAndPersistVersion()
@@ -148,7 +182,7 @@ class PrepareChangeLog(Step):
self._state["build"])
TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE))
- args = "log %s..HEAD --format=%%H" % self._state["last_push"]
+ args = "log %s..HEAD --format=%%H" %
self._state["last_push_bleeding_edge"]
commits = self.Git(args).strip()
# Cache raw commit messages.
@@ -299,9 +333,8 @@ class SquashCommits(Step):
args = "svn find-rev %s" % self._state["prepare_commit_hash"]
svn_revision = self.Git(args).strip()
self.Persist("svn_revision", svn_revision)
- text = MSub(r"^(Version \d+\.\d+\.\d+)$",
- "\\1 (based on bleeding_edge revision r%s)" % svn_revision,
- text)
+ suffix = PUSH_MESSAGE_SUFFIX % int(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.
@@ -575,6 +608,9 @@ def BuildOptions():
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."))
result.add_option("-c", "--chromium", dest="c",
help=("Specify the path to your Chromium src/ "
"directory to automate the V8 roll."))
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
d32c4e16c2cc2fb252992ee7c9216144bcb6a457..a04a0d637bdb3a4bb3555787cd11b5005c57ecb8
100644
--- a/tools/push-to-trunk/test_scripts.py
+++ b/tools/push-to-trunk/test_scripts.py
@@ -478,7 +478,7 @@ class ScriptTest(unittest.TestCase):
"Title\n\nBUG=456\nLOG=N\n\n"],
])
- self.MakeStep().Persist("last_push", "1234")
+ self.MakeStep().Persist("last_push_bleeding_edge", "1234")
self.MakeStep(PrepareChangeLog).Run()
actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])
@@ -664,9 +664,14 @@ Performance and stability improvements on all
platforms.""", commit)
["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"],
--
--
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.