X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/2ace36ab494d7f3ee2748e74be92568725078828..6dd8fafabb5b8e266a85f13c8851ca8a66a1a405:/stgit/commands/status.py diff --git a/stgit/commands/status.py b/stgit/commands/status.py index 156552b..a688f7e 100644 --- a/stgit/commands/status.py +++ b/stgit/commands/status.py @@ -40,6 +40,7 @@ under revision control. The files are prefixed as follows: A 'refresh' command clears the status of the modified, new and deleted files.""" +directory = DirectoryHasRepository() options = [make_option('-m', '--modified', help = 'show modified files only', action = 'store_true'), @@ -65,6 +66,42 @@ options = [make_option('-m', '--modified', action = 'store_true')] +def status(files = None, modified = False, new = False, deleted = False, + conflict = False, unknown = False, noexclude = False, + diff_flags = []): + """Show the tree status + """ + cache_files = git.tree_status(files, + unknown = (files == None), + noexclude = noexclude, + diff_flags = diff_flags) + filtered = (modified or new or deleted or conflict or unknown) + + if filtered: + filestat = [] + if modified: + filestat.append('M') + if new: + filestat.append('A') + filestat.append('N') + if deleted: + filestat.append('D') + if conflict: + filestat.append('C') + if unknown: + filestat.append('?') + cache_files = [x for x in cache_files if x[0] in filestat] + + output = [] + for st, fn in cache_files: + assert files == None or fn in files + if filtered: + output.append(fn) + else: + output.append('%s %s' % (st, fn)) + for o in sorted(output): + out.stdout(o) + def func(parser, options, args): """Show the tree status """ @@ -82,6 +119,9 @@ def func(parser, options, args): else: diff_flags = [] - git.status(args, options.modified, options.new, options.deleted, - options.conflict, options.unknown, options.noexclude, - diff_flags = diff_flags) + # No args means all files + if not args: + args = None + status(args, options.modified, options.new, options.deleted, + options.conflict, options.unknown, options.noexclude, + diff_flags = diff_flags)