1 from stgit
.argparse
import diff_opts_option
, opt
, patch_range
2 from stgit
.commands
.common
import DirectoryHasRepository
, color_diff_flags
, git_commit
3 from stgit
.pager
import pager
6 Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as
10 published by the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, see http://www.gnu.org/licenses/.
21 help = 'Show the tree diff'
23 usage
= ['[options] [--] [<files or dirs>]']
25 Show the diff (default) or diffstat between the current working copy
26 or a tree-ish object and another tree-ish object (defaulting to HEAD).
27 File names can also be given to restrict the diff output. The
28 tree-ish object has the format accepted by the linkstg:id[] command."""
30 args
= ['known_files', 'dirty_files']
35 metavar
='rev1[..[rev2]]',
44 short
='Show the diff between revisions',
50 short
='Show the stat instead of the diff',
52 ] + diff_opts_option()
54 directory
= DirectoryHasRepository()
57 def func(parser
, options
, args
):
58 """Show the tree diff."""
59 repository
= directory
.repository
62 rev_list
= options
.revs
.split('..')
63 if len(rev_list
) not in [1, 2] or not rev_list
[0]:
64 parser
.error('incorrect parameters to -r')
65 elif len(rev_list
) == 1:
66 rev1
= git_commit(rev_list
[0], repository
)
69 rev1
= git_commit(rev_list
[0], repository
)
71 rev2
= git_commit(rev_list
[1], repository
)
75 rev1
= repository
.rev_parse('HEAD')
78 iw
= repository
.default_iw
80 files
= iw
.ls_files(rev1
.data
.tree
, args
)
82 diff_opts
= color_diff_flags()
83 diff_opts
.extend(options
.diff_flags
)
86 diff
= repository
.diff_tree(