blob: 7ce9d34123e9045dccf890030919a87b319c279d [file] [log] [blame]
Wink Saville02d79452009-04-10 13:01:24 -07001#
2# Copyright (C) 2009 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import sys
17from command import Command
18
19class Checkout(Command):
20 common = True
21 helpSummary = "Checkout a branch for development"
22 helpUsage = """
23%prog <branchname> [<project>...]
24
25This subcommand checks out an existing branch and
26is equivalent to the following git command run on
27every project or the list of specified projects:
28
29"git checkout <branchname>"
30"""
31
32 def Execute(self, opt, args):
33 if not args:
34 self.Usage()
35
36 retValue = 0;
37
38 branch = args[0]
39 for project in self.GetProjects(args[1:]):
40 if not project.CheckoutBranch(branch):
41 retValue = 1;
42 print >>sys.stderr, "error: checking out branch '%s' in %s failed" % (branch, project.name)
43
44 if (retValue != 0):
45 sys.exit(retValue);