Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Unified Diff: tools/push-to-trunk/push_to_trunk.py

Issue 171423013: Refactoring: Extract low-level git from push and merge scripts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Correct copyright year. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/push-to-trunk/merge_to_branch.py ('k') | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/push-to-trunk/push_to_trunk.py
diff --git a/tools/push-to-trunk/push_to_trunk.py b/tools/push-to-trunk/push_to_trunk.py
index 24d9b7730ed2af216bac6db0fc2e6bf88764272f..0dc1a077d282cf4bfe24ac31192b8ceb94df3bde 100755
--- a/tools/push-to-trunk/push_to_trunk.py
+++ b/tools/push-to-trunk/push_to_trunk.py
@@ -98,23 +98,20 @@ class FreshBranch(Step):
MESSAGE = "Create a fresh branch."
def RunStep(self):
- args = "checkout -b %s svn/bleeding_edge" % self.Config(BRANCHNAME)
- self.Git(args)
+ self.GitCreateBranch(self.Config(BRANCHNAME), "svn/bleeding_edge")
class DetectLastPush(Step):
MESSAGE = "Detect commit ID of last push to trunk."
def RunStep(self):
- last_push_trunk = self._options.l or self.FindLastTrunkPush()
+ last_push = self._options.l or self.FindLastTrunkPush()
while True:
# Print assumed commit, circumventing git's pager.
- print self.Git("log -1 %s" % last_push_trunk)
+ print self.GitLog(n=1, git_hash=last_push)
if self.Confirm("Is the commit printed above the last push to trunk?"):
break
- args = ("log -1 --format=%%H %s^ --grep=\"%s\""
- % (last_push_trunk, push_pattern))
- last_push_trunk = self.Git(args).strip()
+ last_push = self.FindLastTrunkPush(parent_hash=last_push)
if self._options.b:
# Read the bleeding edge revision of the last push from a command-line
@@ -123,21 +120,19 @@ class DetectLastPush(Step):
else:
# Retrieve the bleeding edge revision of the last push from the text in
# the push commit message.
- args = "log -1 --format=%%s %s" % last_push_trunk
- last_push_trunk_title = self.Git(args).strip()
- last_push_be_svn = PUSH_MESSAGE_RE.match(last_push_trunk_title).group(1)
+ last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push)
+ last_push_be_svn = PUSH_MESSAGE_RE.match(last_push_title).group(1)
if not last_push_be_svn:
self.Die("Could not retrieve bleeding edge revision for trunk push %s"
- % last_push_trunk)
- args = "svn find-rev r%s" % last_push_be_svn
- last_push_bleeding_edge = self.Git(args).strip()
+ % last_push)
+ last_push_bleeding_edge = self.GitSVNFindGitHash(last_push_be_svn)
if not last_push_bleeding_edge:
self.Die("Could not retrieve bleeding edge git hash for trunk push %s"
- % last_push_trunk)
+ % last_push)
# TODO(machenbach): last_push_trunk points to the svn revision on trunk.
# It is not used yet but we'll need it for retrieving the current version.
- self["last_push_trunk"] = last_push_trunk
+ self["last_push_trunk"] = last_push
# TODO(machenbach): This currently points to the prepare push revision that
# will be deprecated soon. After the deprecation it will point to the last
# bleeding_edge revision that went into the last push.
@@ -175,16 +170,15 @@ class PrepareChangeLog(Step):
output = "%s: Version %s\n\n" % (self["date"],
self["version"])
TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE))
-
- args = "log %s..HEAD --format=%%H" % self["last_push_bleeding_edge"]
- commits = self.Git(args).strip()
+ commits = self.GitLog(format="%H",
+ git_hash="%s..HEAD" % self["last_push_bleeding_edge"])
# Cache raw commit messages.
commit_messages = [
[
- self.Git("log -1 %s --format=\"%%s\"" % commit),
- self.Reload(self.Git("log -1 %s --format=\"%%B\"" % commit)),
- self.Git("log -1 %s --format=\"%%an\"" % commit),
+ self.GitLog(n=1, format="%s", git_hash=commit),
+ self.Reload(self.GitLog(n=1, format="%B", git_hash=commit)),
+ self.GitLog(n=1, format="%an", git_hash=commit),
] for commit in commits.splitlines()
]
@@ -266,10 +260,11 @@ class CommitLocal(Step):
# Include optional TBR only in the git command. The persisted commit
# message is used for finding the commit again later.
if self._options.tbr_commit:
- review = "\n\nTBR=%s" % self._options.reviewer
+ message = "%s\n\nTBR=%s" % (self["prep_commit_msg"],
+ self._options.reviewer)
else:
- review = ""
- self.Git("commit -a -m \"%s%s\"" % (self["prep_commit_msg"], review))
+ message = "%s" % self["prep_commit_msg"]
+ self.GitCommit(message)
class CommitRepository(Step):
@@ -282,8 +277,8 @@ class CommitRepository(Step):
TextToFile(GetLastChangeLogEntries(self.Config(CHANGELOG_FILE)),
self.Config(CHANGELOG_ENTRY_FILE))
- self.Git("cl presubmit", "PRESUBMIT_TREE_CHECK=\"skip\"")
- self.Git("cl dcommit -f --bypass-hooks", retry_on=lambda x: x is None)
+ self.GitPresubmit()
+ self.GitDCommit()
class StragglerCommits(Step):
@@ -291,10 +286,10 @@ class StragglerCommits(Step):
"started.")
def RunStep(self):
- self.Git("svn fetch")
- self.Git("checkout svn/bleeding_edge")
- args = "log -1 --format=%%H --grep=\"%s\"" % self["prep_commit_msg"]
- self["prepare_commit_hash"] = self.Git(args).strip()
+ self.GitSVNFetch()
+ self.GitCheckout("svn/bleeding_edge")
+ self["prepare_commit_hash"] = self.GitLog(n=1, format="%H",
+ grep=self["prep_commit_msg"])
class SquashCommits(Step):
@@ -303,8 +298,8 @@ class SquashCommits(Step):
def RunStep(self):
# Instead of relying on "git rebase -i", we'll just create a diff, because
# that's easier to automate.
- args = "diff svn/trunk %s" % self["prepare_commit_hash"]
- TextToFile(self.Git(args), self.Config(PATCH_FILE))
+ TextToFile(self.GitDiff("svn/trunk", self["prepare_commit_hash"]),
+ self.Config(PATCH_FILE))
# Convert the ChangeLog entry to commit message format.
text = FileToText(self.Config(CHANGELOG_ENTRY_FILE))
@@ -314,8 +309,7 @@ class SquashCommits(Step):
# Retrieve svn revision for showing the used bleeding edge revision in the
# commit message.
- args = "svn find-rev %s" % self["prepare_commit_hash"]
- self["svn_revision"] = self.Git(args).strip()
+ self["svn_revision"] = self.GitSVNFindSVNRev(self["prepare_commit_hash"])
suffix = PUSH_MESSAGE_SUFFIX % int(self["svn_revision"])
text = MSub(r"^(Version \d+\.\d+\.\d+)$", "\\1%s" % suffix, text)
@@ -336,7 +330,7 @@ class NewBranch(Step):
MESSAGE = "Create a new branch from trunk."
def RunStep(self):
- self.Git("checkout -b %s svn/trunk" % self.Config(TRUNKBRANCH))
+ self.GitCreateBranch(self.Config(TRUNKBRANCH), "svn/trunk")
class ApplyChanges(Step):
@@ -371,8 +365,8 @@ class CommitTrunk(Step):
MESSAGE = "Commit to local trunk branch."
def RunStep(self):
- self.Git("add \"%s\"" % self.Config(VERSION_FILE))
- self.Git("commit -F \"%s\"" % self.Config(COMMITMSG_FILE))
+ self.GitAdd(self.Config(VERSION_FILE))
+ self.GitCommit(file_name = self.Config(COMMITMSG_FILE))
Command("rm", "-f %s*" % self.Config(COMMITMSG_FILE))
@@ -390,7 +384,7 @@ class CommitSVN(Step):
MESSAGE = "Commit to SVN."
def RunStep(self):
- result = self.Git("svn dcommit 2>&1", retry_on=lambda x: x is None)
+ result = self.GitSVNDCommit()
if not result:
self.Die("'git svn dcommit' failed.")
result = filter(lambda x: re.search(r"^Committed r[0-9]+", x),
@@ -414,9 +408,7 @@ class TagRevision(Step):
MESSAGE = "Tag the new revision."
def RunStep(self):
- self.Git(("svn tag %s -m \"Tagging version %s\""
- % (self["version"], self["version"])),
- retry_on=lambda x: x is None)
+ self.GitSVNTag(self["version"])
class CheckChromium(Step):
@@ -443,7 +435,7 @@ class SwitchChromium(Step):
os.chdir(self["chrome_path"])
self.InitialEnvironmentChecks()
# Check for a clean workdir.
- if self.Git("status -s -uno").strip() != "":
+ if not self.GitIsWorkdirClean():
self.Die("Workspace is not clean. Please commit or undo your changes.")
# Assert that the DEPS file is there.
if not os.path.exists(self.Config(DEPS_FILE)):
@@ -456,9 +448,9 @@ class UpdateChromiumCheckout(Step):
def RunStep(self):
os.chdir(self["chrome_path"])
- self.Git("checkout master")
- self.Git("pull")
- self.Git("checkout -b v8-roll-%s" % self["trunk_revision"])
+ self.GitCheckout("master")
+ self.GitPull()
+ self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"])
class UploadCL(Step):
@@ -482,13 +474,11 @@ class UploadCL(Step):
print "Please enter the email address of a reviewer for the roll CL: ",
self.DieNoManualMode("A reviewer must be specified in forced mode.")
rev = self.ReadLine()
- self.Git("commit -am \"Update V8 to version %s "
- "(based on bleeding_edge revision r%s).\n\nTBR=%s\""
- % (self["version"], self["svn_revision"], rev))
- author_option = self._options.author
- author = " --email \"%s\"" % author_option if author_option else ""
- force_flag = " -f" if self._options.force_upload else ""
- self.Git("cl upload%s --send-mail%s" % (author, force_flag), pipe=False)
+ suffix = PUSH_MESSAGE_SUFFIX % int(self["svn_revision"])
+ self.GitCommit("Update V8 to version %s%s.\n\nTBR=%s"
+ % (self["version"], suffix, rev))
+ self.GitUpload(author=self._options.author,
+ force=self._options.force_upload)
print "CL uploaded."
@@ -518,7 +508,7 @@ class CleanUp(Step):
self.CommonCleanup()
if self.Config(TRUNKBRANCH) != self["current_branch"]:
- self.Git("branch -D %s" % self.Config(TRUNKBRANCH))
+ self.GitDeleteBranch(self.Config(TRUNKBRANCH))
def RunPushToTrunk(config,
« no previous file with comments | « tools/push-to-trunk/merge_to_branch.py ('k') | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698