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 71a037cf1637b7335add334bb7f47789c8757c1a..e0157b799cf7d0ffc45b51bdb8f0f72da8635230 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 |
Jakob Kummerow
2014/02/19 12:44:49
I hope it's on your to-do list to give all these g
Michael Achenbach
2014/02/19 13:23:03
yap
|
options.f = True |
options.m = False |
options.c = chrome_path |
@@ -75,6 +79,7 @@ class PushToTrunkOptions(CommonOptions): |
self.l = options.l |
self.reviewer = options.reviewer |
self.c = options.c |
+ self.b = getattr(options, 'b', None) |
Jakob Kummerow
2014/02/19 12:44:49
Instead of using getattr(), the default value shou
Michael Achenbach
2014/02/19 13:23:03
The whole option design will get a new face in a f
|
self.author = getattr(options, 'a', None) |
class Preparation(Step): |
@@ -100,17 +105,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" |
Jakob Kummerow
2014/02/19 12:44:49
For increased correctness, s/*/+/
Michael Achenbach
2014/02/19 13:23:03
There's no + in grep. At least on my command-line,
|
+ 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\"" |
Jakob Kummerow
2014/02/19 12:44:49
s/%H/%%H/ like above? Why has this worked before?
Michael Achenbach
2014/02/19 13:23:03
Done.
|
+ % (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) |
Jakob Kummerow
2014/02/19 12:44:49
"%d" % int(some_string) is the complicated way of
Michael Achenbach
2014/02/19 13:23:03
Done.
|
+ 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): |
@@ -134,7 +168,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() |
@@ -147,7 +181,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. |
@@ -301,9 +335,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. |
@@ -577,6 +610,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.")) |
Jakob Kummerow
2014/02/19 12:44:49
For clarification, I'd add something like "This is
Michael Achenbach
2014/02/19 13:23:03
Done.
|
result.add_option("-c", "--chromium", dest="c", |
help=("Specify the path to your Chromium src/ " |
"directory to automate the V8 roll.")) |