start.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. for p in err:
  46. print >>sys.stderr,\
  47. "error: %s/: cannot start %s" \
  48. % (p.relpath, nb)
  49. sys.exit(1)