3 Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License version 2 as
7 published by the Free Software Foundation.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 from stgit.argparse import opt
21 from stgit.commands.common import *
22 from stgit.utils import *
23 from stgit import argparse, stack, git
25 help = 'Show the tree status'
27 usage = ['[options] [<files or dirs>]']
29 Show the status of the whole working copy or the given files. The
30 command also shows the files in the current directory which are not
31 under revision control. The files are prefixed as follows:
34 N - newly added to the repository
35 D - deleted from the repository
39 An 'stg refresh' command clears the status of the modified, new and
42 args = [argparse.files]
44 opt('-m', '--modified', action = 'store_true',
45 short = 'Show modified files only'),
46 opt('-n', '--new', action = 'store_true',
47 short = 'Show new files only'),
48 opt('-d', '--deleted', action = 'store_true',
49 short = 'Show deleted files only'),
50 opt('-c', '--conflict', action = 'store_true',
51 short = 'Show conflict files only'),
52 opt('-u', '--unknown', action = 'store_true',
53 short = 'Show unknown files only'),
54 opt('-x', '--noexclude', action = 'store_true',
55 short = 'Do not exclude any files from listing'),
56 opt('--reset', action = 'store_true',
57 short = 'Reset the current tree changes')]
59 directory = DirectoryHasRepository(needs_current_series = False, log = False)
61 def status(files, modified, new, deleted, conflict, unknown, noexclude):
62 """Show the tree status
64 cache_files = git.tree_status(files,
65 unknown = (not files),
66 noexclude = noexclude)
67 filtered = (modified or new or deleted or conflict or unknown)
82 cache_files = [x for x in cache_files if x[0] in filestat]
85 for st, fn in cache_files:
89 output.append('%s %s' % (st, fn))
90 for o in sorted(output):
93 def func(parser, options, args):
94 """Show the tree status
96 args = git.ls_files(args)
97 directory.cd_to_topdir()
102 conflicts = git.get_conflicts()
103 git.resolved([fn for fn in args if fn in conflicts])
109 status(args, options.modified, options.new, options.deleted,
110 options.conflict, options.unknown, options.noexclude)