blob: 190b18f4ee788cc8cf400d57b6e43ef344fbb733 [file] [log] [blame]
Mike Frysingerf6013762019-06-13 02:30:51 -04001# -*- coding:utf-8 -*-
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07002#
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
17from command import PagedCommand
18
David Pursehouse819827a2020-02-12 15:20:19 +090019
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070020class Diff(PagedCommand):
21 common = True
22 helpSummary = "Show changes between commit and working tree"
23 helpUsage = """
24%prog [<project>...]
pelyad67872d2012-03-28 14:49:58 +030025
26The -u option causes '%prog' to generate diff output with file paths
27relative to the repository root, so the output can be applied
28to the Unix 'patch' command.
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070029"""
30
pelyad67872d2012-03-28 14:49:58 +030031 def _Options(self, p):
pelyad67872d2012-03-28 14:49:58 +030032 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 Projectcf31fe92008-10-21 07:00:00 -070036 def Execute(self, opt, args):
Mike Frysinger0a9265e2019-09-30 23:59:27 -040037 ret = 0
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070038 for project in self.GetProjects(args):
Mike Frysinger0a9265e2019-09-30 23:59:27 -040039 if not project.PrintWorkTreeDiff(opt.absolute):
40 ret = 1
41 return ret