The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 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 | |
| 15 | from command import PagedCommand |
| 16 | |
David Pursehouse | 819827a | 2020-02-12 15:20:19 +0900 | [diff] [blame] | 17 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 18 | class Diff(PagedCommand): |
| 19 | common = True |
| 20 | helpSummary = "Show changes between commit and working tree" |
| 21 | helpUsage = """ |
| 22 | %prog [<project>...] |
pelya | d67872d | 2012-03-28 14:49:58 +0300 | [diff] [blame] | 23 | |
| 24 | The -u option causes '%prog' to generate diff output with file paths |
| 25 | relative to the repository root, so the output can be applied |
| 26 | to the Unix 'patch' command. |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 27 | """ |
| 28 | |
pelya | d67872d | 2012-03-28 14:49:58 +0300 | [diff] [blame] | 29 | def _Options(self, p): |
pelya | d67872d | 2012-03-28 14:49:58 +0300 | [diff] [blame] | 30 | p.add_option('-u', '--absolute', |
| 31 | dest='absolute', action='store_true', |
| 32 | help='Paths are relative to the repository root') |
| 33 | |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 34 | def Execute(self, opt, args): |
Mike Frysinger | 0a9265e | 2019-09-30 23:59:27 -0400 | [diff] [blame] | 35 | ret = 0 |
The Android Open Source Project | cf31fe9 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 36 | for project in self.GetProjects(args): |
Mike Frysinger | 0a9265e | 2019-09-30 23:59:27 -0400 | [diff] [blame] | 37 | if not project.PrintWorkTreeDiff(opt.absolute): |
| 38 | ret = 1 |
| 39 | return ret |