The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2008 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 | from git_command import git |
Shawn O. Pearce | 0f0dfa3 | 2009-04-18 14:53:39 -0700 | [diff] [blame] | 19 | from progress import Progress |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 20 | |
| 21 | class Start(Command): |
| 22 | common = True |
| 23 | helpSummary = "Start a new branch for development" |
| 24 | helpUsage = """ |
| 25 | %prog <newbranchname> [<project>...] |
Shawn O. Pearce | 06e556d | 2009-04-18 11:19:01 -0700 | [diff] [blame] | 26 | """ |
| 27 | helpDescription = """ |
| 28 | '%prog' begins a new branch of development, starting from the |
| 29 | revision specified in the manifest. |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 30 | """ |
| 31 | |
| 32 | def Execute(self, opt, args): |
| 33 | if not args: |
| 34 | self.Usage() |
| 35 | |
| 36 | nb = args[0] |
| 37 | if not git.check_ref_format('heads/%s' % nb): |
| 38 | print >>sys.stderr, "error: '%s' is not a valid name" % nb |
| 39 | sys.exit(1) |
| 40 | |
Shawn O. Pearce | 0a389e9 | 2009-04-10 16:21:18 -0700 | [diff] [blame] | 41 | err = [] |
Shawn O. Pearce | 0f0dfa3 | 2009-04-18 14:53:39 -0700 | [diff] [blame] | 42 | all = self.GetProjects(args[1:]) |
| 43 | |
| 44 | pm = Progress('Starting %s' % nb, len(all)) |
| 45 | for project in all: |
| 46 | pm.update() |
Shawn O. Pearce | 0a389e9 | 2009-04-10 16:21:18 -0700 | [diff] [blame] | 47 | if not project.StartBranch(nb): |
| 48 | err.append(project) |
Shawn O. Pearce | 0f0dfa3 | 2009-04-18 14:53:39 -0700 | [diff] [blame] | 49 | pm.end() |
Shawn O. Pearce | 0a389e9 | 2009-04-10 16:21:18 -0700 | [diff] [blame] | 50 | |
| 51 | if err: |
Shawn O. Pearce | 0a389e9 | 2009-04-10 16:21:18 -0700 | [diff] [blame] | 52 | for p in err: |
Shawn O. Pearce | 89e717d | 2009-04-18 15:04:41 -0700 | [diff] [blame] | 53 | print >>sys.stderr,\ |
| 54 | "error: %s/: cannot start %s" \ |
| 55 | % (p.relpath, nb) |
Shawn O. Pearce | 0a389e9 | 2009-04-10 16:21:18 -0700 | [diff] [blame] | 56 | sys.exit(1) |