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):
"--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:
args.extend(["--work-dir", self._options.work_dir])
......
......@@ -198,13 +198,10 @@ class ChangeVersion(Step):
msg = "[Auto-roll] Bump up version to %s" % self["new_version"]
self.GitCommit("%s\n\nTBR=%s" % (msg, self._options.author),
author=self._options.author)
if self._options.svn:
self.SVNCommit("branches/bleeding_edge", msg)
else:
self.GitUpload(author=self._options.author,
force=self._options.force_upload,
bypass_hooks=True)
self.GitDCommit()
self.GitUpload(author=self._options.author,
force=self._options.force_upload,
bypass_hooks=True)
self.GitCLLand()
print "Successfully changed the version."
finally:
# Clean up.
......
......@@ -272,12 +272,6 @@ class VCInterface(object):
def GetBranches(self):
raise NotImplementedError()
def GitSvn(self, hsh, branch=""):
raise NotImplementedError()
def SvnGit(self, rev, branch=""):
raise NotImplementedError()
def MasterBranch(self):
raise NotImplementedError()
......@@ -299,9 +293,6 @@ class VCInterface(object):
def CLLand(self):
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):
"""Sets a tag for the current commit.
......@@ -310,68 +301,12 @@ class VCInterface(object):
raise NotImplementedError()
class GitSvnInterface(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):
class GitInterface(VCInterface):
def Pull(self):
self.step.GitPull()
def Fetch(self):
self.step.Git("fetch")
self.step.GitSVNFetch()
def GetTags(self):
return self.step.Git("tag").strip().splitlines()
......@@ -401,9 +336,6 @@ class GitTagsOnlyMixin(VCInterface):
return "origin/%s" % name
return "branch-heads/%s" % name
def PushRef(self, ref):
self.step.Git("push origin %s" % ref)
def Tag(self, tag, remote, message):
# 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
......@@ -422,42 +354,14 @@ class GitTagsOnlyMixin(VCInterface):
"git updater is lagging behind?")
self.step.Git("tag %s %s" % (tag, commit))
self.PushRef(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()
self.step.Git("push origin %s" % tag)
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")
def CLLand(self):
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):
def __init__(self, text, number, config, state, options, handler):
......@@ -467,7 +371,7 @@ class Step(GitRecipesMixin):
self._state = state
self._options = options
self._side_effect_handler = handler
self.vc = VC_INTERFACES[options.vc_interface]()
self.vc = GitInterface()
self.vc.InjectStep(self)
# The testing configuration might set a different default cwd.
......@@ -561,11 +465,6 @@ class Step(GitRecipesMixin):
raise GitFailedException("'git %s' failed." % args)
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):
if self._options.requires_editor:
return self._side_effect_handler.Command(
......@@ -727,34 +626,6 @@ class Step(GitRecipesMixin):
output += "%s\n" % line
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):
MESSAGE = "Bootstapping v8 checkout."
......@@ -873,17 +744,9 @@ class ScriptsBase(object):
help=("Determine current sheriff to review CLs. On "
"success, this will overwrite the reviewer "
"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",
help="Specify the step where to start work. Default: 0.",
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",
help=("Location where to bootstrap a working v8 "
"checkout."))
......@@ -903,10 +766,6 @@ class ScriptsBase(object):
print "To determine the current sheriff, requires the googler mapping"
parser.print_help()
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.
options.manual = getattr(options, "manual", True)
......@@ -924,8 +783,6 @@ class ScriptsBase(object):
parser.print_help()
return None
if not options.vc_interface:
options.vc_interface = "git_read_svn_write"
if not options.work_dir:
options.work_dir = "/tmp/v8-release-scripts-work-dir"
return options
......
......@@ -45,7 +45,7 @@ GIT_SVN_ID_FOOTER_KEY = 'git-svn-id'
# e.g., git-svn-id: https://v8.googlecode.com/svn/trunk@23117
# 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.
......@@ -285,39 +285,6 @@ class GitRecipesMixin(object):
if value:
match = GIT_SVN_ID_RE.match(value)
if match:
return match.group(2)
return None
### 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)
return match.group(1)
raise GitFailedException("Couldn't determine commit position for %s" %
git_hash)
......@@ -276,9 +276,6 @@ class MergeToBranch(ScriptsBase):
# CC ulan to make sure that fixes are merged to Google3.
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.
for revision in options.revisions:
if (IsSvnNumber(revision) or
......
......@@ -34,7 +34,6 @@ import urllib2
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_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$")
......@@ -52,6 +51,11 @@ class Preparation(Step):
self.PrepareBranch()
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):
MESSAGE = "Create a fresh branch."
......@@ -93,18 +97,8 @@ class DetectLastPush(Step):
# Retrieve the bleeding edge revision of the last push from the text in
# the push commit message.
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
# removed after one successful trunk push.
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")
last_push_bleeding_edge = PUSH_MSG_GIT_RE.match(
last_push_title).group("git_rev")
if not last_push_bleeding_edge: # pragma: no cover
self.Die("Could not retrieve bleeding edge git hash for trunk push %s"
......@@ -357,14 +351,11 @@ class SanityCheck(Step):
self.Die("Execution canceled.") # pragma: no cover
class CommitSVN(Step):
MESSAGE = "Commit to SVN."
class Land(Step):
MESSAGE = "Land the patch."
def RunStep(self):
if self._options.svn:
self.SVNCommit("trunk", self["commit_title"])
else:
self.vc.Land()
self.vc.Land()
class TagRevision(Step):
......@@ -445,7 +436,7 @@ class PushToTrunk(ScriptsBase):
SetVersion,
CommitTrunk,
SanityCheck,
CommitSVN,
Land,
TagRevision,
CleanUp,
]
......
......@@ -136,9 +136,6 @@ class RetrieveV8Releases(Step):
return (self._options.max_releases > 0
and len(releases) > self._options.max_releases)
def GetBleedingEdgeFromPush(self, title):
return MatchSafe(PUSH_MSG_SVN_RE.match(title))
def GetBleedingEdgeGitFromPush(self, title):
return MatchSafe(PUSH_MSG_GIT_RE.match(title))
......@@ -166,13 +163,13 @@ class RetrieveV8Releases(Step):
def GetReleaseDict(
self, git_hash, bleeding_edge_rev, bleeding_edge_git, branch, version,
patches, cl_body):
revision = self.vc.GitSvn(git_hash)
revision = self.GetCommitPositionNumber(git_hash)
return {
# The SVN revision on the branch.
# The cr commit position number on the branch.
"revision": revision,
# The git revision on the branch.
"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,
# The same for git.
"bleeding_edge_git": bleeding_edge_git,
......@@ -211,28 +208,29 @@ class RetrieveV8Releases(Step):
patches = self.GetMergedPatches(body)
title = self.GitLog(n=1, format="%s", git_hash=git_hash)
bleeding_edge_revision = self.GetBleedingEdgeFromPush(title)
bleeding_edge_git = ""
if bleeding_edge_revision:
bleeding_edge_git = self.vc.SvnGit(bleeding_edge_revision,
self.vc.RemoteMasterBranch())
else:
bleeding_edge_git = self.GetBleedingEdgeGitFromPush(title)
bleeding_edge_git = self.GetBleedingEdgeGitFromPush(title)
bleeding_edge_position = ""
if bleeding_edge_git:
bleeding_edge_position = self.GetCommitPositionNumber(bleeding_edge_git)
# TODO(machenbach): Add the commit position number.
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"]
def GetReleasesFromMaster(self):
tag_text = self.SVN("log https://v8.googlecode.com/svn/tags -v --limit 20")
releases = []
for (tag, revision) in re.findall(BLEEDING_EDGE_TAGS_RE, tag_text):
git_hash = self.vc.SvnGit(revision)
# TODO(machenbach): Implement this in git as soon as we tag again on
# master.
# tag_text = self.SVN("log https://v8.googlecode.com/svn/tags -v
# --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
# review link, as tags are not uploaded.
releases.append(self.GetReleaseDict(
git_hash, revision, git_hash, self.vc.MasterBranch(), tag, "", ""))
return releases
# releases.append(self.GetReleaseDict(
# git_hash, revision, git_hash, self.vc.MasterBranch(), tag, "", ""))
return []
def GetReleasesFromBranch(self, 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