blob: 49bb0e1ac99a17463f0e434d08f7701a68fd56a0 [file] [log] [blame]
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07001#
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
16import sys
17from command import Command
18from git_command import git
Shawn O. Pearce0f0dfa32009-04-18 14:53:39 -070019from progress import Progress
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070020
21class Start(Command):
22 common = True
23 helpSummary = "Start a new branch for development"
24 helpUsage = """
25%prog <newbranchname> [<project>...]
Shawn O. Pearce06e556d2009-04-18 11:19:01 -070026"""
27 helpDescription = """
28'%prog' begins a new branch of development, starting from the
29revision specified in the manifest.
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070030"""
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. Pearce0a389e92009-04-10 16:21:18 -070041 err = []
Shawn O. Pearce0f0dfa32009-04-18 14:53:39 -070042 all = self.GetProjects(args[1:])
43
44 pm = Progress('Starting %s' % nb, len(all))
45 for project in all:
46 pm.update()
Shawn O. Pearce0a389e92009-04-10 16:21:18 -070047 if not project.StartBranch(nb):
48 err.append(project)
Shawn O. Pearce0f0dfa32009-04-18 14:53:39 -070049 pm.end()
Shawn O. Pearce0a389e92009-04-10 16:21:18 -070050
51 if err:
52 err.sort()
53 for p in err:
54 print >>sys.stderr, "error: cannot start in %s" % p.relpath
55 sys.exit(1)