diff options
| author | Wink Saville <wink@google.com> | 2009-04-10 13:01:24 -0700 |
|---|---|---|
| committer | Wink Saville <wink@google.com> | 2009-04-10 13:01:24 -0700 |
| commit | 02d7945eb836f33f63b94fb2a556c844faf0ef8d (patch) | |
| tree | 5cbcbfd147616337aebec9d72b0fd0de3bf34b64 /subcmds/checkout.py | |
| parent | 8f82a4f828c2765cc4585f9d749f5155f06fd9e9 (diff) | |
| download | git-repo-02d7945eb836f33f63b94fb2a556c844faf0ef8d.tar.gz | |
Add checkout command.
Teach repo how to checkout a branch in all projects or a list
of specific projects.
Bug: REPO-21
Diffstat (limited to 'subcmds/checkout.py')
| -rw-r--r-- | subcmds/checkout.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/subcmds/checkout.py b/subcmds/checkout.py new file mode 100644 index 00000000..7ce9d341 --- /dev/null +++ b/subcmds/checkout.py | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | # | ||
| 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 | |||
| 16 | import sys | ||
| 17 | from command import Command | ||
| 18 | |||
| 19 | class Checkout(Command): | ||
| 20 | common = True | ||
| 21 | helpSummary = "Checkout a branch for development" | ||
| 22 | helpUsage = """ | ||
| 23 | %prog <branchname> [<project>...] | ||
| 24 | |||
| 25 | This subcommand checks out an existing branch and | ||
| 26 | is equivalent to the following git command run on | ||
| 27 | every 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); | ||
