Commit 90b6fc7f authored by Michael Achenbach's avatar Michael Achenbach

Switch release scripts to pure git.

This removes all svn features from the release scripts.

This also fixes a bug in commit position retrieval.

BUG=chromium:410721
LOG=n
R=tandrii@chromium.org
TBR=tandrii@chromium.org
TEST=script_test.py

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

Cr-Commit-Position: refs/heads/master@{#25307}
parent 5b509a71
...@@ -112,12 +112,6 @@ class PushToCandidates(Step): ...@@ -112,12 +112,6 @@ class PushToCandidates(Step):
"--force", "--force",
] ]
if self._options.svn:
args.extend(["--svn", self._options.svn])
if self._options.svn_config:
args.extend(["--svn-config", self._options.svn_config])
if self._options.vc_interface:
args.extend(["--vc-interface", self._options.vc_interface])
if self._options.work_dir: if self._options.work_dir:
args.extend(["--work-dir", self._options.work_dir]) args.extend(["--work-dir", self._options.work_dir])
......
...@@ -198,13 +198,10 @@ class ChangeVersion(Step): ...@@ -198,13 +198,10 @@ class ChangeVersion(Step):
msg = "[Auto-roll] Bump up version to %s" % self["new_version"] msg = "[Auto-roll] Bump up version to %s" % self["new_version"]
self.GitCommit("%s\n\nTBR=%s" % (msg, self._options.author), self.GitCommit("%s\n\nTBR=%s" % (msg, self._options.author),
author=self._options.author) author=self._options.author)
if self._options.svn: self.GitUpload(author=self._options.author,
self.SVNCommit("branches/bleeding_edge", msg) force=self._options.force_upload,
else: bypass_hooks=True)
self.GitUpload(author=self._options.author, self.GitCLLand()
force=self._options.force_upload,
bypass_hooks=True)
self.GitDCommit()
print "Successfully changed the version." print "Successfully changed the version."
finally: finally:
# Clean up. # Clean up.
......
...@@ -272,12 +272,6 @@ class VCInterface(object): ...@@ -272,12 +272,6 @@ class VCInterface(object):
def GetBranches(self): def GetBranches(self):
raise NotImplementedError() raise NotImplementedError()
def GitSvn(self, hsh, branch=""):
raise NotImplementedError()
def SvnGit(self, rev, branch=""):
raise NotImplementedError()
def MasterBranch(self): def MasterBranch(self):
raise NotImplementedError() raise NotImplementedError()
...@@ -299,9 +293,6 @@ class VCInterface(object): ...@@ -299,9 +293,6 @@ class VCInterface(object):
def CLLand(self): def CLLand(self):
raise NotImplementedError() raise NotImplementedError()
# TODO(machenbach): There is some svn knowledge in this interface. In svn,
# tag and commit are different remote commands, while in git we would commit
# and tag locally and then push/land in one unique step.
def Tag(self, tag, remote, message): def Tag(self, tag, remote, message):
"""Sets a tag for the current commit. """Sets a tag for the current commit.
...@@ -310,68 +301,12 @@ class VCInterface(object): ...@@ -310,68 +301,12 @@ class VCInterface(object):
raise NotImplementedError() raise NotImplementedError()
class GitSvnInterface(VCInterface): class GitInterface(VCInterface):
def Pull(self):
self.step.GitSVNRebase()
def Fetch(self):
self.step.GitSVNFetch()
def GetTags(self):
# Get remote tags.
tags = filter(lambda s: re.match(r"^svn/tags/[\d+\.]+$", s),
self.step.GitRemotes())
# Remove 'svn/tags/' prefix.
return map(lambda s: s[9:], tags)
def GetBranches(self):
# Get relevant remote branches, e.g. "svn/3.25".
branches = filter(lambda s: re.match(r"^svn/\d+\.\d+$", s),
self.step.GitRemotes())
# Remove 'svn/' prefix.
return map(lambda s: s[4:], branches)
def GitSvn(self, hsh, branch=""):
return self.step.GitSVNFindSVNRev(hsh, branch)
def SvnGit(self, rev, branch=""):
return self.step.GitSVNFindGitHash(rev, branch)
def MasterBranch(self):
return "bleeding_edge"
def CandidateBranch(self):
return "trunk"
def RemoteMasterBranch(self):
return "svn/bleeding_edge"
def RemoteCandidateBranch(self):
return "svn/trunk"
def RemoteBranch(self, name):
return "svn/%s" % name
def Land(self):
self.step.GitSVNDCommit()
def CLLand(self):
self.step.GitDCommit()
def Tag(self, tag, remote, _):
self.step.GitSVNFetch()
self.step.Git("rebase %s" % remote)
self.step.GitSVNTag(tag)
class GitTagsOnlyMixin(VCInterface):
def Pull(self): def Pull(self):
self.step.GitPull() self.step.GitPull()
def Fetch(self): def Fetch(self):
self.step.Git("fetch") self.step.Git("fetch")
self.step.GitSVNFetch()
def GetTags(self): def GetTags(self):
return self.step.Git("tag").strip().splitlines() return self.step.Git("tag").strip().splitlines()
...@@ -401,9 +336,6 @@ class GitTagsOnlyMixin(VCInterface): ...@@ -401,9 +336,6 @@ class GitTagsOnlyMixin(VCInterface):
return "origin/%s" % name return "origin/%s" % name
return "branch-heads/%s" % name return "branch-heads/%s" % name
def PushRef(self, ref):
self.step.Git("push origin %s" % ref)
def Tag(self, tag, remote, message): def Tag(self, tag, remote, message):
# Wait for the commit to appear. Assumes unique commit message titles (this # Wait for the commit to appear. Assumes unique commit message titles (this
# is the case for all automated merge and push commits - also no title is # is the case for all automated merge and push commits - also no title is
...@@ -422,42 +354,14 @@ class GitTagsOnlyMixin(VCInterface): ...@@ -422,42 +354,14 @@ class GitTagsOnlyMixin(VCInterface):
"git updater is lagging behind?") "git updater is lagging behind?")
self.step.Git("tag %s %s" % (tag, commit)) self.step.Git("tag %s %s" % (tag, commit))
self.PushRef(tag) self.step.Git("push origin %s" % tag)
class GitReadSvnWriteInterface(GitTagsOnlyMixin, GitSvnInterface):
pass
class GitInterface(GitTagsOnlyMixin):
def Fetch(self):
self.step.Git("fetch")
def GitSvn(self, hsh, branch=""):
return ""
def SvnGit(self, rev, branch=""):
raise NotImplementedError()
def Land(self): def Land(self):
# FIXME(machenbach): This will not work with checkouts from bot_update
# after flag day because it will push to the cache. Investigate if it
# will work with "cl land".
self.step.Git("push origin") self.step.Git("push origin")
def CLLand(self): def CLLand(self):
self.step.GitCLLand() self.step.GitCLLand()
def PushRef(self, ref):
self.step.Git("push https://chromium.googlesource.com/v8/v8 %s" % ref)
VC_INTERFACES = {
"git_svn": GitSvnInterface,
"git_read_svn_write": GitReadSvnWriteInterface,
"git": GitInterface,
}
class Step(GitRecipesMixin): class Step(GitRecipesMixin):
def __init__(self, text, number, config, state, options, handler): def __init__(self, text, number, config, state, options, handler):
...@@ -467,7 +371,7 @@ class Step(GitRecipesMixin): ...@@ -467,7 +371,7 @@ class Step(GitRecipesMixin):
self._state = state self._state = state
self._options = options self._options = options
self._side_effect_handler = handler self._side_effect_handler = handler
self.vc = VC_INTERFACES[options.vc_interface]() self.vc = GitInterface()
self.vc.InjectStep(self) self.vc.InjectStep(self)
# The testing configuration might set a different default cwd. # The testing configuration might set a different default cwd.
...@@ -561,11 +465,6 @@ class Step(GitRecipesMixin): ...@@ -561,11 +465,6 @@ class Step(GitRecipesMixin):
raise GitFailedException("'git %s' failed." % args) raise GitFailedException("'git %s' failed." % args)
return result return result
def SVN(self, args="", prefix="", pipe=True, retry_on=None, cwd=None):
cmd = lambda: self._side_effect_handler.Command(
"svn", args, prefix, pipe, cwd=cwd or self.default_cwd)
return self.Retry(cmd, retry_on, [5, 30])
def Editor(self, args): def Editor(self, args):
if self._options.requires_editor: if self._options.requires_editor:
return self._side_effect_handler.Command( return self._side_effect_handler.Command(
...@@ -727,34 +626,6 @@ class Step(GitRecipesMixin): ...@@ -727,34 +626,6 @@ class Step(GitRecipesMixin):
output += "%s\n" % line output += "%s\n" % line
TextToFile(output, version_file) TextToFile(output, version_file)
def SVNCommit(self, root, commit_message):
patch = self.GitDiff("HEAD^", "HEAD")
TextToFile(patch, self._config["PATCH_FILE"])
self.Command("svn", "update", cwd=self._options.svn)
if self.Command("svn", "status", cwd=self._options.svn) != "":
self.Die("SVN checkout not clean.")
if not self.Command("patch", "-d %s -p1 -i %s" %
(root, self._config["PATCH_FILE"]),
cwd=self._options.svn):
self.Die("Could not apply patch.")
for line in self.Command(
"svn", "status", cwd=self._options.svn).splitlines():
# Check for added and removed items. Svn status has seven status columns.
# The first contains ? for unknown and ! for missing.
match = re.match(r"^(.)...... (.*)$", line)
if match and match.group(1) == "?":
self.Command("svn", "add --force %s" % match.group(2),
cwd=self._options.svn)
if match and match.group(1) == "!":
self.Command("svn", "delete --force %s" % match.group(2),
cwd=self._options.svn)
self.Command(
"svn",
"commit --non-interactive --username=%s --config-dir=%s -m \"%s\"" %
(self._options.author, self._options.svn_config, commit_message),
cwd=self._options.svn)
class BootstrapStep(Step): class BootstrapStep(Step):
MESSAGE = "Bootstapping v8 checkout." MESSAGE = "Bootstapping v8 checkout."
...@@ -873,17 +744,9 @@ class ScriptsBase(object): ...@@ -873,17 +744,9 @@ class ScriptsBase(object):
help=("Determine current sheriff to review CLs. On " help=("Determine current sheriff to review CLs. On "
"success, this will overwrite the reviewer " "success, this will overwrite the reviewer "
"option.")) "option."))
parser.add_argument("--svn",
help=("Optional full svn checkout for the commit."
"The folder needs to be the svn root."))
parser.add_argument("--svn-config",
help=("Optional folder used as svn --config-dir."))
parser.add_argument("-s", "--step", parser.add_argument("-s", "--step",
help="Specify the step where to start work. Default: 0.", help="Specify the step where to start work. Default: 0.",
default=0, type=int) default=0, type=int)
parser.add_argument("--vc-interface",
help=("Choose VC interface out of git_svn|"
"git_read_svn_write."))
parser.add_argument("--work-dir", parser.add_argument("--work-dir",
help=("Location where to bootstrap a working v8 " help=("Location where to bootstrap a working v8 "
"checkout.")) "checkout."))
...@@ -903,10 +766,6 @@ class ScriptsBase(object): ...@@ -903,10 +766,6 @@ class ScriptsBase(object):
print "To determine the current sheriff, requires the googler mapping" print "To determine the current sheriff, requires the googler mapping"
parser.print_help() parser.print_help()
return None return None
if options.svn and not options.svn_config:
print "Using pure svn for committing requires also --svn-config"
parser.print_help()
return None
# Defaults for options, common to all scripts. # Defaults for options, common to all scripts.
options.manual = getattr(options, "manual", True) options.manual = getattr(options, "manual", True)
...@@ -924,8 +783,6 @@ class ScriptsBase(object): ...@@ -924,8 +783,6 @@ class ScriptsBase(object):
parser.print_help() parser.print_help()
return None return None
if not options.vc_interface:
options.vc_interface = "git_read_svn_write"
if not options.work_dir: if not options.work_dir:
options.work_dir = "/tmp/v8-release-scripts-work-dir" options.work_dir = "/tmp/v8-release-scripts-work-dir"
return options return options
......
...@@ -45,7 +45,7 @@ GIT_SVN_ID_FOOTER_KEY = 'git-svn-id' ...@@ -45,7 +45,7 @@ GIT_SVN_ID_FOOTER_KEY = 'git-svn-id'
# e.g., git-svn-id: https://v8.googlecode.com/svn/trunk@23117 # e.g., git-svn-id: https://v8.googlecode.com/svn/trunk@23117
# ce2b1a6d-e550-0410-aec6-3dcde31c8c00 # ce2b1a6d-e550-0410-aec6-3dcde31c8c00
GIT_SVN_ID_RE = re.compile(r'((?:\w+)://[^@]+)@(\d+)\s+(?:[a-zA-Z0-9\-]+)') GIT_SVN_ID_RE = re.compile(r'[^@]+@(\d+)\s+(?:[a-zA-Z0-9\-]+)')
# Copied from bot_update.py. # Copied from bot_update.py.
...@@ -285,39 +285,6 @@ class GitRecipesMixin(object): ...@@ -285,39 +285,6 @@ class GitRecipesMixin(object):
if value: if value:
match = GIT_SVN_ID_RE.match(value) match = GIT_SVN_ID_RE.match(value)
if match: if match:
return match.group(2) return match.group(1)
return None raise GitFailedException("Couldn't determine commit position for %s" %
git_hash)
### Git svn stuff
def GitSVNFetch(self, **kwargs):
self.Git("svn fetch", **kwargs)
def GitSVNRebase(self, **kwargs):
self.Git("svn rebase", **kwargs)
# TODO(machenbach): Unused? Remove.
@Strip
def GitSVNLog(self, **kwargs):
return self.Git("svn log -1 --oneline", **kwargs)
@Strip
def GitSVNFindGitHash(self, revision, branch="", **kwargs):
assert revision
args = MakeArgs(["svn find-rev", "r%s" % revision, branch])
# Pick the last line if multiple lines are available. The first lines might
# print information about rebuilding the svn-git mapping.
return self.Git(args, **kwargs).splitlines()[-1]
@Strip
def GitSVNFindSVNRev(self, git_hash, branch="", **kwargs):
return self.Git(MakeArgs(["svn find-rev", git_hash, branch]), **kwargs)
def GitSVNDCommit(self, **kwargs):
return self.Git("svn dcommit 2>&1", retry_on=lambda x: x is None, **kwargs)
def GitSVNTag(self, version, **kwargs):
self.Git(("svn tag %s -m \"Tagging version %s\"" % (version, version)),
retry_on=lambda x: x is None,
**kwargs)
...@@ -276,9 +276,6 @@ class MergeToBranch(ScriptsBase): ...@@ -276,9 +276,6 @@ class MergeToBranch(ScriptsBase):
# CC ulan to make sure that fixes are merged to Google3. # CC ulan to make sure that fixes are merged to Google3.
options.cc = "ulan@chromium.org" options.cc = "ulan@chromium.org"
# Thd old git-svn workflow is deprecated for this script.
assert options.vc_interface != "git_svn"
# Make sure to use git hashes in the new workflows. # Make sure to use git hashes in the new workflows.
for revision in options.revisions: for revision in options.revisions:
if (IsSvnNumber(revision) or if (IsSvnNumber(revision) or
......
...@@ -34,7 +34,6 @@ import urllib2 ...@@ -34,7 +34,6 @@ import urllib2
from common_includes import * from common_includes import *
PUSH_MSG_SVN_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$")
PUSH_MSG_GIT_SUFFIX = " (based on %s)" PUSH_MSG_GIT_SUFFIX = " (based on %s)"
PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$") PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$")
...@@ -52,6 +51,11 @@ class Preparation(Step): ...@@ -52,6 +51,11 @@ class Preparation(Step):
self.PrepareBranch() self.PrepareBranch()
self.DeleteBranch(self.Config("TRUNKBRANCH")) self.DeleteBranch(self.Config("TRUNKBRANCH"))
# Allow directly pushing to candidates.
if not self.Git("config --get remote.origin.push").strip():
self.Git("config --add remote.origin.push "
"refs/remotes/origin/candidates:refs/pending/heads/candidates")
class FreshBranch(Step): class FreshBranch(Step):
MESSAGE = "Create a fresh branch." MESSAGE = "Create a fresh branch."
...@@ -93,18 +97,8 @@ class DetectLastPush(Step): ...@@ -93,18 +97,8 @@ class DetectLastPush(Step):
# Retrieve the bleeding edge revision of the last push from the text in # Retrieve the bleeding edge revision of the last push from the text in
# the push commit message. # the push commit message.
last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push) last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push)
# TODO(machenbach): This is only needed for the git transition. Can be last_push_bleeding_edge = PUSH_MSG_GIT_RE.match(
# removed after one successful trunk push. last_push_title).group("git_rev")
match = PUSH_MSG_SVN_RE.match(last_push_title)
if match:
last_push_be_svn = match.group(1)
if not last_push_be_svn: # pragma: no cover
self.Die("Could not retrieve bleeding edge rev for trunk push %s"
% last_push)
last_push_bleeding_edge = self.vc.SvnGit(last_push_be_svn)
else:
last_push_bleeding_edge = PUSH_MSG_GIT_RE.match(
last_push_title).group("git_rev")
if not last_push_bleeding_edge: # pragma: no cover if not last_push_bleeding_edge: # pragma: no cover
self.Die("Could not retrieve bleeding edge git hash for trunk push %s" self.Die("Could not retrieve bleeding edge git hash for trunk push %s"
...@@ -357,14 +351,11 @@ class SanityCheck(Step): ...@@ -357,14 +351,11 @@ class SanityCheck(Step):
self.Die("Execution canceled.") # pragma: no cover self.Die("Execution canceled.") # pragma: no cover
class CommitSVN(Step): class Land(Step):
MESSAGE = "Commit to SVN." MESSAGE = "Land the patch."
def RunStep(self): def RunStep(self):
if self._options.svn: self.vc.Land()
self.SVNCommit("trunk", self["commit_title"])
else:
self.vc.Land()
class TagRevision(Step): class TagRevision(Step):
...@@ -445,7 +436,7 @@ class PushToTrunk(ScriptsBase): ...@@ -445,7 +436,7 @@ class PushToTrunk(ScriptsBase):
SetVersion, SetVersion,
CommitTrunk, CommitTrunk,
SanityCheck, SanityCheck,
CommitSVN, Land,
TagRevision, TagRevision,
CleanUp, CleanUp,
] ]
......
...@@ -136,9 +136,6 @@ class RetrieveV8Releases(Step): ...@@ -136,9 +136,6 @@ class RetrieveV8Releases(Step):
return (self._options.max_releases > 0 return (self._options.max_releases > 0
and len(releases) > self._options.max_releases) and len(releases) > self._options.max_releases)
def GetBleedingEdgeFromPush(self, title):
return MatchSafe(PUSH_MSG_SVN_RE.match(title))
def GetBleedingEdgeGitFromPush(self, title): def GetBleedingEdgeGitFromPush(self, title):
return MatchSafe(PUSH_MSG_GIT_RE.match(title)) return MatchSafe(PUSH_MSG_GIT_RE.match(title))
...@@ -166,13 +163,13 @@ class RetrieveV8Releases(Step): ...@@ -166,13 +163,13 @@ class RetrieveV8Releases(Step):
def GetReleaseDict( def GetReleaseDict(
self, git_hash, bleeding_edge_rev, bleeding_edge_git, branch, version, self, git_hash, bleeding_edge_rev, bleeding_edge_git, branch, version,
patches, cl_body): patches, cl_body):
revision = self.vc.GitSvn(git_hash) revision = self.GetCommitPositionNumber(git_hash)
return { return {
# The SVN revision on the branch. # The cr commit position number on the branch.
"revision": revision, "revision": revision,
# The git revision on the branch. # The git revision on the branch.
"revision_git": git_hash, "revision_git": git_hash,
# The SVN revision on bleeding edge (only for newer trunk pushes). # The cr commit position number on master.
"bleeding_edge": bleeding_edge_rev, "bleeding_edge": bleeding_edge_rev,
# The same for git. # The same for git.
"bleeding_edge_git": bleeding_edge_git, "bleeding_edge_git": bleeding_edge_git,
...@@ -211,28 +208,29 @@ class RetrieveV8Releases(Step): ...@@ -211,28 +208,29 @@ class RetrieveV8Releases(Step):
patches = self.GetMergedPatches(body) patches = self.GetMergedPatches(body)
title = self.GitLog(n=1, format="%s", git_hash=git_hash) title = self.GitLog(n=1, format="%s", git_hash=git_hash)
bleeding_edge_revision = self.GetBleedingEdgeFromPush(title) bleeding_edge_git = self.GetBleedingEdgeGitFromPush(title)
bleeding_edge_git = "" bleeding_edge_position = ""
if bleeding_edge_revision: if bleeding_edge_git:
bleeding_edge_git = self.vc.SvnGit(bleeding_edge_revision, bleeding_edge_position = self.GetCommitPositionNumber(bleeding_edge_git)
self.vc.RemoteMasterBranch()) # TODO(machenbach): Add the commit position number.
else:
bleeding_edge_git = self.GetBleedingEdgeGitFromPush(title)
return self.GetReleaseDict( return self.GetReleaseDict(
git_hash, bleeding_edge_revision, bleeding_edge_git, branch, version, git_hash, bleeding_edge_position, bleeding_edge_git, branch, version,
patches, body), self["patch"] patches, body), self["patch"]
def GetReleasesFromMaster(self): def GetReleasesFromMaster(self):
tag_text = self.SVN("log https://v8.googlecode.com/svn/tags -v --limit 20") # TODO(machenbach): Implement this in git as soon as we tag again on
releases = [] # master.
for (tag, revision) in re.findall(BLEEDING_EDGE_TAGS_RE, tag_text): # tag_text = self.SVN("log https://v8.googlecode.com/svn/tags -v
git_hash = self.vc.SvnGit(revision) # --limit 20")
# releases = []
# for (tag, revision) in re.findall(BLEEDING_EDGE_TAGS_RE, tag_text):
# git_hash = self.vc.SvnGit(revision)
# Add bleeding edge release. It does not contain patches or a code # Add bleeding edge release. It does not contain patches or a code
# review link, as tags are not uploaded. # review link, as tags are not uploaded.
releases.append(self.GetReleaseDict( # releases.append(self.GetReleaseDict(
git_hash, revision, git_hash, self.vc.MasterBranch(), tag, "", "")) # git_hash, revision, git_hash, self.vc.MasterBranch(), tag, "", ""))
return releases return []
def GetReleasesFromBranch(self, branch): def GetReleasesFromBranch(self, branch):
self.GitReset(self.vc.RemoteBranch(branch)) self.GitReset(self.vc.RemoteBranch(branch))
......
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