diff.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright (C) 2008 The Android Open Source Project
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from command import PagedCommand
  15. class Diff(PagedCommand):
  16. common = True
  17. helpSummary = "Show changes between commit and working tree"
  18. helpUsage = """
  19. %prog [<project>...]
  20. The -u option causes '%prog' to generate diff output with file paths
  21. relative to the repository root, so the output can be applied
  22. to the Unix 'patch' command.
  23. """
  24. def _Options(self, p):
  25. p.add_option('-u', '--absolute',
  26. dest='absolute', action='store_true',
  27. help='Paths are relative to the repository root')
  28. def Execute(self, opt, args):
  29. ret = 0
  30. for project in self.GetProjects(args):
  31. if not project.PrintWorkTreeDiff(opt.absolute):
  32. ret = 1
  33. return ret