Chromium Code Reviews| 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..cbe879e44a130295c92e1c8f97e9eea1bd298fe3 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 Exception() |
|
tandrii(chromium)
2014/09/25 12:50:08
any reason why not
raise NotImplementedError
Michael Achenbach
2014/09/25 13:13:48
Done.
|
| + |
| + def Fetch(self): |
| + raise Exception() |
| + |
| + def GetTags(self): |
| + raise Exception() |
| + |
| + def GetBranches(self): |
| + raise Exception() |
| + |
| + def GitSvn(self, hsh, branch=""): |
| + raise Exception() |
| + |
| + def SvnGit(self, rev, branch=""): |
| + raise Exception() |
| + |
| + def RemoteMasterBranch(self): |
| + raise Exception() |
| + |
| + def RemoteCandidateBranch(self): |
| + raise Exception() |
| + |
| + def RemoteBranch(self, name): |
| + raise Exception() |
| + |
| + def Land(self): |
| + raise Exception() |
| + |
| + def CLLand(self): |
| + raise Exception() |
| + |
| + # 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 Exception() |
| + |
| + |
| +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) |