diff.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. from command import PagedCommand
  16. class Diff(PagedCommand):
  17. common = True
  18. helpSummary = "Show changes between commit and working tree"
  19. helpUsage = """
  20. %prog [<project>...]
  21. The -u option causes '%prog' to generate diff output with file paths
  22. relative to the repository root, so the output can be applied
  23. to the Unix 'patch' command.
  24. """
  25. def _Options(self, p):
  26. def cmd(option, opt_str, value, parser):
  27. setattr(parser.values, option.dest, list(parser.rargs))
  28. while parser.rargs:
  29. del parser.rargs[0]
  30. p.add_option('-u', '--absolute',
  31. dest='absolute', action='store_true',
  32. help='Paths are relative to the repository root')
  33. def Execute(self, opt, args):
  34. for project in self.GetProjects(args):
  35. project.PrintWorkTreeDiff(opt.absolute)