blob: fa41e70ec3fe3093c346931e2b7207b1e4c1f92d [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
19class Diff(PagedCommand):
20 common = True
21 helpSummary = "Show changes between commit and working tree"
22 helpUsage = """
23%prog [<project>...]
pelyad67872d2012-03-28 14:49:58 +030024
25The -u option causes '%prog' to generate diff output with file paths
26relative to the repository root, so the output can be applied
27to the Unix 'patch' command.
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070028"""
29
pelyad67872d2012-03-28 14:49:58 +030030 def _Options(self, p):
31 def cmd(option, opt_str, value, parser):
32 setattr(parser.values, option.dest, list(parser.rargs))
33 while parser.rargs:
34 del parser.rargs[0]
35 p.add_option('-u', '--absolute',
36 dest='absolute', action='store_true',
37 help='Paths are relative to the repository root')
38
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070039 def Execute(self, opt, args):
Mike Frysinger0a9265e2019-09-30 23:59:27 -040040 ret = 0
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070041 for project in self.GetProjects(args):
Mike Frysinger0a9265e2019-09-30 23:59:27 -040042 if not project.PrintWorkTreeDiff(opt.absolute):
43 ret = 1
44 return ret