start.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. import sys
  16. from command import Command
  17. from git_command import git
  18. class Start(Command):
  19. common = True
  20. helpSummary = "Start a new branch for development"
  21. helpUsage = """
  22. %prog <newbranchname> [<project>...]
  23. """
  24. helpDescription = """
  25. '%prog' begins a new branch of development, starting from the
  26. revision specified in the manifest.
  27. """
  28. def Execute(self, opt, args):
  29. if not args:
  30. self.Usage()
  31. nb = args[0]
  32. if not git.check_ref_format('heads/%s' % nb):
  33. print >>sys.stderr, "error: '%s' is not a valid name" % nb
  34. sys.exit(1)
  35. err = []
  36. for project in self.GetProjects(args[1:]):
  37. if not project.StartBranch(nb):
  38. err.append(project)
  39. if err:
  40. err.sort()
  41. for p in err:
  42. print >>sys.stderr, "error: cannot start in %s" % p.relpath
  43. sys.exit(1)