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

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

Issue 607463002: Refactoring: Extract interface for VC in release scripts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review. Created 6 years, 3 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/bump_up_version.py ('k') | tools/push-to-trunk/merge_to_branch.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/push-to-trunk/common_includes.py
diff --git a/tools/push-to-trunk/common_includes.py b/tools/push-to-trunk/common_includes.py
index 670ecead6dcbdcba5c9c4c20032ae116b8cb4795..3d2616f84e36938de5d0d92b039f56f314a664d3 100644
--- a/tools/push-to-trunk/common_includes.py
+++ b/tools/push-to-trunk/common_includes.py
@@ -255,6 +255,98 @@ class NoRetryException(Exception):
pass
+class VCInterface(object):
+ def InjectStep(self, step):
+ self.step=step
+
+ def Pull(self):
+ raise NotImplementedError()
+
+ def Fetch(self):
+ raise NotImplementedError()
+
+ def GetTags(self):
+ raise NotImplementedError()
+
+ def GetBranches(self):
+ raise NotImplementedError()
+
+ def GitSvn(self, hsh, branch=""):
+ raise NotImplementedError()
+
+ def SvnGit(self, rev, branch=""):
+ raise NotImplementedError()
+
+ def RemoteMasterBranch(self):
+ raise NotImplementedError()
+
+ def RemoteCandidateBranch(self):
+ raise NotImplementedError()
+
+ def RemoteBranch(self, name):
+ raise NotImplementedError()
+
+ def Land(self):
+ raise NotImplementedError()
+
+ 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):
+ 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 RemoteMasterBranch(self):
+ return "svn/bleeding_edge"
+
+ def RemoteCandidateBranch(self):
+ return "svn/trunk"
+
+ def RemoteBranch(self, name):
+ return "svn/%s" % name
+
+ def Land(self):
+ return self.step.GitSVNDCommit()
+
+ def CLLand(self):
+ return self.step.GitDCommit()
+
+ def Tag(self, tag):
+ self.step.GitSVNTag(tag)
+
+
+
class Step(GitRecipesMixin):
def __init__(self, text, number, config, state, options, handler):
self._text = text
@@ -263,6 +355,8 @@ class Step(GitRecipesMixin):
self._state = state
self._options = options
self._side_effect_handler = handler
+ self.vc = GitSvnInterface()
+ self.vc.InjectStep(self)
# The testing configuration might set a different default cwd.
self.default_cwd = self._config.get("DEFAULT_CWD") or DEFAULT_CWD
@@ -422,7 +516,7 @@ class Step(GitRecipesMixin):
self["current_branch"] = self.GitCurrentBranch()
# Fetch unfetched revisions.
- self.GitSVNFetch()
+ self.vc.Fetch()
def PrepareBranch(self):
# Delete the branch that will be created later if it exists already.
@@ -493,7 +587,7 @@ class Step(GitRecipesMixin):
# Non-patched versions only have three numbers followed by the "(based
# on...) comment."
push_pattern += " (based"
- branch = "" if parent_hash else branch or "svn/trunk"
+ branch = "" if parent_hash else branch or self.vc.RemoteCandidateBranch()
return self.GitLog(n=1, format="%H", grep=push_pattern,
parent_hash=parent_hash, branch=branch)
« no previous file with comments | « tools/push-to-trunk/bump_up_version.py ('k') | tools/push-to-trunk/merge_to_branch.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698