[PATCH] 'hg status -q' output skips non-tracked files
Zoran Bosnjak
zoran.bosnjak at via.si
Sat Mar 1 16:23:24 CST 2008
# HG changeset patch
# User Zoran Bosnjak <zoran.bosnjak at via.si>
# Date 1204407003 -3600
# Node ID 90a087257f1e1138b4dd3981fa21c9262f2288bd
# Parent 434139080ed4007d99e843b203c7da0850238744
'hg status -q' output skips non-tracked files.
The '-q' flag was ignored in status command. But this flag
can be used to hide non-tracked files in hg status output.
This small correction makes status command more general,
similar to 'svn status', where '-q' flag has the same effect.
The '-u' and '-A' flags have priority over '-q'.
A testcase and doc-string for status was extended to cover
'-q' flag.
diff -r 434139080ed4 -r 90a087257f1e mercurial/commands.py
--- a/mercurial/commands.py Mon Jan 28 22:19:12 2008 -0500
+++ b/mercurial/commands.py Sat Mar 01 22:30:03 2008 +0100
@@ -2480,6 +2480,9 @@ def status(ui, repo, *pats, **opts):
-i (ignored), -C (copies) or -A is given. Unless options described
with "show only ..." are given, the options -mardu are used.
+ Option -q/--quiet hides untracked files unless explicitly
+ requested by -u.
+
NOTE: status may appear to disagree with diff if permissions have
changed or a merge has occurred. The standard diff format does not
report permission changes and diff only reports changes relative
@@ -2524,6 +2527,12 @@ def status(ui, repo, *pats, **opts):
for opt, char, changes in ([ct for ct in explicit_changetypes
if all or opts[ct[0]]]
or changetypes):
+
+ # skip unknown files if -q, but -u and -A have priority over -q
+ if (not opts['unknown']) and (not opts['all']):
+ if opt == 'unknown' and ui.quiet:
+ continue
+
if opts['no_status']:
format = "%%s%s" % end
else:
diff -r 434139080ed4 -r 90a087257f1e tests/test-help.out
--- a/tests/test-help.out Mon Jan 28 22:19:12 2008 -0500
+++ b/tests/test-help.out Sat Mar 01 22:30:03 2008 +0100
@@ -222,6 +222,9 @@ show changed files in the working direct
-i (ignored), -C (copies) or -A is given. Unless options described
with "show only ..." are given, the options -mardu are used.
+ Option -q/--quiet hides untracked files unless explicitly
+ requested by -u.
+
NOTE: status may appear to disagree with diff if permissions have
changed or a merge has occurred. The standard diff format does not
report permission changes and diff only reports changes relative
diff -r 434139080ed4 -r 90a087257f1e tests/test-status
--- a/tests/test-status Mon Jan 28 22:19:12 2008 -0500
+++ b/tests/test-status Sat Mar 01 22:30:03 2008 +0100
@@ -44,3 +44,51 @@ hg status ignoreddir/file
hg status ignoreddir/file
echo "hg status -i ignoreddir/file:"
hg status -i ignoreddir/file
+cd ..
+
+# check 'status -q' and some combinations
+hg init repo3
+cd repo3
+touch modified removed deleted ignored
+echo "^ignored$" > .hgignore
+hg commit -A -m 'initial checkin'
+touch added unknown ignored
+hg add added
+echo "test" >> modified
+hg remove removed
+rm deleted
+hg copy modified copied
+
+# Run status with 2 different flags.
+# Check if result is the same or different.
+# If result is not as expected, raise error
+function assert {
+ hg status $1 > ../a
+ hg status $2 > ../b
+ out=`diff ../a ../b`
+ if [ $? -ne 0 ]; then
+ out=1
+ else
+ out=0
+ fi
+ if [ $3 -eq 0 ]; then
+ df="same"
+ else
+ df="different"
+ fi
+ if [ $out -ne $3 ]; then
+ echo "Error on $1 and $2, should be $df."
+ fi
+}
+
+# assert flag1 flag2 [0-same | 1-different]
+assert "-q" "-mard" 0
+assert "-A" "-mardicCu" 0
+assert "-qA" "-mardicCu" 0
+assert "-qAu" "-A" 0
+assert "-qA" "-A" 0
+assert "-qu" "-u" 0
+assert "-q" "-u" 1
+assert "-m" "-a" 1
+assert "-r" "-d" 1
+
diff -r 434139080ed4 -r 90a087257f1e tests/test-status.out
--- a/tests/test-status.out Mon Jan 28 22:19:12 2008 -0500
+++ b/tests/test-status.out Sat Mar 01 22:30:03 2008 +0100
@@ -120,3 +120,7 @@ hg status ignoreddir/file:
hg status ignoreddir/file:
hg status -i ignoreddir/file:
I ignoreddir/file
+adding .hgignore
+adding deleted
+adding modified
+adding removed
More information about the Mercurial-devel
mailing list