start.py 1.5 KB

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