Add ability to make pure svn commits to roll scripts

BUG=chromium:408523
LOG=n
TBR=jarin@chromium.org
TEST=script_test.py

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23754 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7da038fd
......@@ -27,6 +27,7 @@ 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",
}
......@@ -196,12 +197,16 @@ class ChangeVersion(Step):
self.SetVersion(self.Config(VERSION_FILE), "new_")
try:
self.GitCommit("[Auto-roll] Bump up version to %s\n\nTBR=%s" %
(self["new_version"], self._options.author))
self.GitUpload(author=self._options.author,
force=self._options.force_upload,
bypass_hooks=True)
self.GitDCommit()
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()
print "Successfully changed the version."
finally:
# Clean up.
......
......@@ -529,6 +529,20 @@ 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])
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.")
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 UploadStep(Step):
MESSAGE = "Upload for code review."
......@@ -631,6 +645,11 @@ 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)
......@@ -650,6 +669,10 @@ 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)
......
......@@ -1370,7 +1370,7 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
self.assertEquals(expected_json, json.loads(FileToText(json_output)))
def testBumpUpVersion(self):
def _bumpUpVersion(self):
TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile()
self.WriteFakeVersionFile()
......@@ -1379,7 +1379,7 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
build=build,
patch=patch)
self.Expect([
return [
Cmd("git status -s -uno", ""),
Cmd("git checkout -f bleeding_edge", "", cb=ResetVersion(11, 4)),
Cmd("git pull", ""),
......@@ -1403,17 +1403,45 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
Cmd("git checkout -b auto-bump-up-version bleeding_edge", "",
cb=ResetVersion(11, 4)),
Cmd("git commit -am \"[Auto-roll] Bump up version to 3.11.6.0\n\n"
"TBR=author@chromium.org\"", ""),
"TBR=author@chromium.org\" "
"--author \"author@chromium.org <author@chromium.org>\"", ""),
]
def testBumpUpVersionGit(self):
expectations = self._bumpUpVersion()
expectations += [
Cmd("git cl upload --send-mail --email \"author@chromium.org\" -f "
"--bypass-hooks", ""),
Cmd("git cl dcommit -f --bypass-hooks", ""),
Cmd("git checkout -f bleeding_edge", ""),
Cmd("git branch", "auto-bump-up-version\n* bleeding_edge"),
Cmd("git branch -D auto-bump-up-version", ""),
])
]
self.Expect(expectations)
BumpUpVersion(TEST_CONFIG, self).Run(["-a", "author@chromium.org"])
def testBumpUpVersionSvn(self):
expectations = self._bumpUpVersion()
expectations += [
Cmd("git diff HEAD^ HEAD", "patch content"),
Cmd("patch -d branches/bleeding_edge -p1 -i %s" %
TEST_CONFIG[PATCH_FILE], "Applied patch...", 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 bleeding_edge", ""),
Cmd("git branch", "auto-bump-up-version\n* bleeding_edge"),
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]"])
def testAutoTag(self):
TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile()
self.WriteFakeVersionFile()
......
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