diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -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), @@ -2541,11 +2549,6 @@ def status(ui, repo, *pats, **opts): 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 --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -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 --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -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 --git a/tests/test-help.out b/tests/test-help.out --- a/tests/test-help.out +++ b/tests/test-help.out @@ -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 --git a/tests/test-status b/tests/test-status --- a/tests/test-status +++ b/tests/test-status @@ -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