Refactoring: Remove more legacy from release scripts.

- Remove an unused feature that allowed to check for required
  data before each script step.
- Use a relative path to the version file. In the production
  environment, this will point to the cwd/version_file, while
  in the test environment it is fake_cwd/version_file.

TBR=tandrii@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24140 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9583236d
......@@ -11,7 +11,6 @@ from common_includes import *
CONFIG = {
BRANCHNAME: "auto-tag-v8",
PERSISTFILE_BASENAME: "/tmp/v8-auto-tag-tempfile",
VERSION_FILE: "src/version.cc",
}
......@@ -54,7 +53,7 @@ class GetOldestUntaggedVersion(Step):
format="%H", grep="\\[Auto\\-roll\\] Bump up version to").splitlines():
# Get the version.
if not self.GitCheckoutFileSafe(self._config[VERSION_FILE], git_hash):
if not self.GitCheckoutFileSafe(VERSION_FILE, git_hash):
continue
self.ReadAndPersistVersion()
......@@ -65,7 +64,7 @@ class GetOldestUntaggedVersion(Step):
version = version[:-2]
# Clean up checked-out version file.
self.GitCheckoutFileSafe(self._config[VERSION_FILE], "HEAD")
self.GitCheckoutFileSafe(VERSION_FILE, "HEAD")
if version in tags:
if self["candidate"]:
......
......@@ -28,7 +28,6 @@ from common_includes import *
CONFIG = {
PERSISTFILE_BASENAME: "/tmp/v8-bump-up-version-tempfile",
PATCH_FILE: "/tmp/v8-bump-up-version-tempfile-patch-file",
VERSION_FILE: "src/version.cc",
}
VERSION_BRANCH = "auto-bump-up-version"
......@@ -73,7 +72,7 @@ class LastChangeBailout(Step):
MESSAGE = "Stop script if the last change modified the version."
def RunStep(self):
if self._config[VERSION_FILE] in self.GitChangedFiles(self["latest"]):
if VERSION_FILE in self.GitChangedFiles(self["latest"]):
print "Stop due to recent version change."
return True
......@@ -122,7 +121,7 @@ class LKGRVersionUpToDateBailout(Step):
def RunStep(self):
# If a version-change commit becomes the lkgr, don't bump up the version
# again.
if self._config[VERSION_FILE] in self.GitChangedFiles(self["lkgr"]):
if VERSION_FILE in self.GitChangedFiles(self["lkgr"]):
print "Stop because the lkgr is a version change itself."
return True
......@@ -194,7 +193,7 @@ class ChangeVersion(Step):
def RunStep(self):
self.GitCreateBranch(VERSION_BRANCH, "bleeding_edge")
self.SetVersion(self.Config(VERSION_FILE), "new_")
self.SetVersion(os.path.join(self.default_cwd, VERSION_FILE), "new_")
try:
msg = "[Auto-roll] Bump up version to %s" % self["new_version"]
......
......@@ -47,12 +47,13 @@ from git_recipes import GitFailedException
PERSISTFILE_BASENAME = "PERSISTFILE_BASENAME"
BRANCHNAME = "BRANCHNAME"
VERSION_FILE = "VERSION_FILE"
CHANGELOG_FILE = "CHANGELOG_FILE"
CHANGELOG_ENTRY_FILE = "CHANGELOG_ENTRY_FILE"
COMMITMSG_FILE = "COMMITMSG_FILE"
PATCH_FILE = "PATCH_FILE"
VERSION_FILE = os.path.join("src", "version.cc")
# V8 base directory.
DEFAULT_CWD = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
......@@ -262,9 +263,8 @@ class NoRetryException(Exception):
class Step(GitRecipesMixin):
def __init__(self, text, requires, number, config, state, options, handler):
def __init__(self, text, number, config, state, options, handler):
self._text = text
self._requires = requires
self._number = number
self._config = config
self._state = state
......@@ -298,10 +298,6 @@ class Step(GitRecipesMixin):
if not self._state and os.path.exists(state_file):
self._state.update(json.loads(FileToText(state_file)))
# Skip step if requirement is not met.
if self._requires and not self._state.get(self._requires):
return
print ">>> Step %d: %s" % (self._number, self._text)
try:
return self.RunStep()
......@@ -457,7 +453,7 @@ class Step(GitRecipesMixin):
if match:
value = match.group(1)
self["%s%s" % (prefix, var_name)] = value
for line in LinesInFile(self._config[VERSION_FILE]):
for line in LinesInFile(os.path.join(self.default_cwd, VERSION_FILE)):
for (var_name, def_name) in [("major", "MAJOR_VERSION"),
("minor", "MINOR_VERSION"),
("build", "BUILD_NUMBER"),
......@@ -604,12 +600,8 @@ def MakeStep(step_class=Step, number=0, state=None, config=None,
message = step_class.MESSAGE
except AttributeError:
message = step_class.__name__
try:
requires = step_class.REQUIRES
except AttributeError:
requires = None
return step_class(message, requires, number=number, config=config,
return step_class(message, number=number, config=config,
state=state, options=options,
handler=side_effect_handler)
......
......@@ -41,7 +41,6 @@ CONFIG = {
PERSISTFILE_BASENAME: "/tmp/v8-merge-to-branch-tempfile",
ALREADY_MERGING_SENTINEL_FILE:
"/tmp/v8-merge-to-branch-tempfile-already-merging",
VERSION_FILE: "src/version.cc",
TEMPORARY_PATCH_FILE: "/tmp/v8-prepare-merge-tempfile-temporary-patch",
COMMITMSG_FILE: "/tmp/v8-prepare-merge-tempfile-commitmsg",
COMMIT_HASHES_FILE: "/tmp/v8-merge-to-branch-tempfile-PATCH_COMMIT_HASHES",
......@@ -184,14 +183,14 @@ class IncrementVersion(Step):
if self.Confirm("Automatically increment PATCH_LEVEL? (Saying 'n' will "
"fire up your EDITOR on %s so you can make arbitrary "
"changes. When you're done, save the file and exit your "
"EDITOR.)" % self.Config(VERSION_FILE)):
text = FileToText(self.Config(VERSION_FILE))
"EDITOR.)" % VERSION_FILE):
text = FileToText(os.path.join(self.default_cwd, VERSION_FILE))
text = MSub(r"(?<=#define PATCH_LEVEL)(?P<space>\s+)\d*$",
r"\g<space>%s" % new_patch,
text)
TextToFile(text, self.Config(VERSION_FILE))
TextToFile(text, os.path.join(self.default_cwd, VERSION_FILE))
else:
self.Editor(self.Config(VERSION_FILE))
self.Editor(os.path.join(self.default_cwd, VERSION_FILE))
self.ReadAndPersistVersion("new_")
self["version"] = "%s.%s.%s.%s" % (self["new_major"],
self["new_minor"],
......
......@@ -40,7 +40,6 @@ CONFIG = {
BRANCHNAME: "prepare-push",
TRUNKBRANCH: "trunk-push",
PERSISTFILE_BASENAME: "/tmp/v8-push-to-trunk-tempfile",
VERSION_FILE: "src/version.cc",
CHANGELOG_FILE: "ChangeLog",
CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry",
PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch-file",
......@@ -50,7 +49,6 @@ CONFIG = {
PUSH_MESSAGE_SUFFIX = " (based on bleeding_edge revision r%d)"
PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$")
class Preparation(Step):
MESSAGE = "Preparation."
......@@ -130,7 +128,7 @@ class GetCurrentBleedingEdgeVersion(Step):
MESSAGE = "Get latest bleeding edge version."
def RunStep(self):
self.GitCheckoutFile(self.Config(VERSION_FILE), "svn/bleeding_edge")
self.GitCheckoutFile(VERSION_FILE, "svn/bleeding_edge")
# Store latest version.
self.ReadAndPersistVersion("latest_")
......@@ -143,7 +141,7 @@ class IncrementVersion(Step):
def RunStep(self):
# Retrieve current version from last trunk push.
self.GitCheckoutFile(self.Config(VERSION_FILE), self["last_push_trunk"])
self.GitCheckoutFile(VERSION_FILE, self["last_push_trunk"])
self.ReadAndPersistVersion()
self["trunk_version"] = self.ArrayToVersion("")
......@@ -154,21 +152,21 @@ class IncrementVersion(Step):
if SortingKey(self["trunk_version"]) < SortingKey(self["latest_version"]):
# If the version on bleeding_edge is newer than on trunk, use it.
self.GitCheckoutFile(self.Config(VERSION_FILE), "svn/bleeding_edge")
self.GitCheckoutFile(VERSION_FILE, "svn/bleeding_edge")
self.ReadAndPersistVersion()
if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will "
"fire up your EDITOR on %s so you can make arbitrary "
"changes. When you're done, save the file and exit your "
"EDITOR.)" % self.Config(VERSION_FILE))):
"EDITOR.)" % VERSION_FILE)):
text = FileToText(self.Config(VERSION_FILE))
text = FileToText(os.path.join(self.default_cwd, VERSION_FILE))
text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
r"\g<space>%s" % str(int(self["build"]) + 1),
text)
TextToFile(text, self.Config(VERSION_FILE))
TextToFile(text, os.path.join(self.default_cwd, VERSION_FILE))
else:
self.Editor(self.Config(VERSION_FILE))
self.Editor(os.path.join(self.default_cwd, VERSION_FILE))
# Variables prefixed with 'new_' contain the new version numbers for the
# ongoing trunk push.
......@@ -336,8 +334,8 @@ class SetVersion(Step):
def RunStep(self):
# The version file has been modified by the patch. Reset it to the version
# on trunk and apply the correct version.
self.GitCheckoutFile(self.Config(VERSION_FILE), "svn/trunk")
self.SetVersion(self.Config(VERSION_FILE), "new_")
self.GitCheckoutFile(VERSION_FILE, "svn/trunk")
self.SetVersion(os.path.join(self.default_cwd, VERSION_FILE), "new_")
class CommitTrunk(Step):
......@@ -356,7 +354,7 @@ class SanityCheck(Step):
# prepare push process.
if not self.Confirm("Please check if your local checkout is sane: Inspect "
"%s, compile, run tests. Do you want to commit this new trunk "
"revision to the repository?" % self.Config(VERSION_FILE)):
"revision to the repository?" % VERSION_FILE):
self.Die("Execution canceled.") # pragma: no cover
......
......@@ -25,7 +25,6 @@ CHROMIUM = "CHROMIUM"
CONFIG = {
BRANCHNAME: "retrieve-v8-releases",
PERSISTFILE_BASENAME: "/tmp/v8-releases-tempfile",
VERSION_FILE: "src/version.cc",
}
# Expression for retrieving the bleeding edge revision from a commit message.
......@@ -206,11 +205,11 @@ class RetrieveV8Releases(Step):
releases = []
try:
for git_hash in self.GitLog(format="%H").splitlines():
if self._config[VERSION_FILE] not in self.GitChangedFiles(git_hash):
if VERSION_FILE not in self.GitChangedFiles(git_hash):
continue
if self.ExceedsMax(releases):
break # pragma: no cover
if not self.GitCheckoutFileSafe(self._config[VERSION_FILE], git_hash):
if not self.GitCheckoutFileSafe(VERSION_FILE, git_hash):
break # pragma: no cover
release, patch_level = self.GetRelease(git_hash, branch)
......@@ -228,7 +227,7 @@ class RetrieveV8Releases(Step):
pass
# Clean up checked-out version file.
self.GitCheckoutFileSafe(self._config[VERSION_FILE], "HEAD")
self.GitCheckoutFileSafe(VERSION_FILE, "HEAD")
return releases
def RunStep(self):
......
This diff is collapsed.
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