diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2464,19 +2464,23 @@ def status(ui, repo, *pats, **opts): R = removed ! = deleted, but still tracked ? = not tracked + I = ignored (not shown by default) """ + show_ignored = opts['ignored'] and True or False files, matchfn, anypats = matchpats(repo, pats, opts) cwd = (pats and repo.getcwd()) or '' - modified, added, removed, deleted, unknown = [ + modified, added, removed, deleted, unknown, ignored = [ [util.pathto(cwd, x) for x in n] - for n in repo.changes(files=files, match=matchfn)] + for n in repo.changes(files=files, match=matchfn, + show_ignored=show_ignored)] changetypes = [('modified', 'M', modified), ('added', 'A', added), ('removed', 'R', removed), ('deleted', '!', deleted), - ('unknown', '?', unknown)] + ('unknown', '?', unknown), + ('ignored', 'I', ignored)] end = opts['print0'] and '\0' or '\n' @@ -2952,6 +2956,7 @@ table = { ('r', 'removed', None, _('show only removed files')), ('d', 'deleted', None, _('show only deleted (but tracked) files')), ('u', 'unknown', None, _('show only unknown (not tracked) files')), + ('i', 'ignored', None, _('show ignored files')), ('n', 'no-status', None, _('hide status prefix')), ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -294,7 +294,7 @@ class dirstate(object): kind)) return False - def statwalk(self, files=None, match=util.always, dc=None): + def statwalk(self, files=None, match=util.always, dc=None, ignored=False): self.lazyread() # walk all files by default @@ -307,7 +307,7 @@ class dirstate(object): def statmatch(file_, stat): file_ = util.pconvert(file_) - if file_ not in dc and self.ignore(file_): + if not ignored and file_ not in dc and self.ignore(file_): return False return match(file_) @@ -409,15 +409,18 @@ class dirstate(object): if not seen(k) and (statmatch(k, None)): yield 'm', k, None - def changes(self, files=None, match=util.always): - lookup, modified, added, unknown = [], [], [], [] + def changes(self, files=None, match=util.always, show_ignored=None): + lookup, modified, added, unknown, ignored = [], [], [], [], [] removed, deleted = [], [] - for src, fn, st in self.statwalk(files, match): + for src, fn, st in self.statwalk(files, match, ignored=show_ignored): try: type_, mode, size, time = self[fn] except KeyError: - unknown.append(fn) + if show_ignored and self.ignore(fn): + ignored.append(fn) + else: + unknown.append(fn) continue if src == 'm': nonexistent = True @@ -453,4 +456,4 @@ class dirstate(object): elif type_ == 'r': removed.append(fn) - return (lookup, modified, added, removed, deleted, unknown) + return (lookup, modified, added, removed, deleted, unknown, ignored) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -498,7 +498,7 @@ class localrepository(object): yield src, fn def changes(self, node1=None, node2=None, files=[], match=util.always, - wlock=None): + wlock=None, show_ignored=None): """return changes between two nodes or node and working directory If node1 is None, use the first dirstate parent instead. @@ -531,8 +531,8 @@ class localrepository(object): wlock = self.wlock(wait=0) except lock.LockException: wlock = None - lookup, modified, added, removed, deleted, unknown = ( - self.dirstate.changes(files, match)) + lookup, modified, added, removed, deleted, unknown, ignored = ( + self.dirstate.changes(files, match, show_ignored)) # are we comparing working dir against its parent? if not node1: @@ -555,7 +555,7 @@ class localrepository(object): del mf2[f] else: # we are comparing two revisions - deleted, unknown = [], [] + deleted, unknown, ignored = [], [], [] mf2 = mfmatches(node2) if node1: @@ -573,9 +573,12 @@ class localrepository(object): removed = mf1.keys() # sort and return results: - for l in modified, added, removed, deleted, unknown: + for l in modified, added, removed, deleted, unknown, ignored: l.sort() - return (modified, added, removed, deleted, unknown) + if show_ignored is None: + return (modified, added, removed, deleted, unknown) + else: + return (modified, added, removed, deleted, unknown, ignored) def add(self, list, wlock=None): if not wlock: diff --git a/tests/test-help.out b/tests/test-help.out --- a/tests/test-help.out +++ b/tests/test-help.out @@ -190,6 +190,7 @@ show changed files in the working direct R = removed ! = deleted, but still tracked ? = not tracked + I = ignored (not shown by default) aliases: st @@ -200,6 +201,7 @@ options: -r --removed show only removed files -d --deleted show only deleted (but tracked) files -u --unknown show only unknown (not tracked) files + -i --ignored show ignored files -n --no-status hide status prefix -0 --print0 end filenames with NUL, for use with xargs -I --include include names matching the given patterns