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))
......
......@@ -446,7 +446,6 @@ class ScriptTest(unittest.TestCase):
Cmd("git status -s -uno", ""),
Cmd("git status -s -b -uno", "## some_branch"),
Cmd("git fetch", ""),
Cmd("git svn fetch", ""),
Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"]),
RL("Y"),
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
......@@ -460,7 +459,6 @@ class ScriptTest(unittest.TestCase):
Cmd("git status -s -uno", ""),
Cmd("git status -s -b -uno", "## some_branch"),
Cmd("git fetch", ""),
Cmd("git svn fetch", ""),
Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"]),
RL("n"),
])
......@@ -473,7 +471,6 @@ class ScriptTest(unittest.TestCase):
Cmd("git status -s -uno", ""),
Cmd("git status -s -b -uno", "## some_branch"),
Cmd("git fetch", ""),
Cmd("git svn fetch", ""),
Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"]),
RL("Y"),
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], None),
......@@ -501,8 +498,7 @@ class ScriptTest(unittest.TestCase):
Cmd("git fetch", ""),
Cmd("git log -1 --format=%H --grep=\"Title\" origin/candidates", ""),
])
args = ["--branch", "candidates", "--vc-interface", "git_read_svn_write",
"ab12345"]
args = ["--branch", "candidates", "ab12345"]
self._state["version"] = "tag_name"
self._state["commit_title"] = "Title"
self.assertRaises(Exception,
......@@ -774,9 +770,11 @@ Performance and stability improvements on all platforms.""", commit)
Cmd("git status -s -uno", ""),
Cmd("git status -s -b -uno", "## some_branch\n"),
Cmd("git fetch", ""),
Cmd("git svn fetch", ""),
Cmd("git branch", " branch1\n* branch2\n"),
Cmd("git branch", " branch1\n* branch2\n"),
Cmd("git config --get remote.origin.push", ""),
Cmd("git config --add remote.origin.push "
"refs/remotes/origin/candidates:refs/pending/heads/candidates", ""),
Cmd(("git new-branch %s --upstream origin/master" %
TEST_CONFIG["BRANCHNAME"]),
""),
......@@ -810,7 +808,6 @@ Performance and stability improvements on all platforms.""", commit)
Cmd("vi %s" % TEST_CONFIG["CHANGELOG_ENTRY_FILE"], ""))
expectations += [
Cmd("git fetch", ""),
Cmd("git svn fetch", "fetch result\n"),
Cmd("git checkout -f origin/master", ""),
Cmd("git diff origin/candidates push_hash", "patch content\n"),
Cmd(("git new-branch %s --upstream origin/candidates" %
......@@ -826,7 +823,7 @@ Performance and stability improvements on all platforms.""", commit)
if manual:
expectations.append(RL("Y")) # Sanity check.
expectations += [
Cmd("git svn dcommit 2>&1", ""),
Cmd("git push origin", ""),
Cmd("git fetch", ""),
Cmd("git log -1 --format=%H --grep="
"\"Version 3.22.5 (based on push_hash)\""
......@@ -839,8 +836,7 @@ Performance and stability improvements on all platforms.""", commit)
]
self.Expect(expectations)
args = ["-a", "author@chromium.org", "--revision", "push_hash",
"--vc-interface", "git_read_svn_write",]
args = ["-a", "author@chromium.org", "--revision", "push_hash"]
if force: args.append("-f")
if manual: args.append("-m")
else: args += ["-r", "reviewer@chromium.org"]
......@@ -864,141 +860,6 @@ Performance and stability improvements on all platforms.""", commit)
def testPushToTrunkForced(self):
self._PushToTrunk(force=True)
def testPushToTrunkGit(self):
svn_root = self.MakeEmptyTempDirectory()
TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
# The version file on bleeding edge has build level 5, while the version
# file from trunk has build level 4.
self.WriteFakeVersionFile(build=5)
TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile()
bleeding_edge_change_log = "2014-03-17: Sentinel\n"
TextToFile(bleeding_edge_change_log,
os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
def ResetChangeLog():
"""On 'git co -b new_branch svn/trunk', and 'git checkout -- ChangeLog',
the ChangLog will be reset to its content on trunk."""
trunk_change_log = """1999-04-05: Version 3.22.4
Performance and stability improvements on all platforms.\n"""
TextToFile(trunk_change_log,
os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
def ResetToTrunk():
ResetChangeLog()
self.WriteFakeVersionFile()
def CheckSVNCommit():
commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"])
self.assertEquals(
"""Version 3.22.5 (based on push_hash)
Log text 1 (issue 321).
Performance and stability improvements on all platforms.""", commit)
version = FileToText(
os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE))
self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version))
self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version))
self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
# Check that the change log on the trunk branch got correctly modified.
change_log = FileToText(
os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
self.assertEquals(
"""1999-07-31: Version 3.22.5
Log text 1 (issue 321).
Performance and stability improvements on all platforms.
1999-04-05: Version 3.22.4
Performance and stability improvements on all platforms.\n""",
change_log)
expectations = [
Cmd("git status -s -uno", ""),
Cmd("git status -s -b -uno", "## some_branch\n"),
Cmd("git fetch", ""),
Cmd("git branch", " branch1\n* branch2\n"),
Cmd("git branch", " branch1\n* branch2\n"),
Cmd(("git new-branch %s --upstream origin/master" %
TEST_CONFIG["BRANCHNAME"]),
""),
Cmd(("git log -1 --format=%H --grep="
"\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" "
"origin/candidates"), "hash2\n"),
Cmd("git log -1 hash2", "Log message\n"),
Cmd("git log -1 --format=%s hash2",
"Version 3.4.5 (based on abc3)\n"),
Cmd("git checkout -f origin/master -- src/version.cc",
"", cb=self.WriteFakeVersionFile),
Cmd("git checkout -f hash2 -- src/version.cc", "",
cb=self.WriteFakeVersionFile),
Cmd("git log --format=%H abc3..push_hash", "rev1\n"),
Cmd("git log -1 --format=%s rev1", "Log text 1.\n"),
Cmd("git log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"),
Cmd("git log -1 --format=%an rev1", "author1@chromium.org\n"),
Cmd("git fetch", ""),
Cmd("git checkout -f origin/master", ""),
Cmd("git diff origin/candidates push_hash", "patch content\n"),
Cmd(("git new-branch %s --upstream origin/candidates" %
TEST_CONFIG["TRUNKBRANCH"]), "", cb=ResetToTrunk),
Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG["PATCH_FILE"], ""),
Cmd("git checkout -f origin/candidates -- ChangeLog", "",
cb=ResetChangeLog),
Cmd("git checkout -f origin/candidates -- src/version.cc", "",
cb=self.WriteFakeVersionFile),
Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], "",
cb=CheckSVNCommit),
# TODO(machenbach): Change test to pure git after flag day.
# Cmd("git push origin", ""),
Cmd("git diff HEAD^ HEAD", "patch content"),
Cmd("svn update", "", cwd=svn_root),
Cmd("svn status", "", cwd=svn_root),
Cmd("patch -d trunk -p1 -i %s" %
TEST_CONFIG["PATCH_FILE"], "Applied patch...", cwd=svn_root),
Cmd("svn status", "M OWNERS\n? new_file\n! AUTHORS",
cwd=svn_root),
Cmd("svn add --force new_file", "", cwd=svn_root),
Cmd("svn delete --force AUTHORS", "", cwd=svn_root),
Cmd("svn commit --non-interactive --username=author@chromium.org "
"--config-dir=[CONFIG_DIR] "
"-m \"Version 3.22.5 (based on push_hash)\"",
"", cwd=svn_root),
Cmd("git fetch", ""),
Cmd("git log -1 --format=%H --grep="
"\"Version 3.22.5 (based on push_hash)\""
" origin/candidates", "hsh_to_tag"),
Cmd("git tag 3.22.5 hsh_to_tag", ""),
Cmd("git push https://chromium.googlesource.com/v8/v8 3.22.5", ""),
Cmd("git checkout -f some_branch", ""),
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
Cmd("git branch -D %s" % TEST_CONFIG["TRUNKBRANCH"], ""),
]
self.Expect(expectations)
args = ["-a", "author@chromium.org", "--revision", "push_hash",
"--vc-interface", "git", "-f", "-r", "reviewer@chromium.org",
"--svn", svn_root, "--svn-config", "[CONFIG_DIR]",
"--work-dir", TEST_CONFIG["DEFAULT_CWD"]]
PushToTrunk(TEST_CONFIG, self).Run(args)
cl = FileToText(os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl))
self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl))
self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl))
# Note: The version file is on build number 5 again in the end of this test
# since the git command that merges to the bleeding edge branch is mocked
# out.
C_V8_22624_LOG = """V8 CL.
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22624 123
......@@ -1106,8 +967,7 @@ def get_list():
"Version 3.4.5 (based on abc101)\n"),
])
auto_push.AutoPush(TEST_CONFIG, self).Run(
AUTO_PUSH_ARGS + ["--push", "--vc-interface", "git"])
auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS + ["--push"])
state = json.loads(FileToText("%s-state.json"
% TEST_CONFIG["PERSISTFILE_BASENAME"]))
......@@ -1124,7 +984,6 @@ def get_list():
Cmd("git status -s -uno", ""),
Cmd("git status -s -b -uno", "## some_branch\n"),
Cmd("git fetch", ""),
Cmd("git svn fetch", ""),
])
def RunAutoPush():
......@@ -1139,7 +998,6 @@ def get_list():
Cmd("git status -s -uno", ""),
Cmd("git status -s -b -uno", "## some_branch\n"),
Cmd("git fetch", ""),
Cmd("git svn fetch", ""),
URL("https://v8-status.appspot.com/current?format=json",
"{\"message\": \"Tree is throttled (no push)\"}"),
])
......@@ -1180,7 +1038,6 @@ deps = {
"owner=author%40chromium.org&limit=30&closed=3&format=json",
("{\"results\": [{\"subject\": \"different\"}]}")),
Cmd("git fetch", ""),
Cmd("git svn fetch", ""),
Cmd(("git log -1 --format=%H --grep="
"\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" "
"origin/candidates"), "push_hash\n"),
......@@ -1203,7 +1060,6 @@ deps = {
"owner=author%40chromium.org&limit=30&closed=3&format=json",
("{\"results\": [{\"subject\": \"different\"}]}")),
Cmd("git fetch", ""),
Cmd("git svn fetch", ""),
Cmd(("git log -1 --format=%H --grep="
"\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" "
"origin/candidates"), "push_hash\n"),
......@@ -1262,7 +1118,6 @@ LOG=N
Cmd("git status -s -uno", ""),
Cmd("git status -s -b -uno", "## some_branch\n"),
Cmd("git fetch", ""),
Cmd("git svn fetch", ""),
Cmd("git branch", " branch1\n* branch2\n"),
Cmd("git new-branch %s --upstream origin/candidates" %
TEST_CONFIG["BRANCHNAME"], ""),
......@@ -1321,7 +1176,7 @@ LOG=N
Cmd("git checkout -f %s" % TEST_CONFIG["BRANCHNAME"], ""),
RL("LGTM"), # Enter LGTM for V8 CL.
Cmd("git cl presubmit", "Presubmit successfull\n"),
Cmd("git cl dcommit -f --bypass-hooks", "Closing issue\n",
Cmd("git cl land -f --bypass-hooks", "Closing issue\n",
cb=VerifySVNCommit),
Cmd("git fetch", ""),
Cmd("git log -1 --format=%H --grep=\""
......@@ -1353,33 +1208,6 @@ LOG=N
MergeToBranch(TEST_CONFIG, self).Run(args)
def testReleases(self):
tag_response_text = """
------------------------------------------------------------------------
r22631 | author1@chromium.org | 2014-07-28 02:05:29 +0200 (Mon, 28 Jul 2014)
Changed paths:
A /tags/3.28.43 (from /trunk:22630)
Tagging version 3.28.43
------------------------------------------------------------------------
r22629 | author2@chromium.org | 2014-07-26 05:09:29 +0200 (Sat, 26 Jul 2014)
Changed paths:
A /tags/3.28.41 (from /branches/bleeding_edge:22626)
Tagging version 3.28.41
------------------------------------------------------------------------
r22556 | author3@chromium.org | 2014-07-23 13:31:59 +0200 (Wed, 23 Jul 2014)
Changed paths:
A /tags/3.27.34.7 (from /branches/3.27:22555)
Tagging version 3.27.34.7
------------------------------------------------------------------------
r22627 | author4@chromium.org | 2014-07-26 01:39:15 +0200 (Sat, 26 Jul 2014)
Changed paths:
A /tags/3.28.40 (from /branches/bleeding_edge:22624)
Tagging version 3.28.40
------------------------------------------------------------------------
"""
c_hash2_commit_log = """Revert something.
BUG=12345
......@@ -1400,6 +1228,23 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4567 0039-1c4b
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
"""
c_hash_234_commit_log = """Version 3.3.1.1 (cherry-pick).
Merged abc12.
Review URL: fake.com
Cr-Commit-Position: refs/heads/candidates@{#234}
"""
c_hash_123_commit_log = """Version 3.3.1.0
git-svn-id: googlecode@123 0039-1c4b
"""
c_hash_345_commit_log = """Version 3.4.0.
Cr-Commit-Position: refs/heads/candidates@{#345}
"""
json_output = self.MakeEmptyTempFile()
csv_output = self.MakeEmptyTempFile()
self.WriteFakeVersionFile()
......@@ -1425,7 +1270,6 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
Cmd("git status -s -uno", ""),
Cmd("git status -s -b -uno", "## some_branch\n"),
Cmd("git fetch", ""),
Cmd("git svn fetch", ""),
Cmd("git branch", " branch1\n* branch2\n"),
Cmd("git new-branch %s" % TEST_CONFIG["BRANCHNAME"], ""),
Cmd("git branch -r", " branch-heads/3.21\n branch-heads/3.3\n"),
......@@ -1435,12 +1279,9 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
Cmd("git diff --name-only hash_234 hash_234^", VERSION_FILE),
Cmd("git checkout -f hash_234 -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 1, 1)),
Cmd("git log -1 --format=%B hash_234",
"Version 3.3.1.1 (cherry-pick).\n\n"
"Merged abc12.\n\n"
"Review URL: fake.com\n"),
Cmd("git log -1 --format=%B hash_234", c_hash_234_commit_log),
Cmd("git log -1 --format=%s hash_234", ""),
Cmd("git svn find-rev hash_234", "234"),
Cmd("git log -1 --format=%B hash_234", c_hash_234_commit_log),
Cmd("git log -1 --format=%ci hash_234", "18:15"),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(22, 5)),
......@@ -1449,9 +1290,9 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
Cmd("git diff --name-only hash_123 hash_123^", VERSION_FILE),
Cmd("git checkout -f hash_123 -- %s" % VERSION_FILE, "",
cb=ResetVersion(21, 2)),
Cmd("git log -1 --format=%B hash_123", ""),
Cmd("git log -1 --format=%B hash_123", c_hash_123_commit_log),
Cmd("git log -1 --format=%s hash_123", ""),
Cmd("git svn find-rev hash_123", "123"),
Cmd("git log -1 --format=%B hash_123", c_hash_123_commit_log),
Cmd("git log -1 --format=%ci hash_123", "03:15"),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(22, 5)),
......@@ -1460,21 +1301,13 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
Cmd("git diff --name-only hash_345 hash_345^", VERSION_FILE),
Cmd("git checkout -f hash_345 -- %s" % VERSION_FILE, "",
cb=ResetVersion(22, 3)),
Cmd("git log -1 --format=%B hash_345", ""),
Cmd("git log -1 --format=%B hash_345", c_hash_345_commit_log),
Cmd("git log -1 --format=%s hash_345", ""),
Cmd("git svn find-rev hash_345", "345"),
Cmd("git log -1 --format=%B hash_345", c_hash_345_commit_log),
Cmd("git log -1 --format=%ci hash_345", ""),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(22, 5)),
Cmd("git reset --hard origin/master", ""),
Cmd("svn log https://v8.googlecode.com/svn/tags -v --limit 20",
tag_response_text),
Cmd("git svn find-rev r22626", "hash_22626"),
Cmd("git svn find-rev hash_22626", "22626"),
Cmd("git log -1 --format=%ci hash_22626", "01:23"),
Cmd("git svn find-rev r22624", "hash_22624"),
Cmd("git svn find-rev hash_22624", "22624"),
Cmd("git log -1 --format=%ci hash_22624", "02:34"),
Cmd("git status -s -uno", "", cwd=chrome_dir),
Cmd("git checkout -f master", "", cwd=chrome_dir),
Cmd("git pull", "", cwd=chrome_dir),
......@@ -1513,49 +1346,18 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
])
args = ["-c", TEST_CONFIG["CHROMIUM"],
"--vc-interface", "git_read_svn_write",
"--json", json_output,
"--csv", csv_output,
"--max-releases", "1"]
Releases(TEST_CONFIG, self).Run(args)
# Check expected output.
csv = ("3.28.41,master,22626,,\r\n"
"3.28.40,master,22624,4567,\r\n"
"3.22.3,candidates,345,3456:4566,\r\n"
csv = ("3.22.3,candidates,345,3456:4566,\r\n"
"3.21.2,3.21,123,,\r\n"
"3.3.1.1,3.3,234,,abc12\r\n")
self.assertEquals(csv, FileToText(csv_output))
expected_json = [
{
"revision": "22626",
"revision_git": "hash_22626",
"bleeding_edge": "22626",
"bleeding_edge_git": "hash_22626",
"patches_merged": "",
"version": "3.28.41",
"chromium_revision": "",
"branch": "master",
"review_link": "",
"date": "01:23",
"chromium_branch": "",
"revision_link": "https://code.google.com/p/v8/source/detail?r=22626",
},
{
"revision": "22624",
"revision_git": "hash_22624",
"bleeding_edge": "22624",
"bleeding_edge_git": "hash_22624",
"patches_merged": "",
"version": "3.28.40",
"chromium_revision": "4567",
"branch": "master",
"review_link": "",
"date": "02:34",
"chromium_branch": "",
"revision_link": "https://code.google.com/p/v8/source/detail?r=22624",
},
{
"revision": "345",
"revision_git": "hash_345",
......@@ -1644,7 +1446,7 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
expectations += [
Cmd("git cl upload --send-mail --email \"author@chromium.org\" -f "
"--bypass-hooks", ""),
Cmd("git cl dcommit -f --bypass-hooks", ""),
Cmd("git cl land -f --bypass-hooks", ""),
Cmd("git checkout -f master", ""),
Cmd("git branch", "auto-bump-up-version\n* master"),
Cmd("git branch -D auto-bump-up-version", ""),
......@@ -1653,30 +1455,6 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
BumpUpVersion(TEST_CONFIG, self).Run(["-a", "author@chromium.org"])
def testBumpUpVersionSvn(self):
svn_root = self.MakeEmptyTempDirectory()
expectations = self._bumpUpVersion()
expectations += [
Cmd("git diff HEAD^ HEAD", "patch content"),
Cmd("svn update", "", cwd=svn_root),
Cmd("svn status", "", cwd=svn_root),
Cmd("patch -d branches/bleeding_edge -p1 -i %s" %
TEST_CONFIG["PATCH_FILE"], "Applied patch...", cwd=svn_root),
Cmd("svn status", "M src/version.cc", cwd=svn_root),
Cmd("svn commit --non-interactive --username=author@chromium.org "
"--config-dir=[CONFIG_DIR] "
"-m \"[Auto-roll] Bump up version to 3.11.6.0\"",
"", cwd=svn_root),
Cmd("git checkout -f master", ""),
Cmd("git branch", "auto-bump-up-version\n* master"),
Cmd("git branch -D auto-bump-up-version", ""),
]
self.Expect(expectations)
BumpUpVersion(TEST_CONFIG, self).Run(
["-a", "author@chromium.org",
"--svn", svn_root,
"--svn-config", "[CONFIG_DIR]"])
# Test that we bail out if the last change was a version change.
def testBumpUpVersionBailout1(self):
......
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