blob: f233f690e3812250ec026829a6cae5dbe4a5699f [file] [log] [blame]
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07001#
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
16from command import PagedCommand
17
18class Diff(PagedCommand):
19 common = True
20 helpSummary = "Show changes between commit and working tree"
21 helpUsage = """
22%prog [<project>...]
pelyad67872d2012-03-28 14:49:58 +030023
24The -u option causes '%prog' to generate diff output with file paths
25relative to the repository root, so the output can be applied
26to the Unix 'patch' command.
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070027"""
28
pelyad67872d2012-03-28 14:49:58 +030029 def _Options(self, p):
30 def cmd(option, opt_str, value, parser):
31 setattr(parser.values, option.dest, list(parser.rargs))
32 while parser.rargs:
33 del parser.rargs[0]
34 p.add_option('-u', '--absolute',
35 dest='absolute', action='store_true',
36 help='Paths are relative to the repository root')
37
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070038 def Execute(self, opt, args):
39 for project in self.GetProjects(args):
pelyad67872d2012-03-28 14:49:58 +030040 project.PrintWorkTreeDiff(opt.absolute)