[PATCH] 'hg status -q' output skips non-tracked files
Thomas Arendsen Hein
thomas at intevation.de
Sun Mar 2 06:56:57 CST 2008
* Zoran Bosnjak <zoran.bosnjak at via.si> [20080301 23:56]:
> # 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.
Pushed to crew to get your status testing framework followed by
this patch:
# HG changeset patch
# User Thomas Arendsen Hein <thomas at intevation.de>
# Date 1204462354 -3600
# Node ID 305d4450036a9293eec7b3b057be34fd539f4538
# Parent acc40572da5b26d79106c42eca3b3a1274c05df1
Extend/correct acc40572da5b regarding -qA and ignored files.
hg status -qA will now hide untracked files as described in the doc string.
diff -r acc40572da5b -r 305d4450036a mercurial/commands.py
--- a/mercurial/commands.py Sat Mar 01 22:30:03 2008 +0100
+++ b/mercurial/commands.py Sun Mar 02 13:52:34 2008 +0100
@@ -2493,8 +2493,8 @@ 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.
+ Option -q/--quiet hides untracked (unknown and ignored) files
+ unless explicitly requested with -u/--unknown or -i/-ignored.
NOTE: status may appear to disagree with diff if permissions have
changed or a merge has occurred. The standard diff format does not
@@ -2522,9 +2522,17 @@ def status(ui, repo, *pats, **opts):
cwd = (pats and repo.getcwd()) or ''
modified, added, removed, deleted, unknown, ignored, clean = [
n for n in repo.status(node1=node1, node2=node2, files=files,
- match=matchfn,
- list_ignored=all or opts['ignored'],
- list_clean=all or opts['clean'])]
+ match=matchfn,
+ list_ignored=opts['ignored']
+ or all and not ui.quiet,
+ list_clean=opts['clean'] or all,
+ list_unknown=opts['unknown']
+ or not (ui.quiet or
+ opts['modified'] or
+ opts['added'] or
+ opts['removed'] or
+ opts['deleted'] or
+ opts['ignored']))]
changetypes = (('modified', 'M', modified),
('added', 'A', added),
@@ -2540,11 +2548,6 @@ 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
diff -r acc40572da5b -r 305d4450036a mercurial/dirstate.py
--- a/mercurial/dirstate.py Sat Mar 01 22:30:03 2008 +0100
+++ b/mercurial/dirstate.py Sun Mar 02 13:52:34 2008 +0100
@@ -383,8 +383,8 @@ class dirstate(object):
for src, f, st in self.statwalk(files, match, badmatch=badmatch):
yield src, f
- def statwalk(self, files=None, match=util.always, ignored=False,
- badmatch=None, directories=False):
+ def statwalk(self, files=None, match=util.always, unknown=True,
+ ignored=False, badmatch=None, directories=False):
'''
walk recursively through the directory tree, finding all files
matched by the match function
@@ -412,6 +412,7 @@ class dirstate(object):
return False
return match(file_)
+ # TODO: don't walk unknown directories if unknown and ignored are False
ignore = self._ignore
dirignore = self._dirignore
if ignored:
@@ -527,7 +528,7 @@ class dirstate(object):
if imatch(k):
yield 'm', k, None
- def status(self, files, match, list_ignored, list_clean):
+ def status(self, files, match, list_ignored, list_clean, list_unknown=True):
lookup, modified, added, unknown, ignored = [], [], [], [], []
removed, deleted, clean = [], [], []
@@ -545,14 +546,15 @@ class dirstate(object):
dadd = deleted.append
cadd = clean.append
- for src, fn, st in self.statwalk(files, match, ignored=list_ignored):
+ for src, fn, st in self.statwalk(files, match, unknown=list_unknown,
+ ignored=list_ignored):
if fn in dmap:
type_, mode, size, time, foo = dmap[fn]
else:
if (list_ignored or fn in files) and self._dirignore(fn):
if list_ignored:
iadd(fn)
- else:
+ elif list_unknown:
uadd(fn)
continue
if src == 'm':
diff -r acc40572da5b -r 305d4450036a mercurial/localrepo.py
--- a/mercurial/localrepo.py Sat Mar 01 22:30:03 2008 +0100
+++ b/mercurial/localrepo.py Sun Mar 02 13:52:34 2008 +0100
@@ -959,7 +959,7 @@ class localrepository(repo.repository):
yield src, fn
def status(self, node1=None, node2=None, files=[], match=util.always,
- list_ignored=False, list_clean=False):
+ list_ignored=False, list_clean=False, list_unknown=True):
"""return status of files between two nodes or node and working directory
If node1 is None, use the first dirstate parent instead.
@@ -995,7 +995,8 @@ class localrepository(repo.repository):
if not node2:
(lookup, modified, added, removed, deleted, unknown,
ignored, clean) = self.dirstate.status(files, match,
- list_ignored, list_clean)
+ list_ignored, list_clean,
+ list_unknown)
# are we comparing working dir against its parent?
if compareworking:
diff -r acc40572da5b -r 305d4450036a tests/test-help.out
--- a/tests/test-help.out Sat Mar 01 22:30:03 2008 +0100
+++ b/tests/test-help.out Sun Mar 02 13:52:34 2008 +0100
@@ -222,8 +222,8 @@ 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.
+ Option -q/--quiet hides untracked (unknown and ignored) files
+ unless explicitly requested with -u/--unknown or -i/-ignored.
NOTE: status may appear to disagree with diff if permissions have
changed or a merge has occurred. The standard diff format does not
diff -r acc40572da5b -r 305d4450036a tests/test-status
--- a/tests/test-status Sat Mar 01 22:30:03 2008 +0100
+++ b/tests/test-status Sun Mar 02 13:52:34 2008 +0100
@@ -82,13 +82,14 @@ function assert {
}
# 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
+assert "-q" "-mard" 0
+assert "-A" "-marduicC" 0
+assert "-qA" "-mardcC" 0
+assert "-qAui" "-A" 0
+assert "-qAu" "-marducC" 0
+assert "-qAi" "-mardicC" 0
+assert "-qu" "-u" 0
+assert "-q" "-u" 1
+assert "-m" "-a" 1
+assert "-r" "-d" 1
--
thomas at intevation.de - http://intevation.de/~thomas/ - OpenPGP key: 0x5816791A
Intevation GmbH, Osnabrueck - Register: Amtsgericht Osnabrueck, HR B 18998
Geschaeftsfuehrer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
More information about the Mercurial-devel
mailing list