blob: 1f3abd86b8f0481ec6aee1fb835ccd4e01fb69a3 [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):
40 for project in self.GetProjects(args):
pelyad67872d2012-03-28 14:49:58 +030041 project.PrintWorkTreeDiff(opt.absolute)