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