1 from stgit
import argparse
2 from stgit
.argparse
import opt
3 from stgit
.commands
.common
import (
5 DirectoryHasRepository
,
9 from stgit
.out
import out
12 Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License version 2 as
16 published by the Free Software Foundation.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see http://www.gnu.org/licenses/.
27 help = 'Show the files modified by a patch (or the current patch)'
29 usage
= ['[options] [--] [[<branch>:]<patch>]']
31 List the files modified by the given patch (defaulting to the current
32 one). Passing the '--stat' option shows the diff statistics for the
33 given patch. Note that this command doesn't show the files modified in
34 the working tree and not yet included in the patch by a 'refresh'
35 command. Use the 'diff' or 'status' commands for these files."""
37 args
= ['applied_patches', 'unapplied_patches', 'hidden_patches']
39 opt('-s', '--stat', action
='store_true', short
='Show the diffstat'),
40 opt('--bare', action
='store_true', short
='Bare file names (useful for scripting)'),
41 ] + argparse
.diff_opts_option()
43 directory
= DirectoryHasRepository()
46 def func(parser
, options
, args
):
47 """Show the files modified by a patch (or the current patch)"""
48 if options
.bare
and options
.stat
:
49 raise CmdException('Cannot specify both --bare and --stat')
50 repository
= directory
.repository
52 stack
= repository
.current_stack
55 branch
, name
= parse_rev(args
[0])
56 stack
= repository
.get_stack(branch
)
57 if name
not in stack
.patches
:
58 raise CmdException('%s: Unknown patch name' % name
)
59 commit
= stack
.patches
[name
]
61 parser
.error('incorrect number of arguments')
64 cmd
= ['git', 'diff-tree', '--stat', '--summary', '--no-commit-id']
65 cmd
.extend(options
.diff_flags
)
66 cmd
.extend(color_diff_flags())
67 cmd
.append(commit
.sha1
)
68 out
.stdout_bytes(repository
.run(cmd
).decoding(None).raw_output())
71 for dt
in repository
.diff_tree_files(
72 commit
.data
.parent
.data
.tree
, commit
.data
.tree
74 _
, _
, _
, _
, status
, oldname
, newname
= dt
75 for filename
in [oldname
, newname
]:
84 out
.stdout('%s %s' % (status
, filename
))