changeset 2022:a59da8cc35e4

New option -i/--ignored for 'hg status' to show ignored files. localrepo.changes() now returns an additional list of ignored files if it is called with show_ignored=True.
author Thomas Arendsen Hein <thomas@intevation.de>
date Wed, 29 Mar 2006 22:58:34 +0200
parents fc22ed56afe3
children 3bdd3bf17cfa
files mercurial/commands.py mercurial/dirstate.py mercurial/localrepo.py tests/test-help.out
diffstat 4 files changed, 29 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Mar 29 22:35:21 2006 +0200
+++ b/mercurial/commands.py	Wed Mar 29 22:58:34 2006 +0200
@@ -2464,19 +2464,23 @@
     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 @@
           ('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')),
--- a/mercurial/dirstate.py	Wed Mar 29 22:35:21 2006 +0200
+++ b/mercurial/dirstate.py	Wed Mar 29 22:58:34 2006 +0200
@@ -294,7 +294,7 @@
                 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 @@
 
         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 @@
             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 @@
             elif type_ == 'r':
                 removed.append(fn)
 
-        return (lookup, modified, added, removed, deleted, unknown)
+        return (lookup, modified, added, removed, deleted, unknown, ignored)
--- a/mercurial/localrepo.py	Wed Mar 29 22:35:21 2006 +0200
+++ b/mercurial/localrepo.py	Wed Mar 29 22:58:34 2006 +0200
@@ -498,7 +498,7 @@
                 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 @@
                     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 @@
                         del mf2[f]
         else:
             # we are comparing two revisions
-            deleted, unknown = [], []
+            deleted, unknown, ignored = [], [], []
             mf2 = mfmatches(node2)
 
         if node1:
@@ -573,9 +573,12 @@
             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:
--- a/tests/test-help.out	Wed Mar 29 22:35:21 2006 +0200
+++ b/tests/test-help.out	Wed Mar 29 22:58:34 2006 +0200
@@ -190,6 +190,7 @@
     R = removed
     ! = deleted, but still tracked
     ? = not tracked
+    I = ignored (not shown by default)
 
 aliases: st
 
@@ -200,6 +201,7 @@
  -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