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 c1c2aa56ff0204de35498f52bd6b8a9e35be48f9..a1aef67976d51445d9ddee24a2c476ccaebfb123 100644 |
| --- a/tools/push-to-trunk/common_includes.py |
| +++ b/tools/push-to-trunk/common_includes.py |
| @@ -346,6 +346,43 @@ class GitSvnInterface(VCInterface): |
| self.step.GitSVNTag(tag) |
| +class GitReadOnlyMixin(VCInterface): |
| + def Pull(self): |
| + self.step.GitPull() |
| + |
| + def Fetch(self): |
| + self.step.Git("fetch") |
| + |
| + def GetTags(self): |
| + return self.step.Git("tag").strip().splitlines() |
| + |
| + def GetBranches(self): |
| + # Get relevant remote branches, e.g. "origin/branch-heads/3.25". |
| + branches = filter( |
| + lambda s: re.match(r"^origin/branch\-heads/\d+\.\d+$", s), |
| + self.step.GitRemotes()) |
| + # Remove 'origin/branch-heads/' prefix. |
| + return map(lambda s: s[20:], branches) |
| + |
| + def RemoteMasterBranch(self): |
| + return "origin/master" |
| + |
| + def RemoteCandidateBranch(self): |
| + return "origin/candidates" |
| + |
| + def RemoteBranch(self, name): |
| + return "origin/branch-heads/%s" % name |
| + |
| + |
| +class GitReadSvnWriteInterface(GitReadOnlyMixin, GitSvnInterface): |
| + pass |
| + |
| + |
| +VC_INTERFACES = { |
| + "git_svn": GitSvnInterface, |
| + "git_read_svn_write": GitReadSvnWriteInterface, |
| +} |
| + |
| class Step(GitRecipesMixin): |
| def __init__(self, text, number, config, state, options, handler): |
| @@ -355,7 +392,7 @@ class Step(GitRecipesMixin): |
| self._state = state |
| self._options = options |
| self._side_effect_handler = handler |
| - self.vc = GitSvnInterface() |
| + self.vc = VC_INTERFACES[options.vc_port]() |
| self.vc.InjectStep(self) |
| # The testing configuration might set a different default cwd. |
| @@ -740,6 +777,9 @@ class ScriptsBase(object): |
| parser.add_argument("-s", "--step", |
| help="Specify the step where to start work. Default: 0.", |
| default=0, type=int) |
| + parser.add_argument("--vc-port", |
|
tandrii(chromium)
2014/09/25 15:53:52
why "port" and not "interface"? Is it less typing?
|
| + help=("Choose VC port out of git_svn|" |
| + "git_read_svn_write.")) |
| self._PrepareOptions(parser) |
| if args is None: # pragma: no cover |
| @@ -776,6 +816,9 @@ class ScriptsBase(object): |
| if not self._ProcessOptions(options): |
| parser.print_help() |
| return None |
| + |
| + if not options.vc_port: |
| + options.vc_port = "git_svn" |
| return options |
| def RunSteps(self, step_classes, args=None): |