diff options
author | Catalin Marinas <catalin.marinas@gmail.com> | 2011-09-12 10:13:12 +0100 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@gmail.com> | 2011-09-12 10:13:12 +0100 |
commit | aa99027f77df6a5890872c02061d492c3a13c74e (patch) | |
tree | f37a9312c4f32378d74f8bde31cb6fb77952eb0e | |
parent | bd8778ae3ddf8b1c9d885b9b97aa0ae026bb8ae1 (diff) | |
download | stgit-aa99027f77df6a5890872c02061d492c3a13c74e.tar.gz |
Replace the 'stg status' command with the 'git status -s' alias
There isn't really any point in keeping another status command. The only
functionality missing would be 'status --reset' but this was moved to
the 'reset --hard' command (similar to what Git does).
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
-rw-r--r-- | stgit/commands/status.py | 110 | ||||
-rw-r--r-- | stgit/config.py | 3 | ||||
-rwxr-xr-x | t/t0002-status.sh | 45 | ||||
-rwxr-xr-x | t/t1205-push-subdir.sh | 2 | ||||
-rwxr-xr-x | t/t1501-sink.sh | 2 | ||||
-rwxr-xr-x | t/t1502-float-conflict-1.sh | 2 | ||||
-rwxr-xr-x | t/t1503-float-conflict-2.sh | 2 | ||||
-rwxr-xr-x | t/t2300-refresh-subdir.sh | 6 | ||||
-rwxr-xr-x | t/t2702-refresh-rm.sh | 28 | ||||
-rwxr-xr-x | t/t3101-reset-hard.sh | 2 | ||||
-rwxr-xr-x | t/t3103-undo-hard.sh | 2 | ||||
-rwxr-xr-x | t/t3200-non-ascii-filenames.sh | 2 |
12 files changed, 41 insertions, 165 deletions
diff --git a/stgit/commands/status.py b/stgit/commands/status.py deleted file mode 100644 index 8ea6526..0000000 --- a/stgit/commands/status.py +++ /dev/null @@ -1,110 +0,0 @@ - -__copyright__ = """ -Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com> - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License version 2 as -published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -""" - -import sys, os -from stgit.argparse import opt -from stgit.commands.common import * -from stgit.utils import * -from stgit import argparse, stack, git - -help = 'Show the tree status' -kind = 'wc' -usage = ['[options] [--] [<files or dirs>]'] -description = """ -Show the status of the whole working copy or the given files. The -command also shows the files in the current directory which are not -under revision control. The files are prefixed as follows: - - M - locally modified - N - newly added to the repository - D - deleted from the repository - C - conflict - ? - unknown - -An 'stg refresh' command clears the status of the modified, new and -deleted files.""" - -args = [argparse.files] -options = [ - opt('-m', '--modified', action = 'store_true', - short = 'Show modified files only'), - opt('-n', '--new', action = 'store_true', - short = 'Show new files only'), - opt('-d', '--deleted', action = 'store_true', - short = 'Show deleted files only'), - opt('-c', '--conflict', action = 'store_true', - short = 'Show conflict files only'), - opt('-u', '--unknown', action = 'store_true', - short = 'Show unknown files only'), - opt('-x', '--noexclude', action = 'store_true', - short = 'Do not exclude any files from listing'), - opt('--reset', action = 'store_true', - short = 'Reset the current tree changes')] - -directory = DirectoryHasRepository(needs_current_series = False, log = False) - -def status(files, modified, new, deleted, conflict, unknown, noexclude): - """Show the tree status - """ - cache_files = git.tree_status(files, - unknown = (not files), - noexclude = noexclude) - 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: - 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 - """ - args = git.ls_files(args) - directory.cd_to_topdir() - - if options.reset: - directory.log = True - if args: - conflicts = git.get_conflicts() - git.resolved([fn for fn in args if fn in conflicts]) - git.reset(args) - else: - resolved_all() - git.reset() - else: - status(args, options.modified, options.new, options.deleted, - options.conflict, options.unknown, options.noexclude) diff --git a/stgit/config.py b/stgit/config.py index dd194d3..15c4f7d 100644 --- a/stgit/config.py +++ b/stgit/config.py @@ -40,7 +40,8 @@ class GitConfig: 'stgit.alias.add': ['git add'], 'stgit.alias.rm': ['git rm'], 'stgit.alias.mv': ['git mv'], - 'stgit.alias.resolved': ['git add'] + 'stgit.alias.resolved': ['git add'], + 'stgit.alias.status': ['git status -s'] } __cache = None diff --git a/t/t0002-status.sh b/t/t0002-status.sh index c978845..ce157aa 100755 --- a/t/t0002-status.sh +++ b/t/t0002-status.sh @@ -24,7 +24,7 @@ test_expect_success 'Run status on empty' ' ' cat > expected.txt <<EOF -? foo +?? foo EOF test_expect_success 'Status with an untracked file' ' touch foo && @@ -42,7 +42,7 @@ test_expect_success 'Status with an empty directory' ' ' cat > expected.txt <<EOF -? foo/ +?? foo/ EOF test_expect_success 'Status with an untracked file in a subdir' ' touch foo/bar && @@ -51,7 +51,7 @@ test_expect_success 'Status with an untracked file in a subdir' ' ' cat > expected.txt <<EOF -A foo/bar +A foo/bar EOF test_expect_success 'Status with an added file' ' stg add foo && @@ -60,14 +60,6 @@ test_expect_success 'Status with an added file' ' ' cat > expected.txt <<EOF -foo/bar -EOF -test_expect_success 'Status with an added file and -n option' ' - stg status -n > output.txt && - test_cmp expected.txt output.txt -' - -cat > expected.txt <<EOF EOF test_expect_success 'Status after refresh' ' stg new -m "first patch" && @@ -77,7 +69,7 @@ test_expect_success 'Status after refresh' ' ' cat > expected.txt <<EOF -M foo/bar + M foo/bar EOF test_expect_success 'Status after modification' ' echo "wee" >> foo/bar && @@ -107,8 +99,8 @@ test_expect_success 'Make a conflicting patch' ' ' cat > expected.txt <<EOF -A fie -C foo/bar +A fie +UU foo/bar EOF test_expect_success 'Status after conflicting push' ' conflict stg push && @@ -117,7 +109,7 @@ test_expect_success 'Status after conflicting push' ' ' cat > expected.txt <<EOF -C foo/bar +UU foo/bar EOF test_expect_success 'Status of file' ' stg status foo/bar > output.txt && @@ -125,7 +117,7 @@ test_expect_success 'Status of file' ' ' cat > expected.txt <<EOF -C foo/bar +UU foo/bar EOF test_expect_success 'Status of dir' ' stg status foo > output.txt && @@ -133,7 +125,7 @@ test_expect_success 'Status of dir' ' ' cat > expected.txt <<EOF -A fie +A fie EOF test_expect_success 'Status of other file' ' stg status fie > output.txt && @@ -141,8 +133,8 @@ test_expect_success 'Status of other file' ' ' cat > expected.txt <<EOF -A fie -M foo/bar +A fie +M foo/bar EOF test_expect_success 'Status after resolving the push' ' stg add --update && @@ -151,8 +143,8 @@ test_expect_success 'Status after resolving the push' ' ' cat > expected.txt <<EOF -A fie -D foo/bar +A fie +MD foo/bar EOF test_expect_success 'Status after deleting a file' ' rm foo/bar && @@ -161,7 +153,7 @@ test_expect_success 'Status after deleting a file' ' ' cat > expected.txt <<EOF -D foo/bar +AD foo/bar EOF test_expect_success 'Status of disappeared newborn' ' stg refresh && @@ -173,8 +165,7 @@ test_expect_success 'Status of disappeared newborn' ' ' cat > expected.txt <<EOF -A fay -D fie +R fie -> fay EOF test_expect_success 'Status after renaming a file' ' stg rm foo/bar && @@ -183,10 +174,4 @@ test_expect_success 'Status after renaming a file' ' test_cmp expected.txt output.txt ' -test_expect_success 'Status after renaming a file (with rename detection)' ' - git config stgit.diff-opts -M && - stg status > output.txt && - test_cmp expected.txt output.txt -' - test_done diff --git a/t/t1205-push-subdir.sh b/t/t1205-push-subdir.sh index ed407d0..79aef68 100755 --- a/t/t1205-push-subdir.sh +++ b/t/t1205-push-subdir.sh @@ -49,7 +49,7 @@ test_expect_success 'Conflicting push from subdir' ' cd foo && conflict stg push p2 && cd .. && - [ "$(echo $(stg status --conflict))" = "foo/y.txt x.txt" ] + [ "$(echo $(stg status))" = "UU foo/y.txt UU x.txt" ] ' test_expect_success 'Conflicting add/unknown file in subdir' ' diff --git a/t/t1501-sink.sh b/t/t1501-sink.sh index e2c65cb..6f225e2 100755 --- a/t/t1501-sink.sh +++ b/t/t1501-sink.sh @@ -60,7 +60,7 @@ test_expect_success 'sink specified patch below a target' ' test_expect_success 'sink with conflict' ' conflict stg sink --to=p2 p22 && test "$(echo $(stg series --applied --noprefix))" = "p1 p22" && - test "$(echo $(stg status -c))" = "f2" + test "$(echo $(stg status))" = "DU f2" ' test_done diff --git a/t/t1502-float-conflict-1.sh b/t/t1502-float-conflict-1.sh index 7356d27..fb8101a 100755 --- a/t/t1502-float-conflict-1.sh +++ b/t/t1502-float-conflict-1.sh @@ -31,7 +31,7 @@ test_expect_success 'Float a patch, causing a conflict with the next patch' ' test "$(echo $(stg series))" = "+ p0 > p2 - p1" && test "$(stg id p2)" = "$(git rev-list HEAD~0 -n 1)" && test "$(stg id p0)" = "$(git rev-list HEAD~1 -n 1)" && - test "$(stg status)" = "C foo.txt" && + test "$(stg status)" = "UU foo.txt" && test_cmp foo.txt expected.txt ' diff --git a/t/t1503-float-conflict-2.sh b/t/t1503-float-conflict-2.sh index dc2b6c5..ad42ec5 100755 --- a/t/t1503-float-conflict-2.sh +++ b/t/t1503-float-conflict-2.sh @@ -35,7 +35,7 @@ test_expect_success 'Float a patch, causing a conflict two patches down' ' test "$(stg id p3)" = "$(git rev-list HEAD~0 -n 1)" && test "$(stg id p2)" = "$(git rev-list HEAD~1 -n 1)" && test "$(stg id p0)" = "$(git rev-list HEAD~2 -n 1)" && - test "$(stg status)" = "C foo.txt" && + test "$(stg status)" = "UU foo.txt" && test_cmp foo.txt expected.txt ' diff --git a/t/t2300-refresh-subdir.sh b/t/t2300-refresh-subdir.sh index 34d6e69..becec12 100755 --- a/t/t2300-refresh-subdir.sh +++ b/t/t2300-refresh-subdir.sh @@ -30,13 +30,13 @@ test_expect_success 'Refresh file in subdirectory' ' cd bar && stg refresh bar.txt && cd .. && - [ "$(stg status)" = "M foo.txt" ] + [ "$(stg status)" = " M foo.txt" ] ' test_expect_success 'Refresh whole subdirectory' ' echo bar4 >> bar/bar.txt && stg refresh bar && - [ "$(stg status)" = "M foo.txt" ] + [ "$(stg status)" = " M foo.txt" ] ' test_expect_success 'Refresh subdirectories recursively' ' @@ -66,7 +66,7 @@ test_expect_success 'refresh -u -p <subdir>' ' test_expect_success 'refresh an unapplied patch' ' stg refresh -u && stg goto --keep p0 && - test "$(stg status)" = "M foo.txt" && + test "$(stg status)" = " M foo.txt" && stg refresh -p p1 && test "$(stg status)" = "" && test "$(echo $(stg files p1))" = "A bar/baz.txt M foo.txt" diff --git a/t/t2702-refresh-rm.sh b/t/t2702-refresh-rm.sh index fa81cee..d437198 100755 --- a/t/t2702-refresh-rm.sh +++ b/t/t2702-refresh-rm.sh @@ -25,7 +25,7 @@ test_expect_success 'Initialize StGit stack' ' ' cat > expected0.txt <<EOF -D y.txt +D y.txt EOF printf '' > expected1.txt test_expect_success 'stg rm a file' ' @@ -36,15 +36,15 @@ test_expect_success 'stg rm a file' ' stg refresh && stg status > status1.txt && test_cmp expected1.txt status1.txt && - stg files | sort > files.txt && - test_cmp expected0.txt files.txt + stg files > files.txt && + test_cmp -w expected0.txt files.txt ' reset cat > expected0.txt <<EOF -D y.txt -M x.txt + M x.txt +D y.txt EOF printf '' > expected1.txt test_expect_success 'stg rm a file together with other changes' ' @@ -56,14 +56,14 @@ test_expect_success 'stg rm a file together with other changes' ' stg refresh && stg status > status1.txt && test_cmp expected1.txt status1.txt && - stg files | sort > files.txt && - test_cmp expected0.txt files.txt + stg files > files.txt && + test_cmp -w expected0.txt files.txt ' reset cat > expected0.txt <<EOF -D y.txt + D y.txt EOF printf '' > expected1.txt test_expect_success 'rm a file' ' @@ -74,15 +74,15 @@ test_expect_success 'rm a file' ' stg refresh && stg status > status1.txt && test_cmp expected1.txt status1.txt && - stg files | sort > files.txt && - test_cmp expected0.txt files.txt + stg files > files.txt && + test_cmp -w expected0.txt files.txt ' reset cat > expected0.txt <<EOF -D y.txt -M x.txt + M x.txt + D y.txt EOF printf '' > expected1.txt test_expect_success 'rm a file together with other changes' ' @@ -94,8 +94,8 @@ test_expect_success 'rm a file together with other changes' ' stg refresh && stg status > status1.txt && test_cmp expected1.txt status1.txt && - stg files | sort > files.txt && - test_cmp expected0.txt files.txt + stg files > files.txt && + test_cmp -w expected0.txt files.txt ' test_done diff --git a/t/t3101-reset-hard.sh b/t/t3101-reset-hard.sh index a93682b..85b5f46 100755 --- a/t/t3101-reset-hard.sh +++ b/t/t3101-reset-hard.sh @@ -25,7 +25,7 @@ test_expect_success 'Initialize StGit stack with three patches' ' ' cat > expected.txt <<EOF -C a +UU a EOF test_expect_success 'Pop middle patch, creating a conflict' ' conflict stg pop p2 && diff --git a/t/t3103-undo-hard.sh b/t/t3103-undo-hard.sh index b94543e..f91b8c1 100755 --- a/t/t3103-undo-hard.sh +++ b/t/t3103-undo-hard.sh @@ -26,7 +26,7 @@ test_expect_success 'Initialize StGit stack with three patches' ' ' cat > expected.txt <<EOF -C a +UU a EOF test_expect_success 'Pop middle patch, creating a conflict' ' conflict stg pop p2 && diff --git a/t/t3200-non-ascii-filenames.sh b/t/t3200-non-ascii-filenames.sh index fe2ecc0..748892a 100755 --- a/t/t3200-non-ascii-filenames.sh +++ b/t/t3200-non-ascii-filenames.sh @@ -38,7 +38,7 @@ test_expect_success 'Setup' ' ' cat > expected.txt <<EOF -M skärgårdsö.txt + M "sk\303\244rg\303\245rds\303\266.txt" EOF test_expect_success 'Status of modified non-ASCII file' ' stg status > output.txt && |