blob: 07644c95f140afcefefc321044daf73142c35018 [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>...]
Shawn O. Pearced33f43a2009-04-13 12:11:31 -070024"""
25 helpDescription = """
26The '%prog' command checks out an existing branch that was previously
27created by 'repo start'.
Wink Saville02d79452009-04-10 13:01:24 -070028
Shawn O. Pearced33f43a2009-04-13 12:11:31 -070029The command is equivalent to:
Wink Saville02d79452009-04-10 13:01:24 -070030
Shawn O. Pearced33f43a2009-04-13 12:11:31 -070031 repo forall [<project>...] -c git checkout <branchname>
Wink Saville02d79452009-04-10 13:01:24 -070032"""
33
34 def Execute(self, opt, args):
35 if not args:
36 self.Usage()
37
38 retValue = 0;
39
40 branch = args[0]
41 for project in self.GetProjects(args[1:]):
42 if not project.CheckoutBranch(branch):
43 retValue = 1;
44 print >>sys.stderr, "error: checking out branch '%s' in %s failed" % (branch, project.name)
45
46 if (retValue != 0):
47 sys.exit(retValue);